-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathviewer.js
29 lines (25 loc) · 925 Bytes
/
viewer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
document.addEventListener("DOMContentLoaded", function() {
const urlParams = new URLSearchParams(window.location.search);
if (urlParams.has("id")) {
document.getElementById("assemblyCode").innerHTML =
"Fetching the program from SourceForge...";
const id = urlParams.get("id");
const url = `db.php?id=${encodeURIComponent(id)}`;
console.log(url);
fetch(url)
.then((response) => {
if (!response.ok) {
throw new Error("Network response was not ok");
}
return response.text();
})
.then((data) => {
const asm = document.getElementById("assemblyCode");
data = data.replace("\r\n", "\n");
document.getElementById("assemblyCode").innerText = data;
console.log(asm.textContent);
setUpLineNumbers();
})
.catch((error) => { console.error("Error:", error); });
}
});