]> git.wh0rd.org - tt-rss.git/blame - functions.js
misc style updates
[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
c0e5a40e
AD
11function xmlhttp_ready(obj) {
12 return obj.readyState == 4 || obj.readyState == 0 || !obj.readyState;
13}
14
15
9cfc649a
AD
16function notify_callback() {
17 var container = document.getElementById('notify');
18 if (xmlhttp.readyState == 4) {
19 container.innerHTML=xmlhttp.responseText;
20 }
21}
22
23function rpc_notify_callback() {
24 var container = document.getElementById('notify');
25 if (xmlhttp_rpc.readyState == 4) {
26 container.innerHTML=xmlhttp_rpc.responseText;
27 }
28}
29
7726fa02
AD
30function param_escape(arg) {
31 if (typeof encodeURIComponent != 'undefined')
32 return encodeURIComponent(arg);
33 else
34 return escape(arg);
35}
36
37function param_unescape(arg) {
38 if (typeof decodeURIComponent != 'undefined')
39 return decodeURIComponent(arg);
40 else
41 return unescape(arg);
42}
43
508a81e1
AD
44function delay(gap) {
45 var then,now;
46 then=new Date().getTime();
47 now=then;
48 while((now-then)<gap) {
49 now=new Date().getTime();
50 }
51}
7726fa02
AD
52
53function notify(msg) {
54
55 var n = document.getElementById("notify");
56
f0601b87
AD
57 if (!n) return;
58
7726fa02
AD
59 n.innerHTML = msg;
60
61 if (msg.length == 0) {
62 n.style.display = "none";
63 } else {
64 n.style.display = "block";
65 }
66
67}
68
508a81e1 69function printLockingError() {
f0601b87 70 notify("Please wait until operation finishes");}
508a81e1 71
13ad9102
AD
72var seq = "";
73
74function hotkey_handler(e) {
760966c1 75
13ad9102
AD
76 var keycode;
77
760966c1
AD
78 if (!hotkeys_enabled) return;
79
13ad9102
AD
80 if (window.event) {
81 keycode = window.event.keyCode;
82 } else if (e) {
83 keycode = e.which;
84 }
85
86 if (keycode == 13 || keycode == 27) {
87 seq = "";
88 } else {
89 seq = seq + "" + keycode;
90 }
91
92 var piggie = document.getElementById("piggie");
93
bb7cface 94 if (piggie) {
13ad9102 95
bb7cface
AD
96 if (seq.match("807371717369")) {
97 localPiggieFunction(true);
98 } else {
99 localPiggieFunction(false);
100 }
101 }
102
9cfc649a
AD
103 if (typeof localHotkeyHandler != 'undefined') {
104 localHotkeyHandler(keycode);
105 }
106
13ad9102
AD
107}
108
f0601b87
AD
109function cleanSelected(element) {
110 var content = document.getElementById(element);
111
112 var rows = new Array();
113
114 for (i = 0; i < content.rows.length; i++) {
115 content.rows[i].className = content.rows[i].className.replace("Selected", "");
116 }
117
118}
119
120function getVisibleUnreadHeadlines() {
121 var content = document.getElementById("headlinesList");
122
123 var rows = new Array();
124
125 for (i = 0; i < content.rows.length; i++) {
126 var row_id = content.rows[i].id.replace("RROW-", "");
127 if (row_id.length > 0 && content.rows[i].className.match("Unread")) {
128 rows.push(row_id);
129 }
130 }
131 return rows;
132}
133
134function getVisibleHeadlineIds() {
135
136 var content = document.getElementById("headlinesList");
137
138 var rows = new Array();
139
140 for (i = 0; i < content.rows.length; i++) {
141 var row_id = content.rows[i].id.replace("RROW-", "");
142 if (row_id.length > 0) {
143 rows.push(row_id);
144 }
145 }
146 return rows;
147}
148
149function getFirstVisibleHeadlineId() {
150 var rows = getVisibleHeadlineIds();
151 return rows[0];
152}
153
154function getLastVisibleHeadlineId() {
155 var rows = getVisibleHeadlineIds();
156 return rows[rows.length-1];
157}
158
159function markHeadline(id) {
160 var row = document.getElementById("RROW-" + id);
161 if (row) {
162 row.className = row.className + "Selected";
163 }
164}
165
166function getFeedIds() {
167 var content = document.getElementById("feedsList");
168
169 var rows = new Array();
170
171 for (i = 0; i < content.rows.length; i++) {
172 var id = content.rows[i].id.replace("FEEDR-", "");
173 if (id.length > 0) {
174 rows.push(id);
175 }
176 }
177
178 return rows;
179}
13ad9102 180
7726fa02 181