]>
git.wh0rd.org - tt-rss.git/blob - prefs.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.
9 /*@if (@_jscript_version >= 5)
10 // JScript gives us Conditional compilation, we can cope with old IE versions.
11 // and security blocked creation of the objects.
13 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
16 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
23 if (!xmlhttp
&& typeof XMLHttpRequest
!='undefined') {
24 xmlhttp
= new XMLHttpRequest();
28 function feedlist_callback() {
29 var container
= document
.getElementById('feeds');
30 if (xmlhttp
.readyState
== 4) {
31 container
.innerHTML
=xmlhttp
.responseText
;
35 function notify_callback() {
36 var container
= document
.getElementById('notify');
37 if (xmlhttp
.readyState
== 4) {
38 container
.innerHTML
=xmlhttp
.responseText
;
43 function updateFeedList() {
45 if (xmlhttp
.readyState
!= 4 && xmlhttp
.readyState
!= 0) {
50 document
.getElementById("feeds").innerHTML
= "Loading feeds, please wait...";
52 xmlhttp
.open("GET", "backend.php?op=pref-feeds", true);
53 xmlhttp
.onreadystatechange
=feedlist_callback
;
58 function toggleSelectRow(sender
) {
59 var parent_row
= sender
.parentNode
.parentNode
;
62 if (!parent_row
.className
.match("Selected")) {
63 parent_row
.className
= parent_row
.className
+ "Selected";
66 if (parent_row
.className
.match("Selected")) {
67 parent_row
.className
= parent_row
.className
.replace("Selected", "");
74 if (xmlhttp
.readyState
!= 4 && xmlhttp
.readyState
!= 0) {
79 var link
= document
.getElementById("fadd_link");
81 if (link
.value
.length
== 0) {
82 notify("Missing feed URL.");
84 notify("Adding feed...");
86 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&link=" +
87 param_escape(link
.value
), true);
88 xmlhttp
.onreadystatechange
=feedlist_callback
;
97 function editFeed(feed
) {
99 // notify("Editing feed...");
101 if (xmlhttp
.readyState
!= 4 && xmlhttp
.readyState
!= 0) {
106 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=edit&id=" +
107 param_escape(feed
), true);
108 xmlhttp
.onreadystatechange
=feedlist_callback
;
113 function getSelectedFeeds() {
115 var content
= document
.getElementById("prefFeedList");
117 var sel_rows
= new Array();
119 for (i
= 0; i
< content
.rows
.length
; i
++) {
120 if (content
.rows
[i
].className
.match("Selected")) {
121 var row_id
= content
.rows
[i
].id
.replace("FEEDR-", "");
122 sel_rows
.push(row_id
);
129 function readSelectedFeeds() {
131 if (xmlhttp
.readyState
!= 4 && xmlhttp
.readyState
!= 0) {
136 var sel_rows
= getSelectedFeeds();
138 if (sel_rows
.length
> 0) {
140 notify("Marking selected feeds as read...");
142 xmlhttp
.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+
143 param_escape(sel_rows
.toString()), true);
144 xmlhttp
.onreadystatechange
=notify_callback
;
149 notify("Please select some feeds first.");
154 function unreadSelectedFeeds() {
156 if (xmlhttp
.readyState
!= 4 && xmlhttp
.readyState
!= 0) {
161 var sel_rows
= getSelectedFeeds();
163 if (sel_rows
.length
> 0) {
165 notify("Marking selected feeds as unread...");
167 xmlhttp
.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+
168 param_escape(sel_rows
.toString()), true);
169 xmlhttp
.onreadystatechange
=notify_callback
;
174 notify("Please select some feeds first.");
179 function removeSelectedFeeds() {
181 if (xmlhttp
.readyState
!= 4 && xmlhttp
.readyState
!= 0) {
186 var sel_rows
= getSelectedFeeds();
188 if (sel_rows
.length
> 0) {
190 notify("Removing selected feeds...");
192 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
193 param_escape(sel_rows
.toString()), true);
194 xmlhttp
.onreadystatechange
=feedlist_callback
;
199 notify("Please select some feeds first.");
205 function feedEditCancel() {
207 if (xmlhttp
.readyState
!= 4 && xmlhttp
.readyState
!= 0) {
212 notify("Operation cancelled.");
214 xmlhttp
.open("GET", "backend.php?op=pref-feeds", true);
215 xmlhttp
.onreadystatechange
=feedlist_callback
;
220 function feedEditSave(feed
) {
222 if (xmlhttp
.readyState
!= 4 && xmlhttp
.readyState
!= 0) {
227 notify("Saving feed.");
229 var link
= document
.getElementById("fedit_link").value
;
230 var title
= document
.getElementById("fedit_title").value
;
232 if (link
.length
== 0) {
233 notify("Feed link cannot be blank.");
237 if (title
.length
== 0) {
238 notify("Feed title cannot be blank.");
242 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editSave&id=" +
243 feed
+ "&l=" + param_escape(link
) + "&t=" + param_escape(title
) ,true);
244 xmlhttp
.onreadystatechange
=feedlist_callback
;
249 function editSelectedFeed() {
250 var rows
= getSelectedFeeds();
252 if (rows
.length
== 0) {
253 notify("No feeds are selected.");
257 if (rows
.length
> 1) {
258 notify("Please select one feed.");
266 function localPiggieFunction(enable
) {
268 piggie
.style
.display
= "block";
270 notify("I loveded it!!!");
272 piggie
.style
.display
= "none";
280 document
.onkeydown
= hotkey_handler
;