]>
Commit | Line | Data |
---|---|---|
760966c1 AD |
1 | var hotkeys_enabled = true; |
2 | ||
3 | function disableHotkeys() { | |
4 | hotkeys_enabled = false; | |
5 | } | |
6 | ||
7 | function enableHotkeys() { | |
8 | hotkeys_enabled = true; | |
9 | } | |
10 | ||
c0e5a40e AD |
11 | function xmlhttp_ready(obj) { |
12 | return obj.readyState == 4 || obj.readyState == 0 || !obj.readyState; | |
13 | } | |
14 | ||
15 | ||
9cfc649a AD |
16 | function notify_callback() { |
17 | var container = document.getElementById('notify'); | |
18 | if (xmlhttp.readyState == 4) { | |
19 | container.innerHTML=xmlhttp.responseText; | |
20 | } | |
21 | } | |
22 | ||
23 | function 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 |
30 | function param_escape(arg) { |
31 | if (typeof encodeURIComponent != 'undefined') | |
32 | return encodeURIComponent(arg); | |
33 | else | |
34 | return escape(arg); | |
35 | } | |
36 | ||
37 | function param_unescape(arg) { | |
38 | if (typeof decodeURIComponent != 'undefined') | |
39 | return decodeURIComponent(arg); | |
40 | else | |
41 | return unescape(arg); | |
42 | } | |
43 | ||
508a81e1 AD |
44 | function 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 | 52 | |
c05608c2 AD |
53 | function p_notify(msg) { |
54 | ||
55 | var n = parent.document.getElementById("notify"); | |
56 | var nb = parent.document.getElementById("notify_body"); | |
57 | ||
58 | if (!n || !nb) return; | |
59 | ||
8dcfffd0 AD |
60 | if (msg == "") { |
61 | nb.innerHTML = " "; | |
62 | n.style.background = "#ffffff"; | |
c05608c2 | 63 | } else { |
8dcfffd0 AD |
64 | nb.innerHTML = msg; |
65 | n.style.background = "#fffff0"; | |
66 | } | |
c05608c2 AD |
67 | } |
68 | ||
7726fa02 AD |
69 | function notify(msg) { |
70 | ||
71 | var n = document.getElementById("notify"); | |
c05608c2 | 72 | var nb = document.getElementById("notify_body"); |
7726fa02 | 73 | |
c05608c2 | 74 | if (!n || !nb) return; |
f0601b87 | 75 | |
8dcfffd0 AD |
76 | if (msg == "") { |
77 | nb.innerHTML = " "; | |
78 | n.style.background = "#ffffff"; | |
7726fa02 | 79 | } else { |
8dcfffd0 AD |
80 | nb.innerHTML = msg; |
81 | n.style.background = "#fffff0"; | |
82 | } | |
7726fa02 AD |
83 | |
84 | } | |
85 | ||
508a81e1 | 86 | function printLockingError() { |
f0601b87 | 87 | notify("Please wait until operation finishes");} |
508a81e1 | 88 | |
13ad9102 AD |
89 | var seq = ""; |
90 | ||
91 | function hotkey_handler(e) { | |
760966c1 | 92 | |
13ad9102 AD |
93 | var keycode; |
94 | ||
760966c1 AD |
95 | if (!hotkeys_enabled) return; |
96 | ||
13ad9102 AD |
97 | if (window.event) { |
98 | keycode = window.event.keyCode; | |
99 | } else if (e) { | |
100 | keycode = e.which; | |
101 | } | |
102 | ||
103 | if (keycode == 13 || keycode == 27) { | |
104 | seq = ""; | |
105 | } else { | |
106 | seq = seq + "" + keycode; | |
107 | } | |
108 | ||
109 | var piggie = document.getElementById("piggie"); | |
110 | ||
bb7cface | 111 | if (piggie) { |
13ad9102 | 112 | |
bb7cface AD |
113 | if (seq.match("807371717369")) { |
114 | localPiggieFunction(true); | |
115 | } else { | |
116 | localPiggieFunction(false); | |
117 | } | |
118 | } | |
119 | ||
9cfc649a AD |
120 | if (typeof localHotkeyHandler != 'undefined') { |
121 | localHotkeyHandler(keycode); | |
122 | } | |
123 | ||
13ad9102 AD |
124 | } |
125 | ||
e828e31e | 126 | function cleanSelectedList(element) { |
f0601b87 AD |
127 | var content = document.getElementById(element); |
128 | ||
e828e31e | 129 | for (i = 0; i < content.childNodes.length; i++) { |
4ce19859 AD |
130 | content.childNodes[i].className = |
131 | content.childNodes[i].className.replace("Selected", ""); | |
e828e31e AD |
132 | } |
133 | ||
134 | } | |
135 | ||
136 | ||
137 | function cleanSelected(element) { | |
138 | var content = document.getElementById(element); | |
f0601b87 AD |
139 | |
140 | for (i = 0; i < content.rows.length; i++) { | |
141 | content.rows[i].className = content.rows[i].className.replace("Selected", ""); | |
142 | } | |
143 | ||
144 | } | |
145 | ||
146 | function getVisibleUnreadHeadlines() { | |
147 | var content = document.getElementById("headlinesList"); | |
148 | ||
149 | var rows = new Array(); | |
150 | ||
151 | for (i = 0; i < content.rows.length; i++) { | |
152 | var row_id = content.rows[i].id.replace("RROW-", ""); | |
153 | if (row_id.length > 0 && content.rows[i].className.match("Unread")) { | |
154 | rows.push(row_id); | |
155 | } | |
156 | } | |
157 | return rows; | |
158 | } | |
159 | ||
160 | function getVisibleHeadlineIds() { | |
161 | ||
162 | var content = document.getElementById("headlinesList"); | |
163 | ||
164 | var rows = new Array(); | |
165 | ||
166 | for (i = 0; i < content.rows.length; i++) { | |
167 | var row_id = content.rows[i].id.replace("RROW-", ""); | |
168 | if (row_id.length > 0) { | |
169 | rows.push(row_id); | |
170 | } | |
171 | } | |
172 | return rows; | |
173 | } | |
174 | ||
175 | function getFirstVisibleHeadlineId() { | |
176 | var rows = getVisibleHeadlineIds(); | |
177 | return rows[0]; | |
178 | } | |
179 | ||
180 | function getLastVisibleHeadlineId() { | |
181 | var rows = getVisibleHeadlineIds(); | |
182 | return rows[rows.length-1]; | |
183 | } | |
184 | ||
185 | function markHeadline(id) { | |
186 | var row = document.getElementById("RROW-" + id); | |
187 | if (row) { | |
188 | row.className = row.className + "Selected"; | |
189 | } | |
190 | } | |
191 | ||
192 | function getFeedIds() { | |
193 | var content = document.getElementById("feedsList"); | |
194 | ||
195 | var rows = new Array(); | |
196 | ||
197 | for (i = 0; i < content.rows.length; i++) { | |
198 | var id = content.rows[i].id.replace("FEEDR-", ""); | |
199 | if (id.length > 0) { | |
200 | rows.push(id); | |
201 | } | |
202 | } | |
203 | ||
204 | return rows; | |
205 | } | |
13ad9102 | 206 | |
ac43eba1 AD |
207 | function setCookie(name, value, expires, path, domain, secure) { |
208 | document.cookie= name + "=" + escape(value) + | |
209 | ((expires) ? "; expires=" + expires.toGMTString() : "") + | |
210 | ((path) ? "; path=" + path : "") + | |
211 | ((domain) ? "; domain=" + domain : "") + | |
212 | ((secure) ? "; secure" : ""); | |
213 | } | |
214 | ||
215 | function getCookie(name) { | |
216 | ||
217 | var dc = document.cookie; | |
218 | var prefix = name + "="; | |
219 | var begin = dc.indexOf("; " + prefix); | |
220 | if (begin == -1) { | |
221 | begin = dc.indexOf(prefix); | |
222 | if (begin != 0) return null; | |
223 | } | |
224 | else { | |
225 | begin += 2; | |
226 | } | |
227 | var end = document.cookie.indexOf(";", begin); | |
228 | if (end == -1) { | |
229 | end = dc.length; | |
230 | } | |
231 | return unescape(dc.substring(begin + prefix.length, end)); | |
232 | } | |
233 | ||
1a66d16e AD |
234 | function disableContainerChildren(id, disable, doc) { |
235 | ||
236 | if (!doc) doc = document; | |
237 | ||
238 | var container = doc.getElementById(id); | |
ac43eba1 AD |
239 | |
240 | for (var i = 0; i < container.childNodes.length; i++) { | |
241 | var child = container.childNodes[i]; | |
242 | ||
d5224f0d AD |
243 | try { |
244 | child.disabled = disable; | |
245 | } catch (E) { | |
246 | ||
247 | } | |
ac43eba1 AD |
248 | |
249 | if (disable) { | |
250 | if (child.className && child.className.match("button")) { | |
251 | child.className = "disabledButton"; | |
252 | } | |
253 | } else { | |
254 | if (child.className && child.className.match("disabledButton")) { | |
255 | child.className = "button"; | |
256 | } | |
d5224f0d | 257 | } |
ac43eba1 AD |
258 | } |
259 | ||
260 | } | |
7726fa02 | 261 | |
e828e31e AD |
262 | function gotoPreferences() { |
263 | document.location.href = "prefs.php"; | |
264 | } | |
265 | ||
266 | function gotoMain() { | |
267 | document.location.href = "tt-rss.php"; | |
268 | } | |
269 | ||
8158c57a AD |
270 | function gotoExportOpml() { |
271 | document.location.href = "opml.php?op=Export"; | |
272 | } | |
86741347 AD |
273 | |
274 | function getActiveFeedId() { | |
275 | return getCookie("ttrss_vf_actfeed"); | |
276 | } | |
277 | ||
278 | function setActiveFeedId(id) { | |
279 | return setCookie("ttrss_vf_actfeed", id); | |
280 | } | |
090e250b AD |
281 | |
282 | var xmlhttp_rpc = false; | |
283 | ||
284 | /*@cc_on @*/ | |
285 | /*@if (@_jscript_version >= 5) | |
286 | // JScript gives us Conditional compilation, we can cope with old IE versions. | |
287 | // and security blocked creation of the objects. | |
288 | try { | |
289 | xmlhttp_rpc = new ActiveXObject("Msxml2.XMLHTTP"); | |
290 | } catch (e) { | |
291 | try { | |
292 | xmlhttp_rpc = new ActiveXObject("Microsoft.XMLHTTP"); | |
293 | } catch (E) { | |
294 | xmlhttp_rpc = false; | |
295 | } | |
296 | } | |
297 | @end @*/ | |
298 | ||
299 | if (!xmlhttp_rpc && typeof XMLHttpRequest!='undefined') { | |
300 | xmlhttp_rpc = new XMLHttpRequest(); | |
301 | } | |
302 | ||
303 | function label_counters_callback() { | |
304 | if (xmlhttp_rpc.readyState == 4) { | |
bc18bcdd | 305 | |
9cab3250 | 306 | if (!xmlhttp_rpc.responseXML) { |
bc18bcdd AD |
307 | notify("label_counters_callback: backend did not return valid XML"); |
308 | return; | |
309 | } | |
310 | ||
090e250b AD |
311 | var reply = xmlhttp_rpc.responseXML.firstChild; |
312 | ||
313 | var f_document = parent.frames["feeds-frame"].document; | |
314 | ||
315 | for (var l = 0; l < reply.childNodes.length; l++) { | |
316 | var id = reply.childNodes[l].getAttribute("id"); | |
317 | var ctr = reply.childNodes[l].getAttribute("counter"); | |
318 | ||
319 | var feedctr = f_document.getElementById("FEEDCTR-" + id); | |
320 | var feedu = f_document.getElementById("FEEDU-" + id); | |
392d4563 | 321 | var feedr = f_document.getElementById("FEEDR-" + id); |
090e250b | 322 | |
8143ae1f AD |
323 | if (feedctr && feedu && feedr) { |
324 | ||
325 | feedu.innerHTML = ctr; | |
326 | ||
327 | if (ctr > 0) { | |
328 | feedctr.className = "odd"; | |
329 | if (!feedr.className.match("Unread")) { | |
330 | feedr.className = feedr.className + "Unread"; | |
331 | } | |
332 | } else { | |
333 | feedctr.className = "invisible"; | |
334 | feedr.className = feedr.className.replace("Unread", ""); | |
335 | } | |
336 | } | |
090e250b AD |
337 | } |
338 | } | |
339 | } | |
340 | ||
8073cce7 | 341 | function update_label_counters(feed) { |
090e250b | 342 | if (xmlhttp_ready(xmlhttp_rpc)) { |
8143ae1f | 343 | var query = "backend.php?op=rpc&subop=getAllCounters"; |
e47cfe37 AD |
344 | |
345 | if (feed > 0) { | |
346 | query = query + "&aid=" + feed; | |
347 | } | |
348 | ||
090e250b AD |
349 | xmlhttp_rpc.open("GET", query, true); |
350 | xmlhttp_rpc.onreadystatechange=label_counters_callback; | |
351 | xmlhttp_rpc.send(null); | |
352 | } | |
353 | } | |
7dc66a61 AD |
354 | |
355 | function popupHelp(tid) { | |
356 | var w = window.open("backend.php?op=help&tid=" + tid, | |
357 | "Popup Help", | |
358 | "menubar=no,location=no,resizable=yes,scrollbars=yes,status=no"); | |
359 | } | |
b6644d29 AD |
360 | |
361 | /** * @(#)isNumeric.js * * Copyright (c) 2000 by Sundar Dorai-Raj | |
362 | * * @author Sundar Dorai-Raj | |
363 | * * Email: sdoraira@vt.edu | |
364 | * * This program is free software; you can redistribute it and/or | |
365 | * * modify it under the terms of the GNU General Public License | |
366 | * * as published by the Free Software Foundation; either version 2 | |
367 | * * of the License, or (at your option) any later version, | |
368 | * * provided that any use properly credits the author. | |
369 | * * This program is distributed in the hope that it will be useful, | |
370 | * * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
371 | * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
372 | * * GNU General Public License for more details at http://www.gnu.org * * */ | |
373 | ||
374 | var numbers=".0123456789"; | |
375 | function isNumeric(x) { | |
376 | // is x a String or a character? | |
377 | if(x.length>1) { | |
378 | // remove negative sign | |
379 | x=Math.abs(x)+""; | |
380 | for(j=0;j<x.length;j++) { | |
381 | // call isNumeric recursively for each character | |
382 | number=isNumeric(x.substring(j,j+1)); | |
383 | if(!number) return number; | |
384 | } | |
385 | return number; | |
386 | } | |
387 | else { | |
388 | // if x is number return true | |
389 | if(numbers.indexOf(x)>=0) return true; | |
390 | return false; | |
391 | } | |
392 | } | |
393 | ||
3745788e AD |
394 | |
395 | function hideOrShowFeeds(doc, hide) { | |
396 | ||
397 | var css_rules = doc.styleSheets[0].cssRules; | |
398 | ||
399 | for (i = 0; i < css_rules.length; i++) { | |
400 | var rule = css_rules[i]; | |
401 | ||
402 | if (rule.selectorText == "ul.feedList li.feed") { | |
403 | if (!hide) { | |
404 | rule.style.display = "block"; | |
405 | } else { | |
406 | rule.style.display = "none"; | |
407 | } | |
408 | } | |
409 | ||
410 | } | |
411 | ||
412 | } | |
413 | ||
295f9b42 AD |
414 | function fatalError(code) { |
415 | window.location = "error.php?c=" + param_escape(code); | |
3745788e | 416 | |
295f9b42 | 417 | } |