-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwp-remote-sync.js
75 lines (52 loc) · 1.36 KB
/
wp-remote-sync.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
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
73
74
75
var lastMessageIsStatus = false;
function removeLastLine() {
var el = document.getElementById("job-output");
var pos = el.value.lastIndexOf("\n") + 1;
if (pos < 0)
pos = 0;
el.value = el.value.substring(0, pos);
}
function removeOldLines() {
var el = document.getElementById("job-output");
var value = el.value;
var pos = el.length;
for (var i = 0; i < 100; i++) {
var pos = el.value.lastIndexOf("\n", pos) - 1;
if (pos < 0)
pos = 0;
}
el.value = value.substring(pos);
}
function jobl(message) {
var el = document.getElementById("job-output");
if (lastMessageIsStatus)
removeLastLine();
removeOldLines();
lastMessageIsStatus = false;
el.value += message + "\n";
el.scrollTop = el.scrollHeight;
if (el.setSelectionRange)
el.setSelectionRange(el.value.length, el.value.length);
el.focus();
}
function jobs(message) {
var el = document.getElementById("job-output");
if (lastMessageIsStatus)
removeLastLine();
removeOldLines();
lastMessageIsStatus = true;
var l = el.value.length;
el.value += message;
el.scrollTop = el.scrollHeight;
if (el.setSelectionRange)
el.setSelectionRange(l, l);
el.focus();
}
function jobdone() {
var el = document.getElementById("job-output");
el.blur();
var el = document.getElementById("job-back-button");
el.style.pointerEvents = "auto";
el.style.opacity = 1;
el.style.cursor = "inherit";
}