]>
Commit | Line | Data |
---|---|---|
1 | var hotkeys_enabled = true; | |
2 | ||
3 | function exception_error(location, e) { | |
4 | alert("Exception: " + e.name + "\nMessage: " + e.message + | |
5 | "\nLocation: " + location); | |
6 | } | |
7 | ||
8 | function disableHotkeys() { | |
9 | hotkeys_enabled = false; | |
10 | } | |
11 | ||
12 | function enableHotkeys() { | |
13 | hotkeys_enabled = true; | |
14 | } | |
15 | ||
16 | function xmlhttp_ready(obj) { | |
17 | return obj.readyState == 4 || obj.readyState == 0 || !obj.readyState; | |
18 | } | |
19 | ||
20 | ||
21 | function notify_callback() { | |
22 | var container = document.getElementById('notify'); | |
23 | if (xmlhttp.readyState == 4) { | |
24 | container.innerHTML=xmlhttp.responseText; | |
25 | } | |
26 | } | |
27 | ||
28 | function rpc_notify_callback() { | |
29 | var container = document.getElementById('notify'); | |
30 | if (xmlhttp_rpc.readyState == 4) { | |
31 | container.innerHTML=xmlhttp_rpc.responseText; | |
32 | } | |
33 | } | |
34 | ||
35 | function param_escape(arg) { | |
36 | if (typeof encodeURIComponent != 'undefined') | |
37 | return encodeURIComponent(arg); | |
38 | else | |
39 | return escape(arg); | |
40 | } | |
41 | ||
42 | function param_unescape(arg) { | |
43 | if (typeof decodeURIComponent != 'undefined') | |
44 | return decodeURIComponent(arg); | |
45 | else | |
46 | return unescape(arg); | |
47 | } | |
48 | ||
49 | function delay(gap) { | |
50 | var then,now; | |
51 | then=new Date().getTime(); | |
52 | now=then; | |
53 | while((now-then)<gap) { | |
54 | now=new Date().getTime(); | |
55 | } | |
56 | } | |
57 | ||
58 | function p_notify(msg) { | |
59 | ||
60 | var n = parent.document.getElementById("notify"); | |
61 | var nb = parent.document.getElementById("notify_body"); | |
62 | ||
63 | if (!n || !nb) return; | |
64 | ||
65 | if (msg == "") { | |
66 | nb.innerHTML = " "; | |
67 | // n.style.background = "#ffffff"; | |
68 | } else { | |
69 | nb.innerHTML = msg; | |
70 | // n.style.background = "#fffff0"; | |
71 | } | |
72 | } | |
73 | ||
74 | function notify(msg) { | |
75 | ||
76 | var n = document.getElementById("notify"); | |
77 | var nb = document.getElementById("notify_body"); | |
78 | ||
79 | if (!n || !nb) return; | |
80 | ||
81 | if (msg == "") { | |
82 | nb.innerHTML = " "; | |
83 | // n.style.background = "#ffffff"; | |
84 | } else { | |
85 | nb.innerHTML = msg; | |
86 | // n.style.background = "#fffff0"; | |
87 | } | |
88 | ||
89 | } | |
90 | ||
91 | function printLockingError() { | |
92 | notify("Please wait until operation finishes");} | |
93 | ||
94 | var seq = ""; | |
95 | ||
96 | function hotkey_handler(e) { | |
97 | ||
98 | var keycode; | |
99 | ||
100 | if (!hotkeys_enabled) return; | |
101 | ||
102 | if (window.event) { | |
103 | keycode = window.event.keyCode; | |
104 | } else if (e) { | |
105 | keycode = e.which; | |
106 | } | |
107 | ||
108 | if (keycode == 13 || keycode == 27) { | |
109 | seq = ""; | |
110 | } else { | |
111 | seq = seq + "" + keycode; | |
112 | } | |
113 | ||
114 | var piggie = document.getElementById("piggie"); | |
115 | ||
116 | if (piggie) { | |
117 | ||
118 | if (seq.match("807371717369")) { | |
119 | localPiggieFunction(true); | |
120 | } else { | |
121 | localPiggieFunction(false); | |
122 | } | |
123 | } | |
124 | ||
125 | if (typeof localHotkeyHandler != 'undefined') { | |
126 | localHotkeyHandler(keycode); | |
127 | } | |
128 | ||
129 | } | |
130 | ||
131 | function cleanSelectedList(element) { | |
132 | var content = document.getElementById(element); | |
133 | ||
134 | if (!document.getElementById("feedCatHolder")) { | |
135 | for (i = 0; i < content.childNodes.length; i++) { | |
136 | var child = content.childNodes[i]; | |
137 | child.className = child.className.replace("Selected", ""); | |
138 | } | |
139 | } else { | |
140 | for (i = 0; i < content.childNodes.length; i++) { | |
141 | var child = content.childNodes[i]; | |
142 | ||
143 | if (child.id == "feedCatHolder") { | |
144 | var fcat = child.firstChild; | |
145 | for (j = 0; j < fcat.childNodes.length; j++) { | |
146 | var feed = fcat.childNodes[j]; | |
147 | feed.className = feed.className.replace("Selected", ""); | |
148 | } | |
149 | } | |
150 | } | |
151 | ||
152 | } | |
153 | } | |
154 | ||
155 | ||
156 | function cleanSelected(element) { | |
157 | var content = document.getElementById(element); | |
158 | ||
159 | for (i = 0; i < content.rows.length; i++) { | |
160 | content.rows[i].className = content.rows[i].className.replace("Selected", ""); | |
161 | } | |
162 | ||
163 | } | |
164 | ||
165 | function getVisibleUnreadHeadlines() { | |
166 | var content = document.getElementById("headlinesList"); | |
167 | ||
168 | var rows = new Array(); | |
169 | ||
170 | for (i = 0; i < content.rows.length; i++) { | |
171 | var row_id = content.rows[i].id.replace("RROW-", ""); | |
172 | if (row_id.length > 0 && content.rows[i].className.match("Unread")) { | |
173 | rows.push(row_id); | |
174 | } | |
175 | } | |
176 | return rows; | |
177 | } | |
178 | ||
179 | function getVisibleHeadlineIds() { | |
180 | ||
181 | var content = document.getElementById("headlinesList"); | |
182 | ||
183 | var rows = new Array(); | |
184 | ||
185 | for (i = 0; i < content.rows.length; i++) { | |
186 | var row_id = content.rows[i].id.replace("RROW-", ""); | |
187 | if (row_id.length > 0) { | |
188 | rows.push(row_id); | |
189 | } | |
190 | } | |
191 | return rows; | |
192 | } | |
193 | ||
194 | function getFirstVisibleHeadlineId() { | |
195 | var rows = getVisibleHeadlineIds(); | |
196 | return rows[0]; | |
197 | } | |
198 | ||
199 | function getLastVisibleHeadlineId() { | |
200 | var rows = getVisibleHeadlineIds(); | |
201 | return rows[rows.length-1]; | |
202 | } | |
203 | ||
204 | function markHeadline(id) { | |
205 | var row = document.getElementById("RROW-" + id); | |
206 | if (row) { | |
207 | var is_active = false; | |
208 | ||
209 | if (row.className.match("Active")) { | |
210 | is_active = true; | |
211 | } | |
212 | row.className = row.className.replace("Selected", ""); | |
213 | row.className = row.className.replace("Active", ""); | |
214 | row.className = row.className.replace("Insensitive", ""); | |
215 | ||
216 | if (is_active) { | |
217 | row.className = row.className = "Active"; | |
218 | } | |
219 | ||
220 | row.className = row.className + "Selected"; | |
221 | ||
222 | } | |
223 | } | |
224 | ||
225 | function getFeedIds() { | |
226 | var content = document.getElementById("feedsList"); | |
227 | ||
228 | var rows = new Array(); | |
229 | ||
230 | for (i = 0; i < content.rows.length; i++) { | |
231 | var id = content.rows[i].id.replace("FEEDR-", ""); | |
232 | if (id.length > 0) { | |
233 | rows.push(id); | |
234 | } | |
235 | } | |
236 | ||
237 | return rows; | |
238 | } | |
239 | ||
240 | function setCookie(name, value, expires, path, domain, secure) { | |
241 | document.cookie= name + "=" + escape(value) + | |
242 | ((expires) ? "; expires=" + expires.toGMTString() : "") + | |
243 | ((path) ? "; path=" + path : "") + | |
244 | ((domain) ? "; domain=" + domain : "") + | |
245 | ((secure) ? "; secure" : ""); | |
246 | } | |
247 | ||
248 | function getCookie(name) { | |
249 | ||
250 | var dc = document.cookie; | |
251 | var prefix = name + "="; | |
252 | var begin = dc.indexOf("; " + prefix); | |
253 | if (begin == -1) { | |
254 | begin = dc.indexOf(prefix); | |
255 | if (begin != 0) return null; | |
256 | } | |
257 | else { | |
258 | begin += 2; | |
259 | } | |
260 | var end = document.cookie.indexOf(";", begin); | |
261 | if (end == -1) { | |
262 | end = dc.length; | |
263 | } | |
264 | return unescape(dc.substring(begin + prefix.length, end)); | |
265 | } | |
266 | ||
267 | function disableContainerChildren(id, disable, doc) { | |
268 | ||
269 | if (!doc) doc = document; | |
270 | ||
271 | var container = doc.getElementById(id); | |
272 | ||
273 | for (var i = 0; i < container.childNodes.length; i++) { | |
274 | var child = container.childNodes[i]; | |
275 | ||
276 | try { | |
277 | child.disabled = disable; | |
278 | } catch (E) { | |
279 | ||
280 | } | |
281 | ||
282 | if (disable) { | |
283 | if (child.className && child.className.match("button")) { | |
284 | child.className = "disabledButton"; | |
285 | } | |
286 | } else { | |
287 | if (child.className && child.className.match("disabledButton")) { | |
288 | child.className = "button"; | |
289 | } | |
290 | } | |
291 | } | |
292 | ||
293 | } | |
294 | ||
295 | function gotoPreferences() { | |
296 | document.location.href = "prefs.php"; | |
297 | } | |
298 | ||
299 | function gotoMain() { | |
300 | document.location.href = "tt-rss.php"; | |
301 | } | |
302 | ||
303 | function gotoExportOpml() { | |
304 | document.location.href = "opml.php?op=Export"; | |
305 | } | |
306 | ||
307 | function getActiveFeedId() { | |
308 | return getCookie("ttrss_vf_actfeed"); | |
309 | } | |
310 | ||
311 | function setActiveFeedId(id) { | |
312 | return setCookie("ttrss_vf_actfeed", id); | |
313 | } | |
314 | ||
315 | var xmlhttp_rpc = false; | |
316 | ||
317 | /*@cc_on @*/ | |
318 | /*@if (@_jscript_version >= 5) | |
319 | // JScript gives us Conditional compilation, we can cope with old IE versions. | |
320 | // and security blocked creation of the objects. | |
321 | try { | |
322 | xmlhttp_rpc = new ActiveXObject("Msxml2.XMLHTTP"); | |
323 | } catch (e) { | |
324 | try { | |
325 | xmlhttp_rpc = new ActiveXObject("Microsoft.XMLHTTP"); | |
326 | } catch (E) { | |
327 | xmlhttp_rpc = false; | |
328 | } | |
329 | } | |
330 | @end @*/ | |
331 | ||
332 | if (!xmlhttp_rpc && typeof XMLHttpRequest!='undefined') { | |
333 | xmlhttp_rpc = new XMLHttpRequest(); | |
334 | } | |
335 | ||
336 | function all_counters_callback() { | |
337 | if (xmlhttp_rpc.readyState == 4) { | |
338 | try { | |
339 | if (!xmlhttp_rpc.responseXML) { | |
340 | notify("[all_counters_callback] backend did not return valid XML"); | |
341 | return; | |
342 | } | |
343 | ||
344 | var reply = xmlhttp_rpc.responseXML.firstChild; | |
345 | ||
346 | var f_document = parent.frames["feeds-frame"].document; | |
347 | ||
348 | for (var l = 0; l < reply.childNodes.length; l++) { | |
349 | var id = reply.childNodes[l].getAttribute("id"); | |
350 | var ctr = reply.childNodes[l].getAttribute("counter"); | |
351 | ||
352 | var feedctr = f_document.getElementById("FEEDCTR-" + id); | |
353 | var feedu = f_document.getElementById("FEEDU-" + id); | |
354 | var feedr = f_document.getElementById("FEEDR-" + id); | |
355 | ||
356 | if (feedctr && feedu && feedr) { | |
357 | ||
358 | feedu.innerHTML = ctr; | |
359 | ||
360 | if (ctr > 0) { | |
361 | feedctr.className = "odd"; | |
362 | if (!feedr.className.match("Unread")) { | |
363 | var is_selected = feedr.className.match("Selected"); | |
364 | ||
365 | feedr.className = feedr.className.replace("Selected", ""); | |
366 | feedr.className = feedr.className.replace("Unread", ""); | |
367 | ||
368 | feedr.className = feedr.className + "Unread"; | |
369 | ||
370 | if (is_selected) { | |
371 | feedr.className = feedr.className + "Selected"; | |
372 | } | |
373 | ||
374 | } | |
375 | } else { | |
376 | feedctr.className = "invisible"; | |
377 | feedr.className = feedr.className.replace("Unread", ""); | |
378 | } | |
379 | } | |
380 | } | |
381 | } catch (e) { | |
382 | exception_error("all_counters_callback", e); | |
383 | } | |
384 | } | |
385 | } | |
386 | ||
387 | function update_all_counters(feed) { | |
388 | if (xmlhttp_ready(xmlhttp_rpc)) { | |
389 | var query = "backend.php?op=rpc&subop=getAllCounters"; | |
390 | ||
391 | if (feed > 0) { | |
392 | query = query + "&aid=" + feed; | |
393 | } | |
394 | ||
395 | xmlhttp_rpc.open("GET", query, true); | |
396 | xmlhttp_rpc.onreadystatechange=all_counters_callback; | |
397 | xmlhttp_rpc.send(null); | |
398 | } | |
399 | } | |
400 | ||
401 | function popupHelp(tid) { | |
402 | var w = window.open("backend.php?op=help&tid=" + tid, | |
403 | "Popup Help", | |
404 | "menubar=no,location=no,resizable=yes,scrollbars=yes,status=no"); | |
405 | } | |
406 | ||
407 | /** * @(#)isNumeric.js * * Copyright (c) 2000 by Sundar Dorai-Raj | |
408 | * * @author Sundar Dorai-Raj | |
409 | * * Email: sdoraira@vt.edu | |
410 | * * This program is free software; you can redistribute it and/or | |
411 | * * modify it under the terms of the GNU General Public License | |
412 | * * as published by the Free Software Foundation; either version 2 | |
413 | * * of the License, or (at your option) any later version, | |
414 | * * provided that any use properly credits the author. | |
415 | * * This program is distributed in the hope that it will be useful, | |
416 | * * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
417 | * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
418 | * * GNU General Public License for more details at http://www.gnu.org * * */ | |
419 | ||
420 | var numbers=".0123456789"; | |
421 | function isNumeric(x) { | |
422 | // is x a String or a character? | |
423 | if(x.length>1) { | |
424 | // remove negative sign | |
425 | x=Math.abs(x)+""; | |
426 | for(j=0;j<x.length;j++) { | |
427 | // call isNumeric recursively for each character | |
428 | number=isNumeric(x.substring(j,j+1)); | |
429 | if(!number) return number; | |
430 | } | |
431 | return number; | |
432 | } | |
433 | else { | |
434 | // if x is number return true | |
435 | if(numbers.indexOf(x)>=0) return true; | |
436 | return false; | |
437 | } | |
438 | } | |
439 | ||
440 | ||
441 | function hideOrShowFeeds(doc, hide) { | |
442 | ||
443 | var css_rules = doc.styleSheets[0].cssRules; | |
444 | ||
445 | for (i = 0; i < css_rules.length; i++) { | |
446 | var rule = css_rules[i]; | |
447 | ||
448 | if (rule.selectorText == "ul.feedList li.feed") { | |
449 | if (!hide) { | |
450 | rule.style.display = "block"; | |
451 | } else { | |
452 | rule.style.display = "none"; | |
453 | } | |
454 | } | |
455 | ||
456 | } | |
457 | ||
458 | } | |
459 | ||
460 | function fatalError(code) { | |
461 | window.location = "error.php?c=" + param_escape(code); | |
462 | } | |
463 | ||
464 | function selectTableRow(r, do_select) { | |
465 | r.className = r.className.replace("Selected", ""); | |
466 | ||
467 | if (do_select) { | |
468 | r.className = r.className + "Selected"; | |
469 | } | |
470 | } | |
471 | ||
472 | function selectTableRowsByIdPrefix(content_id, prefix, check_prefix, do_select) { | |
473 | ||
474 | var content = document.getElementById(content_id); | |
475 | ||
476 | if (!content) { | |
477 | alert("[selectTableRows] Element " + content_id + " not found."); | |
478 | return; | |
479 | } | |
480 | ||
481 | for (i = 0; i < content.rows.length; i++) { | |
482 | if (content.rows[i].id.match(prefix)) { | |
483 | selectTableRow(content.rows[i], do_select); | |
484 | } | |
485 | ||
486 | var row_id = content.rows[i].id.replace(prefix, ""); | |
487 | var check = document.getElementById(check_prefix + row_id); | |
488 | ||
489 | if (check) { | |
490 | check.checked = do_select; | |
491 | } | |
492 | } | |
493 | } | |
494 | ||
495 | function getSelectedTableRowIds(content_id, prefix) { | |
496 | ||
497 | var content = document.getElementById(content_id); | |
498 | ||
499 | if (!content) { | |
500 | alert("[getSelectedTableRowIds] Element " + content_id + " not found."); | |
501 | return; | |
502 | } | |
503 | ||
504 | var sel_rows = new Array(); | |
505 | ||
506 | for (i = 0; i < content.rows.length; i++) { | |
507 | if (content.rows[i].className.match("Selected")) { | |
508 | var row_id = content.rows[i].id.replace(prefix + "-", ""); | |
509 | sel_rows.push(row_id); | |
510 | } | |
511 | } | |
512 | ||
513 | return sel_rows; | |
514 | ||
515 | } | |
516 |