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