]>
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 search_query
= "";
14 /*@if (@_jscript_version >= 5)
15 // JScript gives us Conditional compilation, we can cope with old IE versions.
16 // and security blocked creation of the objects.
18 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
21 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
28 if (!xmlhttp
&& typeof XMLHttpRequest
!='undefined') {
29 xmlhttp
= new XMLHttpRequest();
33 function feedlist_callback() {
34 var container = document.getElementById('feeds');
35 if (xmlhttp.readyState == 4) {
36 container.innerHTML=xmlhttp.responseText;
39 scheduleFeedUpdate(false);
40 if (getCookie("ttrss_vf_actfeed")) {
41 viewfeed(getCookie("ttrss_vf_actfeed"), 0, "");
51 function refetch_callback() {
53 if (xmlhttp
.readyState
== 4) {
55 document
.title
= "Tiny Tiny RSS";
56 notify("All feeds updated.");
64 function updateFeed(feed_id
) {
66 var query_str
= "backend.php?op=rpc&subop=updateFeed&feed=" + feed_id
;
68 if (xmlhttp_ready(xmlhttp
)) {
69 xmlhttp
.open("GET", query_str
, true);
70 xmlhttp
.onreadystatechange
=feed_update_callback
;
78 function scheduleFeedUpdate(force
) {
80 notify("Updating feeds in background...");
82 document
.title
= "Tiny Tiny RSS - Updating...";
84 var query_str
= "backend.php?op=rpc&subop=";
87 query_str
= query_str
+ "forceUpdateAllFeeds";
89 query_str
= query_str
+ "updateAllFeeds";
92 if (xmlhttp_ready(xmlhttp
)) {
93 xmlhttp
.open("GET", query_str
, true);
94 xmlhttp
.onreadystatechange
=refetch_callback
;
101 function updateFeedList(silent
, fetch
) {
103 // if (silent != true) {
104 // notify("Loading feed list...");
107 var query_str
= "backend.php?op=feeds";
109 if (getActiveFeedId()) {
110 query_str
= query_str
+ "&actid=" + getActiveFeedId();
113 if (fetch
) query_str
= query_str
+ "&fetch=yes";
115 var feeds_frame
= document
.getElementById("feeds-frame");
117 feeds_frame
.src
= query_str
;
120 function catchupAllFeeds() {
122 var query_str
= "backend.php?op=feeds&subop=catchupAll";
124 notify("Marking all feeds as read...");
126 var feeds_frame
= document
.getElementById("feeds-frame");
128 feeds_frame
.src
= query_str
;
132 function viewCurrentFeed(skip
, subop
) {
134 if (getActiveFeedId()) {
135 viewfeed(getActiveFeedId(), skip
, subop
);
139 function viewfeed(feed
, skip
, subop
) {
141 // notify("Loading headlines...");
145 var searchbox
= document
.getElementById("searchbox");
148 search_query
= searchbox
.value
;
153 var viewbox
= document
.getElementById("viewbox");
158 view_mode
= viewbox
[viewbox
.selectedIndex
].text
;
160 view_mode
= "All Posts";
163 setCookie("ttrss_vf_vmode", view_mode
);
165 var limitbox
= document
.getElementById("limitbox");
170 limit
= limitbox
[limitbox
.selectedIndex
].text
;
171 setCookie("ttrss_vf_limit", limit
);
176 setActiveFeedId(feed
);
178 var f_doc
= frames
["feeds-frame"].document
;
180 // f_doc.getElementById("ACTFEEDID").innerHTML = feed;
182 if (subop
== "MarkAllRead") {
184 var feedr
= f_doc
.getElementById("FEEDR-" + feed
);
185 var feedctr
= f_doc
.getElementById("FEEDCTR-" + feed
);
187 feedctr
.className
= "invisible";
189 if (feedr
.className
.match("Unread")) {
190 feedr
.className
= feedr
.className
.replace("Unread", "");
194 var query
= "backend.php?op=viewfeed&feed=" + param_escape(feed
) +
195 "&skip=" + param_escape(skip
) + "&subop=" + param_escape(subop
) +
196 "&view=" + param_escape(view_mode
) + "&limit=" + limit
;
198 if (search_query
!= "") {
199 query
= query
+ "&search=" + param_escape(search_query
);
202 var headlines_frame
= parent
.frames
["headlines-frame"];
204 headlines_frame
.location
.href
= query
+ "&addheader=true";
206 cleanSelected("feedsList");
207 var feedr
= document
.getElementById("FEEDR-" + feed
);
209 feedr
.className
= feedr
.className
+ "Selected";
212 disableContainerChildren("headlinesToolbar", false, doc
);
220 scheduleFeedUpdate(true);
221 setTimeout("timeout()", 1800*1000);
224 function resetSearch() {
225 var searchbox
= document
.getElementById("searchbox")
227 if (searchbox
.value
!= "" && getActiveFeedId()) {
228 searchbox
.value
= "";
229 viewfeed(getActiveFeedId(), 0, "");
235 if (getActiveFeedId()) {
236 viewfeed(getActiveFeedId(), 0, "");
238 notify("Please select some feed first.");
242 function localPiggieFunction(enable
) {
244 var query_str
= "backend.php?op=feeds&subop=piggie";
246 if (xmlhttp_ready(xmlhttp
)) {
248 xmlhttp
.open("GET", query_str
, true);
249 xmlhttp
.onreadystatechange
=feedlist_callback
;
255 function localHotkeyHandler(keycode
) {
257 /* if (keycode == 78) {
258 return moveToPost('next');
262 return moveToPost('prev');
266 return scheduleFeedUpdate(true);
270 return viewfeed(getActiveFeedId(), 0, "ForceUpdate");
273 // notify("KC: " + keycode);
279 disableContainerChildren("headlinesToolbar", true);
282 document
.getElementById("headlines").innerHTML
=
283 "<b>Fatal error:</b> This program requires XmlHttpRequest " +
284 "to function properly. Your browser doesn't seem to support it.";
288 updateFeedList(false, false);
289 document
.onkeydown
= hotkey_handler
;
291 setTimeout("timeout()", 1800*1000);
292 scheduleFeedUpdate(true);
294 var content
= document
.getElementById("content");
296 if (getCookie("ttrss_vf_vmode")) {
297 var viewbox
= document
.getElementById("viewbox");
298 viewbox
.value
= getCookie("ttrss_vf_vmode");
301 if (getCookie("ttrss_vf_limit")) {
302 var limitbox
= document
.getElementById("limitbox");
303 limitbox
.value
= getCookie("ttrss_vf_limit");
306 // if (getCookie("ttrss_vf_actfeed")) {
307 // viewfeed(getCookie("ttrss_vf_actfeed"), 0, '');
310 setCookie("ttrss_vf_actfeed", "");