itty-bitty/index.html
Nicholas Jitkoff 9e207a57d2 IE Fixes
2018-05-29 07:05:09 -07:00

65 lines
No EOL
2.4 KiB
HTML

<!DOCTYPE html>
<html xmanifest="manifest.appcache">
<title>itty bitty</title>
<meta name="viewport" content="width=device-width">
<script src="src/lzma-d-min.js"></script>
<script src="data.js"></script>
<style type="text/css">
#iframe {border:none;position:absolute;top:0;left:0;width:100%;height:100%}
#edit {position:absolute;z-index:100;position:absolute;top:10px; right:10px; display:none;}
#edit:not(:hover) {border-color:transparent; color:gray;}
</style>
<iframe id="iframe"></iframe>
<button id="edit">Edit</button>
<script type="text/javascript">
function showEdit(editable) {
var link = document.getElementById('edit');
link.onclick = function() { location.href = "/edit" + location.hash }
link.style.display = editable ? "block" : "none";
}
var HEAD_TAGS = "PG1ldGEgY2hhcnNldD0idXRmLTgiPjxtZXRhIG5hbWU9InZpZXdwb3J0IiBjb250ZW50PSJ3aWR0aD1kZXZpY2Utd2lkdGgiPjxiYXNlIHRhcmdldD0iX3RvcCI+PHN0eWxlIHR5cGU9InRleHQvY3NzIj5ib2R5e21hcmdpbjowIGF1dG87cGFkZGluZzoxMnZtaW4gMTB2bWluO21heC13aWR0aDozNWVtO2xpbmUtaGVpZ2h0OjEuNWVtO2ZvbnQtZmFtaWx5OiAtYXBwbGUtc3lzdGVtLEJsaW5rTWFjU3lzdGVtRm9udCxzYW5zLXNlcmlmO3dvcmQtd3JhcDogYnJlYWstd29yZDt9PC9zdHlsZT4g"
window.onhashchange = window.onload = function() {
var hash = window.location.hash.substring(1)
if (!hash.length) {
location.href = "/edit"
} else {
var iframe = document.getElementById('iframe');
var link = document.getElementById('edit');
var preamble = undefined;
var editable = hash.charAt(0) == '!'
var compressed = editable || hash.charAt(0) == ','
if (compressed || editable) {
hash = hash.substring(1)
preamble = HEAD_TAGS
}
if (hash.indexOf("data:") != 0) hash = 'data:text/html;charset=utf-8;' + (compressed ? 'baze64,' : 'base64,') + hash;
// location.href = hash // Redirect to data URI in supported browsers
link.onclick = function() { location.href = "/edit" + location.hash }
showEdit(editable)
var useData = !navigator.userAgent.match(/rv:11/); // || /Edge/.test(navigator.userAgent)
decompressDataURI(hash, preamble, function(hash) {
if (!hash) return;
if (useData) {
if (hash) iframe.src = hash;
} else{
dataToString(hash, function(content){
var doc = iframe.contentWindow.document;
doc.open();
doc.write(content);
doc.close();
})
}
});
}
}
</script>
</html>