IEEE.org     |     IEEE Xplore Digital Library     |     IEEE Standards     |     IEEE Spectrum     |     More Sites

Commit 9e40facf authored by Suhas CV's avatar Suhas CV
Browse files

custom js file load

parent 0cb220f3
Pipeline #638 failed with stage
in 32 seconds
function handleScroll() {
setTimeout(() => {
window.scrollBy(0, -100);
}, 500);
}
let ele = document.getElementsByClassName("ltx_page_main")[0];
let imgElement = document.createElement("img");
imgElement.setAttribute("src", "headerImage.png");
imgElement.setAttribute("alt", "banner");
imgElement.setAttribute("style", "width:100% !important;min-height:auto;");
ele.insertBefore(imgElement, ele.firstChild);
var docs = document.getElementsByClassName("ltx_note ltx_role_footnote");
let cnt = 0;
let footnotes = [];
let doc = docs[cnt];
while (cnt < docs.length) {
footnotes.push(doc.id);
let inner = doc.childNodes[1];
let txt = inner.childNodes[0].textContent;
txt = txt.replace(/ +/g, " ");
txt = txt.replace(/\n/, " ");
if (cnt > 9) footnotes.push(txt.slice(2));
else footnotes.push(txt.slice(1));
cnt++;
doc.innerHTML = `<a href="#fn-${cnt}" onClick="handleScroll()">` + doc.innerHTML + "</a>";
doc = docs[cnt];
}
ele = document.getElementsByTagName("article")[0];
let outer = document.createElement("div", { class: "footnotes-display" });
let heading = document.createElement("h3");
heading.appendChild(document.createTextNode("Footnotes"));
outer.appendChild(heading);
let j = 0;
for (let i = 1; i < footnotes.length; i += 2) {
let p = document.createElement("p");
p.setAttribute("id", "fn-" + (j + 1));
let newC = document.createTextNode( footnotes[i]);
p.appendChild(newC);
outer.appendChild(p);
j++;
}
ele.appendChild(outer);
\ No newline at end of file
......@@ -3,6 +3,7 @@ import zipfile
import uuid
import os
import io
import shutil
from cleaner import clean
......@@ -71,54 +72,7 @@ def extractAndConvert(extractpath):
split1,split2=file_content.split("</body>")
custom_script= '''
<script>
function handleScroll() {
setTimeout(() => {
window.scrollBy(0, -100);
}, 500);
}
let ele = document.getElementsByClassName("ltx_page_main")[0];
let imgElement = document.createElement("img");
imgElement.setAttribute("src", "headerImage.png");
imgElement.setAttribute("alt", "banner");
imgElement.setAttribute("style", "width:100% !important;min-height:auto;");
ele.insertBefore(imgElement, ele.firstChild);
var docs = document.getElementsByClassName("ltx_note ltx_role_footnote");
let cnt = 0;
let footnotes = [];
let doc = docs[cnt];
while (cnt < docs.length) {
footnotes.push(doc.id);
let inner = doc.childNodes[1];
let txt = inner.childNodes[0].textContent;
txt = txt.replace(/ +/g, " ");
txt = txt.replace("\n", " ");
if (cnt > 9) footnotes.push(txt.slice(2));
else footnotes.push(txt.slice(1));
cnt++;
doc.innerHTML = `<a href="#fn-${cnt}" onClick="handleScroll()">` + doc.innerHTML + "</a>";
doc = docs[cnt];
}
ele = document.getElementsByTagName("article")[0];
let outer = document.createElement("div", { class: "footnotes-display" });
let heading = document.createElement("h3");
heading.appendChild(document.createTextNode("Footnotes"));
outer.appendChild(heading);
let j = 0;
for (let i = 1; i < footnotes.length; i += 2) {
let p = document.createElement("p");
p.setAttribute("id", "fn-" + (j + 1));
let newC = document.createTextNode( footnotes[i]);
p.appendChild(newC);
outer.appendChild(p);
j++;
}
ele.appendChild(outer);
<script src="index.js">
</script>
</body>
'''
......@@ -128,6 +82,8 @@ def extractAndConvert(extractpath):
file_out.write(html)
file_out.close()
shutil.copyfile('custom.js',output_file+'/index.js')
os.system('''zip -r ./static/{}.zip {}'''.format(output_file,output_file))
os.system("rm -rf {}".format(file_id))
os.remove(extractpath)
......
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