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