]> git.wh0rd.org - tt-rss.git/blame_incremental - tt-rss.js
posts register as updated when their MD5 hash changes
[tt-rss.git] / tt-rss.js
... / ...
CommitLineData
1/*
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.
4*/
5
6var xmlhttp = false;
7
8var total_unread = 0;
9
10/*@cc_on @*/
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.
14try {
15 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
16} catch (e) {
17 try {
18 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
19 } catch (E) {
20 xmlhttp = false;
21 }
22}
23@end @*/
24
25if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
26 xmlhttp = new XMLHttpRequest();
27}
28
29function feedlist_callback() {
30 var container = document.getElementById('feeds');
31 if (xmlhttp.readyState == 4) {
32 container.innerHTML=xmlhttp.responseText;
33
34 var feedtu = document.getElementById("FEEDTU");
35
36 if (feedtu) {
37 total_unread = feedtu.innerHTML;
38 update_title();
39 }
40 }
41}
42
43function viewfeed_callback() {
44 var container = document.getElementById('headlines');
45 if (xmlhttp.readyState == 4) {
46 container.innerHTML = xmlhttp.responseText;
47
48 var factive = document.getElementById("FACTIVE");
49 var funread = document.getElementById("FUNREAD");
50 var ftotal = document.getElementById("FTOTAL");
51
52 if (ftotal && factive && funread) {
53 var feed_id = factive.innerHTML;
54
55 var feedr = document.getElementById("FEEDR-" + feed_id);
56 var feedt = document.getElementById("FEEDT-" + feed_id);
57 var feedu = document.getElementById("FEEDU-" + feed_id);
58
59 feedt.innerHTML = ftotal.innerHTML;
60 feedu.innerHTML = funread.innerHTML;
61
62 if (feedu.innerHTML > 0 && !feedr.className.match("Unread")) {
63 feedr.className = feedr.className + "Unread";
64 } else if (feedu.innerHTML <= 0) {
65 feedr.className = feedr.className.replace("Unread", "");
66 }
67
68 }
69 }
70}
71
72function view_callback() {
73 var container = document.getElementById('content');
74 if (xmlhttp.readyState == 4) {
75 container.innerHTML=xmlhttp.responseText;
76 }
77}
78
79
80function update_feed_list(called_from_timer, fetch) {
81
82 if (called_from_timer != true) {
83 document.getElementById("feeds").innerHTML = "Loading feeds, please wait...";
84 }
85
86 var query_str = "backend.php?op=feeds";
87
88 if (fetch) query_str = query_str + "&fetch=yes";
89
90 xmlhttp.open("GET", query_str, true);
91 xmlhttp.onreadystatechange=feedlist_callback;
92 xmlhttp.send(null);
93
94
95}
96
97function viewfeed(feed, skip, ext) {
98
99// notify("view-feed: " + feed);
100
101 document.getElementById('headlines').innerHTML='Loading headlines, please wait...';
102 document.getElementById('content').innerHTML='&nbsp;';
103
104 xmlhttp.open("GET", "backend.php?op=viewfeed&feed=" + param_escape(feed) +
105 "&skip=" + param_escape(skip) + "&ext=" + param_escape(ext) , true);
106 xmlhttp.onreadystatechange=viewfeed_callback;
107 xmlhttp.send(null);
108
109}
110
111function view(id,feed_id) {
112
113 var crow = document.getElementById("RROW-" + id);
114
115 if (crow.className.match("Unread")) {
116 var umark = document.getElementById("FEEDU-" + feed_id);
117 umark.innerHTML = umark.innerHTML - 1;
118 crow.className = crow.className.replace("Unread", "");
119
120 if (umark.innerHTML == "0") {
121 var feedr = document.getElementById("FEEDR-" + feed_id);
122 feedr.className = feedr.className.replace("Unread", "");
123 }
124
125 total_unread--;
126
127 update_title();
128 }
129
130 var upd_img_pic = document.getElementById("FUPDPIC-" + id);
131
132 if (upd_img_pic) {
133 upd_img_pic.innerHTML = "";
134 }
135
136 document.getElementById('content').innerHTML='Loading, please wait...';
137
138 xmlhttp.open("GET", "backend.php?op=view&id=" + param_escape(id), true);
139 xmlhttp.onreadystatechange=view_callback;
140 xmlhttp.send(null);
141
142}
143
144function timeout() {
145
146 update_feed_list(true);
147
148 setTimeout("timeout()", 1800*1000);
149
150}
151
152function search(feed, sender) {
153
154 notify("Search: " + feed + ", " + sender.value)
155
156 document.getElementById('headlines').innerHTML='Loading headlines, please wait...';
157 document.getElementById('content').innerHTML='&nbsp;';
158
159 xmlhttp.open("GET", "backend.php?op=viewfeed&feed=" + param_escape(feed) +
160 "&search=" + param_escape(sender.value) + "&ext=SEARCH", true);
161 xmlhttp.onreadystatechange=viewfeed_callback;
162 xmlhttp.send(null);
163
164}
165
166function update_title() {
167 //document.title = "Tiny Tiny RSS (" + total_unread + " unread)";
168}
169
170function init() {
171 update_feed_list(false, false);
172 setTimeout("timeout()", 1800*1000);
173}