]>
git.wh0rd.org - tt-rss.git/blob - feedlist.js
cf41f3ba13902d0b2d3112ce2cbb202ba6173285
1 var _feed_cur_page
= 0;
2 var _infscroll_disable
= 0;
3 var _infscroll_request_sent
= 0;
4 var feed_under_pointer
= undefined;
6 var mouse_is_down
= false;
10 var enable_resize
= false;
12 function viewCategory(cat
) {
13 active_feed_is_cat
= true;
14 viewfeed(cat
, '', true);
18 function feedlist_callback2(transport
) {
20 debug("feedlist_callback2");
21 var f
= document
.getElementById("feeds-frame");
22 f
.innerHTML
= transport
.responseText
;
25 exception_error("feedlist_callback2", e
);
29 function viewNextFeedPage() {
31 //if (!getActiveFeedId()) return;
33 debug("viewNextFeedPage: calling viewfeed(), p: " + _feed_cur_page
+1);
35 viewfeed(getActiveFeedId(), undefined, activeFeedIsCat(), undefined,
36 undefined, _feed_cur_page
+1);
39 exception_error("viewNextFeedPage", e
);
43 function viewfeed(feed
, subop
, is_cat
, subop_param
, skip_history
, offset
) {
46 // if (!offset) page_offset = 0;
48 if (feed
== getActiveFeedId()) {
49 cache_invalidate("F:" + feed
);
52 /* if (getInitParam("theme") == "" || getInitParam("theme") == "compact") {
53 if (getInitParam("hide_feedlist") == 1) {
54 Element.hide("feeds-holder");
58 var force_nocache
= false;
67 _infscroll_disable
= 0;
70 if (getActiveFeedId() != feed
) {
73 _infscroll_disable
= 0;
76 if (page_offset
!= 0 && !subop
) {
77 var date
= new Date();
78 var timestamp
= Math
.round(date
.getTime() / 1000);
80 debug("<b>" + _infscroll_request_sent
+ " : " + timestamp
+ "</b>");
82 if (_infscroll_request_sent
&& _infscroll_request_sent
+ 30 > timestamp
) {
83 debug("infscroll request in progress, aborting");
87 _infscroll_request_sent
= timestamp
;
94 Form
.enable("main_toolbar_form");
96 var toolbar_form
= document
.forms
["main_toolbar_form"];
97 var toolbar_query
= Form
.serialize("main_toolbar_form");
99 if (toolbar_form
.query
) {
100 if (toolbar_form
.query
.value
!= "") {
101 force_nocache
= true;
103 toolbar_form
.query
.value
= "";
106 var query
= "backend.php?op=viewfeed&feed=" + feed
+ "&" +
107 toolbar_query
+ "&subop=" + param_escape(subop
);
109 if (document
.getElementById("search_form")) {
110 var search_query
= Form
.serialize("search_form");
111 query
= query
+ "&" + search_query
;
113 force_nocache
= true;
116 // debug("IS_CAT_STORED: " + activeFeedIsCat() + ", IS_CAT: " + is_cat);
118 if (subop
== "MarkAllRead") {
120 var feedlist
= document
.getElementById('feedList');
122 var next_unread_feed
= getRelativeFeedId(feedlist
,
125 if (!next_unread_feed
) {
126 next_unread_feed
= getRelativeFeedId(feedlist
,
130 var show_next_feed
= getInitParam("on_catchup_show_next_feed") == "1";
132 if (next_unread_feed
&& show_next_feed
&& !activeFeedIsCat()) {
133 query
= query
+ "&nuf=" + param_escape(next_unread_feed
);
134 //setActiveFeedId(next_unread_feed);
135 feed
= next_unread_feed
;
140 query
= query
+ "&cat=1";
143 if (page_offset
!= 0) {
144 query
= query
+ "&skip=" + page_offset
;
146 // to prevent duplicate feed titles when showing grouped vfeeds
147 if (vgroup_last_feed
) {
148 query
= query
+ "&vgrlf=" + param_escape(vgroup_last_feed
);
152 var date
= new Date();
153 var timestamp
= Math
.round(date
.getTime() / 1000);
154 query
= query
+ "&ts=" + timestamp
156 disableContainerChildren("headlinesToolbar", false);
157 Form
.enable("main_toolbar_form");
159 // for piggybacked counters
161 if (tagsAreDisplayed()) {
162 query
= query
+ "&omode=lt";
164 query
= query
+ "&omode=flc";
169 var container
= document
.getElementById("headlinesInnerContainer");
171 /* if (container && page_offset == 0 && !isCdmMode()) {
172 new Effect.Fade(container, {duration: 1, to: 0.01,
173 queue: { position:'end', scope: 'FEEDL-' + feed, limit: 1 } } );
176 var unread_ctr
= get_feed_unread(feed
);
177 var cache_check
= false;
179 if (unread_ctr
!= -1 && !page_offset
&& !force_nocache
&& !subop
) {
181 var cache_prefix
= "";
189 cache_check
= cache_check_param(cache_prefix
+ feed
, unread_ctr
);
190 debug("headline cache check: " + cache_check
);
194 var f
= document
.getElementById("headlines-frame");
196 clean_feed_selections();
198 setActiveFeedId(feed
);
200 if (is_cat
!= undefined) {
201 active_feed_is_cat
= is_cat
;
205 var feedr
= document
.getElementById("FEEDR-" + feed
);
206 if (feedr
&& !feedr
.className
.match("Selected")) {
207 feedr
.className
= feedr
.className
+ "Selected";
211 f
.innerHTML
= cache_find_param(cache_prefix
+ feed
, unread_ctr
);
213 var query
= "backend.php?op=rpc&subop=getAllCounters";
215 if (tagsAreDisplayed()) {
216 query
= query
+ "&omode=tl";
218 query
= query
+ "&omode=flc";
221 new Ajax
.Request(query
, {
222 onComplete: function(transport
) {
224 all_counters_callback2(transport
);
226 exception_error("viewfeed/getcounters", e
);
233 notify_progress("Loading, please wait...", true);
236 new Ajax
.Request(query
, {
237 onComplete: function(transport
) {
238 headlines_callback2(transport
, feed
, is_cat
, page_offset
);
243 exception_error("viewfeed", e
);
247 function toggleCollapseCat_af(effect
) {
248 //var caption = elem.id.replace("FCATLIST-", "");
252 var elem
= effect
.element
;
253 var cat
= elem
.id
.replace("FCATLIST-", "");
254 var cap
= document
.getElementById("FCAP-" + cat
);
256 if (Element
.visible(elem
)) {
257 cap
.innerHTML
= cap
.innerHTML
.replace("…", "");
259 if (cap
.innerHTML
.lastIndexOf("…") != cap
.innerHTML
.length
-3) {
260 cap
.innerHTML
= cap
.innerHTML
+ "…";
265 exception_error("toggleCollapseCat_af", e
);
269 function toggleCollapseCat(cat
) {
272 var cat_elem
= document
.getElementById("FCAT-" + cat
);
273 var cat_list
= document
.getElementById("FCATLIST-" + cat
).parentNode
;
274 var caption
= document
.getElementById("FCAP-" + cat
);
276 /* if (cat_list.className.match("invisible")) {
277 cat_list.className = "";
278 caption.innerHTML = caption.innerHTML.replace("...", "");
280 setCookie("ttrss_vf_uclps", "0");
283 cat_list.className = "invisible";
284 caption.innerHTML = caption.innerHTML + "...";
286 setCookie("ttrss_vf_uclps", "1");
292 if (Element
.visible("FCATLIST-" + cat
)) {
293 setCookie("ttrss_vf_uclps", "1");
295 setCookie("ttrss_vf_uclps", "0");
300 if (Element
.visible("FCATLIST-" + cat
)) {
301 setCookie("ttrss_vf_lclps", "1");
303 setCookie("ttrss_vf_lclps", "0");
308 if (Element
.visible("FCATLIST-" + cat
)) {
309 setCookie("ttrss_vf_vclps", "1");
311 setCookie("ttrss_vf_vclps", "0");
315 Effect
.toggle('FCATLIST-' + cat
, 'blind', { duration
: 0.5,
316 afterFinish
: toggleCollapseCat_af
});
318 new Ajax
.Request("backend.php?op=feeds&subop=collapse&cid=" +
322 exception_error("toggleCollapseCat", e
);
326 function feedlist_init() {
328 // if (arguments.callee.done) return;
329 // arguments.callee.done = true;
331 loading_set_progress(90);
333 debug("in feedlist init");
335 hideOrShowFeeds(document
, getInitParam("hide_read_feeds") == 1);
336 document
.onkeydown
= hotkey_handler
;
337 document
.onmousemove
= mouse_move_handler
;
338 document
.onmousedown
= mouse_down_handler
;
339 document
.onmouseup
= mouse_up_handler
;
340 setTimeout("timeout()", 0);
342 /* debug("about to remove splash, OMG!");
344 var o = document.getElementById("overlay");
347 o.style.display = "none";
348 debug("removed splash!");
351 if (typeof correctPNG
!= 'undefined') {
355 if (getActiveFeedId()) {
356 debug("some feed is open on feedlist refresh, reloading");
357 setTimeout("viewCurrentFeed()", 100);
359 if (getInitParam("cdm_auto_catchup") != 1 && get_feed_unread(-3) > 0) {
360 notify_silent_next();
361 setTimeout("viewfeed(-3)", 100);
367 if (getInitParam("theme") == "") {
368 setTimeout("hide_footer()", 5000);
371 /* if (getInitParam("hide_feedlist") == 1) {
372 init_hidden_feedlist(getInitParam("theme"));
374 init_collapsable_feedlist(getInitParam("theme"));
377 init_collapsable_feedlist(getInitParam("theme"));
380 exception_error("feedlist/init", e
);
384 function hide_footer_af(effect
) {
386 var c
= document
.getElementById("content-frame");
389 c
.style
.bottom
= "0px";
391 var h
= document
.getElementById("headlines-frame");
394 h
.style
.bottom
= "0px";
399 exception_error("hide_footer_af", e
);
403 function hide_footer() {
405 if (Element
.visible("footer")) {
406 new Effect
.Fade("footer", { afterFinish
: hide_footer_af
});
409 exception_error("hide_footer", e
);
414 function init_hidden_feedlist(theme) {
416 debug("init_hidden_feedlist");
418 if (theme != "" && theme != "compact") return;
420 var fl = document.getElementById("feeds-holder");
421 var fh = document.getElementById("headlines-frame");
422 var fc = document.getElementById("content-frame");
423 var ft = document.getElementById("toolbar");
424 var ff = document.getElementById("footer");
425 var fhdr = document.getElementById("header");
427 var fbtn = document.getElementById("toggle_feeds_btn");
429 if (fbtn) Element.show(fbtn);
431 fl.style.top = fh.offsetTop + "px";
432 fl.style.backgroundColor = "white"; //FIXME
436 fh.style.left = "0px";
437 ft.style.left = "0px";
438 if (fc) fc.style.left = "0px";
439 if (ff) ff.style.left = "0px";
441 if (theme == "compact") {
442 fhdr.style.left = "10px";
443 fl.style.top = (fh.offsetTop + 1) + "px";
447 exception_error("init_hidden_feedlist", e);
451 function init_collapsable_feedlist(theme
) {
453 debug("init_collapsable_feedlist");
455 if (theme
!= "" && theme
!= "compact" && theme
!= "graycube" &&
456 theme
!= "compat") return;
458 var fbtn
= document
.getElementById("collapse_feeds_btn");
460 if (fbtn
) Element
.show(fbtn
);
462 if (getCookie("ttrss_vf_fclps") == 1) {
467 exception_error("init_hidden_feedlist", e
);
472 function mouse_move_handler(e
) {
478 client_y
= window
.event
.clientY
;
479 client_x
= window
.event
.clientX
;
481 client_x
= e
.screenX
;
482 client_y
= e
.screenY
;
487 if (mouse_y
== 0) mouse_y
= client_y
;
488 if (mouse_x
== 0) mouse_x
= client_x
;
490 resize_headlines(mouse_x
- client_x
, mouse_y
- client_y
);
495 exception_error("mouse_move_handler", e
);
499 function resize_enabled(b
) {
503 function mouse_down_handler(e
) {
505 if (enable_resize
) mouse_is_down
= true;
507 exception_error("mouse_move_handler", e
);
511 function mouse_up_handler(e
) {
513 mouse_is_down
= false;
515 exception_error("mouse_move_handler", e
);