mirror of
https://github.com/arfct/itty-bitty.git
synced 2026-03-11 08:54:33 +00:00
Adjusted debug
This commit is contained in:
parent
21a0c9cc99
commit
a6a7b37a8b
4 changed files with 26 additions and 24 deletions
|
|
@ -6,7 +6,7 @@
|
|||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker
|
||||
.register('/worker.js')
|
||||
.then(function() { console.log("Service Worker Registered"); });
|
||||
.then(function() { console.debug("Service Worker Registered"); });
|
||||
}
|
||||
|
||||
function dismiss() {
|
||||
|
|
@ -32,9 +32,8 @@
|
|||
}
|
||||
|
||||
window.addEventListener("message", function(e) {
|
||||
console.group("HI")
|
||||
console.log("Message:", e.origin, e.data)
|
||||
console.groupEnd("HI")
|
||||
console.debug("Message:", e.origin, e.data)
|
||||
|
||||
// if (e.origin == 'null' || e.origin = ) {
|
||||
if (e.data.title) document.title = e.data.title;
|
||||
if (e.data.favicon) setFavicon(e.data.favicon);
|
||||
|
|
@ -44,17 +43,17 @@
|
|||
}, false);
|
||||
|
||||
// window.onhashchange =
|
||||
window.onload = function() {
|
||||
window.onload = function() {
|
||||
var fragment = window.location.hash.substring(1);
|
||||
|
||||
if (window.location.search) { // Redirect search to path (coming out of server opengraph forwarding)
|
||||
console.log("window.location.search.substring(1)", window.location.search.substring(1))
|
||||
return window.history.replaceState(null, null, window.location.search.substring(1) + "#" + fragment);
|
||||
window.history.replaceState(null, null, window.location.search.substring(1) + "#" + fragment);
|
||||
}
|
||||
|
||||
var isIE = navigator.userAgent.match(/rv:11/);
|
||||
var isEdge = navigator.userAgent.match(/Edge\//);
|
||||
var isWatch = (window.outerWidth < 200);
|
||||
|
||||
var fragment = window.location.hash.substring(1);
|
||||
if (fragment.length < 3) {
|
||||
return location.href = "/edit";
|
||||
}
|
||||
|
|
@ -83,7 +82,8 @@
|
|||
|
||||
if (fragment.startsWith("data:")) {
|
||||
let info = bitty.infoForDataURL(fragment);
|
||||
|
||||
const renderer = info.params?.render || renderers[info.mediatype].script;
|
||||
|
||||
if (info.mediatype == "text/html") {
|
||||
dataPrefix = HEAD_TAGS;
|
||||
} else if (info.mediatype == "text/plain") {
|
||||
|
|
@ -91,12 +91,11 @@
|
|||
renderMode = "data";
|
||||
} else if (info.type == "text") {
|
||||
} else if (info.type == "image") {
|
||||
} else {
|
||||
} else if (!renderer) {
|
||||
console.log("unknown type, rendering as download")
|
||||
renderMode = "download";
|
||||
}
|
||||
|
||||
const renderer = info.params?.render || renderers[info.mediatype].script;
|
||||
if (renderer) {
|
||||
var script = renderer;
|
||||
if (script.indexOf("/") == -1) script = location.origin + '/render/' + script + '.js'
|
||||
|
|
@ -144,7 +143,7 @@
|
|||
if (isWatch) {
|
||||
contentTarget = document;
|
||||
}
|
||||
console.log("Rendering via", renderMode)
|
||||
console.log("Rendering mode: " + "\x1B[1m" + renderMode)
|
||||
// dataURL = dataURL.replace("application/ld+json", "text/plain");
|
||||
if (renderMode == "download") {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ window.el = function (tagName, attrs, ...children) {
|
|||
function loadScript(src, callback) {
|
||||
let script = el("script", { src });
|
||||
script.addEventListener('load', function(e) {
|
||||
console.log("Loaded", src);
|
||||
console.debug("Loaded script", src);
|
||||
if (callback) callback(e);
|
||||
});
|
||||
document.head.appendChild(script);
|
||||
|
|
@ -35,5 +35,4 @@ window.addEventListener("message", function(e) {
|
|||
window.params.origin = e.origin;
|
||||
console.log("Rendering with", e.data.script, e.data)
|
||||
loadScript(e.data.script);
|
||||
console.log("document.head", document.head)
|
||||
}, false);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
let script = document.currentScript;
|
||||
let reformat = true;
|
||||
console.log("localStorage")
|
||||
|
||||
FRACTION_MAP = {
|
||||
'1/4': '\u00BC',
|
||||
|
|
@ -144,6 +143,8 @@ function highlightStep(e) {
|
|||
}
|
||||
|
||||
const ingredientMatch = /^(?:A )?([\/0-9 \-\u00BC-\u00BE\u2153-\u215E\u2009]*) ?(.*)/
|
||||
|
||||
|
||||
function ingredientEl(string, terms) {
|
||||
if (string == "-") return m("hr");
|
||||
|
||||
|
|
@ -175,7 +176,7 @@ function render() {
|
|||
}
|
||||
console.log("Recipe", json);
|
||||
} catch (e) {
|
||||
console.log("Data", e, {data});
|
||||
console.debug("Data", e, {data});
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -194,8 +195,6 @@ function render() {
|
|||
var ingredientTerms = new Set(
|
||||
Array.from(ingredients.join("\n").matchAll(/[A-Za-z\-]+/g)).map(m => m[0].length > 2 ? m[0].toLowerCase(): "")
|
||||
);
|
||||
|
||||
console.log("instructions", instructions)
|
||||
if (typeof instructions === "string") instructions = [instructions]
|
||||
instructions = flattenInstructions(instructions)
|
||||
let intructionTerms = new Set(
|
||||
|
|
@ -209,14 +208,18 @@ function render() {
|
|||
}
|
||||
})
|
||||
ingredientTerms.delete("");
|
||||
console.log(ingredientTerms);
|
||||
//console.log(ingredientTerms);
|
||||
|
||||
console.log("1 tablespoon".replace(/(tablespoon)/, (a) => {
|
||||
return replacements[a];
|
||||
}))
|
||||
// console.log("1 tablespoon".replace(/(tablespoon)/, (a) => {
|
||||
// return replacements[a];
|
||||
// }))
|
||||
ingredients = ingredients.map(i => m("div.ingredient", { onclick: markIngredient }, ingredientEl(clean(i), ingredientTerms)));
|
||||
|
||||
console.log("instructions", instructions)
|
||||
|
||||
console.group("instructions")
|
||||
console.log(instructions)
|
||||
console.groupEnd("instructions")
|
||||
|
||||
let step = 1;
|
||||
function renderInstructions(instruction, terms) {
|
||||
if (Array.isArray(instruction)) {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ self.addEventListener('install', function(e) {
|
|||
});
|
||||
|
||||
self.addEventListener('fetch', function(event) {
|
||||
console.info("Requested", event.request.url);
|
||||
console.debug("Requested", event.request.url);
|
||||
|
||||
event.respondWith(
|
||||
caches.match(event.request).then(function(response) {
|
||||
return response || fetch(event.request);
|
||||
|
|
|
|||
Loading…
Reference in a new issue