forked from thecuriousteam/PyLibLog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogic.js
57 lines (46 loc) · 1.64 KB
/
logic.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// function showContent(content) {
// var contentDiv = document.getElementById('content');
// // Create a function to load content from an HTML file
// function loadContentFromFile(filename) {
// var xhr = new XMLHttpRequest();
// xhr.onreadystatechange = function() {
// if (xhr.readyState === 4 && xhr.status === 200) {
// contentDiv.innerHTML = xhr.responseText;
// }
// };
// xhr.open('GET', filename, true);
// xhr.send();
// }
// // Use a switch statement to determine which content to load
// switch (content) {
// case 'Django':
// loadContentFromFile('Django.html');
// break;
// case 'Flask':
// loadContentFromFile('about.html');
// break;
// case 'contact':
// loadContentFromFile('contact.html');
// break;
// default:
// contentDiv.innerText = 'Content not found';
// }
// }
function showContent(contentFileName) {
var contentDiv = document.getElementById('content');
var loader = document.querySelector('.progress');
loader.style.display = 'block';
contentDiv.style.display = 'none';
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
contentDiv.innerHTML = xhr.responseText;
setTimeout(function () {
loader.style.display = 'none';
contentDiv.style.display = 'block';
}, 1000);
}
};
xhr.open('GET', contentFileName, true);
xhr.send();
}