]>
git.wh0rd.org - tt-rss.git/blob - tt-rss.js
26218889e40b2cdaa95e4050c52f58201906e7d0
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 var display_tags
= false;
17 /*@if (@_jscript_version >= 5)
18 // JScript gives us Conditional compilation, we can cope with old IE versions.
19 // and security blocked creation of the objects.
21 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
24 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
31 if (!xmlhttp
&& typeof XMLHttpRequest
!='undefined') {
32 xmlhttp
= new XMLHttpRequest();
35 function toggleTags() {
36 display_tags
= !display_tags
;
38 var p
= document
.getElementById("dispSwitchPrompt");
41 p
.innerHTML
= "display feeds";
43 p
.innerHTML
= "display tags";
50 function feedlist_callback() {
51 var container = document.getElementById('feeds');
52 if (xmlhttp.readyState == 4) {
53 container.innerHTML=xmlhttp.responseText;
56 scheduleFeedUpdate(false);
57 if (getCookie("ttrss_vf_actfeed")) {
58 viewfeed(getCookie("ttrss_vf_actfeed"), 0, "");
68 function refetch_callback() {
69 if (xmlhttp
.readyState
== 4) {
71 document
.title
= "Tiny Tiny RSS";
72 notify("All feeds updated.");
74 if (!xmlhttp
.responseXML
) {
75 notify("refetch_callback: backend did not return valid XML");
79 var reply
= xmlhttp
.responseXML
.firstChild
;
82 notify("refetch_callback: backend did not return expected XML object");
86 var f_document
= window
.frames
["feeds-frame"].document
;
88 for (var l
= 0; l
< reply
.childNodes
.length
; l
++) {
89 var id
= reply
.childNodes
[l
].getAttribute("id");
90 var ctr
= reply
.childNodes
[l
].getAttribute("counter");
92 var feedctr
= f_document
.getElementById("FEEDCTR-" + id
);
93 var feedu
= f_document
.getElementById("FEEDU-" + id
);
94 var feedr
= f_document
.getElementById("FEEDR-" + id
);
96 if (feedctr
&& feedu
&& feedr
) {
98 feedu
.innerHTML
= ctr
;
101 feedctr
.className
= "odd";
102 if (!feedr
.className
.match("Unread")) {
103 feedr
.className
= feedr
.className
+ "Unread";
106 feedctr
.className
= "invisible";
107 feedr
.className
= feedr
.className
.replace("Unread", "");
114 function updateFeed(feed_id
) {
116 var query_str
= "backend.php?op=rpc&subop=updateFeed&feed=" + feed_id
;
118 if (xmlhttp_ready(xmlhttp
)) {
119 xmlhttp
.open("GET", query_str
, true);
120 xmlhttp
.onreadystatechange
=feed_update_callback
;
128 function scheduleFeedUpdate(force
) {
130 notify("Updating feeds in background...");
132 document
.title
= "Tiny Tiny RSS - Updating...";
134 var query_str
= "backend.php?op=rpc&subop=";
137 query_str
= query_str
+ "forceUpdateAllFeeds";
139 query_str
= query_str
+ "updateAllFeeds";
142 if (xmlhttp_ready(xmlhttp
)) {
143 xmlhttp
.open("GET", query_str
, true);
144 xmlhttp
.onreadystatechange
=refetch_callback
;
151 function updateFeedList(silent
, fetch
) {
153 // if (silent != true) {
154 // notify("Loading feed list...");
157 var query_str
= "backend.php?op=feeds";
160 query_str
= query_str
+ "&tags=1";
163 if (getActiveFeedId()) {
164 query_str
= query_str
+ "&actid=" + getActiveFeedId();
167 if (fetch
) query_str
= query_str
+ "&fetch=yes";
169 var feeds_frame
= document
.getElementById("feeds-frame");
171 feeds_frame
.src
= query_str
;
174 function catchupAllFeeds() {
176 var query_str
= "backend.php?op=feeds&subop=catchupAll";
178 notify("Marking all feeds as read...");
180 var feeds_frame
= document
.getElementById("feeds-frame");
182 feeds_frame
.src
= query_str
;
186 function viewCurrentFeed(skip
, subop
) {
188 if (getActiveFeedId()) {
189 viewfeed(getActiveFeedId(), skip
, subop
);
193 function viewfeed(feed
, skip
, subop
) {
195 // notify("Loading headlines...");
199 var searchbox
= document
.getElementById("searchbox");
202 search_query
= searchbox
.value
;
207 var searchmodebox
= document
.getElementById("searchmodebox");
210 search_mode
= searchmodebox
.value
;
215 setCookie("ttrss_vf_smode", search_mode
);
217 var viewbox
= document
.getElementById("viewbox");
222 view_mode
= viewbox
[viewbox
.selectedIndex
].text
;
224 view_mode
= "All Posts";
227 setCookie("ttrss_vf_vmode", view_mode
);
229 var limitbox
= document
.getElementById("limitbox");
234 limit
= limitbox
[limitbox
.selectedIndex
].text
;
235 setCookie("ttrss_vf_limit", limit
);
240 setActiveFeedId(feed
);
242 var f_doc
= frames
["feeds-frame"].document
;
244 // f_doc.getElementById("ACTFEEDID").innerHTML = feed;
246 if (subop
== "MarkAllRead") {
248 var feedr
= f_doc
.getElementById("FEEDR-" + feed
);
249 var feedctr
= f_doc
.getElementById("FEEDCTR-" + feed
);
251 feedctr
.className
= "invisible";
253 if (feedr
.className
.match("Unread")) {
254 feedr
.className
= feedr
.className
.replace("Unread", "");
258 var query
= "backend.php?op=viewfeed&feed=" + param_escape(feed
) +
259 "&skip=" + param_escape(skip
) + "&subop=" + param_escape(subop
) +
260 "&view=" + param_escape(view_mode
) + "&limit=" + limit
+
261 "&smode=" + param_escape(search_mode
);
263 if (search_query
!= "") {
264 query
= query
+ "&search=" + param_escape(search_query
);
267 var headlines_frame
= parent
.frames
["headlines-frame"];
269 headlines_frame
.location
.href
= query
+ "&addheader=true";
271 cleanSelected("feedsList");
272 var feedr
= document
.getElementById("FEEDR-" + feed
);
274 feedr
.className
= feedr
.className
+ "Selected";
277 disableContainerChildren("headlinesToolbar", false, doc
);
285 scheduleFeedUpdate(true);
286 setTimeout("timeout()", 1800*1000);
289 function resetSearch() {
290 var searchbox
= document
.getElementById("searchbox")
292 if (searchbox
.value
!= "" && getActiveFeedId()) {
293 searchbox
.value
= "";
294 viewfeed(getActiveFeedId(), 0, "");
299 viewCurrentFeed(0, "");
302 function localPiggieFunction(enable
) {
304 var query_str
= "backend.php?op=feeds&subop=piggie";
306 if (xmlhttp_ready(xmlhttp
)) {
308 xmlhttp
.open("GET", query_str
, true);
309 xmlhttp
.onreadystatechange
=feedlist_callback
;
315 function localHotkeyHandler(keycode
) {
317 /* if (keycode == 78) {
318 return moveToPost('next');
322 return moveToPost('prev');
326 return scheduleFeedUpdate(true);
330 return viewfeed(getActiveFeedId(), 0, "ForceUpdate");
333 // notify("KC: " + keycode);
337 function genericSanityCheck() {
340 document
.getElementById("headlines").innerHTML
=
341 "<b>Fatal error:</b> This program requires XmlHttpRequest " +
342 "to function properly. Your browser doesn't seem to support it.";
346 setCookie("ttrss_vf_test", "TEST");
347 if (getCookie("ttrss_vf_test") != "TEST") {
349 document
.getElementById("headlines").innerHTML
=
350 "<b>Fatal error:</b> This program requires cookies " +
351 "to function properly. Your browser doesn't seem to support them.";
361 disableContainerChildren("headlinesToolbar", true);
363 if (!genericSanityCheck())
366 setCookie("ttrss_vf_actfeed", "");
368 updateFeedList(false, false);
369 document
.onkeydown
= hotkey_handler
;
371 setTimeout("timeout()", 1800*1000);
372 scheduleFeedUpdate(true);
374 var content
= document
.getElementById("content");
376 if (getCookie("ttrss_vf_vmode")) {
377 var viewbox
= document
.getElementById("viewbox");
378 viewbox
.value
= getCookie("ttrss_vf_vmode");
381 if (getCookie("ttrss_vf_limit")) {
382 var limitbox
= document
.getElementById("limitbox");
383 limitbox
.value
= getCookie("ttrss_vf_limit");
386 // if (getCookie("ttrss_vf_actfeed")) {
387 // viewfeed(getCookie("ttrss_vf_actfeed"), 0, '');