-
Notifications
You must be signed in to change notification settings - Fork 1
/
shared.js
41 lines (32 loc) · 880 Bytes
/
shared.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
/*jshint esversion:6 */
var debug_mode = false;
var log_count = 0;
function gebi(n) { return document.getElementById(n); }
function cr(n,c,it) {
var e = document.createElement(n);
if (c) e.className = c;
if (it) e.innerText = it;
return e;
}
function log(t) {
try {
sd = document.getElementById('statusdiv');
sd.innerText += '(' + log_count + '): ' + t + "\n";
sd.scrollTop = sd.scrollHeight;
log_count += 1;
} catch (e) {}
if (debug_mode) {
console.log(t);
}
}
function removeChildrenReplaceWith(elem, newchildren) {
while (elem.firstChild) {
elem.removeChild(elem.firstChild);
}
for (var i = 0; i < newchildren.length; i++) {
elem.appendChild(newchildren[i]);
}
}
function useIfElse(dict, name, deflt) {
return dict.hasOwnProperty(name) ? dict[name] : deflt;
}