]> git.wh0rd.org - tt-rss.git/blob - functions.js
f33b3970d356307bc325a603b61022f75a69eb4e
[tt-rss.git] / functions.js
1 var hotkeys_enabled = true;
2
3 function disableHotkeys() {
4 hotkeys_enabled = false;
5 }
6
7 function enableHotkeys() {
8 hotkeys_enabled = true;
9 }
10
11 function notify_callback() {
12 var container = document.getElementById('notify');
13 if (xmlhttp.readyState == 4) {
14 container.innerHTML=xmlhttp.responseText;
15 }
16 }
17
18 function rpc_notify_callback() {
19 var container = document.getElementById('notify');
20 if (xmlhttp_rpc.readyState == 4) {
21 container.innerHTML=xmlhttp_rpc.responseText;
22 }
23 }
24
25 function param_escape(arg) {
26 if (typeof encodeURIComponent != 'undefined')
27 return encodeURIComponent(arg);
28 else
29 return escape(arg);
30 }
31
32 function param_unescape(arg) {
33 if (typeof decodeURIComponent != 'undefined')
34 return decodeURIComponent(arg);
35 else
36 return unescape(arg);
37 }
38
39 function 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 }
47
48 function 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
62 function printLockingError() {
63 notify("Please wait until operation finishes");
64 }
65
66 var seq = "";
67
68 function hotkey_handler(e) {
69
70 var keycode;
71
72 if (!hotkeys_enabled) return;
73
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
94 if (typeof localHotkeyHandler != 'undefined') {
95 localHotkeyHandler(keycode);
96 }
97
98 }
99
100
101