]>
git.wh0rd.org - tt-rss.git/blob - tt-rss.js
2 This program is Copyright (c) 2003-2005 Andrew Dolgov <cthulhoo@gmail.com>
3 Licensed under GPL v.2 or (at your preference) any later version.
7 var xmlhttp_rpc
= false;
8 var xmlhttp_view
= false;
13 var active_feed_id
= false;
15 var search_query
= "";
18 /*@if (@_jscript_version >= 5)
19 // JScript gives us Conditional compilation, we can cope with old IE versions.
20 // and security blocked creation of the objects.
22 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
25 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
26 xmlhttp_rpc = new ActiveXObject("Microsoft.XMLHTTP");
27 xmlhttp_view = new ActiveXObject("Microsoft.XMLHTTP");
36 if (!xmlhttp
&& typeof XMLHttpRequest
!='undefined') {
37 xmlhttp
= new XMLHttpRequest();
38 xmlhttp_rpc
= new XMLHttpRequest();
39 xmlhttp_view
= new XMLHttpRequest();
43 function feedlist_callback() {
44 var container = document.getElementById('feeds');
45 if (xmlhttp.readyState == 4) {
46 container.innerHTML=xmlhttp.responseText;
49 scheduleFeedUpdate(false);
50 if (getCookie("ttrss_vf_actfeed")) {
51 viewfeed(getCookie("ttrss_vf_actfeed"), 0, "");
61 function checkActiveFeedId() {
63 var actfeedid
= frames
["feeds-frame"].document
.getElementById("ACTFEEDID");
66 active_feed_id
= actfeedid
.innerHTML
;
70 function refetch_callback() {
72 if (xmlhttp_rpc
.readyState
== 4) {
74 document
.title
= "Tiny Tiny RSS";
75 notify("All feeds updated.");
83 function updateFeed(feed_id
) {
85 var query_str
= "backend.php?op=rpc&subop=updateFeed&feed=" + feed_id
;
87 if (xmlhttp_ready(xmlhttp_rpc
)) {
88 xmlhttp_rpc
.open("GET", query_str
, true);
89 xmlhttp_rpc
.onreadystatechange
=feed_update_callback
;
90 xmlhttp_rpc
.send(null);
97 function scheduleFeedUpdate(force
) {
99 notify("Updating feeds in background...");
101 document
.title
= "Tiny Tiny RSS - Updating...";
103 var query_str
= "backend.php?op=rpc&subop=";
106 query_str
= query_str
+ "forceUpdateAllFeeds";
108 query_str
= query_str
+ "updateAllFeeds";
111 if (xmlhttp_ready(xmlhttp_rpc
)) {
112 xmlhttp_rpc
.open("GET", query_str
, true);
113 xmlhttp_rpc
.onreadystatechange
=refetch_callback
;
114 xmlhttp_rpc
.send(null);
120 function updateFeedList(silent
, fetch
) {
122 // if (silent != true) {
123 // notify("Loading feed list...");
126 var query_str
= "backend.php?op=feeds";
128 if (active_feed_id
) {
129 query_str
= query_str
+ "&actid=" + active_feed_id
;
132 if (fetch
) query_str
= query_str
+ "&fetch=yes";
134 var feeds_frame
= document
.getElementById("feeds-frame");
136 feeds_frame
.src
= query_str
;
139 function catchupAllFeeds() {
141 var query_str
= "backend.php?op=feeds&subop=catchupAll";
143 notify("Marking all feeds as read...");
145 var feeds_frame
= document
.getElementById("feeds-frame");
147 feeds_frame
.src
= query_str
;
151 function viewCurrentFeed(skip
, subop
) {
153 active_feed_id
= frames
["feeds-frame"].document
.getElementById("ACTFEEDID").innerHTML
;
155 if (active_feed_id
) {
156 viewfeed(active_feed_id
, skip
, subop
);
160 function viewfeed(feed
, skip
, subop
) {
162 // notify("Loading headlines...");
166 var searchbox
= document
.getElementById("searchbox");
169 search_query
= searchbox
.value
;
174 var viewbox
= document
.getElementById("viewbox");
179 view_mode
= viewbox
.value
;
181 view_mode
= "All Posts";
184 setCookie("ttrss_vf_vmode", view_mode
);
186 var limitbox
= document
.getElementById("limitbox");
191 limit
= limitbox
.value
;
192 setCookie("ttrss_vf_limit", limit
);
197 active_feed_id
= feed
;
199 var f_doc
= frames
["feeds-frame"].document
;
201 f_doc
.getElementById("ACTFEEDID").innerHTML
= feed
;
203 setCookie("ttrss_vf_actfeed", feed
);
205 if (subop
== "MarkAllRead") {
207 var feedr
= f_doc
.getElementById("FEEDR-" + feed
);
208 var feedctr
= f_doc
.getElementById("FEEDCTR-" + feed
);
210 feedctr
.className
= "invisible";
212 if (feedr
.className
.match("Unread")) {
213 feedr
.className
= feedr
.className
.replace("Unread", "");
217 var query
= "backend.php?op=viewfeed&feed=" + param_escape(feed
) +
218 "&skip=" + param_escape(skip
) + "&subop=" + param_escape(subop
) +
219 "&view=" + param_escape(view_mode
) + "&limit=" + limit
;
221 if (search_query
!= "") {
222 query
= query
+ "&search=" + param_escape(search_query
);
225 var headlines_frame
= parent
.frames
["headlines-frame"];
227 headlines_frame
.location
.href
= query
+ "&addheader=true";
229 cleanSelected("feedsList");
230 var feedr
= document
.getElementById("FEEDR-" + feed
);
232 feedr
.className
= feedr
.className
+ "Selected";
235 disableContainerChildren("headlinesToolbar", false, doc
);
243 scheduleFeedUpdate(true);
244 setTimeout("timeout()", 1800*1000);
247 function resetSearch() {
248 var searchbox
= document
.getElementById("searchbox")
250 if (searchbox
.value
!= "" && active_feed_id
) {
251 searchbox
.value
= "";
252 viewfeed(active_feed_id
, 0, "");
258 if (active_feed_id
) {
259 viewfeed(active_feed_id
, 0, "");
261 notify("Please select some feed first.");
265 function localPiggieFunction(enable
) {
267 var query_str
= "backend.php?op=feeds&subop=piggie";
269 if (xmlhttp_ready(xmlhttp
)) {
271 xmlhttp
.open("GET", query_str
, true);
272 xmlhttp
.onreadystatechange
=feedlist_callback
;
278 function localHotkeyHandler(keycode
) {
280 /* if (keycode == 78) {
281 return moveToPost('next');
285 return moveToPost('prev');
289 return scheduleFeedUpdate(true);
293 return viewfeed(active_feed_id
, active_offset
, "ForceUpdate");
296 // notify("KC: " + keycode);
302 disableContainerChildren("headlinesToolbar", true);
306 if (xmlhttp
&& !xmlhttp_rpc
) {
307 xmlhttp_rpc
= xmlhttp
;
308 xmlhttp_view
= xmlhttp
;
311 if (!xmlhttp
|| !xmlhttp_rpc
|| !xmlhttp_view
) {
312 document
.getElementById("headlines").innerHTML
=
313 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
314 "to function properly. Your browser doesn't seem to support it.";
318 updateFeedList(false, false);
319 document
.onkeydown
= hotkey_handler
;
321 setTimeout("timeout()", 1800*1000);
322 scheduleFeedUpdate(true);
324 var content
= document
.getElementById("content");
326 if (getCookie("ttrss_vf_vmode")) {
327 var viewbox
= document
.getElementById("viewbox");
328 viewbox
.value
= getCookie("ttrss_vf_vmode");
331 if (getCookie("ttrss_vf_limit")) {
332 var limitbox
= document
.getElementById("limitbox");
333 limitbox
.value
= getCookie("ttrss_vf_limit");