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