]>
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.
11 /*@if (@_jscript_version >= 5)
12 // JScript gives us Conditional compilation, we can cope with old IE versions.
13 // and security blocked creation of the objects.
15 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
18 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
25 if (!xmlhttp
&& typeof XMLHttpRequest
!='undefined') {
26 xmlhttp
= new XMLHttpRequest();
29 function notify_callback() {
30 var container
= document
.getElementById('notify');
31 if (xmlhttp
.readyState
== 4) {
32 container
.innerHTML
=xmlhttp
.responseText
;
36 function feedlist_callback() {
37 var container
= document
.getElementById('feeds');
38 if (xmlhttp
.readyState
== 4) {
39 container
.innerHTML
=xmlhttp
.responseText
;
41 var feedtu
= document
.getElementById("FEEDTU");
44 total_unread
= feedtu
.innerHTML
;
52 function viewfeed_callback() {
53 var container
= document
.getElementById('headlines');
54 if (xmlhttp
.readyState
== 4) {
55 container
.innerHTML
= xmlhttp
.responseText
;
57 var factive
= document
.getElementById("FACTIVE");
58 var funread
= document
.getElementById("FUNREAD");
59 var ftotal
= document
.getElementById("FTOTAL");
61 if (ftotal
&& factive
&& funread
) {
62 var feed_id
= factive
.innerHTML
;
64 var feedr
= document
.getElementById("FEEDR-" + feed_id
);
65 var feedt
= document
.getElementById("FEEDT-" + feed_id
);
66 var feedu
= document
.getElementById("FEEDU-" + feed_id
);
68 feedt
.innerHTML
= ftotal
.innerHTML
;
69 feedu
.innerHTML
= funread
.innerHTML
;
71 if (feedu
.innerHTML
> 0 && !feedr
.className
.match("Unread")) {
72 feedr
.className
= feedr
.className
+ "Unread";
73 } else if (feedu
.innerHTML
<= 0) {
74 feedr
.className
= feedr
.className
.replace("Unread", "");
84 function view_callback() {
85 var container
= document
.getElementById('content');
86 if (xmlhttp
.readyState
== 4) {
87 container
.innerHTML
=xmlhttp
.responseText
;
92 function updateFeedList(called_from_timer
, fetch
) {
94 if (called_from_timer
!= true) {
95 //document.getElementById("feeds").innerHTML = "Loading feeds, please wait...";
96 notify("Updating feeds...");
99 var query_str
= "backend.php?op=feeds";
101 if (fetch
) query_str
= query_str
+ "&fetch=yes";
103 xmlhttp
.open("GET", query_str
, true);
104 xmlhttp
.onreadystatechange
=feedlist_callback
;
109 function catchupPage(feed
) {
111 var content
= document
.getElementById("headlinesList");
113 var rows
= new Array();
115 for (i
= 0; i
< content
.rows
.length
; i
++) {
116 var row_id
= content
.rows
[i
].id
.replace("RROW-", "");
117 if (row_id
.length
> 0) {
119 content
.rows
[i
].className
= content
.rows
[i
].className
.replace("Unread", "");
123 var feedr
= document
.getElementById("FEEDR-" + feed
);
124 var feedu
= document
.getElementById("FEEDU-" + feed
);
126 feedu
.innerHTML
= feedu
.innerHTML
- rows
.length
;
128 if (feedu
.innerHTML
> 0 && !feedr
.className
.match("Unread")) {
129 feedr
.className
= feedr
.className
+ "Unread";
130 } else if (feedu
.innerHTML
<= 0) {
131 feedr
.className
= feedr
.className
.replace("Unread", "");
134 var query_str
= "backend.php?op=rpc&subop=catchupPage&ids=" +
135 param_escape(rows
.toString());
137 notify("Marking this page as read...");
139 xmlhttp
.open("GET", query_str
, true);
140 xmlhttp
.onreadystatechange
=notify_callback
;
145 function catchupAllFeeds() {
146 var query_str
= "backend.php?op=feeds&subop=catchupAll";
148 notify("Marking all feeds as read...");
150 xmlhttp
.open("GET", query_str
, true);
151 xmlhttp
.onreadystatechange
=feedlist_callback
;
156 function viewfeed(feed
, skip
, subop
) {
158 // document.getElementById('headlines').innerHTML='Loading headlines, please wait...';
159 // document.getElementById('content').innerHTML=' ';
161 xmlhttp
.open("GET", "backend.php?op=viewfeed&feed=" + param_escape(feed
) +
162 "&skip=" + param_escape(skip
) + "&subop=" + param_escape(subop
) , true);
163 xmlhttp
.onreadystatechange
=viewfeed_callback
;
166 notify("Loading headlines...");
170 function view(id
,feed_id
) {
172 var crow
= document
.getElementById("RROW-" + id
);
174 if (crow
.className
.match("Unread")) {
175 var umark
= document
.getElementById("FEEDU-" + feed_id
);
176 umark
.innerHTML
= umark
.innerHTML
- 1;
177 crow
.className
= crow
.className
.replace("Unread", "");
179 if (umark
.innerHTML
== "0") {
180 var feedr
= document
.getElementById("FEEDR-" + feed_id
);
181 feedr
.className
= feedr
.className
.replace("Unread", "");
189 var upd_img_pic
= document
.getElementById("FUPDPIC-" + id
);
192 upd_img_pic
.innerHTML
= "";
195 document
.getElementById('content').innerHTML
='Loading, please wait...';
197 xmlhttp
.open("GET", "backend.php?op=view&id=" + param_escape(id
), true);
198 xmlhttp
.onreadystatechange
=view_callback
;
205 updateFeedList(true, true);
207 setTimeout("timeout()", 1800*1000);
211 function search(feed
, sender
) {
213 notify("Search: " + feed
+ ", " + sender
.value
)
215 document
.getElementById('headlines').innerHTML
='Loading headlines, please wait...';
216 document
.getElementById('content').innerHTML
=' ';
218 xmlhttp
.open("GET", "backend.php?op=viewfeed&feed=" + param_escape(feed
) +
219 "&search=" + param_escape(sender
.value
) + "&ext=SEARCH", true);
220 xmlhttp
.onreadystatechange
=viewfeed_callback
;
225 function update_title() {
226 //document.title = "Tiny Tiny RSS (" + total_unread + " unread)";
230 updateFeedList(false, false);
231 setTimeout("timeout()", 1800*1000);