]> git.wh0rd.org - tt-rss.git/blame - functions.js
some searchbox focus workarouns, content hash checking is optional now
[tt-rss.git] / functions.js
CommitLineData
760966c1
AD
1var hotkeys_enabled = true;
2
3function disableHotkeys() {
4 hotkeys_enabled = false;
5}
6
7function enableHotkeys() {
8 hotkeys_enabled = true;
9}
10
9cfc649a
AD
11function notify_callback() {
12 var container = document.getElementById('notify');
13 if (xmlhttp.readyState == 4) {
14 container.innerHTML=xmlhttp.responseText;
15 }
16}
17
18function rpc_notify_callback() {
19 var container = document.getElementById('notify');
20 if (xmlhttp_rpc.readyState == 4) {
21 container.innerHTML=xmlhttp_rpc.responseText;
22 }
23}
24
7726fa02
AD
25function param_escape(arg) {
26 if (typeof encodeURIComponent != 'undefined')
27 return encodeURIComponent(arg);
28 else
29 return escape(arg);
30}
31
32function param_unescape(arg) {
33 if (typeof decodeURIComponent != 'undefined')
34 return decodeURIComponent(arg);
35 else
36 return unescape(arg);
37}
38
508a81e1
AD
39function delay(gap) {
40 var then,now;
41 then=new Date().getTime();
42 now=then;
43 while((now-then)<gap) {
44 now=new Date().getTime();
45 }
46}
7726fa02
AD
47
48function notify(msg) {
49
50 var n = document.getElementById("notify");
51
52 n.innerHTML = msg;
53
54 if (msg.length == 0) {
55 n.style.display = "none";
56 } else {
57 n.style.display = "block";
58 }
59
60}
61
508a81e1
AD
62function printLockingError() {
63 notify("Please wait until operation finishes");
64}
65
13ad9102
AD
66var seq = "";
67
68function hotkey_handler(e) {
760966c1 69
13ad9102
AD
70 var keycode;
71
760966c1
AD
72 if (!hotkeys_enabled) return;
73
13ad9102
AD
74 if (window.event) {
75 keycode = window.event.keyCode;
76 } else if (e) {
77 keycode = e.which;
78 }
79
80 if (keycode == 13 || keycode == 27) {
81 seq = "";
82 } else {
83 seq = seq + "" + keycode;
84 }
85
86 var piggie = document.getElementById("piggie");
87
88 if (seq.match("807371717369")) {
89 localPiggieFunction(true);
90 } else {
91 localPiggieFunction(false);
92 }
93
9cfc649a
AD
94 if (typeof localHotkeyHandler != 'undefined') {
95 localHotkeyHandler(keycode);
96 }
97
13ad9102
AD
98}
99
100
7726fa02 101