]> git.wh0rd.org - tt-rss.git/blob - feedlist.js
05867d7b3f874f4ef74dd201e149ebe8d1a6665d
[tt-rss.git] / feedlist.js
1 var _feed_cur_page = 0;
2 var _infscroll_disable = 0;
3 var _infscroll_request_sent = 0;
4 var feed_under_pointer = undefined;
5
6 var mouse_is_down = false;
7 var mouse_y = 0;
8 var mouse_x = 0;
9
10 var resize_enabled = false;
11 var selection_disabled = false;
12 var counters_last_request = 0;
13
14 function toggle_sortable_feedlist(enabled) {
15 try {
16
17 if (enabled) {
18 Sortable.create('feedList', {onChange: feedlist_dragsorted, only: "feedCat"});
19 } else {
20 Sortable.destroy('feedList');
21 }
22
23 } catch (e) {
24 exception_error("toggle_sortable_feedlist", e);
25 }
26 }
27
28 function viewCategory(cat) {
29 viewfeed(cat, '', true);
30 return false;
31 }
32
33 function render_offline_feedlist() {
34 try {
35 var tmp = "<ul class=\"feedList\" id=\"feedList\">";
36
37 var rs = db.execute("SELECT id,title,has_icon FROM feeds ORDER BY title");
38
39 while (rs.isValidRow()) {
40
41 var id = rs.field(0);
42 var title = rs.field(1);
43 var has_icon = rs.field(2);
44
45 var rs_u = db.execute("SELECT SUM(unread) FROM articles WHERE feed_id = ?",
46 [id]);
47 var unread = 0;
48
49 if (rs.isValidRow()) {
50 unread = rs_u.field(0);
51 if (!unread) unread = 0;
52 }
53
54 var feed_icon = "";
55
56 if (has_icon) {
57 feed_icon = "<img id='FIMG-"+id+"' src='" + "icons/" + id + ".ico'>";
58 } else {
59 feed_icon = "<img id='FIMG-"+id+"' src='images/blank_icon.gif'>";
60 }
61
62 var row_class = "feed";
63
64 if (unread > 0) {
65 row_class += "Unread";
66 fctr_class = "feedCtrHasUnread";
67 } else {
68 fctr_class = "feedCtrNoUnread";
69 }
70
71 var link = "<a title=\"FIXME\" id=\"FEEDL-"+id+"\""+
72 "href=\"javascript:viewfeed('"+id+"', '', false, '', false, 0);\">"+
73 title + "</a>";
74
75 tmp += "<li id='FEEDR-"+id+"' class="+row_class+">" + feed_icon +
76 "<span id=\"FEEDN-"+id+"\">" + link + "</span>";
77
78 tmp += " <span class='"+fctr_class+"' id=\"FEEDCTR-"+id+"\">" +
79 "(<span id=\"FEEDU-"+id+"\">"+unread+"</span>)</span>";
80
81 tmp += "</li>";
82
83 rs.next();
84 }
85
86 tmp += "</ul>";
87
88 render_feedlist(tmp);
89 } catch (e) {
90 exception_error("render_offline_feedlist", e);
91 }
92 }
93
94 function render_feedlist(data) {
95 try {
96
97 var f = document.getElementById("feeds-frame");
98 f.innerHTML = data;
99 cache_invalidate("FEEDLIST");
100 cache_inject("FEEDLIST", data, getInitParam("num_feeds"));
101 feedlist_init();
102
103 } catch (e) {
104 exception_error("render_feedlist", e);
105 }
106 }
107
108 function feedlist_callback2(transport) {
109 try {
110 debug("feedlist_callback2");
111 if (!transport_error_check(transport)) return;
112 render_feedlist(transport.responseText);
113 } catch (e) {
114 exception_error("feedlist_callback2", e);
115 }
116 }
117
118 function viewNextFeedPage() {
119 try {
120 //if (!getActiveFeedId()) return;
121
122 debug("viewNextFeedPage: calling viewfeed(), p: " + _feed_cur_page+1);
123
124 viewfeed(getActiveFeedId(), undefined, activeFeedIsCat(), undefined,
125 undefined, _feed_cur_page+1);
126
127 } catch (e) {
128 exception_error("viewNextFeedPage", e);
129 }
130 }
131
132 function viewfeed_offline(feed_id, subop, is_cat, subop_param, skip_history, offset) {
133 try {
134 notify('');
135
136 loading_set_progress(100);
137
138 clean_feed_selections();
139
140 setActiveFeedId(feed_id, is_cat);
141
142 if (!is_cat) {
143 var feedr = document.getElementById("FEEDR-" + feed_id);
144 if (feedr && !feedr.className.match("Selected")) {
145 feedr.className = feedr.className + "Selected";
146 }
147 } else {
148 var feedr = document.getElementById("FCAT-" + feed_id);
149 if (feedr && !feedr.className.match("Selected")) {
150 feedr.className = feedr.className + "Selected";
151 }
152 }
153
154 var f = document.getElementById("headlines-frame");
155 try {
156 if (reply.offset == 0) {
157 debug("resetting headlines scrollTop");
158 f.scrollTop = 0;
159 }
160 } catch (e) { };
161
162
163 var container = document.getElementById("headlines-frame");
164
165 var tmp = "";
166
167 rs = db.execute("SELECT title FROM feeds WHERE id = ?", [feed_id]);
168
169 if (rs.isValidRow()) {
170
171 var feed_title = rs.field(0);
172
173 if (offset == 0) {
174 tmp += "<div id=\"headlinesContainer\">";
175
176 tmp += "<div class=\"headlinesSubToolbar\">";
177 tmp += "<div id=\"subtoolbar_ftitle\">";
178 tmp += feed_title;
179 tmp += "</div>";
180
181 var sel_all_link = "javascript:selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', true, '', true)";
182 var sel_unread_link = "javascript:selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', true, 'Unread', true)";
183 var sel_none_link = "javascript:selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false)";
184 var sel_inv_link = "javascript:invertHeadlineSelection()";
185
186 tmp += __('Select:')+
187 " <a href=\""+sel_all_link+"\">"+__('All')+"</a>, "+
188 "<a href=\""+sel_unread_link+"\">"+__('Unread')+"</a>, "+
189 "<a href=\""+sel_inv_link+"\">"+__('Invert')+"</a>, "+
190 "<a href=\""+sel_none_link+"\">"+__('None')+"</a>";
191
192 tmp += "&nbsp;&nbsp;";
193
194 tmp += "</div>";
195
196 tmp += "<div id=\"headlinesInnerContainer\" onscroll=\"headlines_scroll_handler()\">";
197
198 tmp += "<table class=\"headlinesList\" id=\"headlinesList\" cellspacing=\"0\">";
199
200 }
201
202 var rs = db.execute("SELECT * FROM articles WHERE feed_id = ?", [feed_id]);
203
204 var line_num = 0;
205
206 while (rs.isValidRow()) {
207
208 var id = rs.fieldByName("id");
209 var feed_id = rs.fieldByName("feed_id");
210
211 var marked_pic;
212
213 var row_class = (line_num % 2) ? "even" : "odd";
214
215 if (rs.fieldByName("unread") == "1") {
216 row_class += "Unread";
217 }
218
219 if (rs.fieldByName("marked") == "1") {
220 marked_pic = "<img id=\"FMPIC-"+id+"\" "+
221 "src=\"images/mark_set.png\" class=\"markedPic\""+
222 "alt=\"Unstar article\" onclick='javascript:tMark("+id+")'>";
223 } else {
224 marked_pic = "<img id=\"FMPIC-"+id+"\" "+
225 "src=\"images/mark_unset.png\" class=\"markedPic\""+
226 "alt=\"Star article\" onclick='javascript:tMark("+id+")'>";
227 }
228
229 var mouseover_attrs = "onmouseover='postMouseIn($id)' "+
230 "onmouseout='postMouseOut($id)'";
231
232 tmp += "<tr class='"+row_class+"' id='RROW-"+id+"' "+mouseover_attrs+">";
233
234 tmp += "<td class='hlUpdPic'> </td>";
235
236 tmp += "<td class='hlSelectRow'>"+
237 "<input type=\"checkbox\" onclick=\"tSR(this)\" id=\"RCHK-"+id+"\"></td>";
238
239 tmp += "<td class='hlMarkedPic'>"+marked_pic+"</td>";
240
241 tmp += "<td onclick='view("+id+","+feed_id+")' "+
242 "class='hlContent' valign='middle'>";
243
244 tmp += "<a id=\"RTITLE-$id\" href=\"" +
245 param_escape(rs.fieldByName("link")) + "\"" +
246 "onclick=\"return view("+id+","+feed_id+");\">"+
247 rs.fieldByName("title");
248
249 var content_preview = truncate_string(strip_tags(rs.fieldByName("content")),
250 100);
251
252 tmp += "<span class=\"contentPreview\"> - "+content_preview+"</span>";
253
254 tmp += "</a>";
255
256 tmp += "</td>";
257
258 tmp += "<td class=\"hlUpdated\" onclick='view("+id+","+feed_id+")'>"+
259 "<nobr>"+rs.fieldByName("updated").substring(0,16)+"</nobr></td>";
260
261 tmp += "</tr>";
262
263 rs.next();
264 line_num++;
265 }
266
267 if (offset == 0) {
268 tmp += "</table>";
269 tmp += "</div></div>";
270 }
271
272 if (offset == 0) {
273 container.innerHTML = tmp;
274 } else {
275 var ids = getSelectedArticleIds2();
276
277 //container.innerHTML = container.innerHTML + tmp;
278
279 for (var i = 0; i < ids.length; i++) {
280 markHeadline(ids[i]);
281 }
282 }
283 }
284
285 remove_splash();
286
287
288 } catch (e) {
289 exception_error("viewfeed_offline", e);
290 }
291 }
292
293 function viewfeed(feed, subop, is_cat, subop_param, skip_history, offset) {
294 try {
295
296 if (offline_mode) return viewfeed_offline(feed, subop, is_cat, subop_param,
297 skip_history, offset);
298
299 // if (!offset) page_offset = 0;
300
301 last_requested_article = 0;
302 //counters_last_request = 0;
303
304 if (feed == getActiveFeedId()) {
305 cache_invalidate("F:" + feed);
306 }
307
308 /* if (getInitParam("theme") == "" || getInitParam("theme") == "compact") {
309 if (getInitParam("hide_feedlist") == 1) {
310 Element.hide("feeds-holder");
311 }
312 } */
313
314 var force_nocache = false;
315
316 var page_offset = 0;
317
318 if (offset > 0) {
319 page_offset = offset;
320 } else {
321 page_offset = 0;
322 _feed_cur_page = 0;
323 _infscroll_disable = 0;
324 }
325
326 if (getActiveFeedId() != feed) {
327 _feed_cur_page = 0;
328 active_post_id = 0;
329 _infscroll_disable = 0;
330 }
331
332 if (page_offset != 0 && !subop) {
333 var date = new Date();
334 var timestamp = Math.round(date.getTime() / 1000);
335
336 debug("<b>" + _infscroll_request_sent + " : " + timestamp + "</b>");
337
338 if (_infscroll_request_sent && _infscroll_request_sent + 30 > timestamp) {
339 debug("infscroll request in progress, aborting");
340 return;
341 }
342
343 _infscroll_request_sent = timestamp;
344 }
345
346 enableHotkeys();
347
348 closeInfoBox();
349
350 Form.enable("main_toolbar_form");
351
352 var toolbar_form = document.forms["main_toolbar_form"];
353 var toolbar_query = Form.serialize("main_toolbar_form");
354
355 if (toolbar_form.query) {
356 if (toolbar_form.query.value != "") {
357 force_nocache = true;
358 }
359 toolbar_form.query.value = "";
360 }
361
362 var query = "backend.php?op=viewfeed&feed=" + feed + "&" +
363 toolbar_query + "&subop=" + param_escape(subop);
364
365 if (document.getElementById("search_form")) {
366 var search_query = Form.serialize("search_form");
367 query = query + "&" + search_query;
368 closeInfoBox(true);
369 force_nocache = true;
370 }
371
372 // debug("IS_CAT_STORED: " + activeFeedIsCat() + ", IS_CAT: " + is_cat);
373
374 if (subop == "MarkAllRead") {
375
376 var show_next_feed = getInitParam("on_catchup_show_next_feed") == "1";
377
378 if (show_next_feed) {
379
380 if (!activeFeedIsCat()) {
381
382 var feedlist = document.getElementById('feedList');
383
384 var next_unread_feed = getRelativeFeedId(feedlist,
385 feed, "next", true);
386
387 if (!next_unread_feed) {
388 next_unread_feed = getRelativeFeedId(feedlist,
389 -3, "next", true);
390 }
391
392 if (next_unread_feed) {
393 query = query + "&nuf=" + param_escape(next_unread_feed);
394 //setActiveFeedId(next_unread_feed);
395 feed = next_unread_feed;
396 }
397 } else {
398
399 var next_unread_feed = getNextUnreadCat(feed);
400
401 /* we don't need to specify that our next feed is actually
402 a category, because we're in the is_cat mode by definition
403 already */
404
405 if (next_unread_feed && show_next_feed) {
406 query = query + "&nuf=" + param_escape(next_unread_feed);
407 feed = next_unread_feed;
408 }
409
410 }
411 }
412 }
413
414 if (is_cat) {
415 query = query + "&cat=1";
416 }
417
418 if (page_offset != 0) {
419 query = query + "&skip=" + page_offset;
420
421 // to prevent duplicate feed titles when showing grouped vfeeds
422 if (vgroup_last_feed) {
423 query = query + "&vgrlf=" + param_escape(vgroup_last_feed);
424 }
425 }
426
427 var date = new Date();
428 var timestamp = Math.round(date.getTime() / 1000);
429 query = query + "&ts=" + timestamp
430
431 disableContainerChildren("headlinesToolbar", false);
432 Form.enable("main_toolbar_form");
433
434 // for piggybacked counters
435
436 if (tagsAreDisplayed()) {
437 query = query + "&omode=lt";
438 } else {
439 query = query + "&omode=flc";
440 }
441
442 if (!async_counters_work) {
443 query = query + "&csync=true";
444 }
445
446 debug(query);
447
448 var container = document.getElementById("headlinesInnerContainer");
449
450 /* if (container && page_offset == 0 && !isCdmMode()) {
451 new Effect.Fade(container, {duration: 1, to: 0.01,
452 queue: { position:'end', scope: 'FEEDL-' + feed, limit: 1 } } );
453 } */
454
455 var unread_ctr = -1;
456
457 if (!is_cat) unread_ctr = get_feed_unread(feed);
458
459 var cache_check = false;
460
461 if (unread_ctr != -1 && !page_offset && !force_nocache && !subop) {
462
463 var cache_prefix = "";
464
465 if (is_cat) {
466 cache_prefix = "C:";
467 } else {
468 cache_prefix = "F:";
469 }
470
471 cache_check = cache_check_param(cache_prefix + feed, unread_ctr);
472 debug("headline cache check: " + cache_check);
473 }
474
475 if (cache_check) {
476 var f = document.getElementById("headlines-frame");
477
478 clean_feed_selections();
479
480 setActiveFeedId(feed, is_cat);
481
482 if (!is_cat) {
483 var feedr = document.getElementById("FEEDR-" + feed);
484 if (feedr && !feedr.className.match("Selected")) {
485 feedr.className = feedr.className + "Selected";
486 }
487 } else {
488 var feedr = document.getElementById("FCAT-" + feed_id);
489 if (feedr && !feedr.className.match("Selected")) {
490 feedr.className = feedr.className + "Selected";
491 }
492 }
493
494 f.innerHTML = cache_find_param(cache_prefix + feed, unread_ctr);
495
496 request_counters();
497 remove_splash();
498
499 } else {
500
501 if (!page_offset) {
502 notify_progress("Loading, please wait...", true);
503 }
504
505 new Ajax.Request(query, {
506 onComplete: function(transport) {
507 headlines_callback2(transport, page_offset);
508 } });
509 }
510
511 } catch (e) {
512 exception_error("viewfeed", e);
513 }
514 }
515
516 function toggleCollapseCat_af(effect) {
517 //var caption = elem.id.replace("FCATLIST-", "");
518
519 try {
520
521 var elem = effect.element;
522 var cat = elem.id.replace("FCATLIST-", "");
523 var cap = document.getElementById("FCAP-" + cat);
524
525 if (Element.visible(elem)) {
526 cap.innerHTML = cap.innerHTML.replace("…", "");
527 } else {
528 if (cap.innerHTML.lastIndexOf("…") != cap.innerHTML.length-3) {
529 cap.innerHTML = cap.innerHTML + "…";
530 }
531 }
532
533 } catch (e) {
534 exception_error("toggleCollapseCat_af", e);
535 }
536 }
537
538 function toggleCollapseCat(cat) {
539 try {
540
541 var cat_elem = document.getElementById("FCAT-" + cat);
542 var cat_list = document.getElementById("FCATLIST-" + cat).parentNode;
543 var caption = document.getElementById("FCAP-" + cat);
544
545 /* if (cat_list.className.match("invisible")) {
546 cat_list.className = "";
547 caption.innerHTML = caption.innerHTML.replace("...", "");
548 if (cat == 0) {
549 setCookie("ttrss_vf_uclps", "0");
550 }
551 } else {
552 cat_list.className = "invisible";
553 caption.innerHTML = caption.innerHTML + "...";
554 if (cat == 0) {
555 setCookie("ttrss_vf_uclps", "1");
556 }
557
558 } */
559
560 if (cat == 0) {
561 if (Element.visible("FCATLIST-" + cat)) {
562 setCookie("ttrss_vf_uclps", "1");
563 } else {
564 setCookie("ttrss_vf_uclps", "0");
565 }
566 }
567
568 if (cat == -2) {
569 if (Element.visible("FCATLIST-" + cat)) {
570 setCookie("ttrss_vf_lclps", "1");
571 } else {
572 setCookie("ttrss_vf_lclps", "0");
573 }
574 }
575
576 if (cat == -1) {
577 if (Element.visible("FCATLIST-" + cat)) {
578 setCookie("ttrss_vf_vclps", "1");
579 } else {
580 setCookie("ttrss_vf_vclps", "0");
581 }
582 }
583
584 Effect.toggle('FCATLIST-' + cat, 'blind', { duration: 0.5,
585 afterFinish: toggleCollapseCat_af });
586
587 new Ajax.Request("backend.php?op=feeds&subop=collapse&cid=" +
588 param_escape(cat));
589
590 } catch (e) {
591 exception_error("toggleCollapseCat", e);
592 }
593 }
594
595 function feedlist_dragsorted(ctr) {
596 try {
597 var elem = document.getElementById("feedList");
598
599 var cats = elem.getElementsByTagName("LI");
600 var ordered_cats = new Array();
601
602 for (var i = 0; i < cats.length; i++) {
603 if (cats[i].id && cats[i].id.match("FCAT-")) {
604 ordered_cats.push(cats[i].id.replace("FCAT-", ""));
605 }
606 }
607
608 if (ordered_cats.length > 0) {
609
610 var query = "backend.php?op=feeds&subop=catsort&corder=" +
611 param_escape(ordered_cats.toString());
612
613 debug(query);
614
615 new Ajax.Request(query);
616 }
617
618 } catch (e) {
619 exception_error("feedlist_dragsorted", e);
620 }
621 }
622
623 function feedlist_init() {
624 try {
625 // if (arguments.callee.done) return;
626 // arguments.callee.done = true;
627
628 loading_set_progress(90);
629
630 debug("in feedlist init");
631
632 hideOrShowFeeds(getInitParam("hide_read_feeds") == 1);
633 document.onkeydown = hotkey_handler;
634 document.onmousemove = mouse_move_handler;
635 document.onmousedown = mouse_down_handler;
636 document.onmouseup = mouse_up_handler;
637
638 setTimeout("timeout()", 1);
639
640 if (typeof correctPNG != 'undefined') {
641 correctPNG();
642 }
643
644 if (getActiveFeedId()) {
645 //debug("some feed is open on feedlist refresh, reloading");
646 //setTimeout("viewCurrentFeed()", 100);
647 } else {
648 if (getInitParam("cdm_auto_catchup") != 1 && get_feed_unread(-3) > 0) {
649 notify_silent_next();
650 setTimeout("viewfeed(-3)", 100);
651 } else {
652 remove_splash();
653 }
654 }
655
656 if (getInitParam("theme") == "") {
657 setTimeout("hide_footer()", 5000);
658 }
659
660 init_collapsable_feedlist(getInitParam("theme"));
661
662 toggle_sortable_feedlist(isFeedlistSortable());
663
664 } catch (e) {
665 exception_error("feedlist/init", e);
666 }
667 }
668
669 function hide_footer_af(effect) {
670 try {
671 var c = document.getElementById("content-frame");
672
673 if (c) {
674 c.style.bottom = "0px";
675
676 var ioa = document.getElementById("inline_orig_article");
677
678 if (ioa) {
679 ioa.height = c.offsetHeight;
680 }
681
682 } else {
683 var h = document.getElementById("headlines-frame");
684
685 if (h) {
686 h.style.bottom = "0px";
687 }
688 }
689
690 } catch (e) {
691 exception_error("hide_footer_af", e);
692 }
693 }
694
695 function hide_footer() {
696 try {
697 if (Element.visible("footer")) {
698 new Effect.Fade("footer", { afterFinish: hide_footer_af });
699 }
700 } catch (e) {
701 exception_error("hide_footer", e);
702 }
703 }
704
705 /*
706 function init_hidden_feedlist(theme) {
707 try {
708 debug("init_hidden_feedlist");
709
710 if (theme != "" && theme != "compact") return;
711
712 var fl = document.getElementById("feeds-holder");
713 var fh = document.getElementById("headlines-frame");
714 var fc = document.getElementById("content-frame");
715 var ft = document.getElementById("toolbar");
716 var ff = document.getElementById("footer");
717 var fhdr = document.getElementById("header");
718
719 var fbtn = document.getElementById("toggle_feeds_btn");
720
721 if (fbtn) Element.show(fbtn);
722
723 fl.style.top = fh.offsetTop + "px";
724 fl.style.backgroundColor = "white"; //FIXME
725
726 Element.hide(fl);
727
728 fh.style.left = "0px";
729 ft.style.left = "0px";
730 if (fc) fc.style.left = "0px";
731 if (ff) ff.style.left = "0px";
732
733 if (theme == "compact") {
734 fhdr.style.left = "10px";
735 fl.style.top = (fh.offsetTop + 1) + "px";
736 }
737
738 } catch (e) {
739 exception_error("init_hidden_feedlist", e);
740 }
741 } */
742
743 function init_collapsable_feedlist(theme) {
744 try {
745 debug("init_collapsable_feedlist");
746
747 if (theme != "" && theme != "compact" && theme != "graycube" &&
748 theme != "compat") return;
749
750 var fbtn = document.getElementById("collapse_feeds_btn");
751
752 if (fbtn) Element.show(fbtn);
753
754 if (getCookie("ttrss_vf_fclps") == 1) {
755 collapse_feedlist();
756 }
757
758 } catch (e) {
759 exception_error("init_hidden_feedlist", e);
760 }
761
762 }
763
764 function mouse_move_handler(e) {
765 try {
766 var client_y;
767 var client_x;
768
769 if (window.event) {
770 client_y = window.event.clientY;
771 client_x = window.event.clientX;
772 } else if (e) {
773 client_x = e.screenX;
774 client_y = e.screenY;
775 }
776
777 if (mouse_is_down) {
778
779 if (mouse_y == 0) mouse_y = client_y;
780 if (mouse_x == 0) mouse_x = client_x;
781
782 resize_headlines(mouse_x - client_x, mouse_y - client_y);
783
784 mouse_y = client_y;
785 mouse_x = client_x;
786
787 return false;
788 }
789
790 } catch (e) {
791 exception_error("mouse_move_handler", e);
792 }
793 }
794
795 function enable_selection(b) {
796 selection_disabled = !b;
797 }
798
799 function enable_resize(b) {
800 resize_enabled = b;
801 }
802
803 function mouse_down_handler(e) {
804 try {
805
806 /* do not prevent right click */
807 if (e.button && e.button == 2) return;
808
809 if (resize_enabled) {
810 mouse_is_down = true;
811 mouse_x = 0;
812 mouse_y = 0;
813 document.onselectstart = function() { return false; };
814 return false;
815 }
816
817 if (selection_disabled) {
818 document.onselectstart = function() { return false; };
819 return false;
820 }
821
822 } catch (e) {
823 exception_error("mouse_move_handler", e);
824 }
825 }
826
827 function mouse_up_handler(e) {
828 try {
829 mouse_is_down = false;
830
831 if (!selection_disabled) {
832 document.onselectstart = null;
833 var e = document.getElementById("headlineActionsBody");
834 if (e) Element.hide(e);
835 }
836
837 } catch (e) {
838 exception_error("mouse_move_handler", e);
839 }
840 }
841
842 function request_counters_real() {
843
844 try {
845
846 if (offline_mode) return;
847
848 debug("requesting counters...");
849
850 var query = "backend.php?op=rpc&subop=getAllCounters";
851
852 if (tagsAreDisplayed()) {
853 query = query + "&omode=tl";
854 } else {
855 query = query + "&omode=flc";
856 }
857
858 new Ajax.Request(query, {
859 onComplete: function(transport) {
860 try {
861 all_counters_callback2(transport, true);
862 } catch (e) {
863 exception_error("viewfeed/getcounters", e);
864 }
865 } });
866
867 } catch (e) {
868 exception_error("request_counters_real", e);
869 }
870 }
871
872
873 function request_counters() {
874
875 try {
876
877 if (getInitParam("bw_limit") == "1") return;
878
879 var date = new Date();
880 var timestamp = Math.round(date.getTime() / 1000);
881
882 // if (getInitParam("sync_counters") == "1" ||
883 // timestamp - counters_last_request > 10) {
884
885 if (timestamp - counters_last_request > 15) {
886 debug("scheduling request of counters...");
887 window.setTimeout("request_counters_real()", 1000);
888 counters_last_request = timestamp;
889 } else {
890 debug("request_counters: rate limit reached: " + (timestamp - counters_last_request));
891 }
892
893 } catch (e) {
894 exception_error("request_counters", e);
895 }
896 }