Last active
March 3, 2017 08:37
-
-
Save mtso/37ec5ac89264cab1d2c56e61b609dd42 to your computer and use it in GitHub Desktop.
sago prototype
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<body> | |
<script> | |
function readSago(src) { | |
return new Promise(function(resolve, reject) { | |
var rawFile = new XMLHttpRequest(); | |
rawFile.open('GET', src, false); | |
rawFile.onreadystatechange = function() { | |
if (rawFile.readyState === 4 && | |
(rawFile.status === 200 || rawFile.status === 0)) { | |
var text = rawFile.responseText; | |
resolve(text); | |
} else { | |
reject('unsuccessful request to file'); | |
} | |
} | |
rawFile.send(null); | |
}); | |
} | |
window.onload = function() { | |
var sago; | |
for (var i = 0; i < document.scripts.length; i++) { | |
if (document.scripts[i].type === 'text/sago') { | |
sago = document.scripts[i]; | |
} | |
} | |
readSago(sago.src) | |
.then(function(content) { | |
console.log(content); | |
}) | |
.catch(function(err) { | |
console.error(err); | |
}); | |
} | |
</script> | |
<script type="text/sago" src="z-hello.sago"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hello world! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment