]>
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 var active_feed_id
= false;
13 var search_query
= "";
16 /*@if (@_jscript_version >= 5)
17 // JScript gives us Conditional compilation, we can cope with old IE versions.
18 // and security blocked creation of the objects.
20 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
23 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
30 if (!xmlhttp
&& typeof XMLHttpRequest
!='undefined') {
31 xmlhttp
= new XMLHttpRequest();
35 function feedlist_callback() {
36 var container = document.getElementById('feeds');
37 if (xmlhttp.readyState == 4) {
38 container.innerHTML=xmlhttp.responseText;
41 scheduleFeedUpdate(false);
42 if (getCookie("ttrss_vf_actfeed")) {
43 viewfeed(getCookie("ttrss_vf_actfeed"), 0, "");
53 function checkActiveFeedId() {
55 var actfeedid
= frames
["feeds-frame"].document
.getElementById("ACTFEEDID");
58 active_feed_id
= actfeedid
.innerHTML
;
62 function refetch_callback() {
64 if (xmlhttp
.readyState
== 4) {
66 document
.title
= "Tiny Tiny RSS";
67 notify("All feeds updated.");
75 function updateFeed(feed_id
) {
77 var query_str
= "backend.php?op=rpc&subop=updateFeed&feed=" + feed_id
;
79 if (xmlhttp_ready(xmlhttp
)) {
80 xmlhttp
.open("GET", query_str
, true);
81 xmlhttp
.onreadystatechange
=feed_update_callback
;
89 function scheduleFeedUpdate(force
) {
91 notify("Updating feeds in background...");
93 document
.title
= "Tiny Tiny RSS - Updating...";
95 var query_str
= "backend.php?op=rpc&subop=";
98 query_str
= query_str
+ "forceUpdateAllFeeds";
100 query_str
= query_str
+ "updateAllFeeds";
103 if (xmlhttp_ready(xmlhttp
)) {
104 xmlhttp
.open("GET", query_str
, true);
105 xmlhttp
.onreadystatechange
=refetch_callback
;
112 function updateFeedList(silent
, fetch
) {
114 // if (silent != true) {
115 // notify("Loading feed list...");
118 var query_str
= "backend.php?op=feeds";
120 if (active_feed_id
) {
121 query_str
= query_str
+ "&actid=" + active_feed_id
;
124 if (fetch
) query_str
= query_str
+ "&fetch=yes";
126 var feeds_frame
= document
.getElementById("feeds-frame");
128 feeds_frame
.src
= query_str
;
131 function catchupAllFeeds() {
133 var query_str
= "backend.php?op=feeds&subop=catchupAll";
135 notify("Marking all feeds as read...");
137 var feeds_frame
= document
.getElementById("feeds-frame");
139 feeds_frame
.src
= query_str
;
143 function viewCurrentFeed(skip
, subop
) {
145 active_feed_id
= frames
["feeds-frame"].document
.getElementById("ACTFEEDID").innerHTML
;
147 if (active_feed_id
) {
148 viewfeed(active_feed_id
, skip
, subop
);
152 function viewfeed(feed
, skip
, subop
) {
154 // notify("Loading headlines...");
158 var searchbox
= document
.getElementById("searchbox");
161 search_query
= searchbox
.value
;
166 var viewbox
= document
.getElementById("viewbox");
171 view_mode
= viewbox
[viewbox
.selectedIndex
].text
;
173 view_mode
= "All Posts";
176 setCookie("ttrss_vf_vmode", view_mode
);
178 var limitbox
= document
.getElementById("limitbox");
183 limit
= limitbox
[limitbox
.selectedIndex
].text
;
184 setCookie("ttrss_vf_limit", limit
);
189 active_feed_id
= feed
;
191 var f_doc
= frames
["feeds-frame"].document
;
193 f_doc
.getElementById("ACTFEEDID").innerHTML
= feed
;
195 setCookie("ttrss_vf_actfeed", feed
);
197 if (subop
== "MarkAllRead") {
199 var feedr
= f_doc
.getElementById("FEEDR-" + feed
);
200 var feedctr
= f_doc
.getElementById("FEEDCTR-" + feed
);
202 feedctr
.className
= "invisible";
204 if (feedr
.className
.match("Unread")) {
205 feedr
.className
= feedr
.className
.replace("Unread", "");
209 var query
= "backend.php?op=viewfeed&feed=" + param_escape(feed
) +
210 "&skip=" + param_escape(skip
) + "&subop=" + param_escape(subop
) +
211 "&view=" + param_escape(view_mode
) + "&limit=" + limit
;
213 if (search_query
!= "") {
214 query
= query
+ "&search=" + param_escape(search_query
);
217 var headlines_frame
= parent
.frames
["headlines-frame"];
219 headlines_frame
.location
.href
= query
+ "&addheader=true";
221 cleanSelected("feedsList");
222 var feedr
= document
.getElementById("FEEDR-" + feed
);
224 feedr
.className
= feedr
.className
+ "Selected";
227 disableContainerChildren("headlinesToolbar", false, doc
);
235 scheduleFeedUpdate(true);
236 setTimeout("timeout()", 1800*1000);
239 function resetSearch() {
240 var searchbox
= document
.getElementById("searchbox")
242 if (searchbox
.value
!= "" && active_feed_id
) {
243 searchbox
.value
= "";
244 viewfeed(active_feed_id
, 0, "");
250 if (active_feed_id
) {
251 viewfeed(active_feed_id
, 0, "");
253 notify("Please select some feed first.");
257 function localPiggieFunction(enable
) {
259 var query_str
= "backend.php?op=feeds&subop=piggie";
261 if (xmlhttp_ready(xmlhttp
)) {
263 xmlhttp
.open("GET", query_str
, true);
264 xmlhttp
.onreadystatechange
=feedlist_callback
;
270 function localHotkeyHandler(keycode
) {
272 /* if (keycode == 78) {
273 return moveToPost('next');
277 return moveToPost('prev');
281 return scheduleFeedUpdate(true);
285 return viewfeed(active_feed_id
, active_offset
, "ForceUpdate");
288 // notify("KC: " + keycode);
294 disableContainerChildren("headlinesToolbar", true);
297 document
.getElementById("headlines").innerHTML
=
298 "<b>Fatal error:</b> This program requires XmlHttpRequest " +
299 "to function properly. Your browser doesn't seem to support it.";
303 updateFeedList(false, false);
304 document
.onkeydown
= hotkey_handler
;
306 setTimeout("timeout()", 1800*1000);
307 scheduleFeedUpdate(true);
309 var content
= document
.getElementById("content");
311 if (getCookie("ttrss_vf_vmode")) {
312 var viewbox
= document
.getElementById("viewbox");
313 viewbox
.value
= getCookie("ttrss_vf_vmode");
316 if (getCookie("ttrss_vf_limit")) {
317 var limitbox
= document
.getElementById("limitbox");
318 limitbox
.value
= getCookie("ttrss_vf_limit");