Prepare test
This commit is contained in:
12
html/test_02.04.20/resources/js/error.js
Normal file
12
html/test_02.04.20/resources/js/error.js
Normal file
@@ -0,0 +1,12 @@
|
||||
function createError(errorMessage) {
|
||||
const error = document.createElement("div");
|
||||
error.setAttribute('class', 'error');
|
||||
|
||||
const errorBold = document.createElement("b");
|
||||
errorBold.innerHTML = 'ERROR:';
|
||||
error.appendChild(errorBold);
|
||||
|
||||
errorBold.after(errorMessage);
|
||||
|
||||
return error;
|
||||
}
|
||||
22
html/test_02.04.20/resources/js/linkConnector.js
Normal file
22
html/test_02.04.20/resources/js/linkConnector.js
Normal file
@@ -0,0 +1,22 @@
|
||||
const taskArray = tasks.tasks;
|
||||
const grid = document.getElementsByClassName("textboxGrid")[0];
|
||||
|
||||
for (i=0; i<taskArray.length; i++) {
|
||||
|
||||
const linkGridElement = document.createElement("div");
|
||||
linkGridElement.className = "linkGridElement";
|
||||
const path = taskArray[i]["path"];
|
||||
|
||||
linkGridElement.addEventListener("click", function () {
|
||||
window.location.href = path;
|
||||
} )
|
||||
|
||||
const h2 = document.createElement("h2");
|
||||
const link = document.createElement("a");
|
||||
link.href = taskArray[i]["path"];
|
||||
link.innerHTML = taskArray[i]["name"];
|
||||
|
||||
h2.appendChild(link);
|
||||
linkGridElement.appendChild(h2);
|
||||
grid.appendChild(linkGridElement);
|
||||
}
|
||||
1
html/test_02.04.20/resources/js/tasksJSON.js
Normal file
1
html/test_02.04.20/resources/js/tasksJSON.js
Normal file
@@ -0,0 +1 @@
|
||||
const tasks = {"tasks": [{"name": "Oppgave 1", "path": "./oppgaver/oppgave1/oppgave.html"}, {"name": "Oppgave 2", "path": "./oppgaver/oppgave2/oppgave.html"}, {"name": "Oppgave 3", "path": "./oppgaver/oppgave3/oppgave.html"}]}
|
||||
Reference in New Issue
Block a user