]>
git.wh0rd.org - tt-rss.git/blob - functions.js
1 var hotkeys_enabled
= true;
2 var notify_silent
= false;
3 var last_progress_point
= 0;
4 var async_counters_work
= false;
6 /* add method to remove element from array */
8 Array
.prototype.remove = function(s
) {
9 for (var i
=0; i
< this.length
; i
++) {
10 if (s
== this[i
]) this.splice(i
, 1);
18 function exception_error(location
, e
, ext_info
) {
19 var msg
= format_exception_error(location
, e
);
21 if (!ext_info
) ext_info
= "N/A";
27 var ebc
= $("xebContent");
31 Element
.show("dialog_overlay");
32 Element
.show("errorBoxShadow");
35 if (ext_info
.responseText
) {
36 ext_info
= ext_info
.responseText
;
41 "<div><b>Error message:</b></div>" +
42 "<pre>" + msg
+ "</pre>" +
43 "<div><b>Additional information:</b></div>" +
44 "<textarea readonly=\"1\">" + ext_info
+ "</textarea>";
57 function format_exception_error(location
, e
) {
61 var base_fname
= e
.fileName
.substring(e
.fileName
.lastIndexOf("/") + 1);
63 msg
= "Exception: " + e
.name
+ ", " + e
.message
+
64 "\nFunction: " + location
+ "()" +
65 "\nLocation: " + base_fname
+ ":" + e
.lineNumber
;
67 } else if (e
.description
) {
68 msg
= "Exception: " + e
.description
+ "\nFunction: " + location
+ "()";
70 msg
= "Exception: " + e
+ "\nFunction: " + location
+ "()";
73 debug("<b>EXCEPTION: " + msg
+ "</b>");
79 function disableHotkeys() {
80 hotkeys_enabled
= false;
83 function enableHotkeys() {
84 hotkeys_enabled
= true;
87 function open_article_callback(transport
) {
90 if (transport
.responseXML
) {
92 var link
= transport
.responseXML
.getElementsByTagName("link")[0];
93 var id
= transport
.responseXML
.getElementsByTagName("id")[0];
95 debug("open_article_callback, received link: " + link
);
99 var wname
= "ttrss_article_" + id
.firstChild
.nodeValue
;
101 debug("link url: " + link
.firstChild
.nodeValue
+ ", wname " + wname
);
103 var w
= window
.open(link
.firstChild
.nodeValue
, wname
);
105 if (!w
) { notify_error("Failed to load article in new window"); }
108 id
= id
.firstChild
.nodeValue
;
109 if (!$("headlinesList")) {
110 window
.setTimeout("toggleUnread(" + id
+ ", 0)", 100);
114 notify_error("Can't open article: received invalid article link");
117 notify_error("Can't open article: received invalid XML");
121 exception_error("open_article_callback", e
);
125 function param_escape(arg
) {
126 if (typeof encodeURIComponent
!= 'undefined')
127 return encodeURIComponent(arg
);
132 function param_unescape(arg
) {
133 if (typeof decodeURIComponent
!= 'undefined')
134 return decodeURIComponent(arg
);
136 return unescape(arg
);
139 function delay(gap
) {
141 then
=new Date().getTime();
143 while((now
-then
)<gap
) {
144 now
=new Date().getTime();
148 var notify_hide_timerid
= false;
150 function hide_notify() {
153 n
.style
.display
= "none";
157 function notify_silent_next() {
158 notify_silent
= true;
161 function notify_real(msg
, no_hide
, n_type
) {
164 notify_silent
= false;
169 var nb
= $("notify_body");
171 if (!n
|| !nb
) return;
173 if (notify_hide_timerid
) {
174 window
.clearTimeout(notify_hide_timerid
);
178 if (n
.style
.display
== "block") {
179 notify_hide_timerid
= window
.setTimeout("hide_notify()", 0);
183 n
.style
.display
= "block";
195 if (typeof __
!= 'undefined') {
200 n
.className
= "notify";
201 } else if (n_type
== 2) {
202 n
.className
= "notifyProgress";
203 msg
= "<img src='images/indicator_white.gif'> " + msg
;
204 } else if (n_type
== 3) {
205 n
.className
= "notifyError";
206 msg
= "<img src='images/sign_excl.gif'> " + msg
;
207 } else if (n_type
== 4) {
208 n
.className
= "notifyInfo";
209 msg
= "<img src='images/sign_info.gif'> " + msg
;
212 // msg = "<img src='images/live_com_loading.gif'> " + msg;
217 notify_hide_timerid
= window
.setTimeout("hide_notify()", 3000);
221 function notify(msg
, no_hide
) {
222 notify_real(msg
, no_hide
, 1);
225 function notify_progress(msg
, no_hide
) {
226 notify_real(msg
, no_hide
, 2);
229 function notify_error(msg
, no_hide
) {
230 notify_real(msg
, no_hide
, 3);
234 function notify_info(msg
, no_hide
) {
235 notify_real(msg
, no_hide
, 4);
238 function printLockingError() {
239 notify_info("Please wait until operation finishes.");
242 function cleanSelected(element
) {
243 var content
= $(element
);
245 for (i
= 0; i
< content
.rows
.length
; i
++) {
246 content
.rows
[i
].className
= content
.rows
[i
].className
.replace("Selected", "");
250 function getVisibleUnreadHeadlines() {
251 var content
= $("headlinesList");
253 var rows
= new Array();
255 if (!content
) return rows
;
257 for (i
= 0; i
< content
.rows
.length
; i
++) {
258 var row_id
= content
.rows
[i
].id
.replace("RROW-", "");
259 if (row_id
.length
> 0 && content
.rows
[i
].className
.match("Unread")) {
266 function getVisibleHeadlineIds() {
268 var content
= $("headlinesList");
270 var rows
= new Array();
272 if (!content
) return rows
;
274 for (i
= 0; i
< content
.rows
.length
; i
++) {
275 var row_id
= content
.rows
[i
].id
.replace("RROW-", "");
276 if (row_id
.length
> 0) {
283 function getFirstVisibleHeadlineId() {
285 var rows
= cdmGetVisibleArticles();
288 var rows
= getVisibleHeadlineIds();
293 function getLastVisibleHeadlineId() {
295 var rows
= cdmGetVisibleArticles();
296 return rows
[rows
.length
-1];
298 var rows
= getVisibleHeadlineIds();
299 return rows
[rows
.length
-1];
303 function markHeadline(id
) {
304 var row
= $("RROW-" + id
);
306 var is_active
= false;
308 if (row
.className
.match("Active")) {
311 row
.className
= row
.className
.replace("Selected", "");
312 row
.className
= row
.className
.replace("Active", "");
313 row
.className
= row
.className
.replace("Insensitive", "");
316 row
.className
= row
.className
= "Active";
319 var check
= $("RCHK-" + id
);
322 check
.checked
= true;
325 row
.className
= row
.className
+ "Selected";
330 function getFeedIds() {
331 var content
= $("feedsList");
333 var rows
= new Array();
335 for (i
= 0; i
< content
.rows
.length
; i
++) {
336 var id
= content
.rows
[i
].id
.replace("FEEDR-", "");
345 function setCookie(name
, value
, lifetime
, path
, domain
, secure
) {
351 d
.setTime(d
.getTime() + (lifetime
* 1000));
354 debug("setCookie: " + name
+ " => " + value
+ ": " + d
);
356 int_setCookie(name
, value
, d
, path
, domain
, secure
);
360 function int_setCookie(name
, value
, expires
, path
, domain
, secure
) {
361 document
.cookie
= name
+ "=" + escape(value
) +
362 ((expires
) ? "; expires=" + expires
.toGMTString() : "") +
363 ((path
) ? "; path=" + path
: "") +
364 ((domain
) ? "; domain=" + domain
: "") +
365 ((secure
) ? "; secure" : "");
368 function delCookie(name
, path
, domain
) {
369 if (getCookie(name
)) {
370 document
.cookie
= name
+ "=" +
371 ((path
) ? ";path=" + path
: "") +
372 ((domain
) ? ";domain=" + domain
: "" ) +
373 ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
378 function getCookie(name
) {
380 var dc
= document
.cookie
;
381 var prefix
= name
+ "=";
382 var begin
= dc
.indexOf("; " + prefix
);
384 begin
= dc
.indexOf(prefix
);
385 if (begin
!= 0) return null;
390 var end
= document
.cookie
.indexOf(";", begin
);
394 return unescape(dc
.substring(begin
+ prefix
.length
, end
));
397 function disableContainerChildren(id
, disable
, doc
) {
399 if (!doc
) doc
= document
;
401 var container
= $(id
);
404 //alert("disableContainerChildren: element " + id + " not found");
408 for (var i
= 0; i
< container
.childNodes
.length
; i
++) {
409 var child
= container
.childNodes
[i
];
412 child
.disabled
= disable
;
418 if (child
.className
&& child
.className
.match("button")) {
419 child
.className
= "disabledButton";
422 if (child
.className
&& child
.className
.match("disabledButton")) {
423 child
.className
= "button";
430 function gotoPreferences() {
431 document
.location
.href
= "prefs.php";
434 function gotoMain() {
435 document
.location
.href
= "tt-rss.php";
438 function gotoExportOpml() {
439 document
.location
.href
= "opml.php?op=Export";
442 function parse_counters(reply
, scheduled_call
) {
447 var elems
= reply
.getElementsByTagName("counter");
449 for (var l
= 0; l
< elems
.length
; l
++) {
451 var id
= elems
[l
].getAttribute("id");
452 var t
= elems
[l
].getAttribute("type");
453 var ctr
= elems
[l
].getAttribute("counter");
454 var error
= elems
[l
].getAttribute("error");
455 var has_img
= elems
[l
].getAttribute("hi");
456 var updated
= elems
[l
].getAttribute("updated");
457 var title
= elems
[l
].getAttribute("title");
458 var xmsg
= elems
[l
].getAttribute("xmsg");
460 if (id
== "global-unread") {
462 if (ctr
> global_unread
) {
463 offlineDownloadStart(1);
471 if (id
== "subscribed-feeds") {
476 if (t
== "category") {
477 var catctr
= $("FCATCTR-" + id
);
479 catctr
.innerHTML
= "(" + ctr
+ ")";
481 catctr
.className
= "catCtrHasUnread";
483 catctr
.className
= "catCtrNoUnread";
489 var feedctr
= $("FEEDCTR-" + id
);
490 var feedu
= $("FEEDU-" + id
);
491 var feedr
= $("FEEDR-" + id
);
492 var feed_img
= $("FIMG-" + id
);
493 var feedlink
= $("FEEDL-" + id
);
494 var feedupd
= $("FLUPD-" + id
);
496 if (updated
&& feedlink
) {
498 feedlink
.title
= "Error: " + error
+ " (" + updated
+ ")";
500 feedlink
.title
= "Updated: " + updated
;
505 if (!updated
) updated
= "";
509 feedupd
.innerHTML
= updated
+ " " + xmsg
+ " (Error)";
511 feedupd
.innerHTML
= updated
+ " (Error)";
515 feedupd
.innerHTML
= updated
+ " " + xmsg
;
517 feedupd
.innerHTML
= updated
;
522 if (has_img
&& feed_img
) {
523 if (!feed_img
.src
.match(id
+ ".ico")) {
524 feed_img
.src
= getInitParam("icons_location") + "/" + id
+ ".ico";
528 if (feedlink
&& title
) {
529 feedlink
.innerHTML
= title
;
532 if (feedctr
&& feedu
&& feedr
) {
534 if (feedu
.innerHTML
!= ctr
&& id
== getActiveFeedId() && scheduled_call
) {
538 var row_needs_hl
= (ctr
> 0 && ctr
> parseInt(feedu
.innerHTML
));
540 feedu
.innerHTML
= ctr
;
543 feedr
.className
= feedr
.className
.replace("feed", "error");
545 feedr
.className
= feedr
.className
.replace("error", "feed");
549 feedctr
.className
= "feedCtrHasUnread";
550 if (!feedr
.className
.match("Unread")) {
551 var is_selected
= feedr
.className
.match("Selected");
553 feedr
.className
= feedr
.className
.replace("Selected", "");
554 feedr
.className
= feedr
.className
.replace("Unread", "");
556 feedr
.className
= feedr
.className
+ "Unread";
559 feedr
.className
= feedr
.className
+ "Selected";
565 new Effect
.Highlight(feedr
, {duration
: 1, startcolor
: "#fff7d5",
566 queue
: { position
:'end', scope
: 'EFQ-' + id
, limit
: 1 } } );
569 feedctr
.className
= "feedCtrNoUnread";
570 feedr
.className
= feedr
.className
.replace("Unread", "");
575 hideOrShowFeeds(getInitParam("hide_read_feeds") == 1);
577 var feeds_stored
= number_of_feeds
;
579 debug("Feed counters, C: " + feeds_found
+ ", S:" + feeds_stored
);
581 if (feeds_stored
!= feeds_found
) {
582 number_of_feeds
= feeds_found
;
584 if (feeds_stored
!= 0 && feeds_found
!= 0) {
585 debug("Subscribed feed number changed, refreshing feedlist");
586 setTimeout('updateFeedList(false, false)', 50);
589 /* var fl = $("feeds-frame").innerHTML;
591 cache_invalidate("FEEDLIST");
592 cache_inject("FEEDLIST", fl, getInitParam("num_feeds"));
597 exception_error("parse_counters", e
);
601 function parse_counters_reply(transport
, scheduled_call
) {
603 if (!transport
.responseXML
) {
604 notify_error("Backend did not return valid XML", true);
608 var reply
= transport
.responseXML
.firstChild
;
611 notify_error("Backend did not return expected XML object", true);
616 if (!transport_error_check(transport
)) return;
618 var counters
= reply
.getElementsByTagName("counters")[0];
620 parse_counters(counters
, scheduled_call
);
622 var runtime_info
= reply
.getElementsByTagName("runtime-info")[0];
624 parse_runtime_info(runtime_info
);
626 if (feedsSortByUnread()) {
630 hideOrShowFeeds(getInitParam("hide_read_feeds") == 1);
634 function all_counters_callback2(transport
, async_call
) {
636 if (async_call
) async_counters_work
= true;
638 if (offline_mode
) return;
640 debug("<b>all_counters_callback2 IN: " + transport
+ "</b>");
641 parse_counters_reply(transport
);
642 debug("<b>all_counters_callback2 OUT: " + transport
+ "</b>");
645 exception_error("all_counters_callback2", e
, transport
);
649 function get_feed_unread(id
) {
651 return parseInt($("FEEDU-" + id
).innerHTML
);
657 function get_cat_unread(id
) {
659 var ctr
= $("FCATCTR-" + id
).innerHTML
;
660 ctr
= ctr
.replace("(", "");
661 ctr
= ctr
.replace(")", "");
662 return parseInt(ctr
);
668 function get_feed_entry_unread(elem
) {
670 var id
= elem
.id
.replace("FEEDR-", "");
677 return parseInt($("FEEDU-" + id
).innerHTML
);
683 function get_feed_entry_name(elem
) {
684 var id
= elem
.id
.replace("FEEDR-", "");
685 return getFeedName(id
);
689 function resort_category(node
) {
693 debug("resort_category: " + node
);
695 var by_unread
= feedsSortByUnread();
697 var list
= node
.getElementsByTagName("LI");
699 for (i
= 0; i
< list
.length
; i
++) {
701 for (j
= i
+1; j
< list
.length
; j
++) {
703 var tmp_val
= get_feed_entry_unread(list
[i
]);
704 var cur_val
= get_feed_entry_unread(list
[j
]);
706 var tmp_name
= get_feed_entry_name(list
[i
]);
707 var cur_name
= get_feed_entry_name(list
[j
]);
709 if ((by_unread
&& (cur_val
> tmp_val
)) || (!by_unread
&& (cur_name
< tmp_name
))) {
710 tempnode_i
= list
[i
].cloneNode(true);
711 tempnode_j
= list
[j
].cloneNode(true);
712 node
.replaceChild(tempnode_i
, list
[j
]);
713 node
.replaceChild(tempnode_j
, list
[i
]);
719 exception_error("resort_category", e
);
724 function resort_feedlist() {
725 debug("resort_feedlist");
727 if ($("FCATLIST--1")) {
729 var lists
= document
.getElementsByTagName("UL");
731 for (var i
= 0; i
< lists
.length
; i
++) {
732 if (lists
[i
].id
&& lists
[i
].id
.match("FCATLIST-")) {
733 resort_category(lists
[i
]);
738 resort_category($("feedList"));
742 /** * @(#)isNumeric.js * * Copyright (c) 2000 by Sundar Dorai-Raj
743 * * @author Sundar Dorai-Raj
744 * * Email: sdoraira@vt.edu
745 * * This program is free software; you can redistribute it and/or
746 * * modify it under the terms of the GNU General Public License
747 * * as published by the Free Software Foundation; either version 2
748 * * of the License, or (at your option) any later version,
749 * * provided that any use properly credits the author.
750 * * This program is distributed in the hope that it will be useful,
751 * * but WITHOUT ANY WARRANTY; without even the implied warranty of
752 * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
753 * * GNU General Public License for more details at http://www.gnu.org * * */
755 var numbers
=".0123456789";
756 function isNumeric(x
) {
757 // is x a String or a character?
759 // remove negative sign
761 for(j
=0;j
<x
.length
;j
++) {
762 // call isNumeric recursively for each character
763 number
=isNumeric(x
.substring(j
,j
+1));
764 if(!number
) return number
;
769 // if x is number return true
770 if(numbers
.indexOf(x
)>=0) return true;
776 function hideOrShowFeeds(hide
) {
780 debug("hideOrShowFeeds: " + hide
);
782 if ($("FCATLIST--1")) {
784 var lists
= document
.getElementsByTagName("UL");
786 for (var i
= 0; i
< lists
.length
; i
++) {
787 if (lists
[i
].id
&& lists
[i
].id
.match("FCATLIST-")) {
789 var id
= lists
[i
].id
.replace("FCATLIST-", "");
790 hideOrShowFeedsCategory(id
, hide
);
795 hideOrShowFeedsCategory(null, hide
);
799 exception_error("hideOrShowFeeds", e
);
803 function hideOrShowFeedsCategory(id
, hide
) {
811 node
= $("FCATLIST-" + id
);
812 cat_node
= $("FCAT-" + id
);
814 node
= $("feedList"); // no categories
817 // debug("hideOrShowFeedsCategory: " + node + " (" + hide + ")");
822 debug("hideOrShowFeeds: passed node is null, aborting");
826 // debug("cat: " + node.id);
828 if (node
.hasChildNodes() && node
.firstChild
.nextSibling
!= false) {
829 for (i
= 0; i
< node
.childNodes
.length
; i
++) {
830 if (node
.childNodes
[i
].nodeName
!= "LI") { continue; }
832 if (node
.childNodes
[i
].style
!= undefined) {
834 var has_unread
= (node
.childNodes
[i
].className
!= "feed" &&
835 node
.childNodes
[i
].className
!= "label" &&
836 !(!getInitParam("hide_read_shows_special") &&
837 node
.childNodes
[i
].className
== "virt") &&
838 node
.childNodes
[i
].className
!= "error" &&
839 node
.childNodes
[i
].className
!= "tag");
841 // debug(node.childNodes[i].id + " --> " + has_unread);
843 if (hide
&& !has_unread
) {
844 //node.childNodes[i].style.display = "none";
845 var id
= node
.childNodes
[i
].id
;
846 Effect
.Fade(node
.childNodes
[i
], {duration
: 0.3,
847 queue
: { position
: 'end', scope
: 'FFADE-' + id
, limit
: 1 }});
851 node
.childNodes
[i
].style
.display
= "list-item";
852 //Effect.Appear(node.childNodes[i], {duration : 0.3});
856 node
.childNodes
[i
].style
.display
= "list-item";
858 //Effect.Appear(node.childNodes[i], {duration : 0.3});
859 //Effect.Highlight(node.childNodes[i]);
865 // debug("end cat: " + node.id + " unread " + cat_unread);
869 if (cat_unread
== 0) {
870 if (cat_node
.style
== undefined) {
871 debug("ERROR: supplied cat_node " + cat_node
+
872 " has no styles. WTF?");
876 //cat_node.style.display = "none";
877 Effect
.Fade(cat_node
, {duration
: 0.3,
878 queue
: { position
: 'end', scope
: 'CFADE-' + node
.id
, limit
: 1 }});
880 cat_node
.style
.display
= "list-item";
884 cat_node
.style
.display
= "list-item";
891 // debug("unread for category: " + cat_unread);
894 exception_error("hideOrShowFeedsCategory", e
);
898 function selectTableRow(r
, do_select
) {
899 r
.className
= r
.className
.replace("Selected", "");
902 r
.className
= r
.className
+ "Selected";
906 function selectTableRowById(elem_id
, check_id
, do_select
) {
910 var row
= $(elem_id
);
913 selectTableRow(row
, do_select
);
916 var check
= $(check_id
);
919 check
.checked
= do_select
;
922 exception_error("selectTableRowById", e
);
926 function selectTableRowsByIdPrefix(content_id
, prefix
, check_prefix
, do_select
,
927 classcheck
, reset_others
) {
929 var content
= $(content_id
);
932 alert("[selectTableRows] Element " + content_id
+ " not found.");
936 for (i
= 0; i
< content
.rows
.length
; i
++) {
937 if (Element
.visible(content
.rows
[i
])) {
938 if (!classcheck
|| content
.rows
[i
].className
.match(classcheck
)) {
940 if (content
.rows
[i
].id
.match(prefix
)) {
941 selectTableRow(content
.rows
[i
], do_select
);
943 var row_id
= content
.rows
[i
].id
.replace(prefix
, "");
944 var check
= $(check_prefix
+ row_id
);
947 check
.checked
= do_select
;
949 } else if (reset_others
) {
950 selectTableRow(content
.rows
[i
], false);
952 var row_id
= content
.rows
[i
].id
.replace(prefix
, "");
953 var check
= $(check_prefix
+ row_id
);
956 check
.checked
= false;
960 } else if (reset_others
) {
961 selectTableRow(content
.rows
[i
], false);
963 var row_id
= content
.rows
[i
].id
.replace(prefix
, "");
964 var check
= $(check_prefix
+ row_id
);
967 check
.checked
= false;
975 function getSelectedTableRowIds(content_id
, prefix
) {
977 var content
= $(content_id
);
980 alert("[getSelectedTableRowIds] Element " + content_id
+ " not found.");
984 var sel_rows
= new Array();
986 for (i
= 0; i
< content
.rows
.length
; i
++) {
987 if (content
.rows
[i
].id
.match(prefix
) &&
988 content
.rows
[i
].className
.match("Selected")) {
990 var row_id
= content
.rows
[i
].id
.replace(prefix
+ "-", "");
991 sel_rows
.push(row_id
);
999 function toggleSelectRowById(sender
, id
) {
1002 if (sender
.checked
) {
1003 if (!row
.className
.match("Selected")) {
1004 row
.className
= row
.className
+ "Selected";
1007 if (row
.className
.match("Selected")) {
1008 row
.className
= row
.className
.replace("Selected", "");
1013 function toggleSelectListRow(sender
) {
1014 var parent_row
= sender
.parentNode
;
1016 if (sender
.checked
) {
1017 if (!parent_row
.className
.match("Selected")) {
1018 parent_row
.className
= parent_row
.className
+ "Selected";
1021 if (parent_row
.className
.match("Selected")) {
1022 parent_row
.className
= parent_row
.className
.replace("Selected", "");
1027 function tSR(sender
) {
1028 return toggleSelectRow(sender
);
1031 function toggleSelectRow(sender
) {
1032 var parent_row
= sender
.parentNode
.parentNode
;
1034 if (sender
.checked
) {
1035 if (!parent_row
.className
.match("Selected")) {
1036 parent_row
.className
= parent_row
.className
+ "Selected";
1039 if (parent_row
.className
.match("Selected")) {
1040 parent_row
.className
= parent_row
.className
.replace("Selected", "");
1045 function getNextUnreadCat(id
) {
1047 var rows
= $("feedList").getElementsByTagName("LI");
1048 var feeds
= new Array();
1050 var unread_only
= true;
1053 for (var i
= 0; i
< rows
.length
; i
++) {
1054 if (rows
[i
].id
.match("FCAT-")) {
1055 if (rows
[i
].id
== "FCAT-" + id
&& is_cat
|| (Element
.visible(rows
[i
]) && Element
.visible(rows
[i
].parentNode
))) {
1057 var cat_id
= parseInt(rows
[i
].id
.replace("FCAT-", ""));
1060 if (!unread_only
|| get_cat_unread(cat_id
) > 0) {
1068 var idx
= feeds
.indexOf(id
);
1069 if (idx
!= -1 && idx
< feeds
.length
) {
1070 return feeds
[idx
+1];
1072 return feeds
.shift();
1076 exception_error("getNextUnreadCat", e
);
1080 function getRelativeFeedId2(id
, is_cat
, direction
, unread_only
) {
1083 // alert(id + " IC: " + is_cat + " D: " + direction + " U: " + unread_only);
1085 var rows
= $("feedList").getElementsByTagName("LI");
1086 var feeds
= new Array();
1088 for (var i
= 0; i
< rows
.length
; i
++) {
1089 if (rows
[i
].id
.match("FEEDR-")) {
1091 if (rows
[i
].id
== "FEEDR-" + id
&& !is_cat
|| (Element
.visible(rows
[i
]) && Element
.visible(rows
[i
].parentNode
))) {
1094 (rows
[i
].className
.match("Unread") || rows
[i
].id
== "FEEDR-" + id
)) {
1095 feeds
.push(rows
[i
].id
.replace("FEEDR-", ""));
1100 if (rows
[i
].id
.match("FCAT-")) {
1101 if (rows
[i
].id
== "FCAT-" + id
&& is_cat
|| (Element
.visible(rows
[i
]) && Element
.visible(rows
[i
].parentNode
))) {
1103 var cat_id
= parseInt(rows
[i
].id
.replace("FCAT-", ""));
1106 if (!unread_only
|| get_cat_unread(cat_id
) > 0) {
1107 feeds
.push("CAT:"+cat_id
);
1114 // alert(feeds.toString());
1117 if (direction
== "next") {
1118 return feeds
.shift();
1123 if (direction
== "next") {
1124 if (is_cat
) id
= "CAT:" + id
;
1125 var idx
= feeds
.indexOf(id
);
1126 if (idx
!= -1 && idx
< feeds
.length
) {
1127 return feeds
[idx
+1];
1129 return getRelativeFeedId2(false, is_cat
, direction
, unread_only
);
1132 if (is_cat
) id
= "CAT:" + id
;
1133 var idx
= feeds
.indexOf(id
);
1135 return feeds
[idx
-1];
1137 return getRelativeFeedId2(false, is_cat
, direction
, unread_only
);
1144 exception_error("getRelativeFeedId2", e
);
1149 function getRelativeFeedId(list
, id
, direction
, unread_only
) {
1150 var rows
= list
.getElementsByTagName("LI");
1151 var feeds
= new Array();
1153 for (var i
= 0; i
< rows
.length
; i
++) {
1154 if (rows
[i
].id
.match("FEEDR-")) {
1156 if (rows
[i
].id
== "FEEDR-" + id
|| (Element
.visible(rows
[i
]) && Element
.visible(rows
[i
].parentNode
))) {
1159 (rows
[i
].className
.match("Unread") || rows
[i
].id
== "FEEDR-" + id
)) {
1160 feeds
.push(rows
[i
].id
.replace("FEEDR-", ""));
1167 if (direction
== "next") {
1168 return feeds
.shift();
1173 if (direction
== "next") {
1174 var idx
= feeds
.indexOf(id
);
1175 if (idx
!= -1 && idx
< feeds
.length
) {
1176 return feeds
[idx
+1];
1178 return getRelativeFeedId(list
, false, direction
, unread_only
);
1181 var idx
= feeds
.indexOf(id
);
1183 return feeds
[idx
-1];
1185 return getRelativeFeedId(list
, false, direction
, unread_only
);
1192 function showBlockElement(id
, h_id
) {
1196 elem
.style
.display
= "block";
1201 elem
.style
.display
= "none";
1205 alert("[showBlockElement] can't find element with id " + id
);
1209 function appearBlockElement_afh(effect
) {
1213 function checkboxToggleElement(elem
, id
) {
1215 Effect
.Appear(id
, {duration
: 0.5});
1217 Effect
.Fade(id
, {duration
: 0.5});
1221 function appearBlockElement(id
, h_id
) {
1227 Effect
.SlideDown(id
, {duration
: 1.0, afterFinish
: appearBlockElement_afh
});
1229 exception_error("appearBlockElement", e
);
1234 function hideParentElement(e
) {
1235 e
.parentNode
.style
.display
= "none";
1238 function dropboxSelect(e
, v
) {
1239 for (i
= 0; i
< e
.length
; i
++) {
1240 if (e
[i
].value
== v
) {
1241 e
.selectedIndex
= i
;
1247 // originally stolen from http://www.11tmr.com/11tmr.nsf/d6plinks/MWHE-695L9Z
1248 // bugfixed just a little bit :-)
1249 function getURLParam(strParamName
){
1251 var strHref
= window
.location
.href
;
1253 if (strHref
.indexOf("#") == strHref
.length
-1) {
1254 strHref
= strHref
.substring(0, strHref
.length
-1);
1257 if ( strHref
.indexOf("?") > -1 ){
1258 var strQueryString
= strHref
.substr(strHref
.indexOf("?"));
1259 var aQueryString
= strQueryString
.split("&");
1260 for ( var iParam
= 0; iParam
< aQueryString
.length
; iParam
++ ){
1261 if (aQueryString
[iParam
].indexOf(strParamName
+ "=") > -1 ){
1262 var aParam
= aQueryString
[iParam
].split("=");
1263 strReturn
= aParam
[1];
1271 function leading_zero(p
) {
1273 if (s
.length
== 1) s
= "0" + s
;
1277 function closeErrorBox() {
1279 if (Element
.visible("errorBoxShadow")) {
1280 Element
.hide("dialog_overlay");
1281 Element
.hide("errorBoxShadow");
1289 function closeInfoBox(cleanup
) {
1294 if (Element
.visible("infoBoxShadow")) {
1295 Element
.hide("dialog_overlay");
1296 Element
.hide("infoBoxShadow");
1298 if (cleanup
) $("infoBoxShadow").innerHTML
= " ";
1301 exception_error("closeInfoBox", e
);
1308 function displayDlg(id
, param
) {
1310 notify_progress("Loading, please wait...", true);
1314 var query
= "backend.php?op=dlg&id=" +
1315 param_escape(id
) + "¶m=" + param_escape(param
);
1317 new Ajax
.Request(query
, {
1318 onComplete: function (transport
) {
1319 infobox_callback2(transport
);
1325 function infobox_submit_callback2(transport
) {
1329 // called from prefs, reload tab
1330 if (typeof active_tab
!= 'undefined' && active_tab
) {
1331 selectTab(active_tab
, false);
1335 if (transport
.responseText
) {
1336 notify_info(transport
.responseText
);
1340 function infobox_callback2(transport
) {
1343 debug("infobox_callback2");
1345 var box
= $('infoBox');
1349 if (!getInitParam("infobox_disable_overlay")) {
1350 Element
.show("dialog_overlay");
1353 box
.innerHTML
=transport
.responseText
;
1354 Element
.show("infoBoxShadow");
1355 //Effect.SlideDown("infoBoxShadow", {duration : 1.0});
1360 /* FIXME this needs to be moved out somewhere */
1362 if ($("tags_choices")) {
1363 new Ajax
.Autocompleter('tags_str', 'tags_choices',
1364 "backend.php?op=rpc&subop=completeTags",
1365 { tokens
: ',', paramName
: "search" });
1372 exception_error("infobox_callback2", e
);
1376 function createFilter() {
1380 var form
= document
.forms
['filter_add_form'];
1381 var reg_exp
= form
.reg_exp
.value
;
1383 if (reg_exp
== "") {
1384 alert(__("Can't add filter: nothing to match on."));
1388 var query
= Form
.serialize("filter_add_form");
1390 // we can be called from some other tab in Prefs
1391 if (typeof active_tab
!= 'undefined' && active_tab
) {
1392 active_tab
= "filterConfig";
1395 new Ajax
.Request("backend.php?" + query
, {
1396 onComplete: function (transport
) {
1397 infobox_submit_callback2(transport
);
1403 exception_error("createFilter", e
);
1407 function toggleSubmitNotEmpty(e
, submit_id
) {
1409 $(submit_id
).disabled
= (e
.value
== "")
1411 exception_error("toggleSubmitNotEmpty", e
);
1415 function isValidURL(s
) {
1416 return s
.match("http://") != null || s
.match("https://") != null || s
.match("feed://") != null;
1419 function subscribeToFeed() {
1421 var form
= document
.forms
['feed_add_form'];
1422 var feed_url
= form
.feed_url
.value
;
1424 if (feed_url
== "") {
1425 alert(__("Can't subscribe: no feed URL given."));
1429 notify_progress(__("Subscribing to feed..."), true);
1433 var feeds_doc
= document
;
1435 // feeds_doc.location.href = "backend.php?op=error&msg=Loading,%20please wait...";
1437 var query
= Form
.serialize("feed_add_form");
1439 debug("subscribe q: " + query
);
1441 new Ajax
.Request("backend.php", {
1443 onComplete: function(transport
) {
1444 dlg_frefresh_callback(transport
);
1450 function filterCR(e
, f
)
1455 key
= window
.event
.keyCode
; //IE
1457 key
= e
.which
; //firefox
1460 if (typeof f
!= 'undefined') {
1471 var debug_last_class
= "even";
1473 function debug(msg
) {
1475 if (debug_last_class
== "even") {
1476 debug_last_class
= "odd";
1478 debug_last_class
= "even";
1481 var c
= $('debug_output');
1482 if (c
&& Element
.visible(c
)) {
1483 while (c
.lastChild
!= 'undefined' && c
.childNodes
.length
> 100) {
1484 c
.removeChild(c
.lastChild
);
1488 var ts
= leading_zero(d
.getHours()) + ":" + leading_zero(d
.getMinutes()) +
1489 ":" + leading_zero(d
.getSeconds());
1490 c
.innerHTML
= "<li class=\"" + debug_last_class
+ "\"><span class=\"debugTS\">[" + ts
+ "]</span> " +
1491 msg
+ "</li>" + c
.innerHTML
;
1495 function getInitParam(key
) {
1496 return init_params
[key
];
1499 function storeInitParam(key
, value
) {
1500 debug("<b>storeInitParam is OBSOLETE: " + key
+ " => " + value
+ "</b>");
1501 init_params
[key
] = value
;
1504 function fatalError(code
, msg
, ext_info
) {
1507 if (!ext_info
) ext_info
= "N/A";
1510 window
.location
.href
= "tt-rss.php";
1511 } else if (code
== 5) {
1512 window
.location
.href
= "update.php";
1515 if (msg
== "") msg
= "Unknown error";
1517 var ebc
= $("xebContent");
1521 Element
.show("dialog_overlay");
1522 Element
.show("errorBoxShadow");
1523 Element
.hide("xebBtn");
1526 if (ext_info
.responseText
) {
1527 ext_info
= ext_info
.responseText
;
1532 "<div><b>Error message:</b></div>" +
1533 "<pre>" + msg
+ "</pre>" +
1534 "<div><b>Additional information:</b></div>" +
1535 "<textarea readonly=\"1\">" + ext_info
+ "</textarea>";
1540 exception_error("fatalError", e
);
1544 function getFeedName(id
, is_cat
) {
1548 e
= $("FCATN-" + id
);
1550 e
= $("FEEDN-" + id
);
1553 return e
.innerHTML
.stripTags();
1559 function filterDlgCheckType(sender
) {
1563 var ftype
= sender
[sender
.selectedIndex
].value
;
1565 var form
= document
.forms
["filter_add_form"];
1568 form
= document
.forms
["filter_edit_form"];
1572 debug("filterDlgCheckType: can't find form!");
1576 // if selected filter type is 5 (Date) enable the modifier dropbox
1578 Element
.show("filter_dlg_date_mod_box");
1579 Element
.show("filter_dlg_date_chk_box");
1581 Element
.hide("filter_dlg_date_mod_box");
1582 Element
.hide("filter_dlg_date_chk_box");
1587 exception_error("filterDlgCheckType", e
);
1592 function filterDlgCheckAction(sender
) {
1596 var action
= sender
[sender
.selectedIndex
].value
;
1598 var form
= document
.forms
["filter_add_form"];
1601 form
= document
.forms
["filter_edit_form"];
1605 debug("filterDlgCheckAction: can't find form!");
1609 var action_param
= $("filter_dlg_param_box");
1611 if (!action_param
) {
1612 debug("filterDlgCheckAction: can't find action param box!");
1616 // if selected action supports parameters, enable params field
1617 if (action
== 4 || action
== 6 || action
== 7) {
1618 Element
.show(action_param
);
1620 Element
.show(form
.action_param
);
1621 Element
.hide(form
.action_param_label
);
1623 Element
.show(form
.action_param_label
);
1624 Element
.hide(form
.action_param
);
1627 Element
.hide(action_param
);
1631 exception_error("filterDlgCheckAction", e
);
1636 function filterDlgCheckDate() {
1638 var form
= document
.forms
["filter_add_form"];
1641 form
= document
.forms
["filter_edit_form"];
1645 debug("filterDlgCheckAction: can't find form!");
1649 var reg_exp
= form
.reg_exp
.value
;
1651 var query
= "backend.php?op=rpc&subop=checkDate&date=" + reg_exp
;
1653 new Ajax
.Request(query
, {
1654 onComplete: function(transport
) {
1656 var form
= document
.forms
["filter_add_form"];
1659 form
= document
.forms
["filter_edit_form"];
1662 if (transport
.responseXML
) {
1663 var result
= transport
.responseXML
.getElementsByTagName("result")[0];
1665 if (result
&& result
.firstChild
) {
1666 if (result
.firstChild
.nodeValue
== "1") {
1668 new Effect
.Highlight(form
.reg_exp
, {startcolor
: '#00ff00'});
1675 new Effect
.Highlight(form
.reg_exp
, {startcolor
: '#ff0000'});
1681 exception_error("filterDlgCheckDate", e
);
1685 function explainError(code
) {
1686 return displayDlg("explainError", code
);
1689 // this only searches loaded headlines list, not in CDM
1690 function getRelativePostIds(id
, limit
) {
1692 if (!limit
) limit
= 3;
1694 debug("getRelativePostIds: " + id
+ " limit=" + limit
);
1696 var ids
= new Array();
1697 var container
= $("headlinesList");
1700 var rows
= container
.rows
;
1702 for (var i
= 0; i
< rows
.length
; i
++) {
1703 var r_id
= rows
[i
].id
.replace("RROW-", "");
1706 for (var k
= 1; k
<= limit
; k
++) {
1709 if (i
> k
-1) var nid
= rows
[i
-k
].id
.replace("RROW-", "");
1710 if (nid
) ids
.push(nid
);
1712 if (i
< rows
.length
-k
) nid
= rows
[i
+k
].id
.replace("RROW-", "");
1713 if (nid
) ids
.push(nid
);
1724 function openArticleInNewWindow(id
) {
1726 debug("openArticleInNewWindow: " + id
);
1728 var query
= "backend.php?op=rpc&subop=getArticleLink&id=" + id
;
1729 var wname
= "ttrss_article_" + id
;
1731 debug(query
+ " " + wname
);
1733 var w
= window
.open("", wname
);
1735 if (!w
) notify_error("Failed to open window for the article");
1737 new Ajax
.Request(query
, {
1738 onComplete: function(transport
) {
1739 open_article_callback(transport
);
1744 exception_error("openArticleInNewWindow", e
);
1748 /* http://textsnippets.com/posts/show/835 */
1750 Position
.GetWindowSize = function(w
) {
1752 var width
= w
.innerWidth
|| (w
.document
.documentElement
.clientWidth
|| w
.document
.body
.clientWidth
);
1753 var height
= w
.innerHeight
|| (w
.document
.documentElement
.clientHeight
|| w
.document
.body
.clientHeight
);
1754 return [width
, height
]
1757 /* http://textsnippets.com/posts/show/836 */
1759 Position
.Center = function(element
, parent
) {
1761 var d
= Element
.getDimensions(element
);
1766 var ws
= Position
.GetWindowSize();
1770 pw
= parent
.offsetWidth
;
1771 ph
= parent
.offsetHeight
;
1773 element
.style
.top
= (ph
/2) - (h/2) - Position
.deltaY
+ "px";
1774 element
.style
.left
= (pw
/2) - (w/2) - Position
.deltaX
+ "px";
1778 function labeltest_callback(transport
) {
1780 var container
= $('label_test_result');
1782 container
.innerHTML
= transport
.responseText
;
1783 if (!Element
.visible(container
)) {
1784 Effect
.SlideDown(container
, { duration
: 0.5 });
1789 exception_error("labeltest_callback", e
);
1793 function labelTest() {
1796 var container
= $('label_test_result');
1798 var form
= document
.forms
['label_edit_form'];
1800 var sql_exp
= form
.sql_exp
.value
;
1801 var description
= form
.description
.value
;
1803 notify_progress("Loading, please wait...");
1805 var query
= "backend.php?op=pref-labels&subop=test&expr=" +
1806 param_escape(sql_exp
) + "&descr=" + param_escape(description
);
1808 new Ajax
.Request(query
, {
1809 onComplete: function (transport
) {
1810 labeltest_callback(transport
);
1816 exception_error("labelTest", e
);
1820 function isCdmMode() {
1821 return !$("headlinesList");
1824 function getSelectedArticleIds2() {
1825 var rows
= new Array();
1826 var cdm_mode
= isCdmMode();
1829 rows
= cdmGetSelectedArticles();
1831 rows
= getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1834 var ids
= new Array();
1836 for (var i
= 0; i
< rows
.length
; i
++) {
1837 var chk
= $("RCHK-" + rows
[i
]);
1838 if (chk
&& chk
.checked
) {
1846 function displayHelpInfobox(topic_id
) {
1848 var url
= "backend.php?op=help&tid=" + param_escape(topic_id
);
1850 var w
= window
.open(url
, "ttrss_help",
1851 "status=0,toolbar=0,location=0,width=450,height=500,scrollbars=1,menubar=0");
1855 function focus_element(id
) {
1860 exception_error("focus_element", e
);
1865 function loading_set_progress(p
) {
1867 if (p
< last_progress_point
|| !Element
.visible("overlay")) return;
1869 debug("<b>loading_set_progress : " + p
+ " (" + last_progress_point
+ ")</b>");
1871 var o
= $("l_progress_i");
1873 // o.style.width = (p * 2) + "px";
1875 new Effect
.Scale(o
, p
, {
1877 scaleFrom
: last_progress_point
,
1878 scaleMode
: { originalWidth
: 200 },
1879 queue
: { position
: 'end', scope
: 'LSP-Q', limit
: 3 } });
1881 last_progress_point
= p
;
1884 exception_error("loading_set_progress", e
);
1888 function remove_splash() {
1889 if (Element
.visible("overlay")) {
1890 debug("about to remove splash, OMG!");
1891 Element
.hide("overlay");
1892 debug("removed splash!");
1896 function addLabelExample() {
1898 var form
= document
.forms
["label_edit_form"];
1900 var text
= form
.sql_exp
;
1901 var op
= form
.label_fields
[form
.label_fields
.selectedIndex
];
1902 var p
= form
.label_fields_param
;
1909 if (text
.value
!= "") {
1910 if (text
.value
.substring(text
.value
.length
-3, 3).toUpperCase() != "AND") {
1917 if (op
== "unread") {
1918 tmp
= tmp
+ "unread = true";
1921 if (op
== "updated") {
1922 tmp
= tmp
+ "last_read is null and unread = false";
1925 if (op
== "kw_title") {
1926 if (p
.value
== "") {
1927 alert("This action requires a parameter.");
1930 tmp
= tmp
+ "ttrss_entries.title like '%"+p
.value
+"%'";
1933 if (op
== "kw_content") {
1934 if (p
.value
== "") {
1935 alert("This action requires a parameter.");
1939 tmp
= tmp
+ "ttrss_entries.content like '%"+p
.value
+"%'";
1942 if (op
== "scoreE") {
1943 if (isNaN(parseInt(p
.value
))) {
1944 alert("This action expects numeric parameter.");
1947 tmp
= tmp
+ "score = " + p
.value
;
1950 if (op
== "scoreG") {
1951 if (isNaN(parseInt(p
.value
))) {
1952 alert("This action expects numeric parameter.");
1955 tmp
= tmp
+ "score > " + p
.value
;
1958 if (op
== "scoreL") {
1959 if (isNaN(parseInt(p
.value
))) {
1960 alert("This action expects numeric parameter.");
1963 tmp
= tmp
+ "score < " + p
.value
;
1966 if (op
== "newerD") {
1967 if (isNaN(parseInt(p
.value
))) {
1968 alert("This action expects numeric parameter.");
1971 tmp
= tmp
+ "updated > NOW() - INTERVAL '"+parseInt(p
.value
)+" days'";
1974 if (op
== "newerH") {
1975 if (isNaN(parseInt(p
.value
))) {
1976 alert("This action expects numeric parameter.");
1980 tmp
= tmp
+ "updated > NOW() - INTERVAL '"+parseInt(p
.value
)+" hours'";
1983 text
.value
= text
.value
+ tmp
;
1990 exception_error("addLabelExample", e
);
1996 function labelFieldsCheck(elem
) {
1998 var op
= elem
[elem
.selectedIndex
].value
;
2000 var p
= document
.forms
["label_edit_form"].label_fields_param
;
2002 if (op
== "kw_title" || op
== "kw_content" || op
== "scoreL" ||
2003 op
== "scoreG" || op
== "scoreE" || op
== "newerD" ||
2011 exception_error("labelFieldsCheck", e
);
2016 function getSelectedFeedsFromBrowser() {
2018 var list
= $("browseFeedList");
2019 if (!list
) list
= $("browseBigFeedList");
2021 var selected
= new Array();
2023 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
2024 var child
= list
.childNodes
[i
];
2025 if (child
.id
&& child
.id
.match("FBROW-")) {
2026 var id
= child
.id
.replace("FBROW-", "");
2028 var cb
= $("FBCHK-" + id
);
2039 function updateFeedBrowser() {
2042 var query
= "backend.php?op=rpc&subop=feedBrowser";
2044 var search
= $("feed_browser_search");
2045 var limit
= $("feed_browser_limit");
2048 query
= query
+ "&limit=" + limit
[limit
.selectedIndex
].value
;
2052 query
= query
+ "&search=" + param_escape(search
.value
);
2055 notify_progress("Loading, please wait...", true);
2057 new Ajax
.Request(query
, {
2058 onComplete: function(transport
) {
2061 var c
= $("browseFeedList");
2062 var r
= transport
.responseXML
.getElementsByTagName("content")[0];
2063 var nr
= transport
.responseXML
.getElementsByTagName("num-results")[0];
2064 var sb
= $("feed_browser_subscribe");
2067 c
.innerHTML
= r
.firstChild
.nodeValue
;
2071 if (nr
.getAttribute("value") > 0) {
2072 sb
.disabled
= false;
2082 exception_error("updateFeedBrowser", e
);
2086 function browseFeeds(limit
) {
2090 var query
= "backend.php?op=pref-feeds&subop=browse";
2092 notify_progress("Loading, please wait...", true);
2094 new Ajax
.Request(query
, {
2095 onComplete: function(transport
) {
2096 infobox_callback2(transport
);
2101 exception_error("browseFeeds", e
);
2105 function transport_error_check(transport
) {
2107 if (transport
.responseXML
) {
2108 var error
= transport
.responseXML
.getElementsByTagName("error")[0];
2111 var code
= error
.getAttribute("error-code");
2112 var msg
= error
.getAttribute("error-msg");
2114 fatalError(code
, msg
);
2120 exception_error("check_for_error_xml", e
);
2125 function strip_tags(s
) {
2126 return s
.replace(/<\/?[^>]+(>|$)/g, "");
2129 function truncate_string(s
, length
) {
2130 if (!length
) length
= 30;
2131 var tmp
= s
.substring(0, length
);
2132 if (s
.length
> length
) tmp
+= "…";
2137 function switchToFlash(e) {
2140 if (!e) var e = window.event;
2141 if (e.target) targ = e.target;
2142 else if (e.srcElement) targ = e.srcElement;
2143 if (targ.nodeType == 3) // defeat Safari bug
2144 targ = targ.parentNode;
2146 //targ is the link that was clicked
2149 audioTag=audioTag.previousSibling;
2150 } while(audioTag && audioTag.nodeType != 1)
2152 var flashPlayer = audioTag.getElementsByTagName('span')[0];
2153 targ.parentNode.insertBefore(flashPlayer,targ);
2154 targ.parentNode.removeChild(targ);
2155 audioTag.parentNode.removeChild(audioTag);
2159 exception_error("switchToFlash", e);
2163 function html5AudioOrFlash(type) {
2164 var audioTag = document.createElement('audio');
2165 if(! audioTag.canPlayType || audioTag.canPlayType(type) == "no" ||
2166 audioTag.canPlayType(type) == ""){
2167 if($('switchToFlashLink')){
2168 switchToFlash($('switchToFlashLink'));
2173 function hotkey_prefix_timeout() {
2176 var date
= new Date();
2177 var ts
= Math
.round(date
.getTime() / 1000);
2179 if (hotkey_prefix_pressed
&& ts
- hotkey_prefix_pressed
>= 5) {
2180 debug("hotkey_prefix seems to be stuck, aborting");
2181 hotkey_prefix_pressed
= false;
2182 hotkey_prefix
= false;
2183 Element
.hide('cmdline');
2186 setTimeout("hotkey_prefix_timeout()", 1000);
2189 exception_error("hotkey_prefix_timeout", e
);