]>
git.wh0rd.org - tt-rss.git/blob - tt-rss.js
e3f1fc906ab724d160a35b6b5e2e91974473916b
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
;
57 scheduleFeedUpdate(false);
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 updateFeedList(true, false);
110 function scheduleFeedUpdate(force
) {
112 notify("Updating feeds in background...");
114 var query_str
= "backend.php?op=rpc&subop=";
117 query_str
= query_str
= "forceUpdateAllFeeds";
119 query_str
= query_str
= "updateAllFeeds";
122 if (xmlhttp_rpc
.readyState
== 4 || xmlhttp_rpc
.readyState
== 0) {
123 xmlhttp_rpc
.open("GET", query_str
, true);
124 xmlhttp_rpc
.onreadystatechange
=refetch_callback
;
125 xmlhttp_rpc
.send(null);
131 function updateFeedList(silent
, fetch
) {
133 if (silent
!= true) {
134 notify("Loading feed list...");
137 var query_str
= "backend.php?op=feeds";
139 if (fetch
) query_str
= query_str
+ "&fetch=yes";
141 if (xmlhttp
.readyState
== 4 || xmlhttp
.readyState
== 0) {
142 xmlhttp
.open("GET", query_str
, true);
143 xmlhttp
.onreadystatechange
=feedlist_callback
;
150 function catchupPage(feed
) {
152 if (xmlhttp
.readyState
!= 4 && xmlhttp
.readyState
!= 0) {
157 var content
= document
.getElementById("headlinesList");
159 var rows
= new Array();
161 for (i
= 0; i
< content
.rows
.length
; i
++) {
162 var row_id
= content
.rows
[i
].id
.replace("RROW-", "");
163 if (row_id
.length
> 0) {
165 content
.rows
[i
].className
= content
.rows
[i
].className
.replace("Unread", "");
169 var feedr
= document
.getElementById("FEEDR-" + feed
);
170 var feedu
= document
.getElementById("FEEDU-" + feed
);
172 feedu
.innerHTML
= feedu
.innerHTML
- rows
.length
;
174 if (feedu
.innerHTML
> 0 && !feedr
.className
.match("Unread")) {
175 feedr
.className
= feedr
.className
+ "Unread";
176 } else if (feedu
.innerHTML
<= 0) {
177 feedr
.className
= feedr
.className
.replace("Unread", "");
180 var query_str
= "backend.php?op=rpc&subop=catchupPage&ids=" +
181 param_escape(rows
.toString());
183 notify("Marking this page as read...");
185 xmlhttp
.open("GET", query_str
, true);
186 xmlhttp
.onreadystatechange
=notify_callback
;
191 function catchupAllFeeds() {
193 if (xmlhttp
.readyState
!= 4 && xmlhttp
.readyState
!= 0) {
197 var query_str
= "backend.php?op=feeds&subop=catchupAll";
199 notify("Marking all feeds as read...");
201 xmlhttp
.open("GET", query_str
, true);
202 xmlhttp
.onreadystatechange
=feedlist_callback
;
207 function viewfeed(feed
, skip
, subop
) {
209 // document.getElementById('headlines').innerHTML='Loading headlines, please wait...';
210 // document.getElementById('content').innerHTML=' ';
212 if (xmlhttp
.readyState
!= 4 && xmlhttp
.readyState
!= 0) {
217 xmlhttp
.open("GET", "backend.php?op=viewfeed&feed=" + param_escape(feed
) +
218 "&skip=" + param_escape(skip
) + "&subop=" + param_escape(subop
) , true);
219 xmlhttp
.onreadystatechange
=viewfeed_callback
;
222 notify("Loading headlines...");
226 function view(id
,feed_id
) {
228 if (xmlhttp
.readyState
!= 4 && xmlhttp
.readyState
!= 0) {
233 var crow
= document
.getElementById("RROW-" + id
);
235 if (crow
.className
.match("Unread")) {
236 var umark
= document
.getElementById("FEEDU-" + feed_id
);
237 umark
.innerHTML
= umark
.innerHTML
- 1;
238 crow
.className
= crow
.className
.replace("Unread", "");
240 if (umark
.innerHTML
== "0") {
241 var feedr
= document
.getElementById("FEEDR-" + feed_id
);
242 feedr
.className
= feedr
.className
.replace("Unread", "");
250 var upd_img_pic
= document
.getElementById("FUPDPIC-" + id
);
253 upd_img_pic
.innerHTML
= "";
256 document
.getElementById('content').innerHTML
='Loading, please wait...';
258 xmlhttp
.open("GET", "backend.php?op=view&id=" + param_escape(id
), true);
259 xmlhttp
.onreadystatechange
=view_callback
;
266 scheduleFeedUpdate(true);
268 setTimeout("timeout()", 1800*1000);
272 function search(feed
, sender
) {
274 if (xmlhttp
.readyState
!= 4 && xmlhttp
.readyState
!= 0) {
279 notify("Search: " + feed
+ ", " + sender
.value
)
281 document
.getElementById('headlines').innerHTML
='Loading headlines, please wait...';
282 document
.getElementById('content').innerHTML
=' ';
284 xmlhttp
.open("GET", "backend.php?op=viewfeed&feed=" + param_escape(feed
) +
285 "&search=" + param_escape(sender
.value
) + "&ext=SEARCH", true);
286 xmlhttp
.onreadystatechange
=viewfeed_callback
;
291 function update_title() {
292 //document.title = "Tiny Tiny RSS (" + total_unread + " unread)";
296 updateFeedList(false, false);
297 setTimeout("timeout()", 1800*1000);