-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.js
More file actions
72 lines (62 loc) · 2.22 KB
/
utils.js
File metadata and controls
72 lines (62 loc) · 2.22 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
65
66
67
68
69
70
71
72
'use strict';
function getCaretPosition (textarea) {
var caretPos = 0;
if (document.selection) {
textarea.focus ();
var select = document.selection.createRange ();
select.moveStart ('character', -textarea.value.length);
caretPos = select.text.length;
}
else if (textarea.selectionStart || textarea.selectionStart == '0')
caretPos = textarea.selectionStart;
return caretPos;
}
function setCaretPosition(textarea, pos) {
if (textarea.setSelectionRange) {
textarea.focus();
textarea.setSelectionRange(pos, pos);
}
else if (textarea.createTextRange) {
var range = textarea.createTextRange();
range.collapse(true);
range.moveEnd('character', pos);
range.moveStart('character', pos);
range.select();
}
}
function isScrollBottom(table) {
var bottomScroll = false;
var h1 = table.scrollHeight - table.scrollTop;
var h2 = table.clientHeight;
if(table.firstElementChild && table.firstElementChild.lastChild.scrollHeight)
h2 += table.firstElementChild.lastChild.scrollHeight;
if(h1 <= h2)
bottomScroll = true;
return bottomScroll;
}
function getCurrentTime() {
var date = new Date();
var time = ('0' + date.getDate()).slice(-2) + '.' + ('0' + (date.getMonth()+1)).slice(-2) + "<br>";
time += ('0' + date.getHours()).slice(-2) + ':' + ('0' + date.getMinutes()).slice(-2);
time += ':' + ('0' + date.getSeconds()).slice(-2);
return time;
}
var uniqueId = function() {
var date = Date.now();
var random = Math.random() * Math.random();
return Math.floor(date * random).toString();
};
function setIconsVisible(visible) {
if(visible) {
document.getElementsByClassName('icon')[0].style.display = "block";
document.getElementsByClassName('icon')[1].style.display = "block";
} else {
document.getElementsByClassName('icon')[0].style.display = "none";
document.getElementsByClassName('icon')[1].style.display = "none";
}
}
function updateCounter() {
var counter = document.getElementsByClassName('counter-holder')[0];
var count = document.getElementsByClassName("items")[0].rows.length;
counter.innerText = count.toString();
}