-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeatures.js
More file actions
41 lines (37 loc) · 917 Bytes
/
Copy pathfeatures.js
File metadata and controls
41 lines (37 loc) · 917 Bytes
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
/**
* Include file in head of document
*
* @param array of files
*/
function include(file) {
if (document.getElementById(file)) {
return;
}
if (Array.isArray(file)) {
file.forEach(f => include(f));
return true;
}
var el = document.createElement('script');
el.setAttribute("src", file);
el.setAttribute("id", file);
//el.setAttribute("async", false);
document.head.appendChild(el);
}
/**
* Replace all $X in document with string
* @param string ch -> variable name to change
* @param string str -> new string
*/
function replaceDOMVariables(ch, str) {
let old = document.body.innerHTML;
document.body.innerHTML = old.split(ch).join(str);
return old;
}
/**
* @param int min -> minimal value
* @param int max -> maximal value
*
*/
function randomInteger(min, max) {
return Math.floor(Math.random() * (max - min) ) + min;
}