Commit 1ff7bf54 authored by Adrian Wuillemet's avatar Adrian Wuillemet
Browse files

#65 Minor ui improvements

parent 3d49cf8f
......@@ -19,10 +19,12 @@
ul, ol {
margin-left: 20px;
margin-top: 5px;
}
ul li {
list-style-type: none;
font-size: 14px;
}
pre {
......
function setInfo(info: string) {
info = info.replace(/\\n|"/g, "");
info = info.replace(/\\u00a9/g, '©');
info = info.replace(/\\n|"/g, "")
.replace(/\\u00a9/g, '©')
.replace(/<p><img(.*?)<\/p>/g, "");
let article = d3.create("article")
.html(info)
.node();
article.querySelectorAll("pre").forEach(pre => {
let replacement = pre.innerHTML;
replacement.replace(/ /g, " ");
replacement = replacement.replace(/ -/g, "\n\n -");
replacement = replacement.replace(/#/g, "\n#");
pre.innerHTML = replacement.replace(/\$/g, "\n\n$");
// Clear shell info code
let shell = "\\shell\\";
let languageshell = "language-shell";
article.querySelectorAll(`.\\${shell}\\`).forEach(code => {
code.classList.remove(shell);
code.classList.add(languageshell);
code.innerHTML = code.innerHTML.replace(/ /g, " ")
.replace(/ -/g, "\n\n -")
.replace(/#/g, "\n#")
.replace(/\$/g, "\n\n$");
});
// Clear json info code
let json = "\\json\\";
let languagejson = "language-json";
article.querySelectorAll(`.\\${json}\\`).forEach(code => {
code.classList.remove(json);
code.classList.add(languagejson);
code.innerHTML = code.innerHTML.replace("{", "\n{")
.replace(/\s\s+{/g, "\n {")
.replace(/\s\s+"/g, '\n"')
.replace(/\s\s+]/g, "\n]");
});
// Clear .bead info code
let codes = article.querySelectorAll(`code`);
let beadCode = codes[codes.length - 1]
beadCode.innerHTML = beadCode.innerHTML.replace(/\s\s+/g, "\n")
.replace("#!", "\n#!");
article.querySelectorAll("p a").forEach(a => {
let link = a as HTMLLinkElement;
link.innerHTML = link.href.replace(/http:\/\/localhost:[0-9]*\//g, "");
});
let logo = article.querySelector("img") as HTMLImageElement;
logo.src = "/media/logo.png";
let allImages = article.querySelectorAll("img");
for (let index = 1; index < allImages.length; index++) {
const image = allImages[index];
let p = d3.create('p')
.html(`${image.alt.replace(/\\/g, "")}`)
.node();
image.parentNode.append(p);
image.remove();
}
let logo = d3.create("img")
.attr("src", "media/logo.png")
.node();
article.insertBefore(logo, article.firstChild);
Prism.highlightAllUnder(article);
document.getElementById("info").appendChild(article);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment