]>
Commit | Line | Data |
---|---|---|
760966c1 AD |
1 | var hotkeys_enabled = true; |
2 | ||
292a8a12 | 3 | function browser_has_opacity() { |
605f7d46 AD |
4 | return navigator.userAgent.match("Gecko") != null || |
5 | navigator.userAgent.match("Opera") != null; | |
292a8a12 AD |
6 | } |
7 | ||
7719618b | 8 | function exception_error(location, e) { |
83f043bb AD |
9 | var msg; |
10 | ||
11 | if (e.fileName) { | |
12 | var base_fname = e.fileName.substring(e.fileName.lastIndexOf("/") + 1); | |
13 | ||
14 | msg = "Exception: " + e.name + ", " + e.message + | |
15 | "\nFunction: " + location + "()" + | |
16 | "\nLocation: " + base_fname + ":" + e.lineNumber; | |
17 | } else { | |
18 | msg = "Exception: " + e + "\nFunction: " + location + "()"; | |
19 | } | |
20 | ||
21 | alert(msg); | |
7719618b AD |
22 | } |
23 | ||
760966c1 AD |
24 | function disableHotkeys() { |
25 | hotkeys_enabled = false; | |
26 | } | |
27 | ||
28 | function enableHotkeys() { | |
29 | hotkeys_enabled = true; | |
30 | } | |
31 | ||
c0e5a40e AD |
32 | function xmlhttp_ready(obj) { |
33 | return obj.readyState == 4 || obj.readyState == 0 || !obj.readyState; | |
34 | } | |
35 | ||
9cfc649a AD |
36 | function notify_callback() { |
37 | var container = document.getElementById('notify'); | |
38 | if (xmlhttp.readyState == 4) { | |
39 | container.innerHTML=xmlhttp.responseText; | |
40 | } | |
41 | } | |
42 | ||
43 | function rpc_notify_callback() { | |
44 | var container = document.getElementById('notify'); | |
45 | if (xmlhttp_rpc.readyState == 4) { | |
46 | container.innerHTML=xmlhttp_rpc.responseText; | |
47 | } | |
48 | } | |
49 | ||
1572afe5 AD |
50 | function rpc_pnotify_callback() { |
51 | var container = parent.document.getElementById('notify'); | |
52 | if (xmlhttp_rpc.readyState == 4) { | |
53 | container.innerHTML=xmlhttp_rpc.responseText; | |
54 | } | |
55 | } | |
56 | ||
7726fa02 AD |
57 | function param_escape(arg) { |
58 | if (typeof encodeURIComponent != 'undefined') | |
59 | return encodeURIComponent(arg); | |
60 | else | |
61 | return escape(arg); | |
62 | } | |
63 | ||
64 | function param_unescape(arg) { | |
65 | if (typeof decodeURIComponent != 'undefined') | |
66 | return decodeURIComponent(arg); | |
67 | else | |
68 | return unescape(arg); | |
69 | } | |
70 | ||
508a81e1 AD |
71 | function delay(gap) { |
72 | var then,now; | |
73 | then=new Date().getTime(); | |
74 | now=then; | |
75 | while((now-then)<gap) { | |
76 | now=new Date().getTime(); | |
77 | } | |
78 | } | |
7726fa02 | 79 | |
ce3bf408 AD |
80 | var notify_hide_timerid = false; |
81 | var notify_last_doc = false; | |
82 | ||
83 | function hide_notify() { | |
84 | if (notify_last_doc) { | |
85 | var n = notify_last_doc.getElementById("notify"); | |
292a8a12 | 86 | if (browser_has_opacity()) { |
ce3bf408 | 87 | if (notify_opacity >= 0) { |
0655a1d5 | 88 | notify_opacity = notify_opacity - 0.1; |
ce3bf408 | 89 | n.style.opacity = notify_opacity; |
292a8a12 | 90 | notify_hide_timerid = window.setTimeout("hide_notify()", 20); |
ce3bf408 AD |
91 | } else { |
92 | n.style.display = "none"; | |
292a8a12 | 93 | n.style.opacity = 1; |
ce3bf408 AD |
94 | } |
95 | } else { | |
96 | n.style.display = "none"; | |
97 | } | |
8dcfffd0 | 98 | } |
c05608c2 AD |
99 | } |
100 | ||
0530ddd8 | 101 | function notify_real(msg, doc, no_hide, is_err) { |
7726fa02 | 102 | |
ce3bf408 AD |
103 | var n = doc.getElementById("notify"); |
104 | var nb = doc.getElementById("notify_body"); | |
7726fa02 | 105 | |
c05608c2 | 106 | if (!n || !nb) return; |
f0601b87 | 107 | |
0655a1d5 AD |
108 | if (notify_hide_timerid) { |
109 | window.clearTimeout(notify_hide_timerid); | |
110 | } | |
111 | ||
112 | notify_last_doc = doc; | |
113 | notify_opacity = 1; | |
114 | ||
8dcfffd0 | 115 | if (msg == "") { |
0655a1d5 AD |
116 | if (n.style.display == "block") { |
117 | notify_hide_timerid = window.setTimeout("hide_notify()", 0); | |
118 | } | |
119 | return; | |
7726fa02 | 120 | } else { |
0ceded7a | 121 | n.style.display = "block"; |
8dcfffd0 | 122 | } |
7726fa02 | 123 | |
0530ddd8 | 124 | if (is_err) { |
caa53a7c AD |
125 | n.style.backgroundColor = "#ffcccc"; |
126 | n.style.color = "black"; | |
0530ddd8 AD |
127 | n.style.borderColor = "#ff0000"; |
128 | } else { | |
129 | n.style.backgroundColor = "#fff7d5"; | |
130 | n.style.borderColor = "#d7c47a"; | |
131 | n.style.color = "black"; | |
132 | } | |
133 | ||
0ceded7a AD |
134 | nb.innerHTML = msg; |
135 | ||
4d4200a8 | 136 | if (!no_hide) { |
292a8a12 | 137 | notify_hide_timerid = window.setTimeout("hide_notify()", 3000); |
4d4200a8 | 138 | } |
ce3bf408 AD |
139 | } |
140 | ||
0530ddd8 AD |
141 | function p_notify(msg, no_hide, is_err) { |
142 | notify_real(msg, parent.document, no_hide, is_err); | |
ce3bf408 AD |
143 | } |
144 | ||
0530ddd8 AD |
145 | function notify(msg, no_hide, is_err) { |
146 | notify_real(msg, document, no_hide, is_err); | |
7726fa02 AD |
147 | } |
148 | ||
508a81e1 | 149 | function printLockingError() { |
f0601b87 | 150 | notify("Please wait until operation finishes");} |
508a81e1 | 151 | |
13ad9102 AD |
152 | var seq = ""; |
153 | ||
154 | function hotkey_handler(e) { | |
760966c1 | 155 | |
13ad9102 AD |
156 | var keycode; |
157 | ||
760966c1 AD |
158 | if (!hotkeys_enabled) return; |
159 | ||
13ad9102 AD |
160 | if (window.event) { |
161 | keycode = window.event.keyCode; | |
162 | } else if (e) { | |
163 | keycode = e.which; | |
164 | } | |
165 | ||
166 | if (keycode == 13 || keycode == 27) { | |
167 | seq = ""; | |
168 | } else { | |
169 | seq = seq + "" + keycode; | |
170 | } | |
171 | ||
2e02b896 AD |
172 | if (document.getElementById("piggie")) { |
173 | ||
174 | if (seq.match("807371717369")) { | |
175 | seq = ""; | |
176 | localPiggieFunction(true); | |
177 | } else { | |
178 | localPiggieFunction(false); | |
179 | } | |
bb7cface AD |
180 | } |
181 | ||
9cfc649a | 182 | if (typeof localHotkeyHandler != 'undefined') { |
7b433d8c AD |
183 | try { |
184 | localHotkeyHandler(keycode); | |
185 | } catch (e) { | |
83f043bb | 186 | exception_error("hotkey_handler", e); |
7b433d8c | 187 | } |
9cfc649a AD |
188 | } |
189 | ||
13ad9102 AD |
190 | } |
191 | ||
e828e31e | 192 | function cleanSelectedList(element) { |
f0601b87 AD |
193 | var content = document.getElementById(element); |
194 | ||
703b632e AD |
195 | if (!document.getElementById("feedCatHolder")) { |
196 | for (i = 0; i < content.childNodes.length; i++) { | |
197 | var child = content.childNodes[i]; | |
d0bb308e AD |
198 | try { |
199 | child.className = child.className.replace("Selected", ""); | |
200 | } catch (e) { | |
201 | // | |
202 | } | |
703b632e AD |
203 | } |
204 | } else { | |
205 | for (i = 0; i < content.childNodes.length; i++) { | |
206 | var child = content.childNodes[i]; | |
703b632e | 207 | if (child.id == "feedCatHolder") { |
befc807f | 208 | parent.debug(child.id); |
c3f348c2 | 209 | var fcat = child.lastChild; |
703b632e | 210 | for (j = 0; j < fcat.childNodes.length; j++) { |
befc807f | 211 | var feed = fcat.childNodes[j]; |
703b632e AD |
212 | feed.className = feed.className.replace("Selected", ""); |
213 | } | |
214 | } | |
befc807f | 215 | } |
703b632e | 216 | } |
e828e31e AD |
217 | } |
218 | ||
219 | ||
220 | function cleanSelected(element) { | |
221 | var content = document.getElementById(element); | |
f0601b87 AD |
222 | |
223 | for (i = 0; i < content.rows.length; i++) { | |
224 | content.rows[i].className = content.rows[i].className.replace("Selected", ""); | |
225 | } | |
f0601b87 AD |
226 | } |
227 | ||
228 | function getVisibleUnreadHeadlines() { | |
229 | var content = document.getElementById("headlinesList"); | |
230 | ||
231 | var rows = new Array(); | |
232 | ||
233 | for (i = 0; i < content.rows.length; i++) { | |
234 | var row_id = content.rows[i].id.replace("RROW-", ""); | |
235 | if (row_id.length > 0 && content.rows[i].className.match("Unread")) { | |
236 | rows.push(row_id); | |
237 | } | |
238 | } | |
239 | return rows; | |
240 | } | |
241 | ||
242 | function getVisibleHeadlineIds() { | |
243 | ||
244 | var content = document.getElementById("headlinesList"); | |
245 | ||
246 | var rows = new Array(); | |
247 | ||
248 | for (i = 0; i < content.rows.length; i++) { | |
249 | var row_id = content.rows[i].id.replace("RROW-", ""); | |
250 | if (row_id.length > 0) { | |
251 | rows.push(row_id); | |
252 | } | |
253 | } | |
254 | return rows; | |
255 | } | |
256 | ||
257 | function getFirstVisibleHeadlineId() { | |
258 | var rows = getVisibleHeadlineIds(); | |
259 | return rows[0]; | |
260 | } | |
261 | ||
262 | function getLastVisibleHeadlineId() { | |
263 | var rows = getVisibleHeadlineIds(); | |
264 | return rows[rows.length-1]; | |
265 | } | |
266 | ||
267 | function markHeadline(id) { | |
268 | var row = document.getElementById("RROW-" + id); | |
269 | if (row) { | |
35f3c923 AD |
270 | var is_active = false; |
271 | ||
272 | if (row.className.match("Active")) { | |
273 | is_active = true; | |
274 | } | |
275 | row.className = row.className.replace("Selected", ""); | |
276 | row.className = row.className.replace("Active", ""); | |
277 | row.className = row.className.replace("Insensitive", ""); | |
278 | ||
279 | if (is_active) { | |
280 | row.className = row.className = "Active"; | |
281 | } | |
282 | ||
72020095 AD |
283 | var check = document.getElementById("RCHK-" + id); |
284 | ||
285 | if (check) { | |
286 | check.checked = true; | |
287 | } | |
288 | ||
35f3c923 AD |
289 | row.className = row.className + "Selected"; |
290 | ||
f0601b87 AD |
291 | } |
292 | } | |
293 | ||
294 | function getFeedIds() { | |
295 | var content = document.getElementById("feedsList"); | |
296 | ||
297 | var rows = new Array(); | |
298 | ||
299 | for (i = 0; i < content.rows.length; i++) { | |
300 | var id = content.rows[i].id.replace("FEEDR-", ""); | |
301 | if (id.length > 0) { | |
302 | rows.push(id); | |
303 | } | |
304 | } | |
305 | ||
306 | return rows; | |
307 | } | |
13ad9102 | 308 | |
76b4eae1 AD |
309 | function setCookie(name, value, lifetime, path, domain, secure) { |
310 | ||
311 | var d = false; | |
312 | ||
313 | if (lifetime) { | |
314 | d = new Date(); | |
315 | d.setTime(lifetime * 1000); | |
316 | } | |
317 | ||
318 | int_setCookie(name, value, d, path, domain, secure); | |
319 | ||
320 | } | |
321 | ||
322 | function int_setCookie(name, value, expires, path, domain, secure) { | |
ac43eba1 AD |
323 | document.cookie= name + "=" + escape(value) + |
324 | ((expires) ? "; expires=" + expires.toGMTString() : "") + | |
325 | ((path) ? "; path=" + path : "") + | |
326 | ((domain) ? "; domain=" + domain : "") + | |
327 | ((secure) ? "; secure" : ""); | |
328 | } | |
329 | ||
76b4eae1 AD |
330 | function delCookie(name, path, domain) { |
331 | if (getCookie(name)) { | |
332 | document.cookie = name + "=" + | |
333 | ((path) ? ";path=" + path : "") + | |
334 | ((domain) ? ";domain=" + domain : "" ) + | |
335 | ";expires=Thu, 01-Jan-1970 00:00:01 GMT"; | |
336 | } | |
337 | } | |
338 | ||
339 | ||
ac43eba1 AD |
340 | function getCookie(name) { |
341 | ||
342 | var dc = document.cookie; | |
343 | var prefix = name + "="; | |
344 | var begin = dc.indexOf("; " + prefix); | |
345 | if (begin == -1) { | |
346 | begin = dc.indexOf(prefix); | |
347 | if (begin != 0) return null; | |
348 | } | |
349 | else { | |
350 | begin += 2; | |
351 | } | |
352 | var end = document.cookie.indexOf(";", begin); | |
353 | if (end == -1) { | |
354 | end = dc.length; | |
355 | } | |
356 | return unescape(dc.substring(begin + prefix.length, end)); | |
357 | } | |
358 | ||
1a66d16e AD |
359 | function disableContainerChildren(id, disable, doc) { |
360 | ||
361 | if (!doc) doc = document; | |
362 | ||
363 | var container = doc.getElementById(id); | |
ac43eba1 AD |
364 | |
365 | for (var i = 0; i < container.childNodes.length; i++) { | |
366 | var child = container.childNodes[i]; | |
367 | ||
d5224f0d AD |
368 | try { |
369 | child.disabled = disable; | |
370 | } catch (E) { | |
371 | ||
372 | } | |
ac43eba1 AD |
373 | |
374 | if (disable) { | |
375 | if (child.className && child.className.match("button")) { | |
376 | child.className = "disabledButton"; | |
377 | } | |
378 | } else { | |
379 | if (child.className && child.className.match("disabledButton")) { | |
380 | child.className = "button"; | |
381 | } | |
d5224f0d | 382 | } |
ac43eba1 AD |
383 | } |
384 | ||
385 | } | |
7726fa02 | 386 | |
e828e31e AD |
387 | function gotoPreferences() { |
388 | document.location.href = "prefs.php"; | |
389 | } | |
390 | ||
391 | function gotoMain() { | |
392 | document.location.href = "tt-rss.php"; | |
393 | } | |
394 | ||
8158c57a AD |
395 | function gotoExportOpml() { |
396 | document.location.href = "opml.php?op=Export"; | |
397 | } | |
86741347 AD |
398 | |
399 | function getActiveFeedId() { | |
400 | return getCookie("ttrss_vf_actfeed"); | |
401 | } | |
402 | ||
403 | function setActiveFeedId(id) { | |
404 | return setCookie("ttrss_vf_actfeed", id); | |
405 | } | |
090e250b | 406 | |
a58069db | 407 | var xmlhttp_rpc = Ajax.getTransport(); |
090e250b | 408 | |
e8ef3b97 | 409 | function parse_counters(reply, f_document, title_obj, scheduled_call) { |
1a6a9555 AD |
410 | try { |
411 | for (var l = 0; l < reply.childNodes.length; l++) { | |
9cbca41f AD |
412 | if (!reply.childNodes[l] || |
413 | typeof(reply.childNodes[l].getAttribute) == "undefined") { | |
6043fb7e AD |
414 | // where did this come from? |
415 | continue; | |
416 | } | |
417 | ||
1a6a9555 AD |
418 | var id = reply.childNodes[l].getAttribute("id"); |
419 | var t = reply.childNodes[l].getAttribute("type"); | |
420 | var ctr = reply.childNodes[l].getAttribute("counter"); | |
023fe037 AD |
421 | var error = reply.childNodes[l].getAttribute("error"); |
422 | var has_img = reply.childNodes[l].getAttribute("hi"); | |
fb1fb4ab | 423 | var updated = reply.childNodes[l].getAttribute("updated"); |
1a6a9555 AD |
424 | |
425 | if (id == "global-unread") { | |
3bdb368b AD |
426 | title_obj.global_unread = ctr; |
427 | title_obj.updateTitle(); | |
1a6a9555 AD |
428 | continue; |
429 | } | |
430 | ||
431 | if (t == "category") { | |
432 | var catctr = f_document.getElementById("FCATCTR-" + id); | |
433 | if (catctr) { | |
434 | catctr.innerHTML = "(" + ctr + " unread)"; | |
435 | } | |
436 | continue; | |
437 | } | |
438 | ||
439 | var feedctr = f_document.getElementById("FEEDCTR-" + id); | |
440 | var feedu = f_document.getElementById("FEEDU-" + id); | |
441 | var feedr = f_document.getElementById("FEEDR-" + id); | |
023fe037 | 442 | var feed_img = f_document.getElementById("FIMG-" + id); |
fb1fb4ab AD |
443 | var feedlink = f_document.getElementById("FEEDL-" + id); |
444 | ||
445 | if (updated && feedlink) { | |
446 | if (error) { | |
447 | feedlink.title = "Error: " + error + " (" + updated + ")"; | |
448 | } else { | |
449 | feedlink.title = "Updated: " + updated; | |
450 | } | |
451 | } | |
023fe037 | 452 | |
1a6a9555 | 453 | if (feedctr && feedu && feedr) { |
e8ef3b97 AD |
454 | |
455 | if (feedu.innerHTML != ctr && id == getActiveFeedId() && scheduled_call) { | |
456 | var hf = title_obj.parent.frames["headlines-frame"]; | |
457 | hf.location.reload(true); | |
458 | } | |
1a6a9555 AD |
459 | |
460 | feedu.innerHTML = ctr; | |
023fe037 | 461 | |
426d3c57 AD |
462 | if (error) { |
463 | feedr.className = feedr.className.replace("feed", "error"); | |
464 | } else if (id > 0) { | |
465 | feedr.className = feedr.className.replace("error", "feed"); | |
023fe037 | 466 | } |
1a6a9555 AD |
467 | |
468 | if (ctr > 0) { | |
469 | feedctr.className = "odd"; | |
470 | if (!feedr.className.match("Unread")) { | |
471 | var is_selected = feedr.className.match("Selected"); | |
472 | ||
473 | feedr.className = feedr.className.replace("Selected", ""); | |
474 | feedr.className = feedr.className.replace("Unread", ""); | |
475 | ||
476 | feedr.className = feedr.className + "Unread"; | |
477 | ||
478 | if (is_selected) { | |
479 | feedr.className = feedr.className + "Selected"; | |
480 | } | |
481 | ||
482 | } | |
483 | } else { | |
484 | feedctr.className = "invisible"; | |
485 | feedr.className = feedr.className.replace("Unread", ""); | |
486 | } | |
487 | } | |
488 | } | |
489 | } catch (e) { | |
83f043bb | 490 | exception_error("parse_counters", e); |
1a6a9555 AD |
491 | } |
492 | } | |
493 | ||
3bdb368b AD |
494 | // this one is called from feedlist context |
495 | // thus title_obj passed to parse_counters is parent (e.g. main ttrss window) | |
496 | ||
4f3a84f4 | 497 | function all_counters_callback() { |
090e250b | 498 | if (xmlhttp_rpc.readyState == 4) { |
7719618b | 499 | try { |
3866b046 | 500 | if (!xmlhttp_rpc.responseXML || !xmlhttp_rpc.responseXML.firstChild) { |
7719618b AD |
501 | notify("[all_counters_callback] backend did not return valid XML"); |
502 | return; | |
503 | } | |
894ebcf5 AD |
504 | |
505 | if (!parent.frames["feeds-frame"]) { | |
506 | notify("[all_counters_callback] no parent feeds-frame"); | |
507 | return; | |
508 | } | |
509 | ||
7719618b | 510 | var reply = xmlhttp_rpc.responseXML.firstChild; |
7719618b | 511 | var f_document = parent.frames["feeds-frame"].document; |
280ee9a3 | 512 | |
3bdb368b | 513 | parse_counters(reply, f_document, parent); |
7719618b | 514 | |
7719618b AD |
515 | } catch (e) { |
516 | exception_error("all_counters_callback", e); | |
090e250b AD |
517 | } |
518 | } | |
519 | } | |
520 | ||
4f3a84f4 | 521 | function update_all_counters(feed) { |
090e250b | 522 | if (xmlhttp_ready(xmlhttp_rpc)) { |
8143ae1f | 523 | var query = "backend.php?op=rpc&subop=getAllCounters"; |
e47cfe37 AD |
524 | |
525 | if (feed > 0) { | |
526 | query = query + "&aid=" + feed; | |
527 | } | |
528 | ||
090e250b | 529 | xmlhttp_rpc.open("GET", query, true); |
4f3a84f4 | 530 | xmlhttp_rpc.onreadystatechange=all_counters_callback; |
090e250b AD |
531 | xmlhttp_rpc.send(null); |
532 | } | |
533 | } | |
7dc66a61 AD |
534 | |
535 | function popupHelp(tid) { | |
536 | var w = window.open("backend.php?op=help&tid=" + tid, | |
537 | "Popup Help", | |
538 | "menubar=no,location=no,resizable=yes,scrollbars=yes,status=no"); | |
539 | } | |
b6644d29 AD |
540 | |
541 | /** * @(#)isNumeric.js * * Copyright (c) 2000 by Sundar Dorai-Raj | |
542 | * * @author Sundar Dorai-Raj | |
543 | * * Email: sdoraira@vt.edu | |
544 | * * This program is free software; you can redistribute it and/or | |
545 | * * modify it under the terms of the GNU General Public License | |
546 | * * as published by the Free Software Foundation; either version 2 | |
547 | * * of the License, or (at your option) any later version, | |
548 | * * provided that any use properly credits the author. | |
549 | * * This program is distributed in the hope that it will be useful, | |
550 | * * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
551 | * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
552 | * * GNU General Public License for more details at http://www.gnu.org * * */ | |
553 | ||
554 | var numbers=".0123456789"; | |
555 | function isNumeric(x) { | |
556 | // is x a String or a character? | |
557 | if(x.length>1) { | |
558 | // remove negative sign | |
559 | x=Math.abs(x)+""; | |
560 | for(j=0;j<x.length;j++) { | |
561 | // call isNumeric recursively for each character | |
562 | number=isNumeric(x.substring(j,j+1)); | |
563 | if(!number) return number; | |
564 | } | |
565 | return number; | |
566 | } | |
567 | else { | |
568 | // if x is number return true | |
569 | if(numbers.indexOf(x)>=0) return true; | |
570 | return false; | |
571 | } | |
572 | } | |
573 | ||
3745788e AD |
574 | |
575 | function hideOrShowFeeds(doc, hide) { | |
576 | ||
3ed751d4 AD |
577 | if (!doc.styleSheets) return; |
578 | ||
3745788e AD |
579 | var css_rules = doc.styleSheets[0].cssRules; |
580 | ||
bbf4d0b2 AD |
581 | if (!css_rules || !css_rules.length) return; |
582 | ||
3745788e AD |
583 | for (i = 0; i < css_rules.length; i++) { |
584 | var rule = css_rules[i]; | |
585 | ||
586 | if (rule.selectorText == "ul.feedList li.feed") { | |
587 | if (!hide) { | |
588 | rule.style.display = "block"; | |
589 | } else { | |
590 | rule.style.display = "none"; | |
591 | } | |
592 | } | |
593 | ||
594 | } | |
595 | ||
596 | } | |
597 | ||
35f3c923 AD |
598 | function selectTableRow(r, do_select) { |
599 | r.className = r.className.replace("Selected", ""); | |
600 | ||
601 | if (do_select) { | |
602 | r.className = r.className + "Selected"; | |
603 | } | |
604 | } | |
605 | ||
6c12c809 AD |
606 | function selectTableRowById(elem_id, check_id, do_select) { |
607 | ||
608 | try { | |
609 | ||
610 | var row = document.getElementById(elem_id); | |
611 | ||
612 | if (row) { | |
613 | selectTableRow(row, do_select); | |
614 | } | |
615 | ||
616 | var check = document.getElementById(check_id); | |
617 | ||
618 | if (check) { | |
619 | check.checked = do_select; | |
620 | } | |
621 | } catch (e) { | |
622 | exception_error("selectTableRowById", e); | |
623 | } | |
624 | } | |
625 | ||
1572afe5 | 626 | function selectTableRowsByIdPrefix(content_id, prefix, check_prefix, do_select, |
649e0af9 | 627 | classcheck, reset_others) { |
3745788e | 628 | |
35f3c923 AD |
629 | var content = document.getElementById(content_id); |
630 | ||
631 | if (!content) { | |
632 | alert("[selectTableRows] Element " + content_id + " not found."); | |
633 | return; | |
634 | } | |
635 | ||
636 | for (i = 0; i < content.rows.length; i++) { | |
1572afe5 AD |
637 | if (!classcheck || content.rows[i].className.match(classcheck)) { |
638 | ||
639 | if (content.rows[i].id.match(prefix)) { | |
640 | selectTableRow(content.rows[i], do_select); | |
649e0af9 AD |
641 | |
642 | var row_id = content.rows[i].id.replace(prefix, ""); | |
643 | var check = document.getElementById(check_prefix + row_id); | |
3055bc41 | 644 | |
649e0af9 AD |
645 | if (check) { |
646 | check.checked = do_select; | |
647 | } | |
648 | } else if (reset_others) { | |
649 | selectTableRow(content.rows[i], false); | |
7d8d10c6 AD |
650 | |
651 | var row_id = content.rows[i].id.replace(prefix, ""); | |
652 | var check = document.getElementById(check_prefix + row_id); | |
653 | ||
654 | if (check) { | |
655 | check.checked = false; | |
656 | } | |
657 | ||
1572afe5 | 658 | } |
649e0af9 AD |
659 | } else if (reset_others) { |
660 | selectTableRow(content.rows[i], false); | |
7d8d10c6 AD |
661 | |
662 | var row_id = content.rows[i].id.replace(prefix, ""); | |
663 | var check = document.getElementById(check_prefix + row_id); | |
664 | ||
665 | if (check) { | |
666 | check.checked = false; | |
667 | } | |
668 | ||
3055bc41 | 669 | } |
35f3c923 | 670 | } |
295f9b42 | 671 | } |
91ff844a AD |
672 | |
673 | function getSelectedTableRowIds(content_id, prefix) { | |
674 | ||
675 | var content = document.getElementById(content_id); | |
676 | ||
677 | if (!content) { | |
678 | alert("[getSelectedTableRowIds] Element " + content_id + " not found."); | |
679 | return; | |
680 | } | |
681 | ||
682 | var sel_rows = new Array(); | |
683 | ||
684 | for (i = 0; i < content.rows.length; i++) { | |
1572afe5 AD |
685 | if (content.rows[i].id.match(prefix) && |
686 | content.rows[i].className.match("Selected")) { | |
687 | ||
91ff844a AD |
688 | var row_id = content.rows[i].id.replace(prefix + "-", ""); |
689 | sel_rows.push(row_id); | |
690 | } | |
691 | } | |
692 | ||
693 | return sel_rows; | |
694 | ||
695 | } | |
696 | ||
386cbf27 AD |
697 | function toggleSelectRowById(sender, id) { |
698 | var row = document.getElementById(id); | |
699 | ||
700 | if (sender.checked) { | |
701 | if (!row.className.match("Selected")) { | |
702 | row.className = row.className + "Selected"; | |
703 | } | |
704 | } else { | |
705 | if (row.className.match("Selected")) { | |
706 | row.className = row.className.replace("Selected", ""); | |
707 | } | |
708 | } | |
709 | } | |
710 | ||
b92e6209 AD |
711 | function toggleSelectListRow(sender) { |
712 | var parent_row = sender.parentNode; | |
713 | ||
714 | if (sender.checked) { | |
715 | if (!parent_row.className.match("Selected")) { | |
716 | parent_row.className = parent_row.className + "Selected"; | |
717 | } | |
718 | } else { | |
719 | if (parent_row.className.match("Selected")) { | |
720 | parent_row.className = parent_row.className.replace("Selected", ""); | |
721 | } | |
722 | } | |
723 | } | |
724 | ||
386cbf27 | 725 | |
1572afe5 AD |
726 | function toggleSelectRow(sender) { |
727 | var parent_row = sender.parentNode.parentNode; | |
728 | ||
729 | if (sender.checked) { | |
730 | if (!parent_row.className.match("Selected")) { | |
731 | parent_row.className = parent_row.className + "Selected"; | |
732 | } | |
733 | } else { | |
734 | if (parent_row.className.match("Selected")) { | |
735 | parent_row.className = parent_row.className.replace("Selected", ""); | |
736 | } | |
737 | } | |
738 | } | |
739 | ||
3866b046 AD |
740 | function openExternalUrl(url) { |
741 | var w = window.open(url); | |
742 | } | |
1572afe5 | 743 | |
1da76274 | 744 | function getRelativeFeedId(list, id, direction, unread_only) { |
7b433d8c AD |
745 | if (!id) { |
746 | if (direction == "next") { | |
747 | for (i = 0; i < list.childNodes.length; i++) { | |
748 | var child = list.childNodes[i]; | |
1da76274 | 749 | if (child.id && child.id == "feedCatHolder") { |
c3f348c2 | 750 | if (child.lastChild) { |
7b433d8c AD |
751 | var cr = getRelativeFeedId(child.firstChild, id, direction); |
752 | if (cr) return cr; | |
753 | } | |
1da76274 | 754 | } else if (child.id && child.id.match("FEEDR-")) { |
7b433d8c AD |
755 | return child.id.replace('FEEDR-', ''); |
756 | } | |
757 | } | |
758 | } | |
759 | ||
760 | // FIXME select last feed doesn't work when only unread feeds are visible | |
761 | ||
762 | if (direction == "prev") { | |
763 | for (i = list.childNodes.length-1; i >= 0; i--) { | |
764 | var child = list.childNodes[i]; | |
765 | if (child.id == "feedCatHolder") { | |
766 | if (child.firstChild) { | |
767 | var cr = getRelativeFeedId(child.firstChild, id, direction); | |
768 | if (cr) return cr; | |
769 | } | |
770 | } else if (child.id.match("FEEDR-")) { | |
771 | ||
772 | if (getCookie("ttrss_vf_hreadf") == 1) { | |
773 | if (child.className != "feed") { | |
774 | alert(child.className); | |
775 | return child.id.replace('FEEDR-', ''); | |
776 | } | |
777 | } else { | |
778 | return child.id.replace('FEEDR-', ''); | |
779 | } | |
780 | } | |
781 | } | |
782 | } | |
783 | } else { | |
784 | ||
785 | var feed = list.ownerDocument.getElementById("FEEDR-" + getActiveFeedId()); | |
786 | ||
1da76274 AD |
787 | if (getCookie("ttrss_vf_hreadf") == 1) { |
788 | unread_only = true; | |
789 | } | |
790 | ||
7b433d8c AD |
791 | if (direction == "next") { |
792 | ||
1da76274 | 793 | var e = feed; |
7b433d8c | 794 | |
1da76274 | 795 | while (e) { |
7b433d8c | 796 | |
1da76274 AD |
797 | if (e.nextSibling) { |
798 | ||
799 | e = e.nextSibling; | |
800 | ||
801 | } else if (e.parentNode.parentNode.nextSibling) { | |
7b433d8c | 802 | |
1da76274 | 803 | var this_cat = e.parentNode.parentNode; |
7b433d8c | 804 | |
1da76274 | 805 | e = false; |
7b433d8c | 806 | |
1da76274 AD |
807 | if (this_cat && this_cat.nextSibling) { |
808 | while (!e && this_cat.nextSibling) { | |
809 | this_cat = this_cat.nextSibling; | |
810 | if (this_cat.id == "feedCatHolder") { | |
811 | e = this_cat.firstChild.firstChild; | |
7b433d8c AD |
812 | } |
813 | } | |
7b433d8c | 814 | } |
1da76274 AD |
815 | |
816 | } else { | |
817 | e = false; | |
818 | } | |
819 | ||
820 | if (e) { | |
e686782e AD |
821 | if (!unread_only || (unread_only && e.className != "feed" && |
822 | e.className != "error")) { | |
1da76274 AD |
823 | return e.id.replace("FEEDR-", ""); |
824 | } | |
825 | } | |
7b433d8c | 826 | } |
1da76274 | 827 | |
7b433d8c AD |
828 | } else if (direction == "prev") { |
829 | ||
1da76274 | 830 | var e = feed; |
7b433d8c | 831 | |
1da76274 | 832 | while (e) { |
7b433d8c | 833 | |
1da76274 AD |
834 | if (e.previousSibling) { |
835 | ||
836 | e = e.previousSibling; | |
837 | ||
838 | } else if (e.parentNode.parentNode.previousSibling) { | |
7b433d8c | 839 | |
1da76274 | 840 | var this_cat = e.parentNode.parentNode; |
7b433d8c | 841 | |
1da76274 AD |
842 | e = false; |
843 | ||
844 | if (this_cat && this_cat.previousSibling) { | |
845 | while (!e && this_cat.previousSibling) { | |
846 | this_cat = this_cat.previousSibling; | |
847 | if (this_cat.id == "feedCatHolder") { | |
848 | e = this_cat.firstChild.lastChild; | |
7b433d8c AD |
849 | } |
850 | } | |
7b433d8c | 851 | } |
1da76274 AD |
852 | |
853 | } else { | |
854 | e = false; | |
855 | } | |
856 | ||
857 | if (e) { | |
e686782e AD |
858 | if (!unread_only || (unread_only && e.className != "feed" && |
859 | e.className != "error")) { | |
1da76274 AD |
860 | return e.id.replace("FEEDR-", ""); |
861 | } | |
862 | } | |
863 | } | |
7b433d8c AD |
864 | } |
865 | } | |
866 | } | |
36aab70f AD |
867 | |
868 | function showBlockElement(id) { | |
869 | var elem = document.getElementById(id); | |
870 | ||
871 | if (elem) { | |
872 | elem.style.display = "block"; | |
873 | } else { | |
874 | alert("[showBlockElement] can't find element with id " + id); | |
875 | } | |
876 | } | |
877 | ||
a9b0bfd5 AD |
878 | function hideParentElement(e) { |
879 | e.parentNode.style.display = "none"; | |
880 | } | |
1b0809ae AD |
881 | |
882 | function dropboxSelect(e, v) { | |
883 | for (i = 0; i < e.length; i++) { | |
884 | if (e[i].value == v) { | |
885 | e.selectedIndex = i; | |
886 | break; | |
887 | } | |
888 | } | |
889 | } | |
0ee1d1a0 AD |
890 | |
891 | // originally stolen from http://www.11tmr.com/11tmr.nsf/d6plinks/MWHE-695L9Z | |
892 | // bugfixed just a little bit :-) | |
893 | function getURLParam(strParamName){ | |
894 | var strReturn = ""; | |
895 | var strHref = window.location.href; | |
896 | ||
897 | if (strHref.indexOf("#") == strHref.length-1) { | |
898 | strHref = strHref.substring(0, strHref.length-1); | |
899 | } | |
900 | ||
901 | if ( strHref.indexOf("?") > -1 ){ | |
902 | var strQueryString = strHref.substr(strHref.indexOf("?")); | |
903 | var aQueryString = strQueryString.split("&"); | |
904 | for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){ | |
905 | if (aQueryString[iParam].indexOf(strParamName + "=") > -1 ){ | |
906 | var aParam = aQueryString[iParam].split("="); | |
907 | strReturn = aParam[1]; | |
908 | break; | |
909 | } | |
910 | } | |
911 | } | |
912 | return strReturn; | |
913 | } | |
914 | ||
cf1bc085 AD |
915 | function leading_zero(p) { |
916 | var s = String(p); | |
917 | if (s.length == 1) s = "0" + s; | |
918 | return s; | |
919 | } | |
c38c2b69 | 920 | |
e5d758e3 AD |
921 | function closeInfoBox() { |
922 | var box = document.getElementById('infoBox'); | |
923 | var shadow = document.getElementById('infoBoxShadow'); | |
924 | ||
925 | if (shadow) { | |
926 | shadow.style.display = "none"; | |
927 | } else if (box) { | |
928 | box.style.display = "none"; | |
929 | } | |
930 | ||
931 | enableHotkeys(); | |
c14b5566 | 932 | |
e5d758e3 AD |
933 | } |
934 | ||
935 | ||
7b5c6012 AD |
936 | function displayDlg(id, param) { |
937 | ||
938 | if (!xmlhttp_ready(xmlhttp)) { | |
939 | printLockingError(); | |
940 | return | |
941 | } | |
942 | ||
943 | notify(""); | |
944 | ||
945 | xmlhttp.open("GET", "backend.php?op=dlg&id=" + | |
946 | param_escape(id) + "¶m=" + param_escape(param), true); | |
e5d758e3 | 947 | xmlhttp.onreadystatechange=infobox_callback; |
7b5c6012 AD |
948 | xmlhttp.send(null); |
949 | ||
950 | disableHotkeys(); | |
2371c520 | 951 | |
7b5c6012 AD |
952 | } |
953 | ||
e5d758e3 | 954 | function infobox_submit_callback() { |
7b5c6012 | 955 | if (xmlhttp.readyState == 4) { |
e5d758e3 | 956 | closeInfoBox(); |
7b5c6012 AD |
957 | |
958 | // called from prefs, reload tab | |
959 | if (active_tab) { | |
960 | selectTab(active_tab, false); | |
961 | } | |
79f3553b AD |
962 | |
963 | notify(xmlhttp.responseText); | |
964 | ||
7b5c6012 AD |
965 | } |
966 | } | |
967 | ||
e5d758e3 | 968 | function infobox_callback() { |
7b5c6012 | 969 | if (xmlhttp.readyState == 4) { |
e5d758e3 AD |
970 | var box = document.getElementById('infoBox'); |
971 | var shadow = document.getElementById('infoBoxShadow'); | |
972 | if (box) { | |
973 | box.innerHTML=xmlhttp.responseText; | |
974 | if (shadow) { | |
975 | shadow.style.display = "block"; | |
976 | } else { | |
977 | box.style.display = "block"; | |
978 | } | |
979 | } | |
980 | } | |
7b5c6012 AD |
981 | } |
982 | ||
983 | function qaddFilter() { | |
984 | ||
985 | if (!xmlhttp_ready(xmlhttp)) { | |
986 | printLockingError(); | |
987 | return | |
988 | } | |
989 | ||
79f3553b | 990 | var query = Form.serialize("filter_add_form"); |
7b5c6012 | 991 | |
79f3553b AD |
992 | xmlhttp.open("GET", "backend.php?" + query, true); |
993 | xmlhttp.onreadystatechange=infobox_submit_callback; | |
994 | xmlhttp.send(null); | |
7b5c6012 | 995 | |
c14b5566 | 996 | return true; |
7b5c6012 AD |
997 | } |
998 | ||
2371c520 AD |
999 | function toggleSubmitNotEmpty(e, submit_id) { |
1000 | try { | |
1001 | document.getElementById(submit_id).disabled = (e.value == "") | |
1002 | } catch (e) { | |
1003 | exception_error("toggleSubmitNotEmpty", e); | |
1004 | } | |
1005 | } | |
1d7bf5a0 | 1006 | |
605f7d46 AD |
1007 | function isValidURL(s) { |
1008 | return s.match("http://") != null || s.match("https://") != null; | |
1009 | } |