]>
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 | ||
3bdb368b | 361 | function parse_counters(reply, f_document, title_obj) { |
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 AD |
395 | if (feedctr && feedu && feedr) { |
396 | ||
397 | feedu.innerHTML = ctr; | |
023fe037 | 398 | |
426d3c57 AD |
399 | if (error) { |
400 | feedr.className = feedr.className.replace("feed", "error"); | |
401 | } else if (id > 0) { | |
402 | feedr.className = feedr.className.replace("error", "feed"); | |
023fe037 | 403 | } |
1a6a9555 AD |
404 | |
405 | if (ctr > 0) { | |
406 | feedctr.className = "odd"; | |
407 | if (!feedr.className.match("Unread")) { | |
408 | var is_selected = feedr.className.match("Selected"); | |
409 | ||
410 | feedr.className = feedr.className.replace("Selected", ""); | |
411 | feedr.className = feedr.className.replace("Unread", ""); | |
412 | ||
413 | feedr.className = feedr.className + "Unread"; | |
414 | ||
415 | if (is_selected) { | |
416 | feedr.className = feedr.className + "Selected"; | |
417 | } | |
418 | ||
419 | } | |
420 | } else { | |
421 | feedctr.className = "invisible"; | |
422 | feedr.className = feedr.className.replace("Unread", ""); | |
423 | } | |
424 | } | |
425 | } | |
426 | } catch (e) { | |
83f043bb | 427 | exception_error("parse_counters", e); |
1a6a9555 AD |
428 | } |
429 | } | |
430 | ||
3bdb368b AD |
431 | // this one is called from feedlist context |
432 | // thus title_obj passed to parse_counters is parent (e.g. main ttrss window) | |
433 | ||
4f3a84f4 | 434 | function all_counters_callback() { |
090e250b | 435 | if (xmlhttp_rpc.readyState == 4) { |
7719618b | 436 | try { |
3866b046 | 437 | if (!xmlhttp_rpc.responseXML || !xmlhttp_rpc.responseXML.firstChild) { |
7719618b AD |
438 | notify("[all_counters_callback] backend did not return valid XML"); |
439 | return; | |
440 | } | |
441 | ||
442 | var reply = xmlhttp_rpc.responseXML.firstChild; | |
7719618b | 443 | var f_document = parent.frames["feeds-frame"].document; |
280ee9a3 | 444 | |
3bdb368b | 445 | parse_counters(reply, f_document, parent); |
7719618b | 446 | |
7719618b AD |
447 | } catch (e) { |
448 | exception_error("all_counters_callback", e); | |
090e250b AD |
449 | } |
450 | } | |
451 | } | |
452 | ||
4f3a84f4 | 453 | function update_all_counters(feed) { |
090e250b | 454 | if (xmlhttp_ready(xmlhttp_rpc)) { |
8143ae1f | 455 | var query = "backend.php?op=rpc&subop=getAllCounters"; |
e47cfe37 AD |
456 | |
457 | if (feed > 0) { | |
458 | query = query + "&aid=" + feed; | |
459 | } | |
460 | ||
090e250b | 461 | xmlhttp_rpc.open("GET", query, true); |
4f3a84f4 | 462 | xmlhttp_rpc.onreadystatechange=all_counters_callback; |
090e250b AD |
463 | xmlhttp_rpc.send(null); |
464 | } | |
465 | } | |
7dc66a61 AD |
466 | |
467 | function popupHelp(tid) { | |
468 | var w = window.open("backend.php?op=help&tid=" + tid, | |
469 | "Popup Help", | |
470 | "menubar=no,location=no,resizable=yes,scrollbars=yes,status=no"); | |
471 | } | |
b6644d29 AD |
472 | |
473 | /** * @(#)isNumeric.js * * Copyright (c) 2000 by Sundar Dorai-Raj | |
474 | * * @author Sundar Dorai-Raj | |
475 | * * Email: sdoraira@vt.edu | |
476 | * * This program is free software; you can redistribute it and/or | |
477 | * * modify it under the terms of the GNU General Public License | |
478 | * * as published by the Free Software Foundation; either version 2 | |
479 | * * of the License, or (at your option) any later version, | |
480 | * * provided that any use properly credits the author. | |
481 | * * This program is distributed in the hope that it will be useful, | |
482 | * * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
483 | * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
484 | * * GNU General Public License for more details at http://www.gnu.org * * */ | |
485 | ||
486 | var numbers=".0123456789"; | |
487 | function isNumeric(x) { | |
488 | // is x a String or a character? | |
489 | if(x.length>1) { | |
490 | // remove negative sign | |
491 | x=Math.abs(x)+""; | |
492 | for(j=0;j<x.length;j++) { | |
493 | // call isNumeric recursively for each character | |
494 | number=isNumeric(x.substring(j,j+1)); | |
495 | if(!number) return number; | |
496 | } | |
497 | return number; | |
498 | } | |
499 | else { | |
500 | // if x is number return true | |
501 | if(numbers.indexOf(x)>=0) return true; | |
502 | return false; | |
503 | } | |
504 | } | |
505 | ||
3745788e AD |
506 | |
507 | function hideOrShowFeeds(doc, hide) { | |
508 | ||
3ed751d4 AD |
509 | if (!doc.styleSheets) return; |
510 | ||
3745788e AD |
511 | var css_rules = doc.styleSheets[0].cssRules; |
512 | ||
bbf4d0b2 AD |
513 | if (!css_rules || !css_rules.length) return; |
514 | ||
3745788e AD |
515 | for (i = 0; i < css_rules.length; i++) { |
516 | var rule = css_rules[i]; | |
517 | ||
518 | if (rule.selectorText == "ul.feedList li.feed") { | |
519 | if (!hide) { | |
520 | rule.style.display = "block"; | |
521 | } else { | |
522 | rule.style.display = "none"; | |
523 | } | |
524 | } | |
525 | ||
526 | } | |
527 | ||
528 | } | |
529 | ||
91d612b3 AD |
530 | function fatalError(code, params) { |
531 | if (!params) { | |
532 | window.location = "error.php?c=" + param_escape(code); | |
533 | } else { | |
534 | window.location = "error.php?c=" + param_escape(code) + | |
535 | "&p=" + param_escape(params); | |
536 | } | |
35f3c923 AD |
537 | } |
538 | ||
539 | function selectTableRow(r, do_select) { | |
540 | r.className = r.className.replace("Selected", ""); | |
541 | ||
542 | if (do_select) { | |
543 | r.className = r.className + "Selected"; | |
544 | } | |
545 | } | |
546 | ||
6c12c809 AD |
547 | function selectTableRowById(elem_id, check_id, do_select) { |
548 | ||
549 | try { | |
550 | ||
551 | var row = document.getElementById(elem_id); | |
552 | ||
553 | if (row) { | |
554 | selectTableRow(row, do_select); | |
555 | } | |
556 | ||
557 | var check = document.getElementById(check_id); | |
558 | ||
559 | if (check) { | |
560 | check.checked = do_select; | |
561 | } | |
562 | } catch (e) { | |
563 | exception_error("selectTableRowById", e); | |
564 | } | |
565 | } | |
566 | ||
1572afe5 | 567 | function selectTableRowsByIdPrefix(content_id, prefix, check_prefix, do_select, |
649e0af9 | 568 | classcheck, reset_others) { |
3745788e | 569 | |
35f3c923 AD |
570 | var content = document.getElementById(content_id); |
571 | ||
572 | if (!content) { | |
573 | alert("[selectTableRows] Element " + content_id + " not found."); | |
574 | return; | |
575 | } | |
576 | ||
577 | for (i = 0; i < content.rows.length; i++) { | |
1572afe5 AD |
578 | if (!classcheck || content.rows[i].className.match(classcheck)) { |
579 | ||
580 | if (content.rows[i].id.match(prefix)) { | |
581 | selectTableRow(content.rows[i], do_select); | |
649e0af9 AD |
582 | |
583 | var row_id = content.rows[i].id.replace(prefix, ""); | |
584 | var check = document.getElementById(check_prefix + row_id); | |
3055bc41 | 585 | |
649e0af9 AD |
586 | if (check) { |
587 | check.checked = do_select; | |
588 | } | |
589 | } else if (reset_others) { | |
590 | selectTableRow(content.rows[i], false); | |
7d8d10c6 AD |
591 | |
592 | var row_id = content.rows[i].id.replace(prefix, ""); | |
593 | var check = document.getElementById(check_prefix + row_id); | |
594 | ||
595 | if (check) { | |
596 | check.checked = false; | |
597 | } | |
598 | ||
1572afe5 | 599 | } |
649e0af9 AD |
600 | } else if (reset_others) { |
601 | selectTableRow(content.rows[i], false); | |
7d8d10c6 AD |
602 | |
603 | var row_id = content.rows[i].id.replace(prefix, ""); | |
604 | var check = document.getElementById(check_prefix + row_id); | |
605 | ||
606 | if (check) { | |
607 | check.checked = false; | |
608 | } | |
609 | ||
3055bc41 | 610 | } |
35f3c923 | 611 | } |
295f9b42 | 612 | } |
91ff844a AD |
613 | |
614 | function getSelectedTableRowIds(content_id, prefix) { | |
615 | ||
616 | var content = document.getElementById(content_id); | |
617 | ||
618 | if (!content) { | |
619 | alert("[getSelectedTableRowIds] Element " + content_id + " not found."); | |
620 | return; | |
621 | } | |
622 | ||
623 | var sel_rows = new Array(); | |
624 | ||
625 | for (i = 0; i < content.rows.length; i++) { | |
1572afe5 AD |
626 | if (content.rows[i].id.match(prefix) && |
627 | content.rows[i].className.match("Selected")) { | |
628 | ||
91ff844a AD |
629 | var row_id = content.rows[i].id.replace(prefix + "-", ""); |
630 | sel_rows.push(row_id); | |
631 | } | |
632 | } | |
633 | ||
634 | return sel_rows; | |
635 | ||
636 | } | |
637 | ||
386cbf27 AD |
638 | function toggleSelectRowById(sender, id) { |
639 | var row = document.getElementById(id); | |
640 | ||
641 | if (sender.checked) { | |
642 | if (!row.className.match("Selected")) { | |
643 | row.className = row.className + "Selected"; | |
644 | } | |
645 | } else { | |
646 | if (row.className.match("Selected")) { | |
647 | row.className = row.className.replace("Selected", ""); | |
648 | } | |
649 | } | |
650 | } | |
651 | ||
b92e6209 AD |
652 | function toggleSelectListRow(sender) { |
653 | var parent_row = sender.parentNode; | |
654 | ||
655 | if (sender.checked) { | |
656 | if (!parent_row.className.match("Selected")) { | |
657 | parent_row.className = parent_row.className + "Selected"; | |
658 | } | |
659 | } else { | |
660 | if (parent_row.className.match("Selected")) { | |
661 | parent_row.className = parent_row.className.replace("Selected", ""); | |
662 | } | |
663 | } | |
664 | } | |
665 | ||
386cbf27 | 666 | |
1572afe5 AD |
667 | function toggleSelectRow(sender) { |
668 | var parent_row = sender.parentNode.parentNode; | |
669 | ||
670 | if (sender.checked) { | |
671 | if (!parent_row.className.match("Selected")) { | |
672 | parent_row.className = parent_row.className + "Selected"; | |
673 | } | |
674 | } else { | |
675 | if (parent_row.className.match("Selected")) { | |
676 | parent_row.className = parent_row.className.replace("Selected", ""); | |
677 | } | |
678 | } | |
679 | } | |
680 | ||
3866b046 AD |
681 | function openExternalUrl(url) { |
682 | var w = window.open(url); | |
683 | } | |
1572afe5 | 684 | |
7b433d8c AD |
685 | |
686 | function getRelativeFeedId(list, id, direction) { | |
687 | if (!id) { | |
688 | if (direction == "next") { | |
689 | for (i = 0; i < list.childNodes.length; i++) { | |
690 | var child = list.childNodes[i]; | |
691 | if (child.id == "feedCatHolder") { | |
c3f348c2 | 692 | if (child.lastChild) { |
7b433d8c AD |
693 | var cr = getRelativeFeedId(child.firstChild, id, direction); |
694 | if (cr) return cr; | |
695 | } | |
696 | } else if (child.id.match("FEEDR-")) { | |
697 | return child.id.replace('FEEDR-', ''); | |
698 | } | |
699 | } | |
700 | } | |
701 | ||
702 | // FIXME select last feed doesn't work when only unread feeds are visible | |
703 | ||
704 | if (direction == "prev") { | |
705 | for (i = list.childNodes.length-1; i >= 0; i--) { | |
706 | var child = list.childNodes[i]; | |
707 | if (child.id == "feedCatHolder") { | |
708 | if (child.firstChild) { | |
709 | var cr = getRelativeFeedId(child.firstChild, id, direction); | |
710 | if (cr) return cr; | |
711 | } | |
712 | } else if (child.id.match("FEEDR-")) { | |
713 | ||
714 | if (getCookie("ttrss_vf_hreadf") == 1) { | |
715 | if (child.className != "feed") { | |
716 | alert(child.className); | |
717 | return child.id.replace('FEEDR-', ''); | |
718 | } | |
719 | } else { | |
720 | return child.id.replace('FEEDR-', ''); | |
721 | } | |
722 | } | |
723 | } | |
724 | } | |
725 | } else { | |
726 | ||
727 | var feed = list.ownerDocument.getElementById("FEEDR-" + getActiveFeedId()); | |
728 | ||
729 | if (direction == "next") { | |
730 | ||
731 | if (feed.nextSibling) { | |
732 | ||
733 | var next_feed = feed.nextSibling; | |
734 | ||
735 | while (!next_feed.id && next_feed.nextSibling) { | |
736 | next_feed = next_feed.nextSibling; | |
737 | } | |
738 | ||
739 | if (getCookie("ttrss_vf_hreadf") == 1) { | |
740 | while (next_feed && next_feed.className == "feed") { | |
741 | next_feed = next_feed.nextSibling; | |
742 | } | |
743 | } | |
744 | ||
745 | if (next_feed && next_feed.id.match("FEEDR-")) { | |
746 | return next_feed.id.replace("FEEDR-", ""); | |
747 | } | |
748 | } | |
749 | ||
750 | var this_cat = feed.parentNode.parentNode; | |
751 | ||
752 | if (this_cat && this_cat.nextSibling) { | |
753 | while (this_cat = this_cat.nextSibling) { | |
754 | if (this_cat.firstChild && this_cat.firstChild.firstChild) { | |
755 | var next_feed = this_cat.firstChild.firstChild; | |
756 | if (getCookie("ttrss_vf_hreadf") == 1) { | |
757 | while (next_feed && next_feed.className == "feed") { | |
758 | next_feed = next_feed.nextSibling; | |
759 | } | |
760 | } | |
761 | if (next_feed && next_feed.id.match("FEEDR-")) { | |
762 | return next_feed.id.replace("FEEDR-", ""); | |
763 | } | |
764 | } | |
765 | } | |
766 | } | |
767 | } else if (direction == "prev") { | |
768 | ||
769 | if (feed.previousSibling) { | |
770 | ||
771 | var prev_feed = feed.previousSibling; | |
772 | ||
773 | if (getCookie("ttrss_vf_hreadf") == 1) { | |
774 | while (prev_feed && prev_feed.className == "feed") { | |
775 | prev_feed = prev_feed.previousSibling; | |
776 | } | |
777 | } | |
778 | ||
779 | while (!prev_feed.id && prev_feed.previousSibling) { | |
780 | prev_feed = prev_feed.previousSibling; | |
781 | } | |
782 | ||
783 | if (prev_feed && prev_feed.id.match("FEEDR-")) { | |
784 | return prev_feed.id.replace("FEEDR-", ""); | |
785 | } | |
786 | } | |
787 | ||
788 | var this_cat = feed.parentNode.parentNode; | |
789 | ||
790 | if (this_cat && this_cat.previousSibling) { | |
791 | while (this_cat = this_cat.previousSibling) { | |
792 | if (this_cat.lastChild && this_cat.firstChild.lastChild) { | |
793 | var prev_feed = this_cat.firstChild.lastChild; | |
794 | if (getCookie("ttrss_vf_hreadf") == 1) { | |
795 | while (prev_feed && prev_feed.className == "feed") { | |
796 | prev_feed = prev_feed.previousSibling; | |
797 | } | |
798 | } | |
799 | if (prev_feed && prev_feed.id.match("FEEDR-")) { | |
800 | return prev_feed.id.replace("FEEDR-", ""); | |
801 | } | |
802 | } | |
803 | } | |
804 | } | |
805 | } | |
806 | } | |
807 | } | |
36aab70f AD |
808 | |
809 | function showBlockElement(id) { | |
810 | var elem = document.getElementById(id); | |
811 | ||
812 | if (elem) { | |
813 | elem.style.display = "block"; | |
814 | } else { | |
815 | alert("[showBlockElement] can't find element with id " + id); | |
816 | } | |
817 | } | |
818 | ||
a9b0bfd5 AD |
819 | function hideParentElement(e) { |
820 | e.parentNode.style.display = "none"; | |
821 | } | |
1b0809ae AD |
822 | |
823 | function dropboxSelect(e, v) { | |
824 | for (i = 0; i < e.length; i++) { | |
825 | if (e[i].value == v) { | |
826 | e.selectedIndex = i; | |
827 | break; | |
828 | } | |
829 | } | |
830 | } | |
0ee1d1a0 AD |
831 | |
832 | // originally stolen from http://www.11tmr.com/11tmr.nsf/d6plinks/MWHE-695L9Z | |
833 | // bugfixed just a little bit :-) | |
834 | function getURLParam(strParamName){ | |
835 | var strReturn = ""; | |
836 | var strHref = window.location.href; | |
837 | ||
838 | if (strHref.indexOf("#") == strHref.length-1) { | |
839 | strHref = strHref.substring(0, strHref.length-1); | |
840 | } | |
841 | ||
842 | if ( strHref.indexOf("?") > -1 ){ | |
843 | var strQueryString = strHref.substr(strHref.indexOf("?")); | |
844 | var aQueryString = strQueryString.split("&"); | |
845 | for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){ | |
846 | if (aQueryString[iParam].indexOf(strParamName + "=") > -1 ){ | |
847 | var aParam = aQueryString[iParam].split("="); | |
848 | strReturn = aParam[1]; | |
849 | break; | |
850 | } | |
851 | } | |
852 | } | |
853 | return strReturn; | |
854 | } | |
855 | ||
cf1bc085 AD |
856 | function leading_zero(p) { |
857 | var s = String(p); | |
858 | if (s.length == 1) s = "0" + s; | |
859 | return s; | |
860 | } |