]>
Commit | Line | Data |
---|---|---|
bb7cface | 1 | var active_post_id = false; |
4b6206fa | 2 | var last_article_view = false; |
0b126ac2 AD |
3 | var active_real_feed_id = false; |
4 | ||
13f08f75 | 5 | // FIXME: kludges, needs proper implementation |
0b126ac2 | 6 | var _reload_feedlist_after_view = false; |
e08443c1 | 7 | |
ba0978c8 AD |
8 | var _cdm_wd_timeout = false; |
9 | var _cdm_wd_vishist = new Array(); | |
10 | ||
e097e8be AD |
11 | var article_cache = new Array(); |
12 | ||
081e527d | 13 | var vgroup_last_feed = false; |
314fcd2b | 14 | var post_under_pointer = false; |
081e527d | 15 | |
022d9e9e AD |
16 | var last_requested_article = false; |
17 | ||
c7e51de1 AD |
18 | function toggle_published_callback(transport) { |
19 | try { | |
20 | if (transport.responseXML) { | |
21 | ||
22 | all_counters_callback2(transport); | |
23 | ||
24 | var note = transport.responseXML.getElementsByTagName("note")[0]; | |
25 | ||
26 | if (note) { | |
27 | var note_id = note.getAttribute("id"); | |
28 | var note_size = note.getAttribute("size"); | |
29 | var note_content = note.firstChild.nodeValue; | |
30 | ||
31 | var container = $('POSTNOTE-' + note_id); | |
32 | ||
33 | cache_invalidate(note_id); | |
34 | ||
35 | if (container) { | |
36 | if (note_size == "0") { | |
37 | Element.hide(container); | |
38 | } else { | |
39 | container.innerHTML = note_content; | |
40 | Element.show(container); | |
41 | } | |
42 | } | |
43 | } | |
44 | } | |
45 | ||
46 | } catch (e) { | |
47 | exception_error("toggle_published_callback", e, transport); | |
48 | } | |
49 | } | |
50 | ||
1341ea0d AD |
51 | function catchup_callback2(transport, callback) { |
52 | try { | |
53 | debug("catchup_callback2 " + transport + ", " + callback); | |
54 | notify(""); | |
55 | all_counters_callback2(transport); | |
56 | if (callback) { | |
57 | setTimeout(callback, 10); | |
58 | } | |
59 | } catch (e) { | |
273d1e29 | 60 | exception_error("catchup_callback2", e, transport); |
1341ea0d AD |
61 | } |
62 | } | |
63 | ||
e19c1824 | 64 | function clean_feed_selections() { |
a49f5e05 | 65 | try { |
acac8448 | 66 | var feeds = $("feedList").getElementsByTagName("LI"); |
a49f5e05 | 67 | |
6c3b0198 AD |
68 | for (var i = 0; i < feeds.length; i++) { |
69 | if (feeds[i].id && feeds[i].id.match("FEEDR-")) { | |
70 | feeds[i].className = feeds[i].className.replace("Selected", ""); | |
71 | } | |
5ee9816c AD |
72 | if (feeds[i].id && feeds[i].id.match("FCAT-")) { |
73 | feeds[i].className = feeds[i].className.replace("Selected", ""); | |
74 | } | |
6c3b0198 | 75 | } |
e19c1824 AD |
76 | } catch (e) { |
77 | exception_error("clean_feed_selections", e); | |
78 | } | |
79 | } | |
80 | ||
3d72bbdb | 81 | function headlines_callback2(transport, feed_cur_page) { |
e19c1824 AD |
82 | try { |
83 | ||
9ca945a6 AD |
84 | if (!transport.responseText && db) { |
85 | offlineConfirmModeChange(); | |
86 | return; | |
87 | } | |
88 | ||
730dbf19 AD |
89 | loading_set_progress(100); |
90 | ||
e19c1824 AD |
91 | debug("headlines_callback2 [page=" + feed_cur_page + "]"); |
92 | ||
2184738a AD |
93 | if (!transport_error_check(transport)) return; |
94 | ||
e19c1824 | 95 | clean_feed_selections(); |
3d72bbdb AD |
96 | |
97 | var is_cat = false; | |
98 | var feed_id = false; | |
ac541432 | 99 | |
3d72bbdb AD |
100 | if (transport.responseXML) { |
101 | var headlines = transport.responseXML.getElementsByTagName("headlines")[0]; | |
102 | if (headlines) { | |
103 | is_cat = headlines.getAttribute("is_cat"); | |
104 | feed_id = headlines.getAttribute("id"); | |
105 | setActiveFeedId(feed_id, is_cat); | |
106 | } | |
6c3b0198 | 107 | } |
f46192bb | 108 | |
6e35a862 AD |
109 | var ll = $('FLL-' + feed_id); |
110 | ||
6c3b0198 | 111 | if (!is_cat) { |
acac8448 | 112 | var feedr = $("FEEDR-" + feed_id); |
6c3b0198 AD |
113 | if (feedr && !feedr.className.match("Selected")) { |
114 | feedr.className = feedr.className + "Selected"; | |
115 | } | |
6e35a862 | 116 | if (feedr && ll) feedr.removeChild(ll); |
5ee9816c | 117 | } else { |
acac8448 | 118 | var feedr = $("FCAT-" + feed_id); |
5ee9816c AD |
119 | if (feedr && !feedr.className.match("Selected")) { |
120 | feedr.className = feedr.className + "Selected"; | |
121 | } | |
b7665618 AD |
122 | |
123 | var fcap = $("FCAP-" + feed_id); | |
124 | if (fcap && ll) fcap.removeChild(ll); | |
6e35a862 | 125 | |
6c3b0198 | 126 | } |
6e35a862 | 127 | |
105b61b7 AD |
128 | var img = $('FIMG-' + feed_id); |
129 | ||
130 | if (img && !is_cat) { | |
131 | img.src = img.alt; | |
105b61b7 AD |
132 | } |
133 | ||
acac8448 | 134 | var f = $("headlines-frame"); |
6c3b0198 AD |
135 | try { |
136 | if (feed_cur_page == 0) { | |
137 | debug("resetting headlines scrollTop"); | |
138 | f.scrollTop = 0; | |
a49f5e05 | 139 | } |
6c3b0198 AD |
140 | } catch (e) { }; |
141 | ||
142 | if (transport.responseXML) { | |
143 | var headlines = transport.responseXML.getElementsByTagName("headlines")[0]; | |
144 | var headlines_count_obj = transport.responseXML.getElementsByTagName("headlines-count")[0]; | |
e19c1824 | 145 | var headlines_unread_obj = transport.responseXML.getElementsByTagName("headlines-unread")[0]; |
52d7e7da | 146 | var disable_cache_obj = transport.responseXML.getElementsByTagName("disable-cache")[0]; |
e19c1824 | 147 | |
081e527d AD |
148 | var vgroup_last_feed_obj = transport.responseXML.getElementsByTagName("vgroup-last-feed")[0]; |
149 | ||
6c3b0198 | 150 | var headlines_count = headlines_count_obj.getAttribute("value"); |
e19c1824 | 151 | var headlines_unread = headlines_unread_obj.getAttribute("value"); |
52d7e7da | 152 | var disable_cache = disable_cache_obj.getAttribute("value") != "0"; |
e19c1824 | 153 | |
081e527d AD |
154 | vgroup_last_feed = vgroup_last_feed_obj.getAttribute("value"); |
155 | ||
587bef10 AD |
156 | if (headlines_count == 0) { |
157 | _infscroll_disable = 1; | |
158 | } else { | |
159 | _infscroll_disable = 0; | |
160 | } | |
161 | ||
6c3b0198 AD |
162 | var counters = transport.responseXML.getElementsByTagName("counters")[0]; |
163 | var articles = transport.responseXML.getElementsByTagName("article"); | |
164 | var runtime_info = transport.responseXML.getElementsByTagName("runtime-info"); | |
165 | ||
166 | if (feed_cur_page == 0) { | |
167 | if (headlines) { | |
168 | f.innerHTML = headlines.firstChild.nodeValue; | |
e19c1824 | 169 | |
dd5865d4 AD |
170 | var cache_prefix = ""; |
171 | ||
172 | if (is_cat) { | |
173 | cache_prefix = "C:"; | |
174 | } else { | |
175 | cache_prefix = "F:"; | |
176 | } | |
177 | ||
3d72bbdb | 178 | cache_invalidate(cache_prefix + feed_id); |
7e8832b3 | 179 | |
52d7e7da | 180 | if (!disable_cache) { |
3d72bbdb | 181 | cache_inject(cache_prefix + feed_id, |
52d7e7da AD |
182 | headlines.firstChild.nodeValue, headlines_unread); |
183 | } | |
e19c1824 | 184 | |
6c3b0198 AD |
185 | } else { |
186 | debug("headlines_callback: returned no data"); | |
187 | f.innerHTML = "<div class='whiteBox'>" + __('Could not update headlines (missing XML data)') + "</div>"; | |
188 | ||
189 | } | |
190 | } else { | |
191 | if (headlines) { | |
192 | if (headlines_count > 0) { | |
193 | debug("adding some more headlines..."); | |
194 | ||
acac8448 | 195 | var c = $("headlinesList"); |
6c3b0198 AD |
196 | |
197 | if (!c) { | |
acac8448 | 198 | c = $("headlinesInnerContainer"); |
6c3b0198 | 199 | } |
c32cd48a AD |
200 | |
201 | var ids = getSelectedArticleIds2(); | |
6c3b0198 AD |
202 | |
203 | c.innerHTML = c.innerHTML + headlines.firstChild.nodeValue; | |
c32cd48a AD |
204 | |
205 | debug("restore selected ids: " + ids); | |
206 | ||
207 | for (var i = 0; i < ids.length; i++) { | |
208 | markHeadline(ids[i]); | |
209 | } | |
210 | ||
6c3b0198 AD |
211 | } else { |
212 | debug("no new headlines received"); | |
29dfb258 | 213 | } |
29dfb258 | 214 | } else { |
6c3b0198 AD |
215 | debug("headlines_callback: returned no data"); |
216 | notify_error("Error while trying to load more headlines"); | |
217 | } | |
730dbf19 | 218 | |
6c3b0198 AD |
219 | } |
220 | ||
221 | if (articles) { | |
222 | for (var i = 0; i < articles.length; i++) { | |
223 | var a_id = articles[i].getAttribute("id"); | |
224 | debug("found id: " + a_id); | |
225 | cache_inject(a_id, articles[i].firstChild.nodeValue); | |
ac541432 | 226 | } |
007a38d4 | 227 | } else { |
6c3b0198 | 228 | debug("no cached articles received"); |
961f4c73 | 229 | } |
6c3b0198 AD |
230 | |
231 | if (counters) { | |
232 | debug("parsing piggybacked counters: " + counters); | |
233 | parse_counters(counters, false); | |
234 | } else { | |
5aaf9b34 AD |
235 | debug("counters container not found in reply, requesting..."); |
236 | request_counters(); | |
6c3b0198 AD |
237 | } |
238 | ||
239 | if (runtime_info) { | |
240 | debug("parsing runtime info: " + runtime_info[0]); | |
241 | parse_runtime_info(runtime_info[0]); | |
242 | } else { | |
243 | debug("counters container not found in reply"); | |
03c88bdd | 244 | } |
6c3b0198 | 245 | |
3de0261a | 246 | } else { |
6c3b0198 AD |
247 | debug("headlines_callback: returned no XML object"); |
248 | f.innerHTML = "<div class='whiteBox'>" + __('Could not update headlines (missing XML object)') + "</div>"; | |
3de0261a | 249 | } |
6c3b0198 AD |
250 | |
251 | if (typeof correctPNG != 'undefined') { | |
252 | correctPNG(); | |
935f235d | 253 | } |
6c3b0198 AD |
254 | |
255 | if (_cdm_wd_timeout) window.clearTimeout(_cdm_wd_timeout); | |
256 | ||
acac8448 | 257 | if (!$("headlinesList") && |
a969b30b | 258 | getActiveFeedId() != -3 && |
6c3b0198 AD |
259 | getInitParam("cdm_auto_catchup") == 1) { |
260 | debug("starting CDM watchdog"); | |
261 | _cdm_wd_timeout = window.setTimeout("cdmWatchdog()", 5000); | |
262 | _cdm_wd_vishist = new Array(); | |
ac7bcd71 | 263 | } else { |
6c3b0198 | 264 | debug("not in CDM mode or watchdog disabled"); |
ba0978c8 | 265 | } |
6c3b0198 | 266 | |
6c3b0198 | 267 | _feed_cur_page = feed_cur_page; |
82764a41 AD |
268 | _infscroll_request_sent = 0; |
269 | ||
6c3b0198 | 270 | notify(""); |
730dbf19 AD |
271 | |
272 | remove_splash(); | |
273 | ||
6c3b0198 | 274 | } catch (e) { |
273d1e29 | 275 | exception_error("headlines_callback2", e, transport); |
6b4163cb AD |
276 | } |
277 | } | |
278 | ||
e097e8be AD |
279 | function render_article(article) { |
280 | try { | |
acac8448 | 281 | var f = $("content-frame"); |
44cc6f20 AD |
282 | try { |
283 | f.scrollTop = 0; | |
284 | } catch (e) { }; | |
e097e8be | 285 | |
acac8448 | 286 | var fi = $("content-insert"); |
17042fc0 | 287 | |
e5ebee09 AD |
288 | try { |
289 | fi.scrollTop = 0; | |
290 | } catch (e) { }; | |
95f67d2e | 291 | |
17042fc0 | 292 | fi.innerHTML = article; |
95f67d2e | 293 | |
51682b23 | 294 | // article.evalScripts(); |
e097e8be AD |
295 | |
296 | } catch (e) { | |
297 | exception_error("render_article", e); | |
298 | } | |
299 | } | |
300 | ||
71d277de | 301 | function showArticleInHeadlines(id) { |
e097e8be | 302 | |
868d0ed2 | 303 | try { |
e097e8be | 304 | |
868d0ed2 | 305 | cleanSelected("headlinesList"); |
71d277de | 306 | |
acac8448 | 307 | var crow = $("RROW-" + id); |
76283a4c AD |
308 | |
309 | if (!crow) return; | |
310 | ||
868d0ed2 AD |
311 | var article_is_unread = crow.className.match("Unread"); |
312 | ||
313 | crow.className = crow.className.replace("Unread", ""); | |
fdcdf2de AD |
314 | |
315 | selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false); | |
fdcdf2de | 316 | |
acac8448 | 317 | var upd_img_pic = $("FUPDPIC-" + id); |
ebda016b | 318 | |
fdcdf2de | 319 | var cache_prefix = ""; |
ebda016b | 320 | |
fdcdf2de AD |
321 | if (activeFeedIsCat()) { |
322 | cache_prefix = "C:"; | |
323 | } else { | |
324 | cache_prefix = "F:"; | |
325 | } | |
11063ec6 AD |
326 | |
327 | var view_mode = false; | |
328 | ||
329 | try { | |
330 | view_mode = document.forms['main_toolbar_form'].view_mode; | |
331 | view_mode = view_mode[view_mode.selectedIndex].value; | |
332 | } catch (e) { | |
273d1e29 | 333 | // |
11063ec6 AD |
334 | } |
335 | ||
784ac51f AD |
336 | if (upd_img_pic && (upd_img_pic.src.match("updated.png") || |
337 | upd_img_pic.src.match("fresh_sign.png"))) { | |
338 | ||
fdcdf2de | 339 | upd_img_pic.src = "images/blank_icon.gif"; |
ebda016b AD |
340 | |
341 | cache_invalidate(cache_prefix + getActiveFeedId()); | |
ce411c4b AD |
342 | |
343 | cache_inject(cache_prefix + getActiveFeedId(), | |
acac8448 | 344 | $("headlines-frame").innerHTML, |
ce411c4b | 345 | get_feed_unread(getActiveFeedId())); |
fdcdf2de | 346 | |
11063ec6 | 347 | } else if (article_is_unread && view_mode == "all_articles") { |
fdcdf2de AD |
348 | |
349 | cache_invalidate(cache_prefix + getActiveFeedId()); | |
350 | ||
351 | cache_inject(cache_prefix + getActiveFeedId(), | |
acac8448 | 352 | $("headlines-frame").innerHTML, |
fdcdf2de AD |
353 | get_feed_unread(getActiveFeedId())-1); |
354 | ||
3de99e6b AD |
355 | } else if (article_is_unread) { |
356 | cache_invalidate(cache_prefix + getActiveFeedId()); | |
868d0ed2 | 357 | } |
e097e8be | 358 | |
4c009c78 AD |
359 | markHeadline(id); |
360 | ||
868d0ed2 AD |
361 | } catch (e) { |
362 | exception_error("showArticleInHeadlines", e); | |
363 | } | |
71d277de | 364 | } |
e097e8be | 365 | |
71d277de AD |
366 | function article_callback2(transport, id, feed_id) { |
367 | try { | |
368 | debug("article_callback2 " + id); | |
e097e8be | 369 | |
9ca945a6 AD |
370 | if (!transport.responseText && db) { |
371 | offlineConfirmModeChange(); | |
372 | return; | |
373 | } | |
374 | ||
71d277de | 375 | if (transport.responseXML) { |
e097e8be | 376 | |
2184738a AD |
377 | if (!transport_error_check(transport)) return; |
378 | ||
b1039124 | 379 | /* var ll = $('LL-' + id); |
6e35a862 AD |
380 | var content = $('HLC-' + id); |
381 | ||
b1039124 | 382 | if (ll && content) content.removeChild(ll); */ |
6e35a862 | 383 | |
b1039124 AD |
384 | var upic = $('FUPDPIC-' + id); |
385 | ||
386 | if (upic) { | |
387 | upic.src = 'images/blank_icon.gif'; | |
388 | } | |
389 | ||
6e35a862 AD |
390 | if (id != last_requested_article) { |
391 | debug("requested article id is out of sequence, aborting"); | |
392 | return; | |
393 | } | |
394 | ||
395 | active_real_feed_id = feed_id; | |
396 | active_post_id = id; | |
397 | ||
fbcabe1e | 398 | debug("looking for articles to cache..."); |
71d277de AD |
399 | |
400 | var articles = transport.responseXML.getElementsByTagName("article"); | |
401 | ||
402 | for (var i = 0; i < articles.length; i++) { | |
403 | var a_id = articles[i].getAttribute("id"); | |
404 | ||
405 | debug("found id: " + a_id); | |
406 | ||
407 | if (a_id == active_post_id) { | |
408 | debug("active article, rendering..."); | |
409 | render_article(articles[i].firstChild.nodeValue); | |
e097e8be | 410 | } |
71d277de AD |
411 | |
412 | cache_inject(a_id, articles[i].firstChild.nodeValue); | |
e097e8be | 413 | } |
fbcabe1e | 414 | |
fbcabe1e AD |
415 | |
416 | showArticleInHeadlines(id); | |
417 | ||
2f71f07b AD |
418 | if (db) { |
419 | db.execute("UPDATE articles SET unread = 0 WHERE id = ?", [id]); | |
420 | } | |
421 | ||
fbcabe1e | 422 | var reply = transport.responseXML.firstChild.firstChild; |
71d277de AD |
423 | |
424 | } else { | |
425 | debug("article_callback: returned no XML object"); | |
acac8448 | 426 | //var f = $("content-frame"); |
17042fc0 | 427 | //f.innerHTML = "<div class='whiteBox'>" + __('Could not display article (missing XML object)') + "</div>"; |
e097e8be | 428 | } |
4b6206fa AD |
429 | |
430 | var date = new Date(); | |
431 | last_article_view = date.getTime() / 1000; | |
432 | ||
935f235d AD |
433 | if (typeof correctPNG != 'undefined') { |
434 | correctPNG(); | |
435 | } | |
0b126ac2 AD |
436 | |
437 | if (_reload_feedlist_after_view) { | |
438 | setTimeout('updateFeedList(false, false)', 50); | |
439 | _reload_feedlist_after_view = false; | |
440 | } else { | |
d63170bf AD |
441 | if (transport.responseXML) { |
442 | var counters = transport.responseXML.getElementsByTagName("counters")[0]; | |
5a94a953 | 443 | |
d63170bf AD |
444 | if (counters) { |
445 | debug("parsing piggybacked counters: " + counters); | |
446 | parse_counters(counters, false); | |
447 | } else { | |
448 | debug("counters container not found in reply, requesting..."); | |
449 | request_counters(); | |
450 | } | |
5a94a953 | 451 | } |
0b126ac2 | 452 | } |
9ec58704 AD |
453 | |
454 | notify(""); | |
71d277de | 455 | } catch (e) { |
273d1e29 | 456 | exception_error("article_callback2", e, transport); |
6b4163cb AD |
457 | } |
458 | } | |
459 | ||
1dc8dba0 | 460 | function view(id, feed_id, skip_history) { |
ee1f45f4 AD |
461 | |
462 | try { | |
ee1f45f4 | 463 | debug("loading article: " + id + "/" + feed_id); |
45a6446d AD |
464 | |
465 | if (offline_mode) return view_offline(id, feed_id); | |
466 | ||
e097e8be AD |
467 | var cached_article = cache_find(id); |
468 | ||
469 | debug("cache check result: " + (cached_article != false)); | |
ee1f45f4 | 470 | |
ee1f45f4 | 471 | enableHotkeys(); |
664306d3 AD |
472 | hideAuxDlg(); |
473 | ||
1c2d7193 | 474 | //setActiveFeedId(feed_id); |
090e250b | 475 | |
6b4163cb AD |
476 | var query = "backend.php?op=view&id=" + param_escape(id) + |
477 | "&feed=" + param_escape(feed_id); | |
478 | ||
4b6206fa AD |
479 | var date = new Date(); |
480 | ||
71d277de | 481 | var neighbor_ids = getRelativePostIds(active_post_id); |
e097e8be | 482 | |
71d277de | 483 | /* only request uncached articles */ |
e097e8be | 484 | |
71d277de | 485 | var cids_to_request = Array(); |
5a94a953 | 486 | |
71d277de AD |
487 | for (var i = 0; i < neighbor_ids.length; i++) { |
488 | if (!cache_check(neighbor_ids[i])) { | |
489 | cids_to_request.push(neighbor_ids[i]); | |
5a94a953 | 490 | } |
71d277de | 491 | } |
5a94a953 | 492 | |
71d277de | 493 | debug("additional ids: " + cids_to_request.toString()); |
e097e8be | 494 | |
71d277de | 495 | /* additional info for piggyback counters */ |
e097e8be | 496 | |
71d277de AD |
497 | if (tagsAreDisplayed()) { |
498 | query = query + "&omode=lt"; | |
499 | } else { | |
500 | query = query + "&omode=flc"; | |
501 | } | |
e097e8be | 502 | |
71d277de AD |
503 | var date = new Date(); |
504 | var timestamp = Math.round(date.getTime() / 1000); | |
505 | query = query + "&ts=" + timestamp; | |
e097e8be | 506 | |
71d277de | 507 | query = query + "&cids=" + cids_to_request.toString(); |
e097e8be | 508 | |
acac8448 | 509 | var crow = $("RROW-" + id); |
71d277de | 510 | var article_is_unread = crow.className.match("Unread"); |
e097e8be | 511 | |
6cc1fab3 AD |
512 | if (!async_counters_work) { |
513 | query = query + "&csync=true"; | |
514 | } | |
515 | ||
3f70f90f AD |
516 | showArticleInHeadlines(id); |
517 | ||
71d277de | 518 | if (!cached_article) { |
e097e8be | 519 | |
6e35a862 AD |
520 | // notify_progress("Loading, please wait...", true); |
521 | ||
b1039124 | 522 | /* var content = $('HLC-' + id); |
6e35a862 AD |
523 | |
524 | if (content && !$('LL-' + id)) { | |
525 | var ll = document.createElement('img'); | |
526 | ||
527 | ll.src = 'images/indicator_tiny.gif'; | |
528 | ll.className = 'hlLoading'; | |
529 | ll.id = 'LL-' + id; | |
530 | ||
531 | content.appendChild(ll); | |
532 | ||
b1039124 AD |
533 | } */ |
534 | ||
535 | var upic = $('FUPDPIC-' + id); | |
536 | ||
537 | if (upic) { | |
538 | upic.src = 'images/indicator_white.gif'; | |
6e35a862 | 539 | } |
e097e8be | 540 | |
71d277de | 541 | } else if (cached_article && article_is_unread) { |
addb5836 | 542 | |
71d277de | 543 | query = query + "&mode=prefetch"; |
addb5836 | 544 | |
71d277de | 545 | render_article(cached_article); |
addb5836 | 546 | |
71d277de | 547 | } else if (cached_article) { |
e097e8be | 548 | |
71d277de AD |
549 | query = query + "&mode=prefetch_old"; |
550 | render_article(cached_article); | |
997d9d7c | 551 | |
71d277de | 552 | } |
e097e8be | 553 | |
71d277de | 554 | cache_expire(); |
86173d9a | 555 | |
022d9e9e AD |
556 | last_requested_article = id; |
557 | ||
71d277de AD |
558 | new Ajax.Request(query, { |
559 | onComplete: function(transport) { | |
560 | article_callback2(transport, id, feed_id); | |
561 | } }); | |
6b4163cb | 562 | |
a7764e51 AD |
563 | return false; |
564 | ||
ee1f45f4 AD |
565 | } catch (e) { |
566 | exception_error("view", e); | |
567 | } | |
f0601b87 AD |
568 | } |
569 | ||
67343d9f AD |
570 | function tMark(id) { |
571 | return toggleMark(id); | |
572 | } | |
573 | ||
e4f4b46f AD |
574 | function tPub(id) { |
575 | return togglePub(id); | |
576 | } | |
577 | ||
6b0f49f9 AD |
578 | function tMark_afh_off(effect) { |
579 | try { | |
580 | var elem = effect.effects[0].element; | |
581 | ||
582 | debug("tMark_afh_off : " + elem.id); | |
583 | ||
584 | if (elem) { | |
f5e0338d AD |
585 | elem.src = elem.src.replace("mark_set", "mark_unset"); |
586 | elem.alt = __("Star article"); | |
6b0f49f9 AD |
587 | Element.show(elem); |
588 | } | |
589 | ||
590 | } catch (e) { | |
591 | exception_error("tMark_afh_off", e); | |
592 | } | |
593 | } | |
594 | ||
595 | function tPub_afh_off(effect) { | |
596 | try { | |
597 | var elem = effect.effects[0].element; | |
598 | ||
599 | debug("tPub_afh_off : " + elem.id); | |
600 | ||
601 | if (elem) { | |
f5e0338d AD |
602 | elem.src = elem.src.replace("pub_set", "pub_unset"); |
603 | elem.alt = __("Publish article"); | |
6b0f49f9 AD |
604 | Element.show(elem); |
605 | } | |
606 | ||
607 | } catch (e) { | |
608 | exception_error("tPub_afh_off", e); | |
609 | } | |
610 | } | |
e4f4b46f | 611 | |
f5e0338d | 612 | function toggleMark(id, client_only, no_effects) { |
f0601b87 | 613 | |
b685ba25 | 614 | try { |
254e0e4b | 615 | |
b685ba25 AD |
616 | var query = "backend.php?op=rpc&id=" + id + "&subop=mark"; |
617 | ||
618 | query = query + "&afid=" + getActiveFeedId(); | |
619 | ||
620 | if (tagsAreDisplayed()) { | |
621 | query = query + "&omode=tl"; | |
622 | } else { | |
623 | query = query + "&omode=flc"; | |
7ba176d2 | 624 | } |
b685ba25 | 625 | |
acac8448 | 626 | var mark_img = $("FMPIC-" + id); |
56ff7564 AD |
627 | |
628 | if (!mark_img) return; | |
629 | ||
acac8448 AD |
630 | var vfeedu = $("FEEDU--1"); |
631 | var crow = $("RROW-" + id); | |
b685ba25 | 632 | |
f5e0338d AD |
633 | if (mark_img.src.match("mark_unset")) { |
634 | mark_img.src = mark_img.src.replace("mark_unset", "mark_set"); | |
635 | mark_img.alt = __("Unstar article"); | |
b685ba25 | 636 | query = query + "&mark=1"; |
ee8768db | 637 | |
2f71f07b AD |
638 | if (db) { |
639 | db.execute("UPDATE articles SET marked = 1 WHERE id = ?", [id]); | |
640 | } | |
641 | ||
b685ba25 AD |
642 | } else { |
643 | //mark_img.src = "images/mark_unset.png"; | |
f5e0338d | 644 | mark_img.alt = __("Please wait..."); |
b685ba25 AD |
645 | query = query + "&mark=0"; |
646 | ||
acac8448 | 647 | if ($("headlinesList") && !no_effects) { |
b685ba25 AD |
648 | Effect.Puff(mark_img, {duration : 0.25, afterFinish: tMark_afh_off}); |
649 | } else { | |
f5e0338d AD |
650 | mark_img.src = mark_img.src.replace("mark_set", "mark_unset"); |
651 | mark_img.alt = __("Star article"); | |
b685ba25 | 652 | } |
2f71f07b AD |
653 | |
654 | if (db) { | |
655 | db.execute("UPDATE articles SET marked = 0 WHERE id = ?", [id]); | |
656 | } | |
657 | ||
ace1a6da | 658 | } |
772bc83b | 659 | |
46b84d29 | 660 | if (!no_effects) update_local_feedlist_counters(); |
c8a9fe5b | 661 | |
f5e0338d AD |
662 | if (!client_only) { |
663 | debug(query); | |
36e05046 | 664 | |
1341ea0d AD |
665 | new Ajax.Request(query, { |
666 | onComplete: function(transport) { | |
667 | all_counters_callback2(transport); | |
668 | } }); | |
669 | ||
f5e0338d | 670 | } |
f0601b87 | 671 | |
b685ba25 AD |
672 | } catch (e) { |
673 | exception_error("toggleMark", e); | |
674 | } | |
f0601b87 AD |
675 | } |
676 | ||
c7e51de1 | 677 | function togglePub(id, client_only, no_effects, note) { |
e4f4b46f | 678 | |
2bc2147f | 679 | try { |
e4f4b46f | 680 | |
2bc2147f AD |
681 | var query = "backend.php?op=rpc&id=" + id + "&subop=publ"; |
682 | ||
683 | query = query + "&afid=" + getActiveFeedId(); | |
c7e51de1 AD |
684 | |
685 | if (note != undefined) { | |
686 | query = query + "¬e=" + param_escape(note); | |
687 | } else { | |
688 | query = query + "¬e=undefined"; | |
689 | } | |
2bc2147f AD |
690 | |
691 | if (tagsAreDisplayed()) { | |
692 | query = query + "&omode=tl"; | |
693 | } else { | |
694 | query = query + "&omode=flc"; | |
e4f4b46f | 695 | } |
2bc2147f | 696 | |
acac8448 | 697 | var mark_img = $("FPPIC-" + id); |
56ff7564 AD |
698 | |
699 | if (!mark_img) return; | |
700 | ||
acac8448 AD |
701 | var vfeedu = $("FEEDU--2"); |
702 | var crow = $("RROW-" + id); | |
2bc2147f | 703 | |
c7e51de1 | 704 | if (mark_img.src.match("pub_unset") || note != undefined) { |
f5e0338d AD |
705 | mark_img.src = mark_img.src.replace("pub_unset", "pub_set"); |
706 | mark_img.alt = __("Unpublish article"); | |
2bc2147f | 707 | query = query + "&pub=1"; |
ee8768db | 708 | |
e4f4b46f | 709 | } else { |
6b0f49f9 | 710 | //mark_img.src = "images/pub_unset.png"; |
f5e0338d | 711 | mark_img.alt = __("Please wait..."); |
2bc2147f AD |
712 | query = query + "&pub=0"; |
713 | ||
acac8448 | 714 | if ($("headlinesList") && !no_effects) { |
ace1a6da AD |
715 | Effect.Puff(mark_img, {duration : 0.25, afterFinish: tPub_afh_off}); |
716 | } else { | |
f5e0338d AD |
717 | mark_img.src = mark_img.src.replace("pub_set", "pub_unset"); |
718 | mark_img.alt = __("Publish article"); | |
ace1a6da | 719 | } |
e4f4b46f | 720 | } |
b685ba25 | 721 | |
f5e0338d | 722 | if (!client_only) { |
1341ea0d AD |
723 | new Ajax.Request(query, { |
724 | onComplete: function(transport) { | |
c7e51de1 | 725 | toggle_published_callback(transport); |
1341ea0d | 726 | } }); |
f5e0338d | 727 | } |
b685ba25 | 728 | |
2bc2147f | 729 | } catch (e) { |
e4f4b46f | 730 | |
2bc2147f AD |
731 | exception_error("togglePub", e); |
732 | } | |
e4f4b46f AD |
733 | } |
734 | ||
ac162cbe AD |
735 | function correctHeadlinesOffset(id) { |
736 | ||
737 | try { | |
738 | ||
acac8448 AD |
739 | var hlist = $("headlinesList"); |
740 | var container = $("headlinesInnerContainer"); | |
741 | var row = $("RROW-" + id); | |
ac162cbe AD |
742 | |
743 | var viewport = container.offsetHeight; | |
744 | ||
745 | var rel_offset_top = row.offsetTop - container.scrollTop; | |
746 | var rel_offset_bottom = row.offsetTop + row.offsetHeight - container.scrollTop; | |
747 | ||
748 | debug("Rtop: " + rel_offset_top + " Rbtm: " + rel_offset_bottom); | |
749 | debug("Vport: " + viewport); | |
a5e46e0f | 750 | |
ac162cbe AD |
751 | if (rel_offset_top <= 0 || rel_offset_top > viewport) { |
752 | container.scrollTop = row.offsetTop; | |
753 | } else if (rel_offset_bottom > viewport) { | |
a5e46e0f AD |
754 | |
755 | /* doesn't properly work with Opera in some cases because | |
756 | Opera fucks up element scrolling */ | |
757 | ||
ac162cbe AD |
758 | container.scrollTop = row.offsetTop + row.offsetHeight - viewport; |
759 | } | |
760 | ||
761 | } catch (e) { | |
762 | exception_error("correctHeadlinesOffset", e); | |
763 | } | |
764 | ||
765 | } | |
766 | ||
bb7cface | 767 | function moveToPost(mode) { |
f0601b87 | 768 | |
b8e6acea AD |
769 | try { |
770 | ||
5ad9d132 AD |
771 | var rows; |
772 | ||
773 | if (isCdmMode()) { | |
774 | rows = cdmGetVisibleArticles(); | |
775 | } else { | |
776 | rows = getVisibleHeadlineIds(); | |
777 | } | |
b8e6acea | 778 | |
5ad9d132 AD |
779 | var prev_id = false; |
780 | var next_id = false; | |
b8e6acea | 781 | |
acac8448 | 782 | if (!$('RROW-' + active_post_id)) { |
5ad9d132 AD |
783 | active_post_id = false; |
784 | } | |
b8e6acea | 785 | |
5ad9d132 AD |
786 | if (active_post_id == false) { |
787 | next_id = getFirstVisibleHeadlineId(); | |
788 | prev_id = getLastVisibleHeadlineId(); | |
789 | } else { | |
790 | for (var i = 0; i < rows.length; i++) { | |
791 | if (rows[i] == active_post_id) { | |
792 | prev_id = rows[i-1]; | |
793 | next_id = rows[i+1]; | |
b8e6acea AD |
794 | } |
795 | } | |
5ad9d132 | 796 | } |
b8e6acea | 797 | |
5ad9d132 AD |
798 | if (mode == "next") { |
799 | if (next_id) { | |
800 | if (isCdmMode()) { | |
801 | ||
802 | if (!cdmArticleIsActuallyVisible(next_id)) { | |
803 | cdmScrollToArticleId(next_id); | |
804 | } | |
805 | cdmSelectArticles("none"); | |
806 | toggleUnread(next_id, 0, true); | |
807 | toggleSelected(next_id); | |
808 | ||
809 | } else { | |
b8e6acea AD |
810 | correctHeadlinesOffset(next_id); |
811 | view(next_id, getActiveFeedId()); | |
812 | } | |
813 | } | |
5ad9d132 | 814 | } |
b8e6acea | 815 | |
5ad9d132 AD |
816 | if (mode == "prev") { |
817 | if (prev_id) { | |
818 | if (isCdmMode()) { | |
819 | cdmScrollToArticleId(prev_id); | |
820 | cdmSelectArticles("none"); | |
821 | toggleUnread(prev_id, 0, true); | |
822 | toggleSelected(prev_id); | |
823 | } else { | |
b8e6acea AD |
824 | correctHeadlinesOffset(prev_id); |
825 | view(prev_id, getActiveFeedId()); | |
826 | } | |
5ad9d132 AD |
827 | } |
828 | } | |
829 | ||
b8e6acea | 830 | } catch (e) { |
438f2ce9 | 831 | exception_error("moveToPost", e); |
bb7cface | 832 | } |
b8e6acea AD |
833 | } |
834 | ||
835 | function toggleSelected(id) { | |
836 | try { | |
837 | ||
acac8448 | 838 | var cb = $("RCHK-" + id); |
5ad9d132 | 839 | |
acac8448 | 840 | var row = $("RROW-" + id); |
b8e6acea AD |
841 | if (row) { |
842 | var nc = row.className; | |
843 | ||
844 | if (!nc.match("Selected")) { | |
845 | nc = nc + "Selected"; | |
5ad9d132 AD |
846 | if (cb) { |
847 | cb.checked = true; | |
848 | } | |
849 | ||
850 | // In CDM basically last selected article == active article | |
851 | if (isCdmMode()) active_post_id = id; | |
b8e6acea AD |
852 | } else { |
853 | nc = nc.replace("Selected", ""); | |
5ad9d132 AD |
854 | if (cb) { |
855 | cb.checked = false; | |
856 | } | |
857 | ||
b8e6acea | 858 | } |
bb7cface | 859 | |
b8e6acea | 860 | row.className = nc; |
bb7cface | 861 | } |
b8e6acea | 862 | } catch (e) { |
438f2ce9 | 863 | exception_error("toggleSelected", e); |
b8e6acea | 864 | } |
bb7cface AD |
865 | } |
866 | ||
0df009c3 | 867 | function toggleUnread_afh(effect) { |
b8e6acea AD |
868 | try { |
869 | ||
870 | var elem = effect.element; | |
0df009c3 | 871 | elem.style.backgroundColor = ""; |
b8e6acea | 872 | |
b8e6acea | 873 | } catch (e) { |
438f2ce9 | 874 | exception_error("toggleUnread_afh", e); |
b8e6acea | 875 | } |
0df009c3 | 876 | } |
b8e6acea AD |
877 | |
878 | function toggleUnread(id, cmode, effect) { | |
5f51022a | 879 | try { |
5f51022a | 880 | |
acac8448 | 881 | var row = $("RROW-" + id); |
5f51022a AD |
882 | if (row) { |
883 | var nc = row.className; | |
93f66472 | 884 | var is_selected = row.className.match("Selected"); |
5f51022a AD |
885 | nc = nc.replace("Unread", ""); |
886 | nc = nc.replace("Selected", ""); | |
887 | ||
b8e6acea AD |
888 | // since we are removing selection from the object, uncheck |
889 | // corresponding checkbox | |
890 | ||
acac8448 | 891 | var cb = $("RCHK-" + id); |
b8e6acea AD |
892 | if (cb) { |
893 | cb.checked = false; | |
894 | } | |
895 | ||
896 | // NOTE: I'm not sure that resetting selection here is a feature -fox | |
897 | ||
a70ab740 AD |
898 | if (cmode == undefined || cmode == 2) { |
899 | if (row.className.match("Unread")) { | |
900 | row.className = nc; | |
b8e6acea | 901 | |
0df009c3 | 902 | if (effect) { |
b8e6acea AD |
903 | new Effect.Highlight(row, {duration: 1, startcolor: "#fff7d5", |
904 | afterFinish: toggleUnread_afh, | |
905 | queue: { position:'end', scope: 'TMRQ-' + id, limit: 1 } } ); | |
0df009c3 | 906 | } |
b8e6acea | 907 | |
a70ab740 AD |
908 | } else { |
909 | row.className = nc + "Unread"; | |
910 | } | |
1a003258 AD |
911 | |
912 | if (db) { | |
913 | db.execute("UPDATE articles SET unread = not unread "+ | |
914 | "WHERE id = ?", [id]); | |
915 | } | |
916 | ||
a70ab740 | 917 | } else if (cmode == 0) { |
5f51022a | 918 | row.className = nc; |
b8e6acea | 919 | |
54eb7d20 | 920 | if (effect) { |
b8e6acea | 921 | new Effect.Highlight(row, {duration: 1, startcolor: "#fff7d5", |
54eb7d20 | 922 | afterFinish: toggleUnread_afh, |
b8e6acea | 923 | queue: { position:'end', scope: 'TMRQ-' + id, limit: 1 } } ); |
54eb7d20 | 924 | } |
1a003258 AD |
925 | |
926 | if (db) { | |
927 | db.execute("UPDATE articles SET unread = 0 "+ | |
928 | "WHERE id = ?", [id]); | |
929 | } | |
930 | ||
a70ab740 | 931 | } else if (cmode == 1) { |
5f51022a | 932 | row.className = nc + "Unread"; |
1a003258 AD |
933 | |
934 | if (db) { | |
935 | db.execute("UPDATE articles SET unread = 1 "+ | |
936 | "WHERE id = ?", [id]); | |
937 | } | |
938 | ||
5f51022a AD |
939 | } |
940 | ||
1a003258 AD |
941 | update_local_feedlist_counters(); |
942 | ||
93f66472 AD |
943 | // Disable unmarking as selected for the time being (16.05.08) -fox |
944 | if (is_selected) row.className = row.className + "Selected"; | |
945 | ||
a70ab740 | 946 | if (cmode == undefined) cmode = 2; |
5f51022a | 947 | |
2855ee88 AD |
948 | var query = "backend.php?op=rpc&subop=catchupSelected" + |
949 | "&cmode=" + param_escape(cmode); | |
950 | ||
951 | var ids = "?ids=" + param_escape(id); | |
5f51022a | 952 | |
1341ea0d | 953 | // notify_progress("Loading, please wait..."); |
9ec58704 | 954 | |
1341ea0d | 955 | new Ajax.Request(query, { |
2855ee88 | 956 | parameters: ids, |
1341ea0d AD |
957 | onComplete: function(transport) { |
958 | all_counters_callback2(transport); | |
959 | } }); | |
5f51022a AD |
960 | |
961 | } | |
962 | ||
5f51022a AD |
963 | } catch (e) { |
964 | exception_error("toggleUnread", e); | |
965 | } | |
966 | } | |
967 | ||
933ba4ee AD |
968 | function selectionRemoveLabel(id) { |
969 | try { | |
970 | ||
971 | var ids = getSelectedArticleIds2(); | |
972 | ||
973 | if (ids.length == 0) { | |
974 | alert(__("No articles are selected.")); | |
975 | return; | |
976 | } | |
977 | ||
37843d70 | 978 | // var ok = confirm(__("Remove selected articles from label?")); |
933ba4ee | 979 | |
37843d70 | 980 | // if (ok) { |
933ba4ee AD |
981 | |
982 | var query = "backend.php?op=rpc&subop=removeFromLabel&ids=" + | |
983 | param_escape(ids.toString()) + "&lid=" + param_escape(id); | |
984 | ||
985 | // notify_progress("Loading, please wait..."); | |
986 | ||
898e8562 AD |
987 | cache_invalidate("F:" + (-11 - id)); |
988 | ||
933ba4ee AD |
989 | new Ajax.Request(query, { |
990 | onComplete: function(transport) { | |
1c9c6025 AD |
991 | show_labels_in_headlines(transport); |
992 | all_counters_callback2(transport); | |
933ba4ee AD |
993 | } }); |
994 | ||
37843d70 | 995 | // } |
933ba4ee AD |
996 | |
997 | } catch (e) { | |
998 | exception_error("selectionAssignLabel", e); | |
999 | ||
1000 | } | |
1001 | } | |
1002 | ||
b8a637f3 AD |
1003 | function selectionAssignLabel(id) { |
1004 | try { | |
1005 | ||
1006 | var ids = getSelectedArticleIds2(); | |
1007 | ||
1008 | if (ids.length == 0) { | |
1009 | alert(__("No articles are selected.")); | |
1010 | return; | |
1011 | } | |
1012 | ||
37843d70 | 1013 | // var ok = confirm(__("Assign selected articles to label?")); |
b8a637f3 | 1014 | |
37843d70 | 1015 | // if (ok) { |
b8a637f3 | 1016 | |
898e8562 AD |
1017 | cache_invalidate("F:" + (-11 - id)); |
1018 | ||
b8a637f3 AD |
1019 | var query = "backend.php?op=rpc&subop=assignToLabel&ids=" + |
1020 | param_escape(ids.toString()) + "&lid=" + param_escape(id); | |
1021 | ||
1022 | // notify_progress("Loading, please wait..."); | |
1023 | ||
1024 | new Ajax.Request(query, { | |
1025 | onComplete: function(transport) { | |
f9247195 AD |
1026 | show_labels_in_headlines(transport); |
1027 | all_counters_callback2(transport); | |
b8a637f3 AD |
1028 | } }); |
1029 | ||
37843d70 | 1030 | // } |
b8a637f3 AD |
1031 | |
1032 | } catch (e) { | |
1033 | exception_error("selectionAssignLabel", e); | |
1034 | ||
1035 | } | |
1036 | } | |
1037 | ||
2228d0e4 | 1038 | function selectionToggleUnread(cdm_mode, set_state, callback_func, no_error) { |
1572afe5 | 1039 | try { |
386cbf27 AD |
1040 | var rows; |
1041 | ||
1042 | if (cdm_mode) { | |
1043 | rows = cdmGetSelectedArticles(); | |
1044 | } else { | |
1045 | rows = getSelectedTableRowIds("headlinesList", "RROW", "RCHK"); | |
1046 | } | |
1572afe5 | 1047 | |
2228d0e4 | 1048 | if (rows.length == 0 && !no_error) { |
9cc600d1 AD |
1049 | alert(__("No articles are selected.")); |
1050 | return; | |
1051 | } | |
1052 | ||
1572afe5 | 1053 | for (i = 0; i < rows.length; i++) { |
acac8448 | 1054 | var row = $("RROW-" + rows[i]); |
f1f2db64 AD |
1055 | if (row) { |
1056 | var nc = row.className; | |
1057 | nc = nc.replace("Unread", ""); | |
1058 | nc = nc.replace("Selected", ""); | |
1059 | ||
a5ae125a AD |
1060 | if (set_state == undefined) { |
1061 | if (row.className.match("Unread")) { | |
1062 | row.className = nc + "Selected"; | |
1063 | } else { | |
1064 | row.className = nc + "UnreadSelected"; | |
1065 | } | |
46b84d29 AD |
1066 | if (db) { |
1067 | db.execute("UPDATE articles SET unread = NOT unread WHERE id = ?", | |
1068 | [rows[i]]); | |
1069 | } | |
a5ae125a AD |
1070 | } |
1071 | ||
1072 | if (set_state == false) { | |
f1f2db64 | 1073 | row.className = nc + "Selected"; |
46b84d29 AD |
1074 | if (db) { |
1075 | db.execute("UPDATE articles SET unread = 0 WHERE id = ?", | |
1076 | [rows[i]]); | |
1077 | } | |
a5ae125a AD |
1078 | } |
1079 | ||
1080 | if (set_state == true) { | |
f1f2db64 | 1081 | row.className = nc + "UnreadSelected"; |
46b84d29 AD |
1082 | if (db) { |
1083 | db.execute("UPDATE articles SET unread = 1 WHERE id = ?", | |
1084 | [rows[i]]); | |
1085 | } | |
f1f2db64 AD |
1086 | } |
1087 | } | |
1572afe5 AD |
1088 | } |
1089 | ||
1090 | if (rows.length > 0) { | |
1091 | ||
46b84d29 AD |
1092 | update_local_feedlist_counters(); |
1093 | ||
b47b5af7 AD |
1094 | var cmode = ""; |
1095 | ||
1096 | if (set_state == undefined) { | |
1097 | cmode = "2"; | |
1098 | } else if (set_state == true) { | |
1099 | cmode = "1"; | |
1100 | } else if (set_state == false) { | |
1101 | cmode = "0"; | |
1102 | } | |
1103 | ||
2855ee88 AD |
1104 | var query = "backend.php?op=rpc&subop=catchupSelected" + |
1105 | "&cmode=" + cmode; | |
1106 | ||
1107 | var ids = "?ids=" + param_escape(rows.toString()); | |
1572afe5 | 1108 | |
9ec58704 AD |
1109 | notify_progress("Loading, please wait..."); |
1110 | ||
1341ea0d | 1111 | new Ajax.Request(query, { |
2855ee88 | 1112 | parameters: ids, |
1341ea0d AD |
1113 | onComplete: function(transport) { |
1114 | catchup_callback2(transport, callback_func); | |
1115 | } }); | |
1572afe5 AD |
1116 | |
1117 | } | |
1118 | ||
1119 | } catch (e) { | |
83f043bb | 1120 | exception_error("selectionToggleUnread", e); |
1572afe5 AD |
1121 | } |
1122 | } | |
1123 | ||
386cbf27 | 1124 | function selectionToggleMarked(cdm_mode) { |
1572afe5 | 1125 | try { |
1572afe5 | 1126 | |
386cbf27 AD |
1127 | var rows; |
1128 | ||
1129 | if (cdm_mode) { | |
1130 | rows = cdmGetSelectedArticles(); | |
1131 | } else { | |
1132 | rows = getSelectedTableRowIds("headlinesList", "RROW", "RCHK"); | |
1133 | } | |
1572afe5 | 1134 | |
9cc600d1 AD |
1135 | if (rows.length == 0) { |
1136 | alert(__("No articles are selected.")); | |
1137 | return; | |
1138 | } | |
1139 | ||
1572afe5 | 1140 | for (i = 0; i < rows.length; i++) { |
f5e0338d | 1141 | toggleMark(rows[i], true, true); |
1572afe5 AD |
1142 | } |
1143 | ||
46b84d29 AD |
1144 | update_local_feedlist_counters(); |
1145 | ||
1572afe5 AD |
1146 | if (rows.length > 0) { |
1147 | ||
1148 | var query = "backend.php?op=rpc&subop=markSelected&ids=" + | |
1149 | param_escape(rows.toString()) + "&cmode=2"; | |
1150 | ||
2bc2147f AD |
1151 | query = query + "&afid=" + getActiveFeedId(); |
1152 | ||
1341ea0d | 1153 | /* if (tagsAreDisplayed()) { |
2bc2147f AD |
1154 | query = query + "&omode=tl"; |
1155 | } else { | |
1156 | query = query + "&omode=flc"; | |
1341ea0d AD |
1157 | } */ |
1158 | ||
1159 | query = query + "&omode=lc"; | |
2bc2147f | 1160 | |
1341ea0d AD |
1161 | new Ajax.Request(query, { |
1162 | onComplete: function(transport) { | |
1163 | all_counters_callback2(transport); | |
1164 | } }); | |
1572afe5 AD |
1165 | |
1166 | } | |
1167 | ||
1168 | } catch (e) { | |
83f043bb | 1169 | exception_error("selectionToggleMarked", e); |
1572afe5 AD |
1170 | } |
1171 | } | |
1172 | ||
e4f4b46f AD |
1173 | function selectionTogglePublished(cdm_mode) { |
1174 | try { | |
e4f4b46f AD |
1175 | |
1176 | var rows; | |
1177 | ||
1178 | if (cdm_mode) { | |
1179 | rows = cdmGetSelectedArticles(); | |
1180 | } else { | |
1181 | rows = getSelectedTableRowIds("headlinesList", "RROW", "RCHK"); | |
1182 | } | |
1183 | ||
1184 | if (rows.length == 0) { | |
1185 | alert(__("No articles are selected.")); | |
1186 | return; | |
1187 | } | |
1188 | ||
1189 | for (i = 0; i < rows.length; i++) { | |
f5e0338d | 1190 | togglePub(rows[i], true, true); |
e4f4b46f AD |
1191 | } |
1192 | ||
1193 | if (rows.length > 0) { | |
1194 | ||
1195 | var query = "backend.php?op=rpc&subop=publishSelected&ids=" + | |
1196 | param_escape(rows.toString()) + "&cmode=2"; | |
1197 | ||
2bc2147f AD |
1198 | query = query + "&afid=" + getActiveFeedId(); |
1199 | ||
1341ea0d | 1200 | /* if (tagsAreDisplayed()) { |
2bc2147f AD |
1201 | query = query + "&omode=tl"; |
1202 | } else { | |
1203 | query = query + "&omode=flc"; | |
1341ea0d AD |
1204 | } */ |
1205 | ||
1206 | query = query + "&omode=lc"; | |
2bc2147f | 1207 | |
1341ea0d AD |
1208 | new Ajax.Request(query, { |
1209 | onComplete: function(transport) { | |
1210 | all_counters_callback2(transport); | |
1211 | } }); | |
e4f4b46f AD |
1212 | |
1213 | } | |
1214 | ||
1215 | } catch (e) { | |
1216 | exception_error("selectionToggleMarked", e); | |
1217 | } | |
1218 | } | |
1219 | ||
386cbf27 AD |
1220 | function cdmGetSelectedArticles() { |
1221 | var sel_articles = new Array(); | |
acac8448 | 1222 | var container = $("headlinesInnerContainer"); |
386cbf27 AD |
1223 | |
1224 | for (i = 0; i < container.childNodes.length; i++) { | |
1225 | var child = container.childNodes[i]; | |
1226 | ||
02895941 | 1227 | if (child.id && child.id.match("RROW-") && child.className.match("Selected")) { |
386cbf27 AD |
1228 | var c_id = child.id.replace("RROW-", ""); |
1229 | sel_articles.push(c_id); | |
1230 | } | |
1231 | } | |
1232 | ||
1233 | return sel_articles; | |
1234 | } | |
1235 | ||
8be83f42 AD |
1236 | function cdmGetVisibleArticles() { |
1237 | var sel_articles = new Array(); | |
acac8448 | 1238 | var container = $("headlinesInnerContainer"); |
8be83f42 | 1239 | |
3a40e8a2 AD |
1240 | if (!container) return sel_articles; |
1241 | ||
8be83f42 AD |
1242 | for (i = 0; i < container.childNodes.length; i++) { |
1243 | var child = container.childNodes[i]; | |
1244 | ||
02895941 | 1245 | if (child.id && child.id.match("RROW-")) { |
8be83f42 AD |
1246 | var c_id = child.id.replace("RROW-", ""); |
1247 | sel_articles.push(c_id); | |
1248 | } | |
1249 | } | |
1250 | ||
1251 | return sel_articles; | |
1252 | } | |
1253 | ||
1254 | function cdmGetUnreadArticles() { | |
1255 | var sel_articles = new Array(); | |
acac8448 | 1256 | var container = $("headlinesInnerContainer"); |
8be83f42 AD |
1257 | |
1258 | for (i = 0; i < container.childNodes.length; i++) { | |
1259 | var child = container.childNodes[i]; | |
1260 | ||
02895941 | 1261 | if (child.id && child.id.match("RROW-") && child.className.match("Unread")) { |
8be83f42 AD |
1262 | var c_id = child.id.replace("RROW-", ""); |
1263 | sel_articles.push(c_id); | |
1264 | } | |
1265 | } | |
1266 | ||
1267 | return sel_articles; | |
1268 | } | |
1269 | ||
1270 | ||
386cbf27 AD |
1271 | // mode = all,none,unread |
1272 | function cdmSelectArticles(mode) { | |
acac8448 | 1273 | var container = $("headlinesInnerContainer"); |
386cbf27 AD |
1274 | |
1275 | for (i = 0; i < container.childNodes.length; i++) { | |
1276 | var child = container.childNodes[i]; | |
1277 | ||
02895941 | 1278 | if (child.id && child.id.match("RROW-")) { |
06d1a1c1 AD |
1279 | var aid = child.id.replace("RROW-", ""); |
1280 | ||
acac8448 | 1281 | var cb = $("RCHK-" + aid); |
06d1a1c1 | 1282 | |
386cbf27 AD |
1283 | if (mode == "all") { |
1284 | if (!child.className.match("Selected")) { | |
1285 | child.className = child.className + "Selected"; | |
06d1a1c1 | 1286 | cb.checked = true; |
386cbf27 AD |
1287 | } |
1288 | } else if (mode == "unread") { | |
1289 | if (child.className.match("Unread") && !child.className.match("Selected")) { | |
1290 | child.className = child.className + "Selected"; | |
06d1a1c1 | 1291 | cb.checked = true; |
386cbf27 AD |
1292 | } |
1293 | } else { | |
1294 | child.className = child.className.replace("Selected", ""); | |
06d1a1c1 | 1295 | cb.checked = false; |
386cbf27 AD |
1296 | } |
1297 | } | |
1298 | } | |
1299 | } | |
1300 | ||
98bea1b1 | 1301 | function catchupPage() { |
b47b5af7 | 1302 | |
3d72bbdb | 1303 | var fn = getFeedName(getActiveFeedId(), activeFeedIsCat()); |
8a5b4579 | 1304 | |
a5ae125a AD |
1305 | var str = __("Mark all visible articles in %s as read?"); |
1306 | ||
1307 | str = str.replace("%s", fn); | |
8a5b4579 AD |
1308 | |
1309 | if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str)) { | |
1310 | return; | |
1311 | } | |
1312 | ||
acac8448 | 1313 | if ($("headlinesList")) { |
b47b5af7 | 1314 | selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', true, 'Unread', true); |
2228d0e4 | 1315 | selectionToggleUnread(false, false, 'viewCurrentFeed()', true); |
b47b5af7 AD |
1316 | selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false); |
1317 | } else { | |
1318 | cdmSelectArticles('all'); | |
2228d0e4 | 1319 | selectionToggleUnread(true, false, 'viewCurrentFeed()', true) |
b47b5af7 AD |
1320 | cdmSelectArticles('none'); |
1321 | } | |
98bea1b1 AD |
1322 | } |
1323 | ||
e04c18a2 AD |
1324 | function deleteSelection() { |
1325 | ||
1326 | try { | |
1327 | ||
1328 | var rows; | |
1329 | ||
1330 | if ($("headlinesList")) { | |
1331 | rows = getSelectedTableRowIds("headlinesList", "RROW", "RCHK"); | |
1332 | } else { | |
1333 | rows = cdmGetSelectedArticles(); | |
1334 | } | |
1335 | ||
1336 | if (rows.length == 0) { | |
1337 | alert(__("No articles are selected.")); | |
1338 | return; | |
1339 | } | |
1340 | ||
1341 | ||
1342 | var fn = getFeedName(getActiveFeedId(), activeFeedIsCat()); | |
1343 | var str; | |
1344 | var op; | |
1345 | ||
1346 | if (getActiveFeedId() != 0) { | |
1347 | str = __("Delete %d selected articles in %s?"); | |
1348 | } else { | |
1349 | str = __("Delete %d selected articles?"); | |
1350 | } | |
1351 | ||
1352 | str = str.replace("%d", rows.length); | |
1353 | str = str.replace("%s", fn); | |
1354 | ||
1355 | if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str)) { | |
1356 | return; | |
1357 | } | |
1358 | ||
1359 | query = "backend.php?op=rpc&subop=delete&ids=" + param_escape(rows); | |
1360 | ||
1361 | debug(query); | |
1362 | ||
1363 | new Ajax.Request(query, { | |
1364 | onComplete: function(transport) { | |
1365 | viewCurrentFeed(); | |
1366 | } }); | |
1367 | ||
1368 | } catch (e) { | |
1369 | exception_error("archiveSelection", e); | |
1370 | } | |
1371 | } | |
1372 | ||
1373 | function archiveSelection() { | |
1374 | ||
1375 | try { | |
1376 | ||
1377 | var rows; | |
1378 | ||
1379 | if ($("headlinesList")) { | |
1380 | rows = getSelectedTableRowIds("headlinesList", "RROW", "RCHK"); | |
1381 | } else { | |
1382 | rows = cdmGetSelectedArticles(); | |
1383 | } | |
1384 | ||
1385 | if (rows.length == 0) { | |
1386 | alert(__("No articles are selected.")); | |
1387 | return; | |
1388 | } | |
1389 | ||
1390 | ||
1391 | var fn = getFeedName(getActiveFeedId(), activeFeedIsCat()); | |
1392 | var str; | |
1393 | var op; | |
1394 | ||
1395 | if (getActiveFeedId() != 0) { | |
1396 | str = __("Archive %d selected articles in %s?"); | |
1397 | op = "archive"; | |
1398 | } else { | |
1399 | str = __("Move %d archived articles back?"); | |
1400 | op = "unarchive"; | |
1401 | } | |
1402 | ||
1403 | str = str.replace("%d", rows.length); | |
1404 | str = str.replace("%s", fn); | |
1405 | ||
1406 | if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str)) { | |
1407 | return; | |
1408 | } | |
1409 | ||
1410 | query = "backend.php?op=rpc&subop="+op+"&ids=" + param_escape(rows); | |
1411 | ||
1412 | debug(query); | |
1413 | ||
1414 | new Ajax.Request(query, { | |
1415 | onComplete: function(transport) { | |
1416 | viewCurrentFeed(); | |
1417 | } }); | |
1418 | ||
1419 | } catch (e) { | |
1420 | exception_error("archiveSelection", e); | |
1421 | } | |
1422 | } | |
1423 | ||
a5ae125a AD |
1424 | function catchupSelection() { |
1425 | ||
1426 | try { | |
1427 | ||
1428 | var rows; | |
1429 | ||
acac8448 | 1430 | if ($("headlinesList")) { |
a5ae125a AD |
1431 | rows = getSelectedTableRowIds("headlinesList", "RROW", "RCHK"); |
1432 | } else { | |
1433 | rows = cdmGetSelectedArticles(); | |
1434 | } | |
1435 | ||
1436 | if (rows.length == 0) { | |
1437 | alert(__("No articles are selected.")); | |
1438 | return; | |
1439 | } | |
1440 | ||
1441 | ||
3d72bbdb | 1442 | var fn = getFeedName(getActiveFeedId(), activeFeedIsCat()); |
a5ae125a | 1443 | |
ba5fac1b | 1444 | var str = __("Mark %d selected articles in %s as read?"); |
a5ae125a | 1445 | |
ba5fac1b | 1446 | str = str.replace("%d", rows.length); |
a5ae125a AD |
1447 | str = str.replace("%s", fn); |
1448 | ||
1449 | if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str)) { | |
1450 | return; | |
1451 | } | |
1452 | ||
acac8448 | 1453 | if ($("headlinesList")) { |
a5ae125a AD |
1454 | selectionToggleUnread(false, false, 'viewCurrentFeed()', true); |
1455 | // selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false); | |
1456 | } else { | |
1457 | selectionToggleUnread(true, false, 'viewCurrentFeed()', true) | |
1458 | // cdmSelectArticles('none'); | |
1459 | } | |
1460 | ||
1461 | } catch (e) { | |
1462 | exception_error("catchupSelection", e); | |
1463 | } | |
1464 | } | |
1465 | ||
13f08f75 | 1466 | function editArticleTags(id, feed_id, cdm_enabled) { |
0b126ac2 AD |
1467 | displayDlg('editArticleTags', id); |
1468 | } | |
1469 | ||
1470 | ||
2ef1af84 AD |
1471 | function tag_saved_callback(transport) { |
1472 | try { | |
1473 | debug("in tag_saved_callback"); | |
0b126ac2 | 1474 | |
2ef1af84 AD |
1475 | closeInfoBox(); |
1476 | notify(""); | |
0b126ac2 | 1477 | |
2ef1af84 AD |
1478 | if (tagsAreDisplayed()) { |
1479 | _reload_feedlist_after_view = true; | |
1480 | } | |
0b126ac2 | 1481 | |
307d187c AD |
1482 | |
1483 | if (transport.responseXML) { | |
1484 | var tags_str = transport.responseXML.getElementsByTagName("tags-str")[0]; | |
1485 | ||
1486 | if (tags_str) { | |
1487 | var id = tags_str.getAttribute("id"); | |
1488 | ||
1489 | if (id) { | |
acac8448 | 1490 | var tags = $("ATSTR-" + id); |
307d187c AD |
1491 | if (tags) { |
1492 | tags.innerHTML = tags_str.firstChild.nodeValue; | |
1493 | } | |
1494 | } | |
13f08f75 | 1495 | } |
0b126ac2 | 1496 | } |
2ef1af84 AD |
1497 | |
1498 | } catch (e) { | |
307d187c | 1499 | exception_error("tag_saved_callback", e); |
0b126ac2 AD |
1500 | } |
1501 | } | |
1502 | ||
1503 | function editTagsSave() { | |
1504 | ||
42c32916 | 1505 | notify_progress("Saving article tags..."); |
88040f57 | 1506 | |
0b126ac2 AD |
1507 | var form = document.forms["tag_edit_form"]; |
1508 | ||
1509 | var query = Form.serialize("tag_edit_form"); | |
1510 | ||
14b6c54b AD |
1511 | query = "backend.php?op=rpc&subop=setArticleTags&" + query; |
1512 | ||
1513 | debug(query); | |
1514 | ||
2ef1af84 AD |
1515 | new Ajax.Request(query, { |
1516 | onComplete: function(transport) { | |
1517 | tag_saved_callback(transport); | |
1518 | } }); | |
0b126ac2 AD |
1519 | |
1520 | } | |
d62a3b63 AD |
1521 | |
1522 | function editTagsInsert() { | |
1523 | try { | |
1524 | ||
1525 | var form = document.forms["tag_edit_form"]; | |
1526 | ||
1527 | var found_tags = form.found_tags; | |
1528 | var tags_str = form.tags_str; | |
1529 | ||
1530 | var tag = found_tags[found_tags.selectedIndex].value; | |
1531 | ||
1532 | if (tags_str.value.length > 0 && | |
1533 | tags_str.value.lastIndexOf(", ") != tags_str.value.length - 2) { | |
1534 | ||
1535 | tags_str.value = tags_str.value + ", "; | |
1536 | } | |
1537 | ||
1538 | tags_str.value = tags_str.value + tag + ", "; | |
1539 | ||
1540 | found_tags.selectedIndex = 0; | |
1541 | ||
1542 | } catch (e) { | |
438f2ce9 | 1543 | exception_error("editTagsInsert", e); |
d62a3b63 AD |
1544 | } |
1545 | } | |
ba0978c8 | 1546 | |
587bef10 AD |
1547 | function cdmScrollViewport(where) { |
1548 | debug("cdmScrollViewport: " + where); | |
1549 | ||
acac8448 | 1550 | var ctr = $("headlinesInnerContainer"); |
587bef10 AD |
1551 | |
1552 | if (!ctr) return; | |
1553 | ||
1554 | if (where == "bottom") { | |
1555 | ctr.scrollTop = ctr.scrollHeight; | |
1556 | } else { | |
1557 | ctr.scrollTop = where; | |
1558 | } | |
1559 | } | |
1560 | ||
b8e6acea AD |
1561 | function cdmArticleIsBelowViewport(id) { |
1562 | try { | |
acac8448 AD |
1563 | var ctr = $("headlinesInnerContainer"); |
1564 | var e = $("RROW-" + id); | |
b8e6acea AD |
1565 | |
1566 | if (!e || !ctr) return; | |
1567 | ||
1568 | // article starts below viewport | |
1569 | ||
1570 | if (ctr.scrollTop < e.offsetTop) { | |
1571 | return true; | |
1572 | } else { | |
1573 | return false; | |
1574 | } | |
1575 | ||
1576 | } catch (e) { | |
438f2ce9 | 1577 | exception_error("cdmArticleIsVisible", e); |
b8e6acea AD |
1578 | } |
1579 | } | |
1580 | ||
1581 | function cdmArticleIsAboveViewport(id) { | |
1582 | try { | |
acac8448 AD |
1583 | var ctr = $("headlinesInnerContainer"); |
1584 | var e = $("RROW-" + id); | |
b8e6acea AD |
1585 | |
1586 | if (!e || !ctr) return; | |
1587 | ||
1588 | // article starts above viewport | |
1589 | ||
1590 | if (ctr.scrollTop > e.offsetTop + e.offsetHeight) { | |
1591 | return true; | |
1592 | } else { | |
1593 | return false; | |
1594 | } | |
1595 | ||
1596 | } catch (e) { | |
438f2ce9 | 1597 | exception_error("cdmArticleIsVisible", e); |
b8e6acea AD |
1598 | } |
1599 | } | |
1600 | ||
1601 | function cdmScrollToArticleId(id) { | |
1602 | try { | |
acac8448 AD |
1603 | var ctr = $("headlinesInnerContainer"); |
1604 | var e = $("RROW-" + id); | |
b8e6acea AD |
1605 | |
1606 | if (!e || !ctr) return; | |
1607 | ||
1608 | ctr.scrollTop = e.offsetTop; | |
1609 | ||
1610 | } catch (e) { | |
438f2ce9 | 1611 | exception_error("cdmScrollToArticleId", e); |
b8e6acea AD |
1612 | } |
1613 | } | |
1614 | ||
1615 | function cdmArticleIsActuallyVisible(id) { | |
1616 | try { | |
acac8448 AD |
1617 | var ctr = $("headlinesInnerContainer"); |
1618 | var e = $("RROW-" + id); | |
b8e6acea AD |
1619 | |
1620 | if (!e || !ctr) return; | |
1621 | ||
1622 | // article fits in viewport OR article is longer than viewport and | |
1623 | // its bottom is visible | |
1624 | ||
1625 | if (ctr.scrollTop <= e.offsetTop && e.offsetTop + e.offsetHeight <= | |
1626 | ctr.scrollTop + ctr.offsetHeight) { | |
1627 | ||
1628 | return true; | |
1629 | ||
1630 | } else if (e.offsetHeight > ctr.offsetHeight && | |
1631 | e.offsetTop + e.offsetHeight >= ctr.scrollTop && | |
1632 | e.offsetTop + e.offsetHeight <= ctr.scrollTop + ctr.offsetHeight) { | |
1633 | ||
1634 | return true; | |
1635 | ||
1636 | } | |
1637 | ||
1638 | return false; | |
1639 | ||
1640 | } catch (e) { | |
438f2ce9 | 1641 | exception_error("cdmArticleIsVisible", e); |
b8e6acea AD |
1642 | } |
1643 | } | |
1644 | ||
ba0978c8 AD |
1645 | function cdmWatchdog() { |
1646 | ||
1647 | try { | |
1648 | ||
acac8448 | 1649 | var ctr = $("headlinesInnerContainer"); |
ba0978c8 | 1650 | |
9acd22e8 AD |
1651 | if (!ctr) return; |
1652 | ||
ba0978c8 AD |
1653 | var ids = new Array(); |
1654 | ||
1655 | var e = ctr.firstChild; | |
1656 | ||
1657 | while (e) { | |
1658 | if (e.className && e.className == "cdmArticleUnread" && e.id && | |
1659 | e.id.match("RROW-")) { | |
1660 | ||
1661 | // article fits in viewport OR article is longer than viewport and | |
1662 | // its bottom is visible | |
1663 | ||
1664 | if (ctr.scrollTop <= e.offsetTop && e.offsetTop + e.offsetHeight <= | |
1665 | ctr.scrollTop + ctr.offsetHeight) { | |
1666 | ||
1667 | // debug(e.id + " is visible " + e.offsetTop + "." + | |
1668 | // (e.offsetTop + e.offsetHeight) + " vs " + ctr.scrollTop + "." + | |
1669 | // (ctr.scrollTop + ctr.offsetHeight)); | |
1670 | ||
1671 | ids.push(e.id.replace("RROW-", "")); | |
1672 | ||
1673 | } else if (e.offsetHeight > ctr.offsetHeight && | |
1674 | e.offsetTop + e.offsetHeight >= ctr.scrollTop && | |
1675 | e.offsetTop + e.offsetHeight <= ctr.scrollTop + ctr.offsetHeight) { | |
1676 | ||
1677 | ids.push(e.id.replace("RROW-", "")); | |
1678 | ||
1679 | } | |
1680 | ||
c50e2b30 AD |
1681 | // method 2: article bottom is visible and is in upper 1/2 of the viewport |
1682 | ||
1683 | /* if (e.offsetTop + e.offsetHeight >= ctr.scrollTop && | |
1684 | e.offsetTop + e.offsetHeight <= ctr.scrollTop + ctr.offsetHeight/2) { | |
1685 | ||
1686 | ids.push(e.id.replace("RROW-", "")); | |
1687 | ||
1688 | } */ | |
1689 | ||
ba0978c8 AD |
1690 | } |
1691 | ||
1692 | e = e.nextSibling; | |
1693 | } | |
1694 | ||
1695 | debug("cdmWatchdog, ids= " + ids.toString()); | |
1696 | ||
1341ea0d | 1697 | if (ids.length > 0) { |
ba0978c8 AD |
1698 | |
1699 | for (var i = 0; i < ids.length; i++) { | |
acac8448 | 1700 | var e = $("RROW-" + ids[i]); |
ba0978c8 AD |
1701 | if (e) { |
1702 | e.className = e.className.replace("Unread", ""); | |
1703 | } | |
1704 | } | |
1705 | ||
2855ee88 AD |
1706 | var query = "backend.php?op=rpc&subop=catchupSelected" + |
1707 | "&cmode=0"; | |
1708 | ||
1709 | var ids = "?ids=" + param_escape(ids.toString()); | |
ba0978c8 | 1710 | |
1341ea0d | 1711 | new Ajax.Request(query, { |
2855ee88 | 1712 | parameters: ids, |
1341ea0d AD |
1713 | onComplete: function(transport) { |
1714 | all_counters_callback2(transport); | |
1715 | } }); | |
ba0978c8 AD |
1716 | |
1717 | } | |
1718 | ||
c50e2b30 | 1719 | _cdm_wd_timeout = window.setTimeout("cdmWatchdog()", 4000); |
ba0978c8 AD |
1720 | |
1721 | } catch (e) { | |
438f2ce9 | 1722 | exception_error("cdmWatchdog", e); |
ba0978c8 AD |
1723 | } |
1724 | ||
1725 | } | |
e097e8be AD |
1726 | |
1727 | ||
e19c1824 | 1728 | function cache_inject(id, article, param) { |
fb456d28 AD |
1729 | try { |
1730 | if (!cache_check_param(id, param)) { | |
1731 | debug("cache_article: miss: " + id + " [p=" + param + "]"); | |
1732 | ||
1733 | ||
1734 | if (db) { | |
e097e8be | 1735 | |
fb456d28 AD |
1736 | var date = new Date(); |
1737 | var ts = Math.round(date.getTime() / 1000); | |
e097e8be | 1738 | |
fb456d28 AD |
1739 | db.execute("INSERT INTO cache (id, article, param, added) VALUES (?, ?, ?, ?)", |
1740 | [id, article, param, ts]); | |
1741 | } else { | |
1742 | ||
1743 | var cache_obj = new Array(); | |
1744 | ||
1745 | cache_obj["id"] = id; | |
1746 | cache_obj["data"] = article; | |
1747 | cache_obj["param"] = param; | |
1748 | ||
1749 | article_cache.push(cache_obj); | |
1750 | } | |
1751 | ||
1752 | } else { | |
1753 | debug("cache_article: hit: " + id + " [p=" + param + "]"); | |
1754 | } | |
1755 | } catch (e) { | |
1756 | exception_error("cache_inject", e); | |
e097e8be AD |
1757 | } |
1758 | } | |
1759 | ||
1760 | function cache_find(id) { | |
fb456d28 AD |
1761 | |
1762 | if (db) { | |
31234407 | 1763 | var rs = db.execute("SELECT article FROM cache WHERE id = ?", [id]); |
03c96380 | 1764 | var a = false; |
31234407 AD |
1765 | |
1766 | if (rs.isValidRow()) { | |
03c96380 | 1767 | var a = rs.field(0); |
31234407 | 1768 | } |
fb456d28 | 1769 | |
03c96380 AD |
1770 | rs.close(); |
1771 | ||
1772 | return a; | |
1773 | ||
fb456d28 AD |
1774 | } else { |
1775 | for (var i = 0; i < article_cache.length; i++) { | |
1776 | if (article_cache[i]["id"] == id) { | |
1777 | return article_cache[i]["data"]; | |
1778 | } | |
fed4387d | 1779 | } |
e097e8be | 1780 | } |
fed4387d | 1781 | return false; |
e097e8be AD |
1782 | } |
1783 | ||
5d17ead9 | 1784 | function cache_find_param(id, param) { |
fb456d28 AD |
1785 | |
1786 | if (db) { | |
1787 | var rs = db.execute("SELECT article FROM cache WHERE id = ? AND param = ?", | |
1788 | [id, param]); | |
03c96380 | 1789 | var a = false; |
fb456d28 AD |
1790 | |
1791 | if (rs.isValidRow()) { | |
03c96380 | 1792 | a = rs.field(0); |
fb456d28 AD |
1793 | } |
1794 | ||
03c96380 AD |
1795 | rs.close(); |
1796 | ||
1797 | return a; | |
1798 | ||
fb456d28 AD |
1799 | } else { |
1800 | for (var i = 0; i < article_cache.length; i++) { | |
1801 | if (article_cache[i]["id"] == id && article_cache[i]["param"] == param) { | |
1802 | return article_cache[i]["data"]; | |
1803 | } | |
e19c1824 AD |
1804 | } |
1805 | } | |
1806 | return false; | |
1807 | } | |
1808 | ||
e097e8be | 1809 | function cache_check(id) { |
fb456d28 AD |
1810 | |
1811 | if (db) { | |
1812 | var rs = db.execute("SELECT COUNT(*) AS c FROM cache WHERE id = ?", | |
1813 | [id]); | |
03c96380 | 1814 | var a = false; |
fb456d28 AD |
1815 | |
1816 | if (rs.isValidRow()) { | |
03c96380 | 1817 | a = rs.field(0) != "0"; |
fb456d28 AD |
1818 | } |
1819 | ||
03c96380 AD |
1820 | rs.close(); |
1821 | ||
1822 | return a; | |
1823 | ||
fb456d28 AD |
1824 | } else { |
1825 | for (var i = 0; i < article_cache.length; i++) { | |
1826 | if (article_cache[i]["id"] == id) { | |
1827 | return true; | |
1828 | } | |
fed4387d AD |
1829 | } |
1830 | } | |
1831 | return false; | |
e097e8be AD |
1832 | } |
1833 | ||
e19c1824 | 1834 | function cache_check_param(id, param) { |
5d17ead9 | 1835 | |
fb456d28 AD |
1836 | if (db) { |
1837 | var rs = db.execute("SELECT COUNT(*) AS c FROM cache WHERE id = ? AND param = ?", | |
1838 | [id, param]); | |
03c96380 | 1839 | var a = false; |
5d17ead9 | 1840 | |
fb456d28 | 1841 | if (rs.isValidRow()) { |
03c96380 | 1842 | a = rs.field(0) != "0"; |
fb456d28 AD |
1843 | } |
1844 | ||
03c96380 AD |
1845 | rs.close(); |
1846 | ||
1847 | return a; | |
1848 | ||
fb456d28 AD |
1849 | } else { |
1850 | for (var i = 0; i < article_cache.length; i++) { | |
1851 | if (article_cache[i]["id"] == id && article_cache[i]["param"] == param) { | |
1852 | return true; | |
1853 | } | |
e19c1824 AD |
1854 | } |
1855 | } | |
1856 | return false; | |
1857 | } | |
1858 | ||
e097e8be | 1859 | function cache_expire() { |
31234407 AD |
1860 | if (db) { |
1861 | var date = new Date(); | |
1862 | var ts = Math.round(date.getTime() / 1000); | |
1863 | ||
e0999d95 AD |
1864 | db.execute("DELETE FROM cache WHERE added < ? - 1800 AND id LIKE 'FEEDLIST'", [ts]); |
1865 | db.execute("DELETE FROM cache WHERE added < ? - 600 AND (id LIKE 'F:%' OR id LIKE 'C:%')", [ts]); | |
1866 | db.execute("DELETE FROM cache WHERE added < ? - 86400", [ts]); | |
1867 | ||
31234407 AD |
1868 | |
1869 | } else { | |
fb456d28 AD |
1870 | while (article_cache.length > 25) { |
1871 | article_cache.shift(); | |
1872 | } | |
fed4387d | 1873 | } |
e097e8be | 1874 | } |
b07b61da | 1875 | |
3c2d7945 AD |
1876 | function cache_empty() { |
1877 | article_cache = new Array(); | |
1878 | } | |
1879 | ||
b07b61da | 1880 | function cache_invalidate(id) { |
c1b18749 AD |
1881 | try { |
1882 | ||
fb456d28 AD |
1883 | if (db) { |
1884 | rs = db.execute("DELETE FROM cache WHERE id = ?", [id]); | |
1885 | return rs.rowsAffected != 0; | |
1886 | } else { | |
1887 | ||
1888 | var i = 0 | |
1889 | ||
1890 | while (i < article_cache.length) { | |
1891 | if (article_cache[i]["id"] == id) { | |
1892 | debug("cache_invalidate: removed id " + id); | |
1893 | article_cache.splice(i, 1); | |
1894 | return true; | |
1895 | } | |
1896 | i++; | |
c1b18749 | 1897 | } |
b07b61da | 1898 | } |
fb456d28 | 1899 | |
c1b18749 AD |
1900 | debug("cache_invalidate: id not found: " + id); |
1901 | return false; | |
1902 | } catch (e) { | |
1903 | exception_error("cache_invalidate", e); | |
b07b61da | 1904 | } |
b07b61da | 1905 | } |
298f3f78 AD |
1906 | |
1907 | function getActiveArticleId() { | |
1908 | return active_post_id; | |
1909 | } | |
e4914b62 | 1910 | |
3cd4239a | 1911 | function cdmClicked(id) { |
e4914b62 | 1912 | try { |
acac8448 | 1913 | var elem = $("RROW-" + id); |
3cd4239a AD |
1914 | |
1915 | if (elem) { | |
e4914b62 AD |
1916 | var id = elem.id.replace("RROW-", ""); |
1917 | active_post_id = id; | |
5ad9d132 | 1918 | |
96f8322d | 1919 | // cdmSelectArticles("none"); |
b61cf20c | 1920 | toggleUnread(id, 0, true); |
96f8322d | 1921 | // toggleSelected(id); |
5ad9d132 | 1922 | |
e4914b62 AD |
1923 | } |
1924 | } catch (e) { | |
ee8768db | 1925 | exception_error("cdmClicked", e); |
5ad9d132 AD |
1926 | } |
1927 | } | |
e4914b62 | 1928 | |
aa0fa9df AD |
1929 | function preload_article_callback(transport) { |
1930 | try { | |
1931 | if (transport.responseXML) { | |
1932 | var articles = transport.responseXML.getElementsByTagName("article"); | |
1933 | ||
1934 | for (var i = 0; i < articles.length; i++) { | |
1935 | var id = articles[i].getAttribute("id"); | |
b2bb787c | 1936 | if (!cache_check(id)) { |
aa0fa9df AD |
1937 | cache_inject(id, articles[i].firstChild.nodeValue); |
1938 | debug("preloaded article: " + id); | |
1939 | } | |
1940 | } | |
1941 | } | |
1942 | } catch (e) { | |
1943 | exception_error("preload_article_callback", e); | |
1944 | } | |
1945 | } | |
1946 | ||
1947 | function preloadArticleUnderPointer(id) { | |
1948 | try { | |
a598370d AD |
1949 | if (getInitParam("bw_limit") == "1") return; |
1950 | ||
b2bb787c | 1951 | if (post_under_pointer == id && !cache_check(id)) { |
aa0fa9df AD |
1952 | |
1953 | debug("trying to preload article " + id); | |
1954 | ||
1955 | var neighbor_ids = getRelativePostIds(id, 1); | |
1956 | ||
1957 | /* only request uncached articles */ | |
1958 | ||
1959 | var cids_to_request = Array(); | |
1960 | ||
1961 | for (var i = 0; i < neighbor_ids.length; i++) { | |
1962 | if (!cache_check(neighbor_ids[i])) { | |
1963 | cids_to_request.push(neighbor_ids[i]); | |
1964 | } | |
1965 | } | |
1966 | debug("additional ids: " + cids_to_request.toString()); | |
1967 | ||
1968 | cids_to_request.push(id); | |
1969 | ||
1970 | var query = "backend.php?op=rpc&subop=getArticles&ids=" + | |
1971 | cids_to_request.toString(); | |
1972 | new Ajax.Request(query, { | |
1973 | onComplete: function(transport) { | |
1974 | preload_article_callback(transport); | |
1975 | } }); | |
1976 | } | |
1977 | } catch (e) { | |
1978 | exception_error("preloadArticleUnderPointer", e); | |
1979 | } | |
1980 | } | |
1981 | ||
314fcd2b AD |
1982 | function postMouseIn(id) { |
1983 | try { | |
aa0fa9df AD |
1984 | if (post_under_pointer != id) { |
1985 | post_under_pointer = id; | |
1986 | if (!isCdmMode()) { | |
1987 | window.setTimeout("preloadArticleUnderPointer(" + id + ")", 250); | |
1988 | } | |
1989 | } | |
1990 | ||
314fcd2b AD |
1991 | } catch (e) { |
1992 | exception_error("postMouseIn", e); | |
1993 | } | |
1994 | } | |
1995 | ||
1996 | function postMouseOut(id) { | |
1997 | try { | |
1998 | post_under_pointer = false; | |
1999 | } catch (e) { | |
2000 | exception_error("postMouseOut", e); | |
2001 | } | |
2002 | } | |
2003 | ||
ac541432 AD |
2004 | function headlines_scroll_handler() { |
2005 | try { | |
2006 | ||
acac8448 | 2007 | var e = $("headlinesInnerContainer"); |
ac541432 | 2008 | |
4764c27e AD |
2009 | // don't do infinite scrolling when Limit == All |
2010 | ||
2011 | var toolbar_form = document.forms["main_toolbar_form"]; | |
2012 | ||
2013 | var limit = toolbar_form.limit[toolbar_form.limit.selectedIndex]; | |
2014 | if (limit.value != 0) { | |
587bef10 AD |
2015 | |
2016 | debug((e.scrollTop + e.offsetHeight) + " vs " + e.scrollHeight + " dis? " + | |
2017 | _infscroll_disable); | |
2018 | ||
2019 | if (e.scrollTop + e.offsetHeight > e.scrollHeight - 100) { | |
4764c27e AD |
2020 | if (!_infscroll_disable) { |
2021 | debug("more cowbell!"); | |
2022 | viewNextFeedPage(); | |
2023 | } | |
29dfb258 | 2024 | } |
ac541432 AD |
2025 | } |
2026 | ||
2027 | } catch (e) { | |
2028 | exception_error("headlines_scroll_handler", e); | |
2029 | } | |
2030 | } | |
8be83f42 AD |
2031 | |
2032 | function catchupRelativeToArticle(below) { | |
2033 | ||
2034 | try { | |
2035 | ||
49fd1e94 | 2036 | |
8be83f42 AD |
2037 | if (!getActiveArticleId()) { |
2038 | alert(__("No article is selected.")); | |
2039 | return; | |
2040 | } | |
2041 | ||
2042 | var visible_ids; | |
2043 | ||
acac8448 | 2044 | if ($("headlinesList")) { |
8be83f42 AD |
2045 | visible_ids = getVisibleHeadlineIds(); |
2046 | } else { | |
2047 | visible_ids = cdmGetVisibleArticles(); | |
2048 | } | |
2049 | ||
2050 | var ids_to_mark = new Array(); | |
2051 | ||
2052 | if (!below) { | |
2053 | for (var i = 0; i < visible_ids.length; i++) { | |
2054 | if (visible_ids[i] != getActiveArticleId()) { | |
acac8448 | 2055 | var e = $("RROW-" + visible_ids[i]); |
8be83f42 AD |
2056 | |
2057 | if (e && e.className.match("Unread")) { | |
2058 | ids_to_mark.push(visible_ids[i]); | |
2059 | } | |
2060 | } else { | |
2061 | break; | |
2062 | } | |
2063 | } | |
2064 | } else { | |
2065 | for (var i = visible_ids.length-1; i >= 0; i--) { | |
2066 | if (visible_ids[i] != getActiveArticleId()) { | |
acac8448 | 2067 | var e = $("RROW-" + visible_ids[i]); |
8be83f42 AD |
2068 | |
2069 | if (e && e.className.match("Unread")) { | |
2070 | ids_to_mark.push(visible_ids[i]); | |
2071 | } | |
2072 | } else { | |
2073 | break; | |
2074 | } | |
2075 | } | |
2076 | } | |
2077 | ||
2078 | if (ids_to_mark.length == 0) { | |
2079 | alert(__("No articles found to mark")); | |
2080 | } else { | |
2081 | var msg = __("Mark %d article(s) as read?").replace("%d", ids_to_mark.length); | |
2082 | ||
2083 | if (confirm(msg)) { | |
2084 | ||
2085 | for (var i = 0; i < ids_to_mark.length; i++) { | |
acac8448 | 2086 | var e = $("RROW-" + ids_to_mark[i]); |
8be83f42 AD |
2087 | e.className = e.className.replace("Unread", ""); |
2088 | } | |
2089 | ||
2855ee88 AD |
2090 | var query = "backend.php?op=rpc&subop=catchupSelected" + |
2091 | "&cmode=0"; | |
2092 | ||
2093 | var ids = "?ids=" + param_escape(ids_to_mark.toString()); | |
8be83f42 | 2094 | |
5fe7767c | 2095 | new Ajax.Request(query, { |
2855ee88 | 2096 | parameters: ids, |
5fe7767c AD |
2097 | onComplete: function(transport) { |
2098 | catchup_callback2(transport); | |
2099 | } }); | |
2100 | ||
8be83f42 AD |
2101 | } |
2102 | } | |
2103 | ||
2104 | } catch (e) { | |
2105 | exception_error("catchupRelativeToArticle", e); | |
2106 | } | |
2107 | } | |
a04c8e8d AD |
2108 | |
2109 | function cdmExpandArticle(a_id) { | |
2110 | try { | |
2111 | var id = 'CICD-' + a_id; | |
2112 | ||
3cd4239a AD |
2113 | try { |
2114 | Element.hide("CEXC-" + a_id); | |
2115 | } catch (e) { } | |
2116 | ||
a04c8e8d AD |
2117 | Effect.Appear(id, {duration : 0.5, |
2118 | beforeStart: function(effect) { | |
2119 | var h_id = 'CICH-' + a_id; | |
acac8448 | 2120 | var h_elem = $(h_id); |
a04c8e8d AD |
2121 | if (h_elem) { h_elem.style.display = "none"; } |
2122 | ||
2123 | toggleUnread(a_id, 0); | |
2124 | }}); | |
2125 | ||
2126 | ||
2127 | } catch (e) { | |
2128 | exception_error("appearBlockElementF", e); | |
2129 | } | |
2130 | ||
2131 | } | |
2132 | ||
3818a89b AD |
2133 | function fixHeadlinesOrder(ids) { |
2134 | try { | |
2135 | for (var i = 0; i < ids.length; i++) { | |
acac8448 | 2136 | var e = $("RROW-" + ids[i]); |
3818a89b AD |
2137 | |
2138 | if (e) { | |
2139 | if (i % 2 == 0) { | |
2140 | e.className = e.className.replace("even", "odd"); | |
2141 | } else { | |
2142 | e.className = e.className.replace("odd", "even"); | |
2143 | } | |
2144 | } | |
2145 | } | |
2146 | } catch (e) { | |
2147 | exception_error("fixHeadlinesOrder", e); | |
2148 | } | |
2149 | } | |
2150 | ||
df485d4f AD |
2151 | function hideReadHeadlines() { |
2152 | try { | |
2153 | ||
2154 | var ids = false; | |
2155 | var vis_ids = new Array(); | |
2156 | ||
acac8448 | 2157 | if ($("headlinesList")) { |
df485d4f AD |
2158 | ids = getVisibleHeadlineIds(); |
2159 | } else { | |
2160 | ids = cdmGetVisibleArticles(); | |
2161 | } | |
2162 | ||
004523dd AD |
2163 | var read_headlines_visible = true; |
2164 | ||
df485d4f | 2165 | for (var i = 0; i < ids.length; i++) { |
acac8448 | 2166 | var row = $("RROW-" + ids[i]); |
df485d4f AD |
2167 | |
2168 | if (row && row.className) { | |
2169 | if (read_headlines_visible) { | |
2170 | if (row.className.match("Unread") || row.className.match("Selected")) { | |
2171 | Element.show(row); | |
2172 | vis_ids.push(ids[i]); | |
2173 | } else { | |
2174 | //Effect.Fade(row, {duration : 0.3}); | |
2175 | Element.hide(row); | |
2176 | } | |
2177 | } else { | |
2178 | Element.show(row); | |
2179 | vis_ids.push(ids[i]); | |
2180 | } | |
2181 | } | |
2182 | } | |
2183 | ||
2184 | fixHeadlinesOrder(vis_ids); | |
2185 | ||
2186 | read_headlines_visible = !read_headlines_visible; | |
2187 | ||
2188 | } catch (e) { | |
2189 | exception_error("hideReadHeadlines", e); | |
2190 | } | |
2191 | } | |
2192 | ||
e75d70b5 AD |
2193 | function invertHeadlineSelection() { |
2194 | try { | |
2195 | var rows = new Array(); | |
2196 | var r = false; | |
2197 | ||
2198 | if (!isCdmMode()) { | |
2199 | r = document.getElementsByTagName("TR"); | |
2200 | } else { | |
2201 | r = document.getElementsByTagName("DIV"); | |
2202 | } | |
2203 | ||
2204 | for (var i = 0; i < r.length; i++) { | |
2205 | if (r[i].id && r[i].id.match("RROW-")) { | |
2206 | rows.push(r[i]); | |
2207 | } | |
2208 | } | |
2209 | ||
2210 | for (var i = 0; i < rows.length; i++) { | |
2211 | var nc = rows[i].className; | |
2212 | var id = rows[i].id.replace("RROW-", ""); | |
acac8448 | 2213 | var cb = $("RCHK-" + id); |
e75d70b5 AD |
2214 | |
2215 | if (!rows[i].className.match("Selected")) { | |
2216 | nc = nc + "Selected"; | |
2217 | cb.checked = true; | |
2218 | } else { | |
2219 | nc = nc.replace("Selected", ""); | |
2220 | cb.checked = false; | |
2221 | } | |
2222 | ||
2223 | rows[i].className = nc; | |
2224 | ||
2225 | } | |
2226 | ||
2227 | } catch (e) { | |
2228 | exception_error("invertHeadlineSelection", e); | |
2229 | } | |
2230 | } | |
2231 | ||
314fcd2b AD |
2232 | function getArticleUnderPointer() { |
2233 | return post_under_pointer; | |
7a822893 | 2234 | } |
eedfb635 AD |
2235 | |
2236 | function zoomToArticle(id) { | |
2237 | try { | |
2238 | var w = window.open("backend.php?op=view&mode=zoom&id=" + param_escape(id), | |
2239 | "ttrss_zoom_" + id, | |
2240 | "status=0,toolbar=0,location=0,width=450,height=300,scrollbars=1,menubar=0"); | |
2241 | ||
2242 | } catch (e) { | |
2243 | exception_error("zoomToArticle", e); | |
2244 | } | |
2245 | } | |
a411875b | 2246 | |
4710e3dc AD |
2247 | function showOriginalArticleInline(id) { |
2248 | try { | |
2249 | ||
2250 | var query = "backend.php?op=rpc&subop=getArticleLink&id=" + id; | |
2251 | ||
2252 | notify_progress("Loading, please wait...", true); | |
2253 | ||
2254 | new Ajax.Request(query, { | |
2255 | onComplete: function(transport) { | |
2256 | ||
2257 | if (transport.responseXML) { | |
2258 | ||
2259 | var link = transport.responseXML.getElementsByTagName("link")[0]; | |
2260 | var id = transport.responseXML.getElementsByTagName("id")[0]; | |
2261 | ||
2262 | notify(""); | |
2263 | ||
2264 | if (link && id) { | |
2265 | link = link.firstChild.nodeValue; | |
2266 | ||
acac8448 | 2267 | var ci = $("content-insert"); |
4710e3dc AD |
2268 | |
2269 | var tmp = "<iframe id=\"inline_orig_article\" width=\""+ci.offsetWidth+"\" height=\""+ci.offsetHeight+"\" style=\"border-width : 0px;\" src=\""+link+"\"></iframe>"; | |
2270 | ||
2271 | render_article(tmp); | |
2272 | ||
2273 | } | |
2274 | } | |
2275 | } }); | |
2276 | ||
2277 | } catch (e) { | |
2278 | exception_error("showOriginalArticleInline", e); | |
2279 | } | |
2280 | } | |
2281 | ||
2282 | ||
a411875b AD |
2283 | function scrollArticle(offset) { |
2284 | try { | |
2285 | if (!isCdmMode()) { | |
acac8448 | 2286 | var ci = $("content-insert"); |
a411875b AD |
2287 | if (ci) { |
2288 | ci.scrollTop += offset; | |
2289 | } | |
2290 | } else { | |
acac8448 | 2291 | var hi = $("headlinesInnerContainer"); |
a411875b AD |
2292 | if (hi) { |
2293 | hi.scrollTop += offset; | |
2294 | } | |
2295 | ||
2296 | } | |
2297 | } catch (e) { | |
2298 | exception_error("scrollArticle", e); | |
2299 | } | |
2300 | } | |
f9247195 AD |
2301 | |
2302 | function show_labels_in_headlines(transport) { | |
2303 | try { | |
2304 | if (transport.responseXML) { | |
2305 | var info = transport.responseXML.getElementsByTagName("info-for-headlines")[0]; | |
2306 | ||
2307 | var elems = info.getElementsByTagName("entry"); | |
2308 | ||
2309 | for (var l = 0; l < elems.length; l++) { | |
2310 | var e_id = elems[l].getAttribute("id"); | |
2311 | ||
2312 | if (e_id) { | |
2313 | ||
acac8448 | 2314 | var ctr = $("HLLCTR-" + e_id); |
f9247195 AD |
2315 | |
2316 | if (ctr) { | |
2317 | ctr.innerHTML = elems[l].firstChild.nodeValue; | |
2318 | } | |
2319 | } | |
2320 | ||
2321 | } | |
2322 | ||
2323 | } | |
2324 | } catch (e) { | |
2325 | exception_error("show_labels_in_headlines", e); | |
2326 | ||
2327 | } | |
2328 | } | |
bf3c9838 AD |
2329 | |
2330 | function toggleHeadlineActions() { | |
2331 | try { | |
acac8448 AD |
2332 | var e = $("headlineActionsBody"); |
2333 | var p = $("headlineActionsDrop"); | |
bf3c9838 AD |
2334 | |
2335 | if (!Element.visible(e)) { | |
2336 | Element.show(e); | |
2337 | } else { | |
2338 | Element.hide(e); | |
2339 | } | |
2340 | ||
b62f6ff4 | 2341 | e.scrollTop = 0; |
bf3c9838 | 2342 | e.style.left = (p.offsetLeft + 1) + "px"; |
b4dc02e2 | 2343 | e.style.top = (p.offsetTop + p.offsetHeight + 2) + "px"; |
bf3c9838 AD |
2344 | |
2345 | } catch (e) { | |
2346 | exception_error("toggleHeadlineActions", e); | |
2347 | } | |
2348 | } | |
c7e51de1 AD |
2349 | |
2350 | function publishWithNote(id, def_note) { | |
2351 | try { | |
2352 | if (!def_note) def_note = ''; | |
2353 | ||
2354 | var note = prompt(__("Please enter a note for this article:"), def_note); | |
2355 | ||
2356 | if (note != undefined) { | |
2357 | togglePub(id, false, false, note); | |
2358 | } | |
2359 | ||
2360 | } catch (e) { | |
2361 | exception_error("publishWithNote", e); | |
2362 | } | |
2363 | } |