Public
Edited
Dec 3, 2022
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
link.substr(0, link.indexOf("/edit")) + "/export?format=html"
Insert cell
async function getResponse(link) {
const response = await fetch(
link.substr(0, link.indexOf("/edit")) + "/export?format=html",
{
method: "GET"
}
);
const data = await response.text(); // Extracting data as a JSON Object from the response
return data;
}
Insert cell
data = getResponse(link)
Insert cell
style = find_all(/<head/g, "<style", "</style>")[0]
.replace('<style type="text/css">', "")
.replace(new RegExp("pt;", "g"), "px;")
.replace(new RegExp("pt}", "g"), "px}")
Insert cell
span = {
var span_ = find_all(/<span/g, ">", "<");
var span = [];
for (const value of span_) {
if (value != ">") {
span.push(value.slice(1, value.lenght));
}
}
return span;
}
Insert cell
src = {
var src = find_all(/<img/g, "src=", '" style');
var _src = [];
for (const value of src) {
_src.push(value.slice(5, value.length));
}
return _src;
}
Insert cell
ids_ = {
var tmp_ = find_all(/<h5/g, "[", "</span>");
return tmp_;
}
Insert cell
ids_src = {
var ids_src = [];
for (const value of ids_) {
if (value.includes("-src")) {
ids_src.push(value);
}
}
return ids_src;
}
Insert cell
ids = {
var ids = [];
for (const value of ids_) {
console.log(value);
if (value.includes("-src") != true) {
ids.push(value);
}
}
return ids;
}
Insert cell
Insert cell
major = {
var minor_ = find_all(/(&gt;)/gi, "&gt", ";");
var _tmp = [];
for (const value of minor_) {
_tmp.push(value + ";");
}
return _tmp;
}
Insert cell
minor = {
var minor_ = find_all(/(&lt;)/gi, "&lt", ";");
var _tmp = [];
for (const value of minor_) {
_tmp.push(value + ";");
}
return _tmp;
}
Insert cell
quotes = {
var d = find_all(/(&quot;)/gi, "&quot", ";");
var _tmp = [];
for (const value of d) {
_tmp.push(value + ";");
}
return _tmp;
}
Insert cell
h5 = {
var h5 = find_all(/<h5/g, "", ">");
return h5;
}
Insert cell
Insert cell
htl.html`<html><head><meta content="text/html; charset=UTF-8" http-equiv="content-type"><style type="text/css"> ${style}</style>`
Insert cell
to_resolve = {
var render = {
tag: [],
html: []
};
for (let elm = 0; elm < ids_.length; ++elm) {
render.html.push(
the_cleaner_sc(data)
.substring(
get_span_pos(the_cleaner_sc(data), elm),
get_span_pos(the_cleaner_sc(data), elm + 1)
)
.replace(ids_[elm], "")
.replace(new RegExp("</span></h5>", "g"), "")
.replace(new RegExp(">>", "g"), ">")
);
render.tag.push(ids_[elm]);
}
return render;
}
Insert cell
{
var iter_src = 0;
for (let index = 0; index < to_resolve.tag.length; ++index) {
if (ids.includes(to_resolve.tag[index])) {
var div = document.getElementById(
to_resolve.tag[index].replace("[", "").replace("]", "")
);

try {
div.innerHTML = to_resolve.html[index];
} catch (error) {
console.log(error);
}
} else if (ids_src.includes(to_resolve.tag[index])) {
var img = document.getElementById(
to_resolve.tag[index].replace("[", "").replace("]", "")
);

try {
img.src = src[iter_src];
iter_src++;
} catch (error) {
console.log(error);
}
}
}
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more