-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
45 lines (42 loc) · 1.41 KB
/
app.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
function $(str) { return document.querySelector(str); }
function $$(str) { return document.querySelectorAll(str); }
(function() {
window.app = {
init: function() {
console.log("app.init() called.");
$(".loader").style.display = "block";
fetch("resume.json").then(response=>response.json()).then(function(data) {
console.dir(data);
app.data = data;
app.outline();
});
},
outline: function() {
let out = app.dump(app.data);
$(".main").innerHTML = out;
},
dump: function(obj) {
let out = '<ul>';
for (let i in obj) {
let txt = i.replace(/^(.)/, function(str) { return str.toUpperCase(); });
out += '<li>';
if (!obj.length) {
out += '<h3>' + txt + '</h3>';
}
if ((typeof(obj[i]) === "object") || (typeof(obj[i])==="array")) {
out += app.dump(obj[i]);
} else {
let content = "<p>" + obj[i].replace(/\n\n/g, "</p><p>") + "</p>";
out += content;
}
out += "</li>";
}
out += "</ul>";
return out;
}
}
})();
app.init();
if('serviceWorker' in navigator) {
navigator.serviceWorker.register('sw.js');
};