1 var active_post_id = false;
2 var _catchup_callback_func = false;
4 function catchup_callback() {
5 if (xmlhttp_rpc.readyState == 4) {
7 debug("catchup_callback");
8 if (_catchup_callback_func) {
9 setTimeout(_catchup_callback_func, 100);
11 all_counters_callback();
13 exception_error("catchup_callback", e);
18 function headlines_callback() {
19 if (xmlhttp.readyState == 4) {
20 debug("headlines_callback");
21 var f = document.getElementById("headlines-frame");
25 f.innerHTML = xmlhttp.responseText;
26 update_all_counters();
27 if (typeof correctPNG != 'undefined') {
34 function article_callback() {
35 if (xmlhttp.readyState == 4) {
36 debug("article_callback");
37 var f = document.getElementById("content-frame");
41 f.innerHTML = xmlhttp.responseText;
42 if (typeof correctPNG != 'undefined') {
45 update_all_counters();
49 function view(id, feed_id) {
52 debug("loading article: " + id + "/" + feed_id);
56 var crow = document.getElementById("RROW-" + id);
58 crow.className = crow.className.replace("Unread", "");
60 cleanSelected("headlinesList");
62 var upd_img_pic = document.getElementById("FUPDPIC-" + id);
65 upd_img_pic.src = "images/blank_icon.gif";
69 //setActiveFeedId(feed_id);
71 var content = document.getElementById("content-frame");
73 selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false);
74 markHeadline(active_post_id);
76 var query = "backend.php?op=view&id=" + param_escape(id) +
77 "&feed=" + param_escape(feed_id);
79 if (xmlhttp_ready(xmlhttp)) {
80 xmlhttp.open("GET", query, true);
81 xmlhttp.onreadystatechange=article_callback;
84 debug("xmlhttp busy (@view)");
88 exception_error("view", e);
92 function toggleMark(id) {
94 if (!xmlhttp_ready(xmlhttp_rpc)) {
99 var query = "backend.php?op=rpc&id=" + id + "&subop=mark";
101 var mark_img = document.getElementById("FMARKPIC-" + id);
102 var vfeedu = document.getElementById("FEEDU--1");
103 var crow = document.getElementById("RROW-" + id);
105 if (mark_img.alt != "Reset mark") {
106 mark_img.src = "images/mark_set.png";
107 mark_img.alt = "Reset mark";
108 query = query + "&mark=1";
110 if (vfeedu && crow.className.match("Unread")) {
111 vfeedu.innerHTML = (+vfeedu.innerHTML) + 1;
115 mark_img.src = "images/mark_unset.png";
116 mark_img.alt = "Set mark";
117 query = query + "&mark=0";
119 if (vfeedu && crow.className.match("Unread")) {
120 vfeedu.innerHTML = (+vfeedu.innerHTML) - 1;
125 var vfeedctr = document.getElementById("FEEDCTR--1");
126 var vfeedr = document.getElementById("FEEDR--1");
128 if (vfeedu && vfeedctr) {
129 if ((+vfeedu.innerHTML) > 0) {
130 if (crow.className.match("Unread") && !vfeedr.className.match("Unread")) {
131 vfeedr.className = vfeedr.className + "Unread";
132 vfeedctr.className = "odd";
135 vfeedctr.className = "invisible";
136 vfeedr.className = vfeedr.className.replace("Unread", "");
140 debug("toggle starred for aid " + id);
142 new Ajax.Request(query);
146 function moveToPost(mode) {
148 // check for combined mode
149 if (!document.getElementById("headlinesList"))
152 var rows = getVisibleHeadlineIds();
157 if (active_post_id == false) {
158 next_id = getFirstVisibleHeadlineId();
159 prev_id = getLastVisibleHeadlineId();
161 for (var i = 0; i < rows.length; i++) {
162 if (rows[i] == active_post_id) {
169 if (mode == "next") {
170 if (next_id != undefined) {
171 view(next_id, getActiveFeedId());
175 if (mode == "prev") {
176 if ( prev_id != undefined) {
177 view(prev_id, getActiveFeedId());
182 function toggleUnread(id, cmode) {
184 if (!xmlhttp_ready(xmlhttp_rpc)) {
189 var row = document.getElementById("RROW-" + id);
191 var nc = row.className;
192 nc = nc.replace("Unread", "");
193 nc = nc.replace("Selected", "");
195 if (row.className.match("Unread")) {
198 row.className = nc + "Unread";
201 if (!cmode) cmode = 2;
203 var query = "backend.php?op=rpc&subop=catchupSelected&ids=" +
204 param_escape(id) + "&cmode=" + param_escape(cmode);
206 xmlhttp_rpc.open("GET", query, true);
207 xmlhttp_rpc.onreadystatechange=all_counters_callback;
208 xmlhttp_rpc.send(null);
214 exception_error("toggleUnread", e);
218 function selectionToggleUnread(cdm_mode, set_state, callback_func) {
220 if (!xmlhttp_ready(xmlhttp_rpc)) {
228 rows = cdmGetSelectedArticles();
230 rows = getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
233 for (i = 0; i < rows.length; i++) {
234 var row = document.getElementById("RROW-" + rows[i]);
236 var nc = row.className;
237 nc = nc.replace("Unread", "");
238 nc = nc.replace("Selected", "");
240 if (row.className.match("Unread")) {
241 row.className = nc + "Selected";
243 row.className = nc + "UnreadSelected";
248 if (rows.length > 0) {
252 if (set_state == undefined) {
254 } else if (set_state == true) {
256 } else if (set_state == false) {
260 var query = "backend.php?op=rpc&subop=catchupSelected&ids=" +
261 param_escape(rows.toString()) + "&cmode=" + cmode;
263 _catchup_callback_func = callback_func;
265 xmlhttp_rpc.open("GET", query, true);
266 xmlhttp_rpc.onreadystatechange=catchup_callback;
267 xmlhttp_rpc.send(null);
272 exception_error("selectionToggleUnread", e);
276 function selectionToggleMarked(cdm_mode) {
278 if (!xmlhttp_ready(xmlhttp_rpc)) {
286 rows = cdmGetSelectedArticles();
288 rows = getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
291 for (i = 0; i < rows.length; i++) {
292 var row = document.getElementById("RROW-" + rows[i]);
293 var mark_img = document.getElementById("FMARKPIC-" + rows[i]);
295 if (row && mark_img) {
297 if (mark_img.alt == "Set mark") {
298 mark_img.src = "images/mark_set.png";
299 mark_img.alt = "Reset mark";
300 mark_img.setAttribute('onclick',
301 'javascript:toggleMark('+rows[i]+', false)');
304 mark_img.src = "images/mark_unset.png";
305 mark_img.alt = "Set mark";
306 mark_img.setAttribute('onclick',
307 'javascript:toggleMark('+rows[i]+', true)');
312 if (rows.length > 0) {
314 var query = "backend.php?op=rpc&subop=markSelected&ids=" +
315 param_escape(rows.toString()) + "&cmode=2";
317 xmlhttp_rpc.open("GET", query, true);
318 xmlhttp_rpc.onreadystatechange=all_counters_callback;
319 xmlhttp_rpc.send(null);
324 exception_error("selectionToggleMarked", e);
328 function cdmGetSelectedArticles() {
329 var sel_articles = new Array();
330 var container = document.getElementById("headlinesContainer");
332 for (i = 0; i < container.childNodes.length; i++) {
333 var child = container.childNodes[i];
335 if (child.id.match("RROW-") && child.className.match("Selected")) {
336 var c_id = child.id.replace("RROW-", "");
337 sel_articles.push(c_id);
344 // mode = all,none,unread
345 function cdmSelectArticles(mode) {
346 var container = document.getElementById("headlinesContainer");
348 for (i = 0; i < container.childNodes.length; i++) {
349 var child = container.childNodes[i];
351 if (child.id.match("RROW-")) {
352 var aid = child.id.replace("RROW-", "");
354 var cb = document.getElementById("RCHK-" + aid);
357 if (!child.className.match("Selected")) {
358 child.className = child.className + "Selected";
361 } else if (mode == "unread") {
362 if (child.className.match("Unread") && !child.className.match("Selected")) {
363 child.className = child.className + "Selected";
367 child.className = child.className.replace("Selected", "");
374 function catchupPage() {
376 if (document.getElementById("headlinesList")) {
377 selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', true, 'Unread', true);
378 selectionToggleUnread(false, false, 'viewCurrentFeed()');
379 selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false);
381 cdmSelectArticles('all');
382 selectionToggleUnread(true, false, 'viewCurrentFeed()')
383 cdmSelectArticles('none');
387 function labelFromSearch(search, search_mode, match_on, feed_id, is_cat) {
389 if (!xmlhttp_ready(xmlhttp_rpc)) {
393 var title = prompt("Please enter label title:", "");
397 var query = "backend.php?op=labelFromSearch&search=" + param_escape(search) +
398 "&smode=" + param_escape(search_mode) + "&match=" + param_escape(match_on) +
399 "&feed=" + param_escape(feed_id) + "&is_cat=" + param_escape(is_cat) +
400 "&title=" + param_escape(title);
402 debug("LFS: " + query);
404 xmlhttp_rpc.open("GET", query, true);
405 xmlhttp_rpc.onreadystatechange=dlg_frefresh_callback;
406 xmlhttp_rpc.send(null);