2018-10-18 04:14:24 +00:00
|
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<html lang="en">
|
|
|
|
|
<head>
|
|
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
|
|
|
<title>Tweet in a sign</title>
|
2018-10-18 04:44:29 +00:00
|
|
|
|
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js" type="text/javascript"></script>
|
|
|
|
|
<script src="//www.skulpt.org/static/skulpt.min.js" type="text/javascript"></script>
|
|
|
|
|
<script src="//www.skulpt.org/static/skulpt-stdlib.js" type="text/javascript"></script>
|
2018-10-18 04:14:24 +00:00
|
|
|
|
</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;
|
2018-10-18 04:44:29 +00:00
|
|
|
|
scriptFile.src = '//platform.twitter.com/widgets.js';
|
2018-10-18 04:14:24 +00:00
|
|
|
|
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>
|
2018-10-18 04:44:29 +00:00
|
|
|
|
<a href="//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="//platform.twitter.com/widgets.js" charset="utf-8"></script>
|
2018-10-18 04:14:24 +00:00
|
|
|
|
</body>
|
|
|
|
|
</html>
|