-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutils.js
More file actions
64 lines (56 loc) · 1.7 KB
/
Copy pathutils.js
File metadata and controls
64 lines (56 loc) · 1.7 KB
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
57
58
59
60
61
62
63
64
function closePopups(){
removeElementsByClass('popup');
focusEditor();
}
function closePopupDialogs(){
removeElementsByClass('popup-dialog');
var popups = document.getElementsByClassName('popup');
if(popups.length > 0){
popups[0].focus();
}
else {
focusEditor();
}
}
function removeElementsByClass(className){
try{
var elements = document.getElementsByClassName(className);
while(elements.length > 0){
elements[0].onblur = null;
elements[0].parentNode.removeChild(elements[0]);
}
}
catch(err){
logError(err);
}
}
function createButton(text){
var btn = document.createElement("button");
btn.innerHTML = text;
btn.type = "button";
return btn;
}
function getPaddedDateTimeString() {
const now = new Date();
const year = now.getFullYear();
const month = String(now.getMonth() + 1).padStart(2, '0'); // Month is 0-indexed
const day = String(now.getDate()).padStart(2, '0');
const hours = String(now.getHours()).padStart(2, '0');
const minutes = String(now.getMinutes()).padStart(2, '0');
const seconds = String(now.getSeconds()).padStart(2, '0');
return `${year}-${month}-${day}-${hours}${minutes}${seconds}`;
}
function downloadTextFile(text, filename) {
const blob = new Blob([text], { type: "text/plain" });
const url = URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
link.download = filename;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
URL.revokeObjectURL(url);
}
function logError(e){
console.log(e);
}