]>
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");
21 xmlhttp_rpc = new ActiveXObject("Microsoft.XMLHTTP");
29 if (!xmlhttp
&& typeof XMLHttpRequest
!='undefined') {
30 xmlhttp
= new XMLHttpRequest();
31 xmlhttp_rpc
= new XMLHttpRequest();
35 function notify_callback() {
36 var container
= document
.getElementById('notify');
37 if (xmlhttp
.readyState
== 4) {
38 container
.innerHTML
=xmlhttp
.responseText
;
42 function feedlist_callback() {
43 var container
= document
.getElementById('feeds');
44 if (xmlhttp
.readyState
== 4) {
45 container
.innerHTML
=xmlhttp
.responseText
;
47 // var feedtu = document.getElementById("FEEDTU");
49 // total_unread = feedtu.innerHTML;
54 scheduleFeedUpdate(false);
62 function viewfeed_callback() {
63 var container
= document
.getElementById('headlines');
64 if (xmlhttp
.readyState
== 4) {
65 container
.innerHTML
= xmlhttp
.responseText
;
67 var factive
= document
.getElementById("FACTIVE");
68 var funread
= document
.getElementById("FUNREAD");
69 var ftotal
= document
.getElementById("FTOTAL");
71 if (ftotal
&& factive
&& funread
) {
72 var feed_id
= factive
.innerHTML
;
74 var feedr
= document
.getElementById("FEEDR-" + feed_id
);
75 var feedt
= document
.getElementById("FEEDT-" + feed_id
);
76 var feedu
= document
.getElementById("FEEDU-" + feed_id
);
78 feedt
.innerHTML
= ftotal
.innerHTML
;
79 feedu
.innerHTML
= funread
.innerHTML
;
81 if (feedu
.innerHTML
> 0 && !feedr
.className
.match("Unread")) {
82 feedr
.className
= feedr
.className
+ "Unread";
83 } else if (feedu
.innerHTML
<= 0) {
84 feedr
.className
= feedr
.className
.replace("Unread", "");
94 function view_callback() {
95 var container
= document
.getElementById('content');
96 if (xmlhttp
.readyState
== 4) {
97 container
.innerHTML
=xmlhttp
.responseText
;
101 function refetch_callback() {
102 if (xmlhttp_rpc
.readyState
== 4) {
103 notify("All feeds updated");
105 var container
= document
.getElementById('feeds');
107 container
.innerHTML
= xmlhttp_rpc
.responseText
;
109 document
.title
= "Tiny Tiny RSS";
111 //updateFeedList(true, false);
115 function scheduleFeedUpdate(force
) {
117 notify("Updating feeds in background...");
119 document
.title
= "Tiny Tiny RSS - Updating...";
121 var query_str
= "backend.php?op=rpc&subop=";
124 query_str
= query_str
+ "forceUpdateAllFeeds";
126 query_str
= query_str
+ "updateAllFeeds";
129 if (xmlhttp_rpc
.readyState
== 4 || xmlhttp_rpc
.readyState
== 0) {
130 xmlhttp_rpc
.open("GET", query_str
, true);
131 xmlhttp_rpc
.onreadystatechange
=refetch_callback
;
132 xmlhttp_rpc
.send(null);
138 function updateFeedList(silent
, fetch
) {
140 if (silent
!= true) {
141 notify("Loading feed list...");
144 var query_str
= "backend.php?op=feeds";
146 if (fetch
) query_str
= query_str
+ "&fetch=yes";
148 if (xmlhttp
.readyState
== 4 || xmlhttp
.readyState
== 0) {
149 xmlhttp
.open("GET", query_str
, true);
150 xmlhttp
.onreadystatechange
=feedlist_callback
;
157 function catchupPage(feed
) {
159 if (xmlhttp
.readyState
!= 4 && xmlhttp
.readyState
!= 0) {
164 var content
= document
.getElementById("headlinesList");
166 var rows
= new Array();
168 for (i
= 0; i
< content
.rows
.length
; i
++) {
169 var row_id
= content
.rows
[i
].id
.replace("RROW-", "");
170 if (row_id
.length
> 0) {
171 if (content
.rows
[i
].className
.match("Unread")) {
173 content
.rows
[i
].className
= content
.rows
[i
].className
.replace("Unread", "");
178 if (rows
.length
> 0) {
180 var feedr
= document
.getElementById("FEEDR-" + feed
);
181 var feedu
= document
.getElementById("FEEDU-" + feed
);
183 feedu
.innerHTML
= feedu
.innerHTML
- rows
.length
;
185 if (feedu
.innerHTML
> 0 && !feedr
.className
.match("Unread")) {
186 feedr
.className
= feedr
.className
+ "Unread";
187 } else if (feedu
.innerHTML
<= 0) {
188 feedr
.className
= feedr
.className
.replace("Unread", "");
191 var query_str
= "backend.php?op=rpc&subop=catchupPage&ids=" +
192 param_escape(rows
.toString());
194 notify("Marking this page as read...");
196 xmlhttp
.open("GET", query_str
, true);
197 xmlhttp
.onreadystatechange
=notify_callback
;
201 notify("No unread items on this page.");
206 function catchupAllFeeds() {
208 if (xmlhttp
.readyState
!= 4 && xmlhttp
.readyState
!= 0) {
212 var query_str
= "backend.php?op=feeds&subop=catchupAll";
214 notify("Marking all feeds as read...");
216 xmlhttp
.open("GET", query_str
, true);
217 xmlhttp
.onreadystatechange
=feedlist_callback
;
222 function viewfeed(feed
, skip
, subop
) {
224 // document.getElementById('headlines').innerHTML='Loading headlines, please wait...';
225 // document.getElementById('content').innerHTML=' ';
227 if (xmlhttp
.readyState
!= 4 && xmlhttp
.readyState
!= 0) {
232 xmlhttp
.open("GET", "backend.php?op=viewfeed&feed=" + param_escape(feed
) +
233 "&skip=" + param_escape(skip
) + "&subop=" + param_escape(subop
) , true);
234 xmlhttp
.onreadystatechange
=viewfeed_callback
;
237 notify("Loading headlines...");
241 function view(id
,feed_id
) {
243 if (xmlhttp
.readyState
!= 4 && xmlhttp
.readyState
!= 0) {
248 var crow
= document
.getElementById("RROW-" + id
);
250 if (crow
.className
.match("Unread")) {
251 var umark
= document
.getElementById("FEEDU-" + feed_id
);
252 umark
.innerHTML
= umark
.innerHTML
- 1;
253 crow
.className
= crow
.className
.replace("Unread", "");
255 if (umark
.innerHTML
== "0") {
256 var feedr
= document
.getElementById("FEEDR-" + feed_id
);
257 feedr
.className
= feedr
.className
.replace("Unread", "");
265 var upd_img_pic
= document
.getElementById("FUPDPIC-" + id
);
268 upd_img_pic
.innerHTML
= "";
271 document
.getElementById('content').innerHTML
='Loading, please wait...';
273 xmlhttp
.open("GET", "backend.php?op=view&id=" + param_escape(id
), true);
274 xmlhttp
.onreadystatechange
=view_callback
;
281 scheduleFeedUpdate(true);
283 setTimeout("timeout()", 1800*1000);
287 function search(feed
, sender
) {
289 if (xmlhttp
.readyState
!= 4 && xmlhttp
.readyState
!= 0) {
294 notify("Search: " + feed
+ ", " + sender
.value
)
296 document
.getElementById('headlines').innerHTML
='Loading headlines, please wait...';
297 document
.getElementById('content').innerHTML
=' ';
299 xmlhttp
.open("GET", "backend.php?op=viewfeed&feed=" + param_escape(feed
) +
300 "&search=" + param_escape(sender
.value
) + "&ext=SEARCH", true);
301 xmlhttp
.onreadystatechange
=viewfeed_callback
;
306 function update_title() {
307 //document.title = "Tiny Tiny RSS (" + total_unread + " unread)";
311 updateFeedList(false, false);
312 setTimeout("timeout()", 1800*1000);