itty-bitty/docs/render/parse.js
2022-05-17 08:37:07 -07:00

22 lines
No EOL
647 B
JavaScript

// let title = params.title
parent.postMessage({title:"Parsing Content..."}, "*");
document.write("PARSING CONTENT…")
const parser = new DOMParser();
const doc = parser.parseFromString(params.body, "text/html");
let ldjson = doc.querySelector('script[type="application/ld+json"]')
if (ldjson) {
ldjson = ldjson.innerText.trim();
let f = new FileReader();
f.onload = function(e) {
//top.location.href = ( '/#/' + e.target.result);
parent.postMessage({replaceURL:'/temp#/' + e.target.result}, "*");
};
f.readAsDataURL(new Blob([ldjson],{type : 'application/ld+json;charset=utf-8'}));
} else {
alert("No recipe found")
}