]>
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;
13 /*@if (@_jscript_version >= 5)
14 // JScript gives us Conditional compilation, we can cope with old IE versions.
15 // and security blocked creation of the objects.
17 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
20 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
27 if (!xmlhttp
&& typeof XMLHttpRequest
!='undefined') {
28 xmlhttp
= new XMLHttpRequest();
29 xmlhttp_rpc
= new XMLHttpRequest();
33 function printLockingError() {
34 notify("Please wait until operation finishes");
37 function notify_callback() {
38 var container
= document
.getElementById('notify');
39 if (xmlhttp
.readyState
== 4) {
40 container
.innerHTML
=xmlhttp
.responseText
;
44 function feedlist_callback() {
45 var container
= document
.getElementById('feeds');
46 if (xmlhttp
.readyState
== 4) {
47 container
.innerHTML
=xmlhttp
.responseText
;
49 // var feedtu = document.getElementById("FEEDTU");
51 // total_unread = feedtu.innerHTML;
56 scheduleFeedUpdate(false);
64 function viewfeed_callback() {
65 var container
= document
.getElementById('headlines');
66 if (xmlhttp
.readyState
== 4) {
67 container
.innerHTML
= xmlhttp
.responseText
;
69 var factive
= document
.getElementById("FACTIVE");
70 var funread
= document
.getElementById("FUNREAD");
71 var ftotal
= document
.getElementById("FTOTAL");
73 if (ftotal
&& factive
&& funread
) {
74 var feed_id
= factive
.innerHTML
;
76 var feedr
= document
.getElementById("FEEDR-" + feed_id
);
77 var feedt
= document
.getElementById("FEEDT-" + feed_id
);
78 var feedu
= document
.getElementById("FEEDU-" + feed_id
);
80 feedt
.innerHTML
= ftotal
.innerHTML
;
81 feedu
.innerHTML
= funread
.innerHTML
;
83 if (feedu
.innerHTML
> 0 && !feedr
.className
.match("Unread")) {
84 feedr
.className
= feedr
.className
+ "Unread";
85 } else if (feedu
.innerHTML
<= 0) {
86 feedr
.className
= feedr
.className
.replace("Unread", "");
96 function view_callback() {
97 var container
= document
.getElementById('content');
98 if (xmlhttp
.readyState
== 4) {
99 container
.innerHTML
=xmlhttp
.responseText
;
103 function refetch_callback() {
104 if (xmlhttp_rpc
.readyState
== 4) {
105 notify("All feeds updated");
107 var container
= document
.getElementById('feeds');
109 container
.innerHTML
= xmlhttp_rpc
.responseText
;
111 //updateFeedList(true, false);
115 function scheduleFeedUpdate(force
) {
117 notify("Updating feeds in background...");
119 var query_str
= "backend.php?op=rpc&subop=";
122 query_str
= query_str
+ "forceUpdateAllFeeds";
124 query_str
= query_str
+ "updateAllFeeds";
127 if (xmlhttp_rpc
.readyState
== 4 || xmlhttp_rpc
.readyState
== 0) {
128 xmlhttp_rpc
.open("GET", query_str
, true);
129 xmlhttp_rpc
.onreadystatechange
=refetch_callback
;
130 xmlhttp_rpc
.send(null);
136 function updateFeedList(silent
, fetch
) {
138 if (silent
!= true) {
139 notify("Loading feed list...");
142 var query_str
= "backend.php?op=feeds";
144 if (fetch
) query_str
= query_str
+ "&fetch=yes";
146 if (xmlhttp
.readyState
== 4 || xmlhttp
.readyState
== 0) {
147 xmlhttp
.open("GET", query_str
, true);
148 xmlhttp
.onreadystatechange
=feedlist_callback
;
155 function catchupPage(feed
) {
157 if (xmlhttp
.readyState
!= 4 && xmlhttp
.readyState
!= 0) {
162 var content
= document
.getElementById("headlinesList");
164 var rows
= new Array();
166 for (i
= 0; i
< content
.rows
.length
; i
++) {
167 var row_id
= content
.rows
[i
].id
.replace("RROW-", "");
168 if (row_id
.length
> 0) {
169 if (content
.rows
[i
].className
.match("Unread")) {
171 content
.rows
[i
].className
= content
.rows
[i
].className
.replace("Unread", "");
176 if (rows
.length
> 0) {
178 var feedr
= document
.getElementById("FEEDR-" + feed
);
179 var feedu
= document
.getElementById("FEEDU-" + feed
);
181 feedu
.innerHTML
= feedu
.innerHTML
- rows
.length
;
183 if (feedu
.innerHTML
> 0 && !feedr
.className
.match("Unread")) {
184 feedr
.className
= feedr
.className
+ "Unread";
185 } else if (feedu
.innerHTML
<= 0) {
186 feedr
.className
= feedr
.className
.replace("Unread", "");
189 var query_str
= "backend.php?op=rpc&subop=catchupPage&ids=" +
190 param_escape(rows
.toString());
192 notify("Marking this page as read...");
194 xmlhttp
.open("GET", query_str
, true);
195 xmlhttp
.onreadystatechange
=notify_callback
;
199 notify("No unread items on this page.");
204 function catchupAllFeeds() {
206 if (xmlhttp
.readyState
!= 4 && xmlhttp
.readyState
!= 0) {
210 var query_str
= "backend.php?op=feeds&subop=catchupAll";
212 notify("Marking all feeds as read...");
214 xmlhttp
.open("GET", query_str
, true);
215 xmlhttp
.onreadystatechange
=feedlist_callback
;
220 function viewfeed(feed
, skip
, subop
) {
222 // document.getElementById('headlines').innerHTML='Loading headlines, please wait...';
223 // document.getElementById('content').innerHTML=' ';
225 if (xmlhttp
.readyState
!= 4 && xmlhttp
.readyState
!= 0) {
230 xmlhttp
.open("GET", "backend.php?op=viewfeed&feed=" + param_escape(feed
) +
231 "&skip=" + param_escape(skip
) + "&subop=" + param_escape(subop
) , true);
232 xmlhttp
.onreadystatechange
=viewfeed_callback
;
235 notify("Loading headlines...");
239 function view(id
,feed_id
) {
241 if (xmlhttp
.readyState
!= 4 && xmlhttp
.readyState
!= 0) {
246 var crow
= document
.getElementById("RROW-" + id
);
248 if (crow
.className
.match("Unread")) {
249 var umark
= document
.getElementById("FEEDU-" + feed_id
);
250 umark
.innerHTML
= umark
.innerHTML
- 1;
251 crow
.className
= crow
.className
.replace("Unread", "");
253 if (umark
.innerHTML
== "0") {
254 var feedr
= document
.getElementById("FEEDR-" + feed_id
);
255 feedr
.className
= feedr
.className
.replace("Unread", "");
263 var upd_img_pic
= document
.getElementById("FUPDPIC-" + id
);
266 upd_img_pic
.innerHTML
= "";
269 document
.getElementById('content').innerHTML
='Loading, please wait...';
271 xmlhttp
.open("GET", "backend.php?op=view&id=" + param_escape(id
), true);
272 xmlhttp
.onreadystatechange
=view_callback
;
279 scheduleFeedUpdate(true);
281 setTimeout("timeout()", 1800*1000);
285 function search(feed
, sender
) {
287 if (xmlhttp
.readyState
!= 4 && xmlhttp
.readyState
!= 0) {
292 notify("Search: " + feed
+ ", " + sender
.value
)
294 document
.getElementById('headlines').innerHTML
='Loading headlines, please wait...';
295 document
.getElementById('content').innerHTML
=' ';
297 xmlhttp
.open("GET", "backend.php?op=viewfeed&feed=" + param_escape(feed
) +
298 "&search=" + param_escape(sender
.value
) + "&ext=SEARCH", true);
299 xmlhttp
.onreadystatechange
=viewfeed_callback
;
304 function update_title() {
305 //document.title = "Tiny Tiny RSS (" + total_unread + " unread)";
309 updateFeedList(false, false);
310 setTimeout("timeout()", 1800*1000);