]> git.wh0rd.org - tt-rss.git/blob - feedlist.js
add offset support for queryFeedHeadlines
[tt-rss.git] / feedlist.js
1 //var xmlhttp = Ajax.getTransport();
2
3 function viewCategory(cat) {
4 active_feed_is_cat = true;
5 viewfeed(cat, '', true);
6 }
7
8 function feedlist_callback() {
9 if (xmlhttp.readyState == 4) {
10 debug("feedlist_callback");
11 var f = document.getElementById("feeds-frame");
12 f.innerHTML = xmlhttp.responseText;
13 feedlist_init();
14 }
15 }
16
17 function viewfeed(feed, subop, is_cat, subop_param, skip_history) {
18 try {
19
20 enableHotkeys();
21
22 if (!skip_history) {
23 history_push('FEED:' + feed + ':' + subop + ':' + is_cat +
24 ':' + subop_param);
25 }
26
27 var toolbar_query = Form.serialize("main_toolbar_form");
28 var toolbar_form = document.forms["main_toolbar_form"];
29
30 if (document.forms["main_toolbar_form"].query) {
31 toolbar_form.query.value = "";
32 }
33
34 /* storeInitParam("toolbar_limit",
35 toolbar_form.limit[toolbar_form.limit.selectedIndex].value);
36
37 storeInitParam("toolbar_view_mode",
38 toolbar_form.view_mode[toolbar_form.view_mode.selectedIndex].value); */
39
40 var query = "backend.php?op=viewfeed&feed=" + feed + "&" +
41 toolbar_query + "&subop=" + param_escape(subop);
42
43 if (document.getElementById("search_form")) {
44 var search_query = Form.serialize("search_form");
45 query = query + "&" + search_query;
46 closeInfoBox(true);
47 }
48
49 debug("IS_CAT_STORED: " + activeFeedIsCat() + ", IS_CAT: " + is_cat);
50
51 var fe = document.getElementById("FEEDR-" + getActiveFeedId());
52
53 if (fe) {
54 fe.className = fe.className.replace("Selected", "");
55 }
56
57 setActiveFeedId(feed);
58
59 if (is_cat != undefined) {
60 active_feed_is_cat = is_cat;
61 }
62
63 if (subop == "MarkAllRead") {
64
65 var feedlist = document.getElementById('feedList');
66
67 var next_unread_feed = getRelativeFeedId(feedlist,
68 getActiveFeedId(), "next", true);
69
70 if (!next_unread_feed) {
71 next_unread_feed = getRelativeFeedId(feedlist,
72 -1, "next", true);
73 }
74
75 var show_next_feed = getInitParam("on_catchup_show_next_feed") == "1";
76
77 if (next_unread_feed && show_next_feed && !activeFeedIsCat()) {
78 query = query + "&nuf=" + param_escape(next_unread_feed);
79 setActiveFeedId(next_unread_feed);
80 }
81 }
82
83 if (activeFeedIsCat()) {
84 query = query + "&cat=1";
85 }
86
87 if (navigator.userAgent.match("Opera")) {
88 var date = new Date();
89 var timestamp = Math.round(date.getTime() / 1000);
90 query = query + "&ts=" + timestamp
91 }
92
93 if (!activeFeedIsCat()) {
94 var feedr = document.getElementById("FEEDR-" + getActiveFeedId());
95 if (feedr && !feedr.className.match("Selected")) {
96 feedr.className = feedr.className + "Selected";
97 }
98 }
99
100 disableContainerChildren("headlinesToolbar", false);
101 Form.enable("main_toolbar_form");
102
103 debug(query);
104
105 /* var container = document.getElementById("headlines-frame");
106
107 container.innerHTML = "<div class=\"loadingPrompt\"><img src=\"images/indicator_white.gif\">&nbsp;" +
108 "Loading, please wait...</div>"; */
109
110 notify("Loading, please wait...", true);
111
112 // xmlhttp.abort();
113
114 if (xmlhttp_ready(xmlhttp)) {
115 xmlhttp.open("GET", query, true);
116 xmlhttp.onreadystatechange=headlines_callback;
117 xmlhttp.send(null);
118 } else {
119 debug("xmlhttp busy (@feeds)");
120 }
121
122 } catch (e) {
123 exception_error("viewfeed", e);
124 }
125 }
126
127 function toggleCollapseCat(cat) {
128 try {
129 if (!xmlhttp_ready(xmlhttp)) {
130 printLockingError();
131 return;
132 }
133
134 var cat_elem = document.getElementById("FCAT-" + cat);
135 var cat_list = document.getElementById("FCATLIST-" + cat).parentNode;
136 var caption = document.getElementById("FCAP-" + cat);
137
138 if (cat_list.className.match("invisible")) {
139 cat_list.className = "";
140 caption.innerHTML = caption.innerHTML.replace("...", "");
141 if (cat == 0) {
142 setCookie("ttrss_vf_uclps", "0");
143 }
144 } else {
145 cat_list.className = "invisible";
146 caption.innerHTML = caption.innerHTML + "...";
147 if (cat == 0) {
148 setCookie("ttrss_vf_uclps", "1");
149 }
150 }
151
152 new Ajax.Request("backend.php?op=feeds&subop=collapse&cid=" +
153 param_escape(cat));
154
155 } catch (e) {
156 exception_error("toggleCollapseCat", e);
157 }
158 }
159
160 function feedlist_init() {
161 try {
162 // if (arguments.callee.done) return;
163 // arguments.callee.done = true;
164
165 debug("in feedlist init");
166
167 hideOrShowFeeds(document, getInitParam("hide_read_feeds") == 1);
168 document.onkeydown = hotkey_handler;
169 setTimeout("timeout()", 0);
170
171 debug("about to remove splash, OMG!");
172
173 var o = document.getElementById("overlay");
174
175 if (o) {
176 o.style.display = "none";
177 debug("removed splash!");
178 }
179
180 if (typeof correctPNG != 'undefined') {
181 correctPNG();
182 }
183
184 if (getActiveFeedId()) {
185 debug("some feed is open on feedlist refresh, reloading");
186 setTimeout("viewCurrentFeed()", 100);
187 }
188
189 } catch (e) {
190 exception_error("feedlist/init", e);
191 }
192 }