diff --git a/docs/index.js b/docs/index.js
index 15e84e3..f0e871b 100644
--- a/docs/index.js
+++ b/docs/index.js
@@ -23,19 +23,24 @@
// document.body.classList.remove("toasting")
// }
+ let autohideTimeout;
function showLoader(state) {
let loader = document.getElementById("loader");
-
+ if (autohideTimeout) {
+ clearTimeout(autohideTimeout);
+ autohideTimeout = undefined;
+ }
if (state) {
if (!loader) {
loader = document.createElement("div");
loader.id = "loader";
document.body.appendChild(loader);
- }
+ }
+ autohideTimeout = setTimeout(() => {showLoader(false)}, 3000)
} else if (loader) {
- setTimeout(() => loader?.parentElement?.removeChild(loader), 500)
+ setTimeout(() => loader?.parentElement?.removeChild(loader), 1000)
}
- setTimeout(() => document.body.classList.toggle("loading", state), 1)
+ setTimeout(() => document.body.classList.toggle("loading", state), 500)
}
window.showLoader = showLoader;
@@ -64,11 +69,12 @@
}
const renderers = {
- "application/ld+json": {script:"/render/recipe.min.html"},
+ "application/ld+json": {script:"/render/recipe.html"},
"text/canvas+javascript": {script:"canvas"},
"text/javascript": {script:"script"},
"application/bitsy": {script:"/render/bitsy.html", sandbox:"bitsy"},
"c": {script:"color"},
+ "e": {rewrite: "data:text/html;cipher=aes;format=gz;base64,"},
"text/rawhtml": {script:"parse"},
"javascript": {script:"bookmarklet"},
"ipfs": {script:"ipfs", sandbox:"ipfs"},
@@ -83,7 +89,7 @@
if (navigator.share) {
navigator.share(info)
- .then(() => { console.log('Thanks for sharing!');})
+ .then(() => { console.log('Shared!');})
.catch(console.error);
} else {
copyLink(info)
@@ -111,7 +117,7 @@
if (navigator.wakeLock) {
wakeLock = await navigator.wakeLock.request();
wakeLock.addEventListener('release', () => {});
- console.log('Keeping Screen Awake:', !wakeLock.released);
+ console.log('💡 Keeping Screen Awake:', !wakeLock.released);
} else {
// keepAwake();
}
@@ -196,11 +202,13 @@
}, false);
async function renderContent() {
+
showLoader(true)
var fragment = window.location.hash.substring(1);
- if (fragment.length < 3 && !isFramed) {
+ let content = null //sessionStorage.getItem("editor-content");
+ if (content || (fragment.length < 3 && !isFramed)) {
return location.href = "/edit";
}
@@ -284,6 +292,10 @@
renderMode = "download";
}
+ if (durl.params.style == "default") {
+ dataPrefix = bitty.HEAD_TAGS_EXTENDED();
+ }
+
if (renderer) {
var script = renderer.script;
if (script.indexOf("/") == -1) script = location.origin + '/render/' + script + '.js'
@@ -317,7 +329,13 @@
'Edge only supports shorter URLs (maximum 2083 bytes).
Larger sites may require a different browser.
Learn more';
}
- await durl.decompress();
+ await durl.decompress()
+
+ if (durl.error) {
+ writeDocContent(iframe.contentWindow.document, atob(bitty.HEAD_TAGS_EXTENDED()) + `