]>
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;
8 var xmlhttp_view
= false;
13 var active_feed_id
= false;
15 var search_query
= "";
18 /*@if (@_jscript_version >= 5)
19 // JScript gives us Conditional compilation, we can cope with old IE versions.
20 // and security blocked creation of the objects.
22 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
25 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
26 xmlhttp_rpc = new ActiveXObject("Microsoft.XMLHTTP");
27 xmlhttp_view = new ActiveXObject("Microsoft.XMLHTTP");
36 if (!xmlhttp
&& typeof XMLHttpRequest
!='undefined') {
37 xmlhttp
= new XMLHttpRequest();
38 xmlhttp_rpc
= new XMLHttpRequest();
39 xmlhttp_view
= new XMLHttpRequest();
43 function feedlist_callback() {
44 var container = document.getElementById('feeds');
45 if (xmlhttp.readyState == 4) {
46 container.innerHTML=xmlhttp.responseText;
49 scheduleFeedUpdate(false);
50 if (getCookie("ttrss_vf_actfeed")) {
51 viewfeed(getCookie("ttrss_vf_actfeed"), 0, "");
62 function refetch_callback() {
64 if (xmlhttp_rpc
.readyState
== 4) {
65 notify("All feeds updated");
67 active_feed_id
= frames
["feeds-frame"].document
.getElementById("ACTFEEDID").innerHTML
;
69 document
.title
= "Tiny Tiny RSS";
77 function updateFeed(feed_id
) {
79 var query_str
= "backend.php?op=rpc&subop=updateFeed&feed=" + feed_id
;
81 if (xmlhttp_ready(xmlhttp_rpc
)) {
82 xmlhttp_rpc
.open("GET", query_str
, true);
83 xmlhttp_rpc
.onreadystatechange
=feed_update_callback
;
84 xmlhttp_rpc
.send(null);
91 function scheduleFeedUpdate(force
) {
93 notify("Updating feeds in background...");
95 document
.title
= "Tiny Tiny RSS - Updating...";
97 var query_str
= "backend.php?op=rpc&subop=";
100 query_str
= query_str
+ "forceUpdateAllFeeds";
102 query_str
= query_str
+ "updateAllFeeds";
105 if (xmlhttp_ready(xmlhttp_rpc
)) {
106 xmlhttp_rpc
.open("GET", query_str
, true);
107 xmlhttp_rpc
.onreadystatechange
=refetch_callback
;
108 xmlhttp_rpc
.send(null);
114 function updateFeedList(silent
, fetch
) {
116 // if (silent != true) {
117 // notify("Loading feed list...");
120 var query_str
= "backend.php?op=feeds";
122 if (active_feed_id
) {
123 query_str
= query_str
+ "&actid=" + active_feed_id
;
126 if (fetch
) query_str
= query_str
+ "&fetch=yes";
128 var feeds_frame
= document
.getElementById("feeds-frame");
130 feeds_frame
.src
= query_str
;
133 function catchupAllFeeds() {
135 var query_str
= "backend.php?op=feeds&subop=catchupAll";
137 notify("Marking all feeds as read...");
139 var feeds_frame
= document
.getElementById("feeds-frame");
141 feeds_frame
.src
= query_str
;
145 function viewCurrentFeed(skip
, subop
) {
147 active_feed_id
= frames
["feeds-frame"].document
.getElementById("ACTFEEDID").innerHTML
;
149 if (active_feed_id
) {
150 viewfeed(active_feed_id
, skip
, subop
);
154 function viewfeed(feed
, skip
, subop
) {
156 notify("Loading headlines...");
160 var searchbox
= document
.getElementById("searchbox");
163 search_query
= searchbox
.value
;
168 var viewbox
= document
.getElementById("viewbox");
173 view_mode
= viewbox
.value
;
175 view_mode
= "All Posts";
178 setCookie("ttrss_vf_vmode", view_mode
);
180 var limitbox
= document
.getElementById("limitbox");
185 limit
= limitbox
.value
;
186 setCookie("ttrss_vf_limit", limit
);
191 active_feed_id
= feed
;
193 var f_doc
= frames
["feeds-frame"].document
;
195 f_doc
.getElementById("ACTFEEDID").innerHTML
= feed
;
197 setCookie("ttrss_vf_actfeed", feed
);
199 if (subop
== "MarkAllRead") {
201 var feedr
= f_doc
.getElementById("FEEDR-" + feed
);
202 var feedt
= f_doc
.getElementById("FEEDT-" + feed
);
203 var feedu
= f_doc
.getElementById("FEEDU-" + feed
);
205 feedu
.innerHTML
= "0";
207 if (feedr
.className
.match("Unread")) {
208 feedr
.className
= feedr
.className
.replace("Unread", "");
212 var query
= "backend.php?op=viewfeed&feed=" + param_escape(feed
) +
213 "&skip=" + param_escape(skip
) + "&subop=" + param_escape(subop
) +
214 "&view=" + param_escape(view_mode
) + "&limit=" + limit
;
216 if (search_query
!= "") {
217 query
= query
+ "&search=" + param_escape(search_query
);
220 var headlines_frame
= parent
.frames
["headlines-frame"];
222 headlines_frame
.location
.href
= query
+ "&addheader=true";
224 cleanSelected("feedsList");
225 var feedr
= document
.getElementById("FEEDR-" + feed
);
227 feedr
.className
= feedr
.className
+ "Selected";
230 disableContainerChildren("headlinesToolbar", false, doc
);
238 scheduleFeedUpdate(true);
239 setTimeout("timeout()", 1800*1000);
242 function resetSearch() {
243 var searchbox
= document
.getElementById("searchbox")
245 if (searchbox
.value
!= "" && active_feed_id
) {
246 searchbox
.value
= "";
247 viewfeed(active_feed_id
, 0, "");
252 if (active_feed_id
) {
253 viewfeed(active_feed_id
, 0, "");
255 notify("Please select some feed first.");
259 function localPiggieFunction(enable
) {
261 var query_str
= "backend.php?op=feeds&subop=piggie";
263 if (xmlhttp_ready(xmlhttp
)) {
265 xmlhttp
.open("GET", query_str
, true);
266 xmlhttp
.onreadystatechange
=feedlist_callback
;
272 function localHotkeyHandler(keycode
) {
274 /* if (keycode == 78) {
275 return moveToPost('next');
279 return moveToPost('prev');
283 return scheduleFeedUpdate(true);
287 return viewfeed(active_feed_id
, active_offset
, "ForceUpdate");
290 // notify("KC: " + keycode);
296 disableContainerChildren("headlinesToolbar", true);
300 if (xmlhttp
&& !xmlhttp_rpc
) {
301 xmlhttp_rpc
= xmlhttp
;
302 xmlhttp_view
= xmlhttp
;
305 if (!xmlhttp
|| !xmlhttp_rpc
|| !xmlhttp_view
) {
306 document
.getElementById("headlines").innerHTML
=
307 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
308 "to function properly. Your browser doesn't seem to support it.";
312 updateFeedList(false, false);
313 document
.onkeydown
= hotkey_handler
;
314 setTimeout("timeout()", 1800*1000);
316 scheduleFeedUpdate(true);
318 var content
= document
.getElementById("content");
320 if (getCookie("ttrss_vf_vmode")) {
321 var viewbox
= document
.getElementById("viewbox");
322 viewbox
.value
= getCookie("ttrss_vf_vmode");
325 if (getCookie("ttrss_vf_limit")) {
326 var limitbox
= document
.getElementById("limitbox");
327 limitbox
.value
= getCookie("ttrss_vf_limit");