]>
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");
52 total_unread
= feedtu
.innerHTML
;
65 function viewfeed_callback() {
66 var container
= document
.getElementById('headlines');
67 if (xmlhttp
.readyState
== 4) {
68 container
.innerHTML
= xmlhttp
.responseText
;
70 var factive
= document
.getElementById("FACTIVE");
71 var funread
= document
.getElementById("FUNREAD");
72 var ftotal
= document
.getElementById("FTOTAL");
74 if (ftotal
&& factive
&& funread
) {
75 var feed_id
= factive
.innerHTML
;
77 var feedr
= document
.getElementById("FEEDR-" + feed_id
);
78 var feedt
= document
.getElementById("FEEDT-" + feed_id
);
79 var feedu
= document
.getElementById("FEEDU-" + feed_id
);
81 feedt
.innerHTML
= ftotal
.innerHTML
;
82 feedu
.innerHTML
= funread
.innerHTML
;
84 if (feedu
.innerHTML
> 0 && !feedr
.className
.match("Unread")) {
85 feedr
.className
= feedr
.className
+ "Unread";
86 } else if (feedu
.innerHTML
<= 0) {
87 feedr
.className
= feedr
.className
.replace("Unread", "");
97 function view_callback() {
98 var container
= document
.getElementById('content');
99 if (xmlhttp
.readyState
== 4) {
100 container
.innerHTML
=xmlhttp
.responseText
;
104 function refetch_callback() {
105 if (xmlhttp_rpc
.readyState
== 4) {
106 // feeds are updated in background
107 updateFeedList(false, false);
108 // notify("All feeds updated");
112 function scheduleFeedUpdate() {
114 notify("Updating feeds in background...");
116 var query_str
= "backend.php?op=rpc&subop=forceUpdateAllFeeds";
118 if (xmlhttp_rpc
.readyState
== 4 || xmlhttp_rpc
.readyState
== 0) {
119 xmlhttp_rpc
.open("GET", query_str
, true);
120 xmlhttp_rpc
.onreadystatechange
=refetch_callback
;
121 xmlhttp_rpc
.send(null);
127 function updateFeedList(silent
, fetch
) {
129 if (silent
!= true) {
130 notify("Updating feed list...");
133 var query_str
= "backend.php?op=feeds";
135 if (fetch
) query_str
= query_str
+ "&fetch=yes";
137 if (xmlhttp
.readyState
== 4 || xmlhttp
.readyState
== 0) {
138 xmlhttp
.open("GET", query_str
, true);
139 xmlhttp
.onreadystatechange
=feedlist_callback
;
146 function catchupPage(feed
) {
148 if (xmlhttp
.readyState
!= 4 && xmlhttp
.readyState
!= 0) {
153 var content
= document
.getElementById("headlinesList");
155 var rows
= new Array();
157 for (i
= 0; i
< content
.rows
.length
; i
++) {
158 var row_id
= content
.rows
[i
].id
.replace("RROW-", "");
159 if (row_id
.length
> 0) {
161 content
.rows
[i
].className
= content
.rows
[i
].className
.replace("Unread", "");
165 var feedr
= document
.getElementById("FEEDR-" + feed
);
166 var feedu
= document
.getElementById("FEEDU-" + feed
);
168 feedu
.innerHTML
= feedu
.innerHTML
- rows
.length
;
170 if (feedu
.innerHTML
> 0 && !feedr
.className
.match("Unread")) {
171 feedr
.className
= feedr
.className
+ "Unread";
172 } else if (feedu
.innerHTML
<= 0) {
173 feedr
.className
= feedr
.className
.replace("Unread", "");
176 var query_str
= "backend.php?op=rpc&subop=catchupPage&ids=" +
177 param_escape(rows
.toString());
179 notify("Marking this page as read...");
181 xmlhttp
.open("GET", query_str
, true);
182 xmlhttp
.onreadystatechange
=notify_callback
;
187 function catchupAllFeeds() {
189 if (xmlhttp
.readyState
!= 4 && xmlhttp
.readyState
!= 0) {
193 var query_str
= "backend.php?op=feeds&subop=catchupAll";
195 notify("Marking all feeds as read...");
197 xmlhttp
.open("GET", query_str
, true);
198 xmlhttp
.onreadystatechange
=feedlist_callback
;
203 function viewfeed(feed
, skip
, subop
) {
205 // document.getElementById('headlines').innerHTML='Loading headlines, please wait...';
206 // document.getElementById('content').innerHTML=' ';
208 if (xmlhttp
.readyState
!= 4 && xmlhttp
.readyState
!= 0) {
213 xmlhttp
.open("GET", "backend.php?op=viewfeed&feed=" + param_escape(feed
) +
214 "&skip=" + param_escape(skip
) + "&subop=" + param_escape(subop
) , true);
215 xmlhttp
.onreadystatechange
=viewfeed_callback
;
218 notify("Loading headlines...");
222 function view(id
,feed_id
) {
224 if (xmlhttp
.readyState
!= 4 && xmlhttp
.readyState
!= 0) {
229 var crow
= document
.getElementById("RROW-" + id
);
231 if (crow
.className
.match("Unread")) {
232 var umark
= document
.getElementById("FEEDU-" + feed_id
);
233 umark
.innerHTML
= umark
.innerHTML
- 1;
234 crow
.className
= crow
.className
.replace("Unread", "");
236 if (umark
.innerHTML
== "0") {
237 var feedr
= document
.getElementById("FEEDR-" + feed_id
);
238 feedr
.className
= feedr
.className
.replace("Unread", "");
246 var upd_img_pic
= document
.getElementById("FUPDPIC-" + id
);
249 upd_img_pic
.innerHTML
= "";
252 document
.getElementById('content').innerHTML
='Loading, please wait...';
254 xmlhttp
.open("GET", "backend.php?op=view&id=" + param_escape(id
), true);
255 xmlhttp
.onreadystatechange
=view_callback
;
262 scheduleFeedUpdate();
264 setTimeout("timeout()", 1800*1000);
268 function search(feed
, sender
) {
270 if (xmlhttp
.readyState
!= 4 && xmlhttp
.readyState
!= 0) {
275 notify("Search: " + feed
+ ", " + sender
.value
)
277 document
.getElementById('headlines').innerHTML
='Loading headlines, please wait...';
278 document
.getElementById('content').innerHTML
=' ';
280 xmlhttp
.open("GET", "backend.php?op=viewfeed&feed=" + param_escape(feed
) +
281 "&search=" + param_escape(sender
.value
) + "&ext=SEARCH", true);
282 xmlhttp
.onreadystatechange
=viewfeed_callback
;
287 function update_title() {
288 //document.title = "Tiny Tiny RSS (" + total_unread + " unread)";
292 updateFeedList(false, false);
293 setTimeout("timeout()", 1800*1000);