1 var active_post_id = false;
2 var _catchup_callback_func = false;
3 var last_article_view = false;
4 var active_real_feed_id = false;
6 var _tag_active_post_id = false;
7 var _tag_active_feed_id = false;
8 var _tag_active_cdm = false;
10 // FIXME: kludge, to restore scrollTop after tag editor terminates
11 var _tag_cdm_scroll = false;
13 // FIXME: kludges, needs proper implementation
14 var _reload_feedlist_after_view = false;
16 var _cdm_wd_timeout = false;
17 var _cdm_wd_vishist = new Array();
19 var article_cache = new Array();
21 function catchup_callback() {
22 if (xmlhttp_rpc.readyState == 4) {
24 debug("catchup_callback");
26 all_counters_callback();
27 if (_catchup_callback_func) {
28 setTimeout(_catchup_callback_func, 10);
31 exception_error("catchup_callback", e);
36 function headlines_callback() {
37 if (xmlhttp.readyState == 4) {
38 debug("headlines_callback");
39 var f = document.getElementById("headlines-frame");
41 if (feed_cur_page == 0) {
42 debug("resetting headlines scrollTop");
47 if (xmlhttp.responseXML) {
48 var headlines = xmlhttp.responseXML.getElementsByTagName("headlines")[0];
49 var counters = xmlhttp.responseXML.getElementsByTagName("counters")[0];
50 var articles = xmlhttp.responseXML.getElementsByTagName("article");
51 var runtime_info = xmlhttp.responseXML.getElementsByTagName("runtime-info");
53 if (feed_cur_page == 0) {
55 f.innerHTML = headlines.firstChild.nodeValue;
57 debug("headlines_callback: returned no data");
58 f.innerHTML = "<div class='whiteBox'>" + __('Could not update headlines (missing XML data)') + "</div>";
63 debug("adding some more headlines...");
65 var c = document.getElementById("headlinesList");
68 c = document.getElementById("headlinesInnerContainer");
71 c.innerHTML = c.innerHTML + headlines.firstChild.nodeValue;
73 debug("headlines_callback: returned no data");
74 notify_error("Error while trying to load more headlines");
80 for (var i = 0; i < articles.length; i++) {
81 var a_id = articles[i].getAttribute("id");
82 debug("found id: " + a_id);
83 cache_inject(a_id, articles[i].firstChild.nodeValue);
86 debug("no cached articles received");
90 debug("parsing piggybacked counters: " + counters);
91 parse_counters(counters, false);
93 debug("counters container not found in reply");
97 debug("parsing runtime info: " + runtime_info[0]);
98 parse_runtime_info(runtime_info[0]);
100 debug("counters container not found in reply");
104 debug("headlines_callback: returned no XML object");
105 f.innerHTML = "<div class='whiteBox'>" + __('Could not update headlines (missing XML object)') + "</div>";
108 if (typeof correctPNG != 'undefined') {
112 if (_cdm_wd_timeout) window.clearTimeout(_cdm_wd_timeout);
114 if (!document.getElementById("headlinesList") &&
115 getInitParam("cdm_auto_catchup") == 1) {
116 debug("starting CDM watchdog");
117 _cdm_wd_timeout = window.setTimeout("cdmWatchdog()", 5000);
118 _cdm_wd_vishist = new Array();
120 debug("not in CDM mode or watchdog disabled");
123 if (_tag_cdm_scroll) {
125 document.getElementById("headlinesInnerContainer").scrollTop = _tag_cdm_scroll;
126 _tag_cdm_scroll = false;
127 debug("resetting headlinesInner scrollTop");
136 function render_article(article) {
138 var f = document.getElementById("content-frame");
143 f.innerHTML = article;
146 exception_error("render_article", e);
150 function article_callback() {
151 if (xmlhttp.readyState == 4) {
152 debug("article_callback");
155 if (xmlhttp.responseXML) {
156 var reply = xmlhttp.responseXML.firstChild.firstChild;
158 var articles = xmlhttp.responseXML.getElementsByTagName("article");
160 for (var i = 0; i < articles.length; i++) {
161 var a_id = articles[i].getAttribute("id");
163 debug("found id: " + a_id);
165 if (a_id == active_post_id) {
166 debug("active article, rendering...");
167 render_article(articles[i].firstChild.nodeValue);
170 cache_inject(a_id, articles[i].firstChild.nodeValue);
174 debug("article_callback: returned no XML object");
175 var f = document.getElementById("content-frame");
176 f.innerHTML = "<div class='whiteBox'>" + __('Could not display article (missing XML object)') + "</div>";
179 exception_error("article_callback", e);
182 var date = new Date();
183 last_article_view = date.getTime() / 1000;
185 if (typeof correctPNG != 'undefined') {
189 if (_reload_feedlist_after_view) {
190 setTimeout('updateFeedList(false, false)', 50);
191 _reload_feedlist_after_view = false;
193 var counters = xmlhttp.responseXML.getElementsByTagName("counters")[0];
196 debug("parsing piggybacked counters: " + counters);
197 parse_counters(counters, false);
199 debug("counters container not found in reply");
207 function view(id, feed_id, skip_history) {
210 debug("loading article: " + id + "/" + feed_id);
212 active_real_feed_id = feed_id;
214 var cached_article = cache_find(id);
216 debug("cache check result: " + (cached_article != false));
220 //setActiveFeedId(feed_id);
222 var query = "backend.php?op=view&id=" + param_escape(id) +
223 "&feed=" + param_escape(feed_id);
225 var date = new Date();
227 if (!xmlhttp_ready(xmlhttp) && last_article_view < date.getTime() / 1000 - 15) {
228 debug("<b>xmlhttp seems to be stuck at view, aborting</b>");
231 debug("trying alternative reset method for Safari");
232 xmlhttp = Ajax.getTransport();
236 if (xmlhttp_ready(xmlhttp)) {
240 cleanSelected("headlinesList");
242 var crow = document.getElementById("RROW-" + active_post_id);
244 var article_is_unread = crow.className.match("Unread");
245 debug("article is unread: " + article_is_unread);
247 crow.className = crow.className.replace("Unread", "");
249 var upd_img_pic = document.getElementById("FUPDPIC-" + active_post_id);
252 upd_img_pic.src = "images/blank_icon.gif";
255 selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false);
256 markHeadline(active_post_id);
258 var neighbor_ids = getRelativePostIds(active_post_id);
260 /* only request uncached articles */
262 var cids_to_request = Array();
264 for (var i = 0; i < neighbor_ids.length; i++) {
265 if (!cache_check(neighbor_ids[i])) {
266 cids_to_request.push(neighbor_ids[i]);
270 debug("additional ids: " + cids_to_request.toString());
272 /* additional info for piggyback counters */
274 if (tagsAreDisplayed()) {
275 query = query + "&omode=lt";
277 query = query + "&omode=flc";
280 var date = new Date();
281 var timestamp = Math.round(date.getTime() / 1000);
282 query = query + "&ts=" + timestamp;
284 query = query + "&cids=" + cids_to_request.toString();
286 if (!cached_article) {
288 notify_progress("Loading, please wait...");
292 xmlhttp.open("GET", query, true);
293 xmlhttp.onreadystatechange=article_callback;
295 } else if (cached_article && article_is_unread) {
297 query = query + "&mode=prefetch";
301 xmlhttp.open("GET", query, true);
302 xmlhttp.onreadystatechange=article_callback;
305 render_article(cached_article);
307 } else if (cached_article) {
309 query = query + "&mode=prefetch_old";
313 xmlhttp.open("GET", query, true);
314 xmlhttp.onreadystatechange=article_callback;
317 render_article(cached_article);
324 debug("xmlhttp busy (@view)");
329 exception_error("view", e);
334 return toggleMark(id);
338 return togglePub(id);
342 function toggleMark(id) {
344 if (!xmlhttp_ready(xmlhttp_rpc)) {
349 var query = "backend.php?op=rpc&id=" + id + "&subop=mark";
351 query = query + "&afid=" + getActiveFeedId();
353 if (tagsAreDisplayed()) {
354 query = query + "&omode=tl";
356 query = query + "&omode=flc";
359 var mark_img = document.getElementById("FMPIC-" + id);
360 var vfeedu = document.getElementById("FEEDU--1");
361 var crow = document.getElementById("RROW-" + id);
363 if (mark_img.alt != "Reset mark") {
364 mark_img.src = "images/mark_set.png";
365 mark_img.alt = "Reset mark";
366 query = query + "&mark=1";
368 if (vfeedu && crow.className.match("Unread")) {
369 vfeedu.innerHTML = (+vfeedu.innerHTML) + 1;
373 mark_img.src = "images/mark_unset.png";
374 mark_img.alt = "Set mark";
375 query = query + "&mark=0";
377 if (vfeedu && crow.className.match("Unread")) {
378 vfeedu.innerHTML = (+vfeedu.innerHTML) - 1;
383 var vfeedctr = document.getElementById("FEEDCTR--1");
384 var vfeedr = document.getElementById("FEEDR--1");
386 if (vfeedu && vfeedctr) {
387 if ((+vfeedu.innerHTML) > 0) {
388 if (crow.className.match("Unread") && !vfeedr.className.match("Unread")) {
389 vfeedr.className = vfeedr.className + "Unread";
390 vfeedctr.className = "odd";
393 vfeedctr.className = "invisible";
394 vfeedr.className = vfeedr.className.replace("Unread", "");
398 debug("toggle starred for aid " + id);
400 new Ajax.Request(query);
404 function togglePub(id) {
408 if (!xmlhttp_ready(xmlhttp_rpc)) {
413 var query = "backend.php?op=rpc&id=" + id + "&subop=publ";
415 query = query + "&afid=" + getActiveFeedId();
417 if (tagsAreDisplayed()) {
418 query = query + "&omode=tl";
420 query = query + "&omode=flc";
423 var mark_img = document.getElementById("FPPIC-" + id);
424 var vfeedu = document.getElementById("FEEDU--2");
425 var crow = document.getElementById("RROW-" + id);
427 if (mark_img.alt != "Unpublish") {
428 mark_img.src = "images/pub_set.png";
429 mark_img.alt = "Unpublish";
430 query = query + "&pub=1";
432 if (vfeedu && crow.className.match("Unread")) {
433 vfeedu.innerHTML = (+vfeedu.innerHTML) + 1;
437 mark_img.src = "images/pub_unset.png";
438 mark_img.alt = "Publish";
439 query = query + "&pub=0";
441 if (vfeedu && crow.className.match("Unread")) {
442 vfeedu.innerHTML = (+vfeedu.innerHTML) - 1;
447 var vfeedctr = document.getElementById("FEEDCTR--2");
448 var vfeedr = document.getElementById("FEEDR--2");
450 if (vfeedu && vfeedctr) {
451 if ((+vfeedu.innerHTML) > 0) {
452 if (crow.className.match("Unread") && !vfeedr.className.match("Unread")) {
453 vfeedr.className = vfeedr.className + "Unread";
454 vfeedctr.className = "odd";
457 vfeedctr.className = "invisible";
458 vfeedr.className = vfeedr.className.replace("Unread", "");
462 debug("toggle published for aid " + id);
464 new Ajax.Request(query);
467 exception_error("togglePub", e);
471 function correctHeadlinesOffset(id) {
475 var hlist = document.getElementById("headlinesList");
476 var container = document.getElementById("headlinesInnerContainer");
477 var row = document.getElementById("RROW-" + id);
479 var viewport = container.offsetHeight;
481 var rel_offset_top = row.offsetTop - container.scrollTop;
482 var rel_offset_bottom = row.offsetTop + row.offsetHeight - container.scrollTop;
484 debug("Rtop: " + rel_offset_top + " Rbtm: " + rel_offset_bottom);
485 debug("Vport: " + viewport);
487 if (rel_offset_top <= 0 || rel_offset_top > viewport) {
488 container.scrollTop = row.offsetTop;
489 } else if (rel_offset_bottom > viewport) {
491 /* doesn't properly work with Opera in some cases because
492 Opera fucks up element scrolling */
494 container.scrollTop = row.offsetTop + row.offsetHeight - viewport;
498 exception_error("correctHeadlinesOffset", e);
503 function moveToPost(mode) {
505 // check for combined mode
506 if (!document.getElementById("headlinesList"))
509 var rows = getVisibleHeadlineIds();
514 if (!document.getElementById('RROW-' + active_post_id)) {
515 active_post_id = false;
518 if (active_post_id == false) {
519 next_id = getFirstVisibleHeadlineId();
520 prev_id = getLastVisibleHeadlineId();
522 for (var i = 0; i < rows.length; i++) {
523 if (rows[i] == active_post_id) {
530 if (mode == "next") {
532 correctHeadlinesOffset(next_id);
533 view(next_id, getActiveFeedId());
537 if (mode == "prev") {
539 correctHeadlinesOffset(prev_id);
540 view(prev_id, getActiveFeedId());
545 function toggleUnread(id, cmode) {
547 if (!xmlhttp_ready(xmlhttp_rpc)) {
552 var row = document.getElementById("RROW-" + id);
554 var nc = row.className;
555 nc = nc.replace("Unread", "");
556 nc = nc.replace("Selected", "");
558 if (row.className.match("Unread")) {
561 row.className = nc + "Unread";
564 if (!cmode) cmode = 2;
566 var query = "backend.php?op=rpc&subop=catchupSelected&ids=" +
567 param_escape(id) + "&cmode=" + param_escape(cmode);
569 notify_progress("Loading, please wait...");
571 xmlhttp_rpc.open("GET", query, true);
572 xmlhttp_rpc.onreadystatechange=all_counters_callback;
573 xmlhttp_rpc.send(null);
579 exception_error("toggleUnread", e);
583 function selectionToggleUnread(cdm_mode, set_state, callback_func, no_error) {
585 if (!xmlhttp_ready(xmlhttp_rpc)) {
593 rows = cdmGetSelectedArticles();
595 rows = getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
598 if (rows.length == 0 && !no_error) {
599 alert(__("No articles are selected."));
603 for (i = 0; i < rows.length; i++) {
604 var row = document.getElementById("RROW-" + rows[i]);
606 var nc = row.className;
607 nc = nc.replace("Unread", "");
608 nc = nc.replace("Selected", "");
610 if (row.className.match("Unread")) {
611 row.className = nc + "Selected";
613 row.className = nc + "UnreadSelected";
618 if (rows.length > 0) {
622 if (set_state == undefined) {
624 } else if (set_state == true) {
626 } else if (set_state == false) {
630 var query = "backend.php?op=rpc&subop=catchupSelected&ids=" +
631 param_escape(rows.toString()) + "&cmode=" + cmode;
633 _catchup_callback_func = callback_func;
635 notify_progress("Loading, please wait...");
637 xmlhttp_rpc.open("GET", query, true);
638 xmlhttp_rpc.onreadystatechange=catchup_callback;
639 xmlhttp_rpc.send(null);
644 exception_error("selectionToggleUnread", e);
648 function selectionToggleMarked(cdm_mode) {
650 if (!xmlhttp_ready(xmlhttp_rpc)) {
658 rows = cdmGetSelectedArticles();
660 rows = getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
663 if (rows.length == 0) {
664 alert(__("No articles are selected."));
668 for (i = 0; i < rows.length; i++) {
669 var row = document.getElementById("RROW-" + rows[i]);
670 var mark_img = document.getElementById("FMPIC-" + rows[i]);
672 if (row && mark_img) {
674 if (mark_img.alt == "Set mark") {
675 mark_img.src = "images/mark_set.png";
676 mark_img.alt = "Reset mark";
677 mark_img.setAttribute('onclick',
678 'javascript:toggleMark('+rows[i]+', false)');
681 mark_img.src = "images/mark_unset.png";
682 mark_img.alt = "Set mark";
683 mark_img.setAttribute('onclick',
684 'javascript:toggleMark('+rows[i]+', true)');
689 if (rows.length > 0) {
691 var query = "backend.php?op=rpc&subop=markSelected&ids=" +
692 param_escape(rows.toString()) + "&cmode=2";
694 query = query + "&afid=" + getActiveFeedId();
696 if (tagsAreDisplayed()) {
697 query = query + "&omode=tl";
699 query = query + "&omode=flc";
702 xmlhttp_rpc.open("GET", query, true);
703 xmlhttp_rpc.onreadystatechange=all_counters_callback;
704 xmlhttp_rpc.send(null);
709 exception_error("selectionToggleMarked", e);
713 function selectionTogglePublished(cdm_mode) {
715 if (!xmlhttp_ready(xmlhttp_rpc)) {
723 rows = cdmGetSelectedArticles();
725 rows = getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
728 if (rows.length == 0) {
729 alert(__("No articles are selected."));
733 for (i = 0; i < rows.length; i++) {
734 var row = document.getElementById("RROW-" + rows[i]);
735 var mark_img = document.getElementById("FPPIC-" + rows[i]);
737 if (row && mark_img) {
739 if (mark_img.alt == "Publish") {
740 mark_img.src = "images/pub_set.png";
741 mark_img.alt = "Unpublish";
742 mark_img.setAttribute('onclick',
743 'javascript:togglePub('+rows[i]+', false)');
746 mark_img.src = "images/pub_unset.png";
747 mark_img.alt = "Publish";
748 mark_img.setAttribute('onclick',
749 'javascript:togglePub('+rows[i]+', true)');
754 if (rows.length > 0) {
756 var query = "backend.php?op=rpc&subop=publishSelected&ids=" +
757 param_escape(rows.toString()) + "&cmode=2";
759 query = query + "&afid=" + getActiveFeedId();
761 if (tagsAreDisplayed()) {
762 query = query + "&omode=tl";
764 query = query + "&omode=flc";
767 xmlhttp_rpc.open("GET", query, true);
768 xmlhttp_rpc.onreadystatechange=all_counters_callback;
769 xmlhttp_rpc.send(null);
774 exception_error("selectionToggleMarked", e);
778 function cdmGetSelectedArticles() {
779 var sel_articles = new Array();
780 var container = document.getElementById("headlinesInnerContainer");
782 for (i = 0; i < container.childNodes.length; i++) {
783 var child = container.childNodes[i];
785 if (child.id.match("RROW-") && child.className.match("Selected")) {
786 var c_id = child.id.replace("RROW-", "");
787 sel_articles.push(c_id);
794 // mode = all,none,unread
795 function cdmSelectArticles(mode) {
796 var container = document.getElementById("headlinesInnerContainer");
798 for (i = 0; i < container.childNodes.length; i++) {
799 var child = container.childNodes[i];
801 if (child.id.match("RROW-")) {
802 var aid = child.id.replace("RROW-", "");
804 var cb = document.getElementById("RCHK-" + aid);
807 if (!child.className.match("Selected")) {
808 child.className = child.className + "Selected";
811 } else if (mode == "unread") {
812 if (child.className.match("Unread") && !child.className.match("Selected")) {
813 child.className = child.className + "Selected";
817 child.className = child.className.replace("Selected", "");
824 function catchupPage() {
826 var fn = getFeedName(getActiveFeedId(), active_feed_is_cat);
828 var str = "Mark all visible articles in " + fn + " as read?";
830 if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str)) {
834 if (document.getElementById("headlinesList")) {
835 selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', true, 'Unread', true);
836 selectionToggleUnread(false, false, 'viewCurrentFeed()', true);
837 selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false);
839 cdmSelectArticles('all');
840 selectionToggleUnread(true, false, 'viewCurrentFeed()', true)
841 cdmSelectArticles('none');
845 function labelFromSearch(search, search_mode, match_on, feed_id, is_cat) {
847 if (!xmlhttp_ready(xmlhttp_rpc)) {
851 var title = prompt("Please enter label title:", "");
855 var query = "backend.php?op=labelFromSearch&search=" + param_escape(search) +
856 "&smode=" + param_escape(search_mode) + "&match=" + param_escape(match_on) +
857 "&feed=" + param_escape(feed_id) + "&is_cat=" + param_escape(is_cat) +
858 "&title=" + param_escape(title);
860 debug("LFS: " + query);
862 xmlhttp_rpc.open("GET", query, true);
863 xmlhttp_rpc.onreadystatechange=dlg_frefresh_callback;
864 xmlhttp_rpc.send(null);
869 function editArticleTags(id, feed_id, cdm_enabled) {
870 _tag_active_post_id = id;
871 _tag_active_feed_id = feed_id;
872 _tag_active_cdm = cdm_enabled;
874 cache_invalidate(id);
877 _tag_cdm_scroll = document.getElementById("headlinesInnerContainer").scrollTop;
879 displayDlg('editArticleTags', id);
883 function tag_saved_callback() {
884 if (xmlhttp_rpc.readyState == 4) {
886 debug("in tag_saved_callback");
891 if (tagsAreDisplayed()) {
892 _reload_feedlist_after_view = true;
895 if (!_tag_active_cdm) {
896 if (active_post_id == _tag_active_post_id) {
897 debug("reloading current article");
898 view(_tag_active_post_id, _tag_active_feed_id);
901 debug("reloading current feed");
906 exception_error("catchup_callback", e);
911 function editTagsSave() {
913 if (!xmlhttp_ready(xmlhttp_rpc)) {
917 notify_progress("Saving article tags...");
919 var form = document.forms["tag_edit_form"];
921 var query = Form.serialize("tag_edit_form");
923 query = "backend.php?op=rpc&subop=setArticleTags&" + query;
927 xmlhttp_rpc.open("GET", query, true);
928 xmlhttp_rpc.onreadystatechange=tag_saved_callback;
929 xmlhttp_rpc.send(null);
933 function editTagsInsert() {
936 var form = document.forms["tag_edit_form"];
938 var found_tags = form.found_tags;
939 var tags_str = form.tags_str;
941 var tag = found_tags[found_tags.selectedIndex].value;
943 if (tags_str.value.length > 0 &&
944 tags_str.value.lastIndexOf(", ") != tags_str.value.length - 2) {
946 tags_str.value = tags_str.value + ", ";
949 tags_str.value = tags_str.value + tag + ", ";
951 found_tags.selectedIndex = 0;
954 exception_error(e, "editTagsInsert");
958 function cdmWatchdog() {
962 var ctr = document.getElementById("headlinesInnerContainer");
966 var ids = new Array();
968 var e = ctr.firstChild;
971 if (e.className && e.className == "cdmArticleUnread" && e.id &&
972 e.id.match("RROW-")) {
974 // article fits in viewport OR article is longer than viewport and
975 // its bottom is visible
977 if (ctr.scrollTop <= e.offsetTop && e.offsetTop + e.offsetHeight <=
978 ctr.scrollTop + ctr.offsetHeight) {
980 // debug(e.id + " is visible " + e.offsetTop + "." +
981 // (e.offsetTop + e.offsetHeight) + " vs " + ctr.scrollTop + "." +
982 // (ctr.scrollTop + ctr.offsetHeight));
984 ids.push(e.id.replace("RROW-", ""));
986 } else if (e.offsetHeight > ctr.offsetHeight &&
987 e.offsetTop + e.offsetHeight >= ctr.scrollTop &&
988 e.offsetTop + e.offsetHeight <= ctr.scrollTop + ctr.offsetHeight) {
990 ids.push(e.id.replace("RROW-", ""));
994 // method 2: article bottom is visible and is in upper 1/2 of the viewport
996 /* if (e.offsetTop + e.offsetHeight >= ctr.scrollTop &&
997 e.offsetTop + e.offsetHeight <= ctr.scrollTop + ctr.offsetHeight/2) {
999 ids.push(e.id.replace("RROW-", ""));
1008 debug("cdmWatchdog, ids= " + ids.toString());
1010 if (ids.length > 0 && xmlhttp_ready(xmlhttp_rpc)) {
1012 for (var i = 0; i < ids.length; i++) {
1013 var e = document.getElementById("RROW-" + ids[i]);
1015 e.className = e.className.replace("Unread", "");
1019 var query = "backend.php?op=rpc&subop=catchupSelected&ids=" +
1020 param_escape(ids.toString()) + "&cmode=0";
1022 xmlhttp_rpc.open("GET", query, true);
1023 xmlhttp_rpc.onreadystatechange=all_counters_callback;
1024 xmlhttp_rpc.send(null);
1028 _cdm_wd_timeout = window.setTimeout("cdmWatchdog()", 4000);
1031 exception_error(e, "cdmWatchdog");
1037 function cache_inject(id, article) {
1038 if (!cache_check(id)) {
1039 debug("cache_article: miss: " + id);
1041 var cache_obj = new Array();
1043 cache_obj["id"] = id;
1044 cache_obj["data"] = article;
1046 article_cache.push(cache_obj);
1049 debug("cache_article: hit: " + id);
1053 function cache_find(id) {
1054 for (var i = 0; i < article_cache.length; i++) {
1055 if (article_cache[i]["id"] == id) {
1056 return article_cache[i]["data"];
1062 function cache_check(id) {
1063 for (var i = 0; i < article_cache.length; i++) {
1064 if (article_cache[i]["id"] == id) {
1071 function cache_expire() {
1072 while (article_cache.length > 20) {
1073 article_cache.shift();
1077 function cache_invalidate(id) {
1082 while (i < article_cache.length) {
1083 if (article_cache[i]["id"] == id) {
1084 debug("cache_invalidate: removed id " + id);
1085 article_cache.splice(i, 1);
1090 debug("cache_invalidate: id not found: " + id);
1093 exception_error("cache_invalidate", e);
1097 function getActiveArticleId() {
1098 return active_post_id;
1101 function cdmMouseIn(elem) {
1103 if (elem.id && elem.id.match("RROW-")) {
1104 var id = elem.id.replace("RROW-", "");
1105 active_post_id = id;
1108 exception_error("cdmMouseIn", e);
1113 function cdmMouseOut(elem) {
1114 active_post_id = false;
1117 function headlines_scroll_handler() {
1120 var e = document.getElementById("headlinesInnerContainer");
1122 if (e.scrollTop + e.offsetHeight > e.scrollHeight - 300) {
1123 debug("more cowbell!");
1129 exception_error("headlines_scroll_handler", e);