]>
Commit | Line | Data |
---|---|---|
760966c1 AD |
1 | var hotkeys_enabled = true; |
2 | ||
7719618b | 3 | function exception_error(location, e) { |
83f043bb AD |
4 | var msg; |
5 | ||
6 | if (e.fileName) { | |
7 | var base_fname = e.fileName.substring(e.fileName.lastIndexOf("/") + 1); | |
8 | ||
9 | msg = "Exception: " + e.name + ", " + e.message + | |
10 | "\nFunction: " + location + "()" + | |
11 | "\nLocation: " + base_fname + ":" + e.lineNumber; | |
12 | } else { | |
13 | msg = "Exception: " + e + "\nFunction: " + location + "()"; | |
14 | } | |
15 | ||
16 | alert(msg); | |
7719618b AD |
17 | } |
18 | ||
760966c1 AD |
19 | function disableHotkeys() { |
20 | hotkeys_enabled = false; | |
21 | } | |
22 | ||
23 | function enableHotkeys() { | |
24 | hotkeys_enabled = true; | |
25 | } | |
26 | ||
c0e5a40e AD |
27 | function xmlhttp_ready(obj) { |
28 | return obj.readyState == 4 || obj.readyState == 0 || !obj.readyState; | |
29 | } | |
30 | ||
31 | ||
9cfc649a AD |
32 | function notify_callback() { |
33 | var container = document.getElementById('notify'); | |
34 | if (xmlhttp.readyState == 4) { | |
35 | container.innerHTML=xmlhttp.responseText; | |
36 | } | |
37 | } | |
38 | ||
39 | function rpc_notify_callback() { | |
40 | var container = document.getElementById('notify'); | |
41 | if (xmlhttp_rpc.readyState == 4) { | |
42 | container.innerHTML=xmlhttp_rpc.responseText; | |
43 | } | |
44 | } | |
45 | ||
1572afe5 AD |
46 | function rpc_pnotify_callback() { |
47 | var container = parent.document.getElementById('notify'); | |
48 | if (xmlhttp_rpc.readyState == 4) { | |
49 | container.innerHTML=xmlhttp_rpc.responseText; | |
50 | } | |
51 | } | |
52 | ||
7726fa02 AD |
53 | function param_escape(arg) { |
54 | if (typeof encodeURIComponent != 'undefined') | |
55 | return encodeURIComponent(arg); | |
56 | else | |
57 | return escape(arg); | |
58 | } | |
59 | ||
60 | function param_unescape(arg) { | |
61 | if (typeof decodeURIComponent != 'undefined') | |
62 | return decodeURIComponent(arg); | |
63 | else | |
64 | return unescape(arg); | |
65 | } | |
66 | ||
508a81e1 AD |
67 | function delay(gap) { |
68 | var then,now; | |
69 | then=new Date().getTime(); | |
70 | now=then; | |
71 | while((now-then)<gap) { | |
72 | now=new Date().getTime(); | |
73 | } | |
74 | } | |
7726fa02 | 75 | |
c05608c2 AD |
76 | function p_notify(msg) { |
77 | ||
78 | var n = parent.document.getElementById("notify"); | |
79 | var nb = parent.document.getElementById("notify_body"); | |
80 | ||
81 | if (!n || !nb) return; | |
82 | ||
8dcfffd0 AD |
83 | if (msg == "") { |
84 | nb.innerHTML = " "; | |
e93919dd | 85 | // n.style.background = "#ffffff"; |
c05608c2 | 86 | } else { |
8dcfffd0 | 87 | nb.innerHTML = msg; |
e93919dd | 88 | // n.style.background = "#fffff0"; |
8dcfffd0 | 89 | } |
c05608c2 AD |
90 | } |
91 | ||
7726fa02 AD |
92 | function notify(msg) { |
93 | ||
94 | var n = document.getElementById("notify"); | |
c05608c2 | 95 | var nb = document.getElementById("notify_body"); |
7726fa02 | 96 | |
c05608c2 | 97 | if (!n || !nb) return; |
f0601b87 | 98 | |
8dcfffd0 AD |
99 | if (msg == "") { |
100 | nb.innerHTML = " "; | |
e93919dd | 101 | // n.style.background = "#ffffff"; |
7726fa02 | 102 | } else { |
8dcfffd0 | 103 | nb.innerHTML = msg; |
e93919dd | 104 | // n.style.background = "#fffff0"; |
8dcfffd0 | 105 | } |
7726fa02 AD |
106 | |
107 | } | |
108 | ||
508a81e1 | 109 | function printLockingError() { |
f0601b87 | 110 | notify("Please wait until operation finishes");} |
508a81e1 | 111 | |
13ad9102 AD |
112 | var seq = ""; |
113 | ||
114 | function hotkey_handler(e) { | |
760966c1 | 115 | |
13ad9102 AD |
116 | var keycode; |
117 | ||
760966c1 AD |
118 | if (!hotkeys_enabled) return; |
119 | ||
13ad9102 AD |
120 | if (window.event) { |
121 | keycode = window.event.keyCode; | |
122 | } else if (e) { | |
123 | keycode = e.which; | |
124 | } | |
125 | ||
126 | if (keycode == 13 || keycode == 27) { | |
127 | seq = ""; | |
128 | } else { | |
129 | seq = seq + "" + keycode; | |
130 | } | |
131 | ||
2e02b896 AD |
132 | if (document.getElementById("piggie")) { |
133 | ||
134 | if (seq.match("807371717369")) { | |
135 | seq = ""; | |
136 | localPiggieFunction(true); | |
137 | } else { | |
138 | localPiggieFunction(false); | |
139 | } | |
bb7cface AD |
140 | } |
141 | ||
9cfc649a | 142 | if (typeof localHotkeyHandler != 'undefined') { |
7b433d8c AD |
143 | try { |
144 | localHotkeyHandler(keycode); | |
145 | } catch (e) { | |
83f043bb | 146 | exception_error("hotkey_handler", e); |
7b433d8c | 147 | } |
9cfc649a AD |
148 | } |
149 | ||
13ad9102 AD |
150 | } |
151 | ||
e828e31e | 152 | function cleanSelectedList(element) { |
f0601b87 AD |
153 | var content = document.getElementById(element); |
154 | ||
703b632e AD |
155 | if (!document.getElementById("feedCatHolder")) { |
156 | for (i = 0; i < content.childNodes.length; i++) { | |
157 | var child = content.childNodes[i]; | |
158 | child.className = child.className.replace("Selected", ""); | |
159 | } | |
160 | } else { | |
161 | for (i = 0; i < content.childNodes.length; i++) { | |
162 | var child = content.childNodes[i]; | |
163 | ||
164 | if (child.id == "feedCatHolder") { | |
c3f348c2 | 165 | var fcat = child.lastChild; |
703b632e | 166 | for (j = 0; j < fcat.childNodes.length; j++) { |
937881b5 | 167 | var feed = fcat.childNodes[j]; |
703b632e AD |
168 | feed.className = feed.className.replace("Selected", ""); |
169 | } | |
170 | } | |
171 | } | |
e828e31e | 172 | |
703b632e | 173 | } |
e828e31e AD |
174 | } |
175 | ||
176 | ||
177 | function cleanSelected(element) { | |
178 | var content = document.getElementById(element); | |
f0601b87 AD |
179 | |
180 | for (i = 0; i < content.rows.length; i++) { | |
181 | content.rows[i].className = content.rows[i].className.replace("Selected", ""); | |
182 | } | |
183 | ||
184 | } | |
185 | ||
186 | function getVisibleUnreadHeadlines() { | |
187 | var content = document.getElementById("headlinesList"); | |
188 | ||
189 | var rows = new Array(); | |
190 | ||
191 | for (i = 0; i < content.rows.length; i++) { | |
192 | var row_id = content.rows[i].id.replace("RROW-", ""); | |
193 | if (row_id.length > 0 && content.rows[i].className.match("Unread")) { | |
194 | rows.push(row_id); | |
195 | } | |
196 | } | |
197 | return rows; | |
198 | } | |
199 | ||
200 | function getVisibleHeadlineIds() { | |
201 | ||
202 | var content = document.getElementById("headlinesList"); | |
203 | ||
204 | var rows = new Array(); | |
205 | ||
206 | for (i = 0; i < content.rows.length; i++) { | |
207 | var row_id = content.rows[i].id.replace("RROW-", ""); | |
208 | if (row_id.length > 0) { | |
209 | rows.push(row_id); | |
210 | } | |
211 | } | |
212 | return rows; | |
213 | } | |
214 | ||
215 | function getFirstVisibleHeadlineId() { | |
216 | var rows = getVisibleHeadlineIds(); | |
217 | return rows[0]; | |
218 | } | |
219 | ||
220 | function getLastVisibleHeadlineId() { | |
221 | var rows = getVisibleHeadlineIds(); | |
222 | return rows[rows.length-1]; | |
223 | } | |
224 | ||
225 | function markHeadline(id) { | |
226 | var row = document.getElementById("RROW-" + id); | |
227 | if (row) { | |
35f3c923 AD |
228 | var is_active = false; |
229 | ||
230 | if (row.className.match("Active")) { | |
231 | is_active = true; | |
232 | } | |
233 | row.className = row.className.replace("Selected", ""); | |
234 | row.className = row.className.replace("Active", ""); | |
235 | row.className = row.className.replace("Insensitive", ""); | |
236 | ||
237 | if (is_active) { | |
238 | row.className = row.className = "Active"; | |
239 | } | |
240 | ||
241 | row.className = row.className + "Selected"; | |
242 | ||
f0601b87 AD |
243 | } |
244 | } | |
245 | ||
246 | function getFeedIds() { | |
247 | var content = document.getElementById("feedsList"); | |
248 | ||
249 | var rows = new Array(); | |
250 | ||
251 | for (i = 0; i < content.rows.length; i++) { | |
252 | var id = content.rows[i].id.replace("FEEDR-", ""); | |
253 | if (id.length > 0) { | |
254 | rows.push(id); | |
255 | } | |
256 | } | |
257 | ||
258 | return rows; | |
259 | } | |
13ad9102 | 260 | |
ac43eba1 AD |
261 | function setCookie(name, value, expires, path, domain, secure) { |
262 | document.cookie= name + "=" + escape(value) + | |
263 | ((expires) ? "; expires=" + expires.toGMTString() : "") + | |
264 | ((path) ? "; path=" + path : "") + | |
265 | ((domain) ? "; domain=" + domain : "") + | |
266 | ((secure) ? "; secure" : ""); | |
267 | } | |
268 | ||
269 | function getCookie(name) { | |
270 | ||
271 | var dc = document.cookie; | |
272 | var prefix = name + "="; | |
273 | var begin = dc.indexOf("; " + prefix); | |
274 | if (begin == -1) { | |
275 | begin = dc.indexOf(prefix); | |
276 | if (begin != 0) return null; | |
277 | } | |
278 | else { | |
279 | begin += 2; | |
280 | } | |
281 | var end = document.cookie.indexOf(";", begin); | |
282 | if (end == -1) { | |
283 | end = dc.length; | |
284 | } | |
285 | return unescape(dc.substring(begin + prefix.length, end)); | |
286 | } | |
287 | ||
1a66d16e AD |
288 | function disableContainerChildren(id, disable, doc) { |
289 | ||
290 | if (!doc) doc = document; | |
291 | ||
292 | var container = doc.getElementById(id); | |
ac43eba1 AD |
293 | |
294 | for (var i = 0; i < container.childNodes.length; i++) { | |
295 | var child = container.childNodes[i]; | |
296 | ||
d5224f0d AD |
297 | try { |
298 | child.disabled = disable; | |
299 | } catch (E) { | |
300 | ||
301 | } | |
ac43eba1 AD |
302 | |
303 | if (disable) { | |
304 | if (child.className && child.className.match("button")) { | |
305 | child.className = "disabledButton"; | |
306 | } | |
307 | } else { | |
308 | if (child.className && child.className.match("disabledButton")) { | |
309 | child.className = "button"; | |
310 | } | |
d5224f0d | 311 | } |
ac43eba1 AD |
312 | } |
313 | ||
314 | } | |
7726fa02 | 315 | |
e828e31e AD |
316 | function gotoPreferences() { |
317 | document.location.href = "prefs.php"; | |
318 | } | |
319 | ||
320 | function gotoMain() { | |
321 | document.location.href = "tt-rss.php"; | |
322 | } | |
323 | ||
8158c57a AD |
324 | function gotoExportOpml() { |
325 | document.location.href = "opml.php?op=Export"; | |
326 | } | |
86741347 AD |
327 | |
328 | function getActiveFeedId() { | |
329 | return getCookie("ttrss_vf_actfeed"); | |
330 | } | |
331 | ||
332 | function setActiveFeedId(id) { | |
333 | return setCookie("ttrss_vf_actfeed", id); | |
334 | } | |
090e250b AD |
335 | |
336 | var xmlhttp_rpc = false; | |
337 | ||
338 | /*@cc_on @*/ | |
339 | /*@if (@_jscript_version >= 5) | |
340 | // JScript gives us Conditional compilation, we can cope with old IE versions. | |
341 | // and security blocked creation of the objects. | |
342 | try { | |
343 | xmlhttp_rpc = new ActiveXObject("Msxml2.XMLHTTP"); | |
344 | } catch (e) { | |
345 | try { | |
346 | xmlhttp_rpc = new ActiveXObject("Microsoft.XMLHTTP"); | |
347 | } catch (E) { | |
348 | xmlhttp_rpc = false; | |
349 | } | |
350 | } | |
351 | @end @*/ | |
352 | ||
353 | if (!xmlhttp_rpc && typeof XMLHttpRequest!='undefined') { | |
354 | xmlhttp_rpc = new XMLHttpRequest(); | |
355 | } | |
356 | ||
3bdb368b | 357 | function parse_counters(reply, f_document, title_obj) { |
1a6a9555 AD |
358 | try { |
359 | for (var l = 0; l < reply.childNodes.length; l++) { | |
9cbca41f AD |
360 | if (!reply.childNodes[l] || |
361 | typeof(reply.childNodes[l].getAttribute) == "undefined") { | |
6043fb7e AD |
362 | // where did this come from? |
363 | continue; | |
364 | } | |
365 | ||
1a6a9555 AD |
366 | var id = reply.childNodes[l].getAttribute("id"); |
367 | var t = reply.childNodes[l].getAttribute("type"); | |
368 | var ctr = reply.childNodes[l].getAttribute("counter"); | |
023fe037 AD |
369 | var error = reply.childNodes[l].getAttribute("error"); |
370 | var has_img = reply.childNodes[l].getAttribute("hi"); | |
1a6a9555 AD |
371 | |
372 | if (id == "global-unread") { | |
3bdb368b AD |
373 | title_obj.global_unread = ctr; |
374 | title_obj.updateTitle(); | |
1a6a9555 AD |
375 | continue; |
376 | } | |
377 | ||
378 | if (t == "category") { | |
379 | var catctr = f_document.getElementById("FCATCTR-" + id); | |
380 | if (catctr) { | |
381 | catctr.innerHTML = "(" + ctr + " unread)"; | |
382 | } | |
383 | continue; | |
384 | } | |
385 | ||
386 | var feedctr = f_document.getElementById("FEEDCTR-" + id); | |
387 | var feedu = f_document.getElementById("FEEDU-" + id); | |
388 | var feedr = f_document.getElementById("FEEDR-" + id); | |
023fe037 AD |
389 | var feed_img = f_document.getElementById("FIMG-" + id); |
390 | ||
1a6a9555 AD |
391 | if (feedctr && feedu && feedr) { |
392 | ||
393 | feedu.innerHTML = ctr; | |
023fe037 | 394 | |
426d3c57 AD |
395 | if (error) { |
396 | feedr.className = feedr.className.replace("feed", "error"); | |
397 | } else if (id > 0) { | |
398 | feedr.className = feedr.className.replace("error", "feed"); | |
023fe037 | 399 | } |
1a6a9555 AD |
400 | |
401 | if (ctr > 0) { | |
402 | feedctr.className = "odd"; | |
403 | if (!feedr.className.match("Unread")) { | |
404 | var is_selected = feedr.className.match("Selected"); | |
405 | ||
406 | feedr.className = feedr.className.replace("Selected", ""); | |
407 | feedr.className = feedr.className.replace("Unread", ""); | |
408 | ||
409 | feedr.className = feedr.className + "Unread"; | |
410 | ||
411 | if (is_selected) { | |
412 | feedr.className = feedr.className + "Selected"; | |
413 | } | |
414 | ||
415 | } | |
416 | } else { | |
417 | feedctr.className = "invisible"; | |
418 | feedr.className = feedr.className.replace("Unread", ""); | |
419 | } | |
420 | } | |
421 | } | |
422 | } catch (e) { | |
83f043bb | 423 | exception_error("parse_counters", e); |
1a6a9555 AD |
424 | } |
425 | } | |
426 | ||
3bdb368b AD |
427 | // this one is called from feedlist context |
428 | // thus title_obj passed to parse_counters is parent (e.g. main ttrss window) | |
429 | ||
4f3a84f4 | 430 | function all_counters_callback() { |
090e250b | 431 | if (xmlhttp_rpc.readyState == 4) { |
7719618b | 432 | try { |
3866b046 | 433 | if (!xmlhttp_rpc.responseXML || !xmlhttp_rpc.responseXML.firstChild) { |
7719618b AD |
434 | notify("[all_counters_callback] backend did not return valid XML"); |
435 | return; | |
436 | } | |
437 | ||
438 | var reply = xmlhttp_rpc.responseXML.firstChild; | |
7719618b | 439 | var f_document = parent.frames["feeds-frame"].document; |
280ee9a3 | 440 | |
3bdb368b | 441 | parse_counters(reply, f_document, parent); |
7719618b | 442 | |
7719618b AD |
443 | } catch (e) { |
444 | exception_error("all_counters_callback", e); | |
090e250b AD |
445 | } |
446 | } | |
447 | } | |
448 | ||
4f3a84f4 | 449 | function update_all_counters(feed) { |
090e250b | 450 | if (xmlhttp_ready(xmlhttp_rpc)) { |
8143ae1f | 451 | var query = "backend.php?op=rpc&subop=getAllCounters"; |
e47cfe37 AD |
452 | |
453 | if (feed > 0) { | |
454 | query = query + "&aid=" + feed; | |
455 | } | |
456 | ||
090e250b | 457 | xmlhttp_rpc.open("GET", query, true); |
4f3a84f4 | 458 | xmlhttp_rpc.onreadystatechange=all_counters_callback; |
090e250b AD |
459 | xmlhttp_rpc.send(null); |
460 | } | |
461 | } | |
7dc66a61 AD |
462 | |
463 | function popupHelp(tid) { | |
464 | var w = window.open("backend.php?op=help&tid=" + tid, | |
465 | "Popup Help", | |
466 | "menubar=no,location=no,resizable=yes,scrollbars=yes,status=no"); | |
467 | } | |
b6644d29 AD |
468 | |
469 | /** * @(#)isNumeric.js * * Copyright (c) 2000 by Sundar Dorai-Raj | |
470 | * * @author Sundar Dorai-Raj | |
471 | * * Email: sdoraira@vt.edu | |
472 | * * This program is free software; you can redistribute it and/or | |
473 | * * modify it under the terms of the GNU General Public License | |
474 | * * as published by the Free Software Foundation; either version 2 | |
475 | * * of the License, or (at your option) any later version, | |
476 | * * provided that any use properly credits the author. | |
477 | * * This program is distributed in the hope that it will be useful, | |
478 | * * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
479 | * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
480 | * * GNU General Public License for more details at http://www.gnu.org * * */ | |
481 | ||
482 | var numbers=".0123456789"; | |
483 | function isNumeric(x) { | |
484 | // is x a String or a character? | |
485 | if(x.length>1) { | |
486 | // remove negative sign | |
487 | x=Math.abs(x)+""; | |
488 | for(j=0;j<x.length;j++) { | |
489 | // call isNumeric recursively for each character | |
490 | number=isNumeric(x.substring(j,j+1)); | |
491 | if(!number) return number; | |
492 | } | |
493 | return number; | |
494 | } | |
495 | else { | |
496 | // if x is number return true | |
497 | if(numbers.indexOf(x)>=0) return true; | |
498 | return false; | |
499 | } | |
500 | } | |
501 | ||
3745788e AD |
502 | |
503 | function hideOrShowFeeds(doc, hide) { | |
504 | ||
3ed751d4 AD |
505 | if (!doc.styleSheets) return; |
506 | ||
3745788e AD |
507 | var css_rules = doc.styleSheets[0].cssRules; |
508 | ||
bbf4d0b2 AD |
509 | if (!css_rules || !css_rules.length) return; |
510 | ||
3745788e AD |
511 | for (i = 0; i < css_rules.length; i++) { |
512 | var rule = css_rules[i]; | |
513 | ||
514 | if (rule.selectorText == "ul.feedList li.feed") { | |
515 | if (!hide) { | |
516 | rule.style.display = "block"; | |
517 | } else { | |
518 | rule.style.display = "none"; | |
519 | } | |
520 | } | |
521 | ||
522 | } | |
523 | ||
524 | } | |
525 | ||
91d612b3 AD |
526 | function fatalError(code, params) { |
527 | if (!params) { | |
528 | window.location = "error.php?c=" + param_escape(code); | |
529 | } else { | |
530 | window.location = "error.php?c=" + param_escape(code) + | |
531 | "&p=" + param_escape(params); | |
532 | } | |
35f3c923 AD |
533 | } |
534 | ||
535 | function selectTableRow(r, do_select) { | |
536 | r.className = r.className.replace("Selected", ""); | |
537 | ||
538 | if (do_select) { | |
539 | r.className = r.className + "Selected"; | |
540 | } | |
541 | } | |
542 | ||
6c12c809 AD |
543 | function selectTableRowById(elem_id, check_id, do_select) { |
544 | ||
545 | try { | |
546 | ||
547 | var row = document.getElementById(elem_id); | |
548 | ||
549 | if (row) { | |
550 | selectTableRow(row, do_select); | |
551 | } | |
552 | ||
553 | var check = document.getElementById(check_id); | |
554 | ||
555 | if (check) { | |
556 | check.checked = do_select; | |
557 | } | |
558 | } catch (e) { | |
559 | exception_error("selectTableRowById", e); | |
560 | } | |
561 | } | |
562 | ||
1572afe5 | 563 | function selectTableRowsByIdPrefix(content_id, prefix, check_prefix, do_select, |
649e0af9 | 564 | classcheck, reset_others) { |
3745788e | 565 | |
35f3c923 AD |
566 | var content = document.getElementById(content_id); |
567 | ||
568 | if (!content) { | |
569 | alert("[selectTableRows] Element " + content_id + " not found."); | |
570 | return; | |
571 | } | |
572 | ||
573 | for (i = 0; i < content.rows.length; i++) { | |
1572afe5 AD |
574 | if (!classcheck || content.rows[i].className.match(classcheck)) { |
575 | ||
576 | if (content.rows[i].id.match(prefix)) { | |
577 | selectTableRow(content.rows[i], do_select); | |
649e0af9 AD |
578 | |
579 | var row_id = content.rows[i].id.replace(prefix, ""); | |
580 | var check = document.getElementById(check_prefix + row_id); | |
3055bc41 | 581 | |
649e0af9 AD |
582 | if (check) { |
583 | check.checked = do_select; | |
584 | } | |
585 | } else if (reset_others) { | |
586 | selectTableRow(content.rows[i], false); | |
7d8d10c6 AD |
587 | |
588 | var row_id = content.rows[i].id.replace(prefix, ""); | |
589 | var check = document.getElementById(check_prefix + row_id); | |
590 | ||
591 | if (check) { | |
592 | check.checked = false; | |
593 | } | |
594 | ||
1572afe5 | 595 | } |
649e0af9 AD |
596 | } else if (reset_others) { |
597 | selectTableRow(content.rows[i], false); | |
7d8d10c6 AD |
598 | |
599 | var row_id = content.rows[i].id.replace(prefix, ""); | |
600 | var check = document.getElementById(check_prefix + row_id); | |
601 | ||
602 | if (check) { | |
603 | check.checked = false; | |
604 | } | |
605 | ||
3055bc41 | 606 | } |
35f3c923 | 607 | } |
295f9b42 | 608 | } |
91ff844a AD |
609 | |
610 | function getSelectedTableRowIds(content_id, prefix) { | |
611 | ||
612 | var content = document.getElementById(content_id); | |
613 | ||
614 | if (!content) { | |
615 | alert("[getSelectedTableRowIds] Element " + content_id + " not found."); | |
616 | return; | |
617 | } | |
618 | ||
619 | var sel_rows = new Array(); | |
620 | ||
621 | for (i = 0; i < content.rows.length; i++) { | |
1572afe5 AD |
622 | if (content.rows[i].id.match(prefix) && |
623 | content.rows[i].className.match("Selected")) { | |
624 | ||
91ff844a AD |
625 | var row_id = content.rows[i].id.replace(prefix + "-", ""); |
626 | sel_rows.push(row_id); | |
627 | } | |
628 | } | |
629 | ||
630 | return sel_rows; | |
631 | ||
632 | } | |
633 | ||
386cbf27 AD |
634 | function toggleSelectRowById(sender, id) { |
635 | var row = document.getElementById(id); | |
636 | ||
637 | if (sender.checked) { | |
638 | if (!row.className.match("Selected")) { | |
639 | row.className = row.className + "Selected"; | |
640 | } | |
641 | } else { | |
642 | if (row.className.match("Selected")) { | |
643 | row.className = row.className.replace("Selected", ""); | |
644 | } | |
645 | } | |
646 | } | |
647 | ||
b92e6209 AD |
648 | function toggleSelectListRow(sender) { |
649 | var parent_row = sender.parentNode; | |
650 | ||
651 | if (sender.checked) { | |
652 | if (!parent_row.className.match("Selected")) { | |
653 | parent_row.className = parent_row.className + "Selected"; | |
654 | } | |
655 | } else { | |
656 | if (parent_row.className.match("Selected")) { | |
657 | parent_row.className = parent_row.className.replace("Selected", ""); | |
658 | } | |
659 | } | |
660 | } | |
661 | ||
386cbf27 | 662 | |
1572afe5 AD |
663 | function toggleSelectRow(sender) { |
664 | var parent_row = sender.parentNode.parentNode; | |
665 | ||
666 | if (sender.checked) { | |
667 | if (!parent_row.className.match("Selected")) { | |
668 | parent_row.className = parent_row.className + "Selected"; | |
669 | } | |
670 | } else { | |
671 | if (parent_row.className.match("Selected")) { | |
672 | parent_row.className = parent_row.className.replace("Selected", ""); | |
673 | } | |
674 | } | |
675 | } | |
676 | ||
3866b046 AD |
677 | function openExternalUrl(url) { |
678 | var w = window.open(url); | |
679 | } | |
1572afe5 | 680 | |
7b433d8c AD |
681 | |
682 | function getRelativeFeedId(list, id, direction) { | |
683 | if (!id) { | |
684 | if (direction == "next") { | |
685 | for (i = 0; i < list.childNodes.length; i++) { | |
686 | var child = list.childNodes[i]; | |
687 | if (child.id == "feedCatHolder") { | |
c3f348c2 | 688 | if (child.lastChild) { |
7b433d8c AD |
689 | var cr = getRelativeFeedId(child.firstChild, id, direction); |
690 | if (cr) return cr; | |
691 | } | |
692 | } else if (child.id.match("FEEDR-")) { | |
693 | return child.id.replace('FEEDR-', ''); | |
694 | } | |
695 | } | |
696 | } | |
697 | ||
698 | // FIXME select last feed doesn't work when only unread feeds are visible | |
699 | ||
700 | if (direction == "prev") { | |
701 | for (i = list.childNodes.length-1; i >= 0; i--) { | |
702 | var child = list.childNodes[i]; | |
703 | if (child.id == "feedCatHolder") { | |
704 | if (child.firstChild) { | |
705 | var cr = getRelativeFeedId(child.firstChild, id, direction); | |
706 | if (cr) return cr; | |
707 | } | |
708 | } else if (child.id.match("FEEDR-")) { | |
709 | ||
710 | if (getCookie("ttrss_vf_hreadf") == 1) { | |
711 | if (child.className != "feed") { | |
712 | alert(child.className); | |
713 | return child.id.replace('FEEDR-', ''); | |
714 | } | |
715 | } else { | |
716 | return child.id.replace('FEEDR-', ''); | |
717 | } | |
718 | } | |
719 | } | |
720 | } | |
721 | } else { | |
722 | ||
723 | var feed = list.ownerDocument.getElementById("FEEDR-" + getActiveFeedId()); | |
724 | ||
725 | if (direction == "next") { | |
726 | ||
727 | if (feed.nextSibling) { | |
728 | ||
729 | var next_feed = feed.nextSibling; | |
730 | ||
731 | while (!next_feed.id && next_feed.nextSibling) { | |
732 | next_feed = next_feed.nextSibling; | |
733 | } | |
734 | ||
735 | if (getCookie("ttrss_vf_hreadf") == 1) { | |
736 | while (next_feed && next_feed.className == "feed") { | |
737 | next_feed = next_feed.nextSibling; | |
738 | } | |
739 | } | |
740 | ||
741 | if (next_feed && next_feed.id.match("FEEDR-")) { | |
742 | return next_feed.id.replace("FEEDR-", ""); | |
743 | } | |
744 | } | |
745 | ||
746 | var this_cat = feed.parentNode.parentNode; | |
747 | ||
748 | if (this_cat && this_cat.nextSibling) { | |
749 | while (this_cat = this_cat.nextSibling) { | |
750 | if (this_cat.firstChild && this_cat.firstChild.firstChild) { | |
751 | var next_feed = this_cat.firstChild.firstChild; | |
752 | if (getCookie("ttrss_vf_hreadf") == 1) { | |
753 | while (next_feed && next_feed.className == "feed") { | |
754 | next_feed = next_feed.nextSibling; | |
755 | } | |
756 | } | |
757 | if (next_feed && next_feed.id.match("FEEDR-")) { | |
758 | return next_feed.id.replace("FEEDR-", ""); | |
759 | } | |
760 | } | |
761 | } | |
762 | } | |
763 | } else if (direction == "prev") { | |
764 | ||
765 | if (feed.previousSibling) { | |
766 | ||
767 | var prev_feed = feed.previousSibling; | |
768 | ||
769 | if (getCookie("ttrss_vf_hreadf") == 1) { | |
770 | while (prev_feed && prev_feed.className == "feed") { | |
771 | prev_feed = prev_feed.previousSibling; | |
772 | } | |
773 | } | |
774 | ||
775 | while (!prev_feed.id && prev_feed.previousSibling) { | |
776 | prev_feed = prev_feed.previousSibling; | |
777 | } | |
778 | ||
779 | if (prev_feed && prev_feed.id.match("FEEDR-")) { | |
780 | return prev_feed.id.replace("FEEDR-", ""); | |
781 | } | |
782 | } | |
783 | ||
784 | var this_cat = feed.parentNode.parentNode; | |
785 | ||
786 | if (this_cat && this_cat.previousSibling) { | |
787 | while (this_cat = this_cat.previousSibling) { | |
788 | if (this_cat.lastChild && this_cat.firstChild.lastChild) { | |
789 | var prev_feed = this_cat.firstChild.lastChild; | |
790 | if (getCookie("ttrss_vf_hreadf") == 1) { | |
791 | while (prev_feed && prev_feed.className == "feed") { | |
792 | prev_feed = prev_feed.previousSibling; | |
793 | } | |
794 | } | |
795 | if (prev_feed && prev_feed.id.match("FEEDR-")) { | |
796 | return prev_feed.id.replace("FEEDR-", ""); | |
797 | } | |
798 | } | |
799 | } | |
800 | } | |
801 | } | |
802 | } | |
803 | } | |
36aab70f AD |
804 | |
805 | function showBlockElement(id) { | |
806 | var elem = document.getElementById(id); | |
807 | ||
808 | if (elem) { | |
809 | elem.style.display = "block"; | |
810 | } else { | |
811 | alert("[showBlockElement] can't find element with id " + id); | |
812 | } | |
813 | } | |
814 | ||
a9b0bfd5 AD |
815 | function hideParentElement(e) { |
816 | e.parentNode.style.display = "none"; | |
817 | } | |
1b0809ae AD |
818 | |
819 | function dropboxSelect(e, v) { | |
820 | for (i = 0; i < e.length; i++) { | |
821 | if (e[i].value == v) { | |
822 | e.selectedIndex = i; | |
823 | break; | |
824 | } | |
825 | } | |
826 | } |