Added index file

master
Gabriel Muñoz 2018-10-18 04:14:24 +00:00
parent 68c6bba5e6
commit 78cdf020ef
1 changed files with 77 additions and 0 deletions

77
public/index.html 100644
View File

@ -0,0 +1,77 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Tweet in a sign</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js" type="text/javascript"></script>
<script src="http://www.skulpt.org/static/skulpt.min.js" type="text/javascript"></script>
<script src="http://www.skulpt.org/static/skulpt-stdlib.js" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript">
var cont = 0;
function outf(text) {
console.log(text);
var mypre = document.getElementById("output");
mypre.innerHTML = mypre.innerHTML + text;
}
function builtinRead(x) {
if (Sk.builtinFiles === undefined || Sk.builtinFiles["files"][x] === undefined)
throw "File not found: '" + x + "'";
return Sk.builtinFiles["files"][x];
}
function runit() {
var text = document.getElementById("text").value;
var prog = `
text = "${text}"
items = text.split()
parts = []
part = ""
for x, item in enumerate(items):
if len(part + " " + item) > 18:
parts.append(part.center(22).rstrip())
part = ""
part = part + " " + item
parts.append(part.center(22).rstrip())
result = "\\n".join(parts)
figure = '''| ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄|
{}
|___________|
\\ (•◡•) /
\\ /
---
| |'''.format(result)
print(figure)`;
var mypre = document.getElementById("output");
mypre.innerHTML = '';
Sk.pre = "output";
Sk.configure({output:outf, read:builtinRead});
var myPromise = Sk.misceval.asyncToPromise(function() {
return Sk.importMainWithBody("<stdin>", false, prog, true);
});
myPromise.then(function(mod) {
console.log('success');
document.getElementById("twitter-widget-"+cont).remove();
cont++;
document.body.innerHTML = document.body.innerHTML + '<a href="https://twitter.com/share?ref_src=twsrc%5Etfw" class="twitter-share-button" id="tweet" data-text="'+document.getElementById("output").innerHTML+'" data-show-count="false">Tweet</a>';
var scriptFile = document.createElement('script');
scriptFile.type = 'text/javascript';
scriptFile.async = true;
scriptFile.src = 'https://platform.twitter.com/widgets.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(scriptFile, s);
},
function(err) {
console.log(err.toString());
});
}
</script>
<input id="text" type="text"><button onclick="runit()">Declarar</button>
<br>
<textarea name="" id="output" cols="30" rows="10"></textarea>
<a href="https://twitter.com/share?ref_src=twsrc%5Etfw" class="twitter-share-button" id="tweet" data-text="nothing" data-show-count="false">Tweet</a><script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
</body>
</html>