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