]>
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.
8 var active_feed
= false;
11 /*@if (@_jscript_version >= 5)
12 // JScript gives us Conditional compilation, we can cope with old IE versions.
13 // and security blocked creation of the objects.
15 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
18 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
25 if (!xmlhttp
&& typeof XMLHttpRequest
!='undefined') {
26 xmlhttp
= new XMLHttpRequest();
30 function feedlist_callback() {
31 var container
= document
.getElementById('feeds');
32 if (xmlhttp
.readyState
== 4) {
33 container
.innerHTML
=xmlhttp
.responseText
;
36 var row
= document
.getElementById("FEEDR-" + active_feed
);
38 if (!row
.className
.match("Selected")) {
39 row
.className
= row
.className
+ "Selected";
42 var checkbox
= document
.getElementById("FRCHK-" + active_feed
);
44 checkbox
.checked
= true;
50 function notify_callback() {
51 var container
= document
.getElementById('notify');
52 if (xmlhttp
.readyState
== 4) {
53 container
.innerHTML
=xmlhttp
.responseText
;
58 function updateFeedList() {
60 if (!xmlhttp_ready(xmlhttp
)) {
65 document
.getElementById("feeds").innerHTML
= "Loading feeds, please wait...";
67 xmlhttp
.open("GET", "backend.php?op=pref-feeds", true);
68 xmlhttp
.onreadystatechange
=feedlist_callback
;
73 function toggleSelectRow(sender
) {
74 var parent_row
= sender
.parentNode
.parentNode
;
77 if (!parent_row
.className
.match("Selected")) {
78 parent_row
.className
= parent_row
.className
+ "Selected";
81 if (parent_row
.className
.match("Selected")) {
82 parent_row
.className
= parent_row
.className
.replace("Selected", "");
89 if (!xmlhttp_ready(xmlhttp
)) {
94 var link
= document
.getElementById("fadd_link");
96 if (link
.value
.length
== 0) {
97 notify("Missing feed URL.");
99 notify("Adding feed...");
101 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&link=" +
102 param_escape(link
.value
), true);
103 xmlhttp
.onreadystatechange
=feedlist_callback
;
112 function editFeed(feed
) {
114 // notify("Editing feed...");
116 if (!xmlhttp_ready(xmlhttp
)) {
123 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=edit&id=" +
124 param_escape(feed
), true);
125 xmlhttp
.onreadystatechange
=feedlist_callback
;
130 function getSelectedFeeds() {
132 var content
= document
.getElementById("prefFeedList");
134 var sel_rows
= new Array();
136 for (i
= 0; i
< content
.rows
.length
; i
++) {
137 if (content
.rows
[i
].className
.match("Selected")) {
138 var row_id
= content
.rows
[i
].id
.replace("FEEDR-", "");
139 sel_rows
.push(row_id
);
146 function readSelectedFeeds() {
148 if (!xmlhttp_ready(xmlhttp
)) {
153 var sel_rows
= getSelectedFeeds();
155 if (sel_rows
.length
> 0) {
157 notify("Marking selected feeds as read...");
159 xmlhttp
.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+
160 param_escape(sel_rows
.toString()), true);
161 xmlhttp
.onreadystatechange
=notify_callback
;
166 notify("Please select some feeds first.");
171 function unreadSelectedFeeds() {
173 if (!xmlhttp_ready(xmlhttp
)) {
178 var sel_rows
= getSelectedFeeds();
180 if (sel_rows
.length
> 0) {
182 notify("Marking selected feeds as unread...");
184 xmlhttp
.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+
185 param_escape(sel_rows
.toString()), true);
186 xmlhttp
.onreadystatechange
=notify_callback
;
191 notify("Please select some feeds first.");
196 function removeSelectedFeeds() {
198 if (!xmlhttp_ready(xmlhttp
)) {
203 var sel_rows
= getSelectedFeeds();
205 if (sel_rows
.length
> 0) {
207 notify("Removing selected feeds...");
209 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
210 param_escape(sel_rows
.toString()), true);
211 xmlhttp
.onreadystatechange
=feedlist_callback
;
216 notify("Please select some feeds first.");
222 function feedEditCancel() {
224 if (!xmlhttp_ready(xmlhttp
)) {
231 notify("Operation cancelled.");
233 xmlhttp
.open("GET", "backend.php?op=pref-feeds", true);
234 xmlhttp
.onreadystatechange
=feedlist_callback
;
239 function feedEditSave() {
241 var feed
= active_feed
;
243 if (!xmlhttp_ready(xmlhttp
)) {
248 var link
= document
.getElementById("iedit_link").value
;
249 var title
= document
.getElementById("iedit_title").value
;
251 // notify("Saving feed.");
253 if (link
.length
== 0) {
254 notify("Feed link cannot be blank.");
258 if (title
.length
== 0) {
259 notify("Feed title cannot be blank.");
265 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editSave&id=" +
266 feed
+ "&l=" + param_escape(link
) + "&t=" + param_escape(title
) ,true);
267 xmlhttp
.onreadystatechange
=feedlist_callback
;
272 function editSelectedFeed() {
273 var rows
= getSelectedFeeds();
275 if (rows
.length
== 0) {
276 notify("No feeds are selected.");
280 if (rows
.length
> 1) {
281 notify("Please select one feed.");
289 function localPiggieFunction(enable
) {
291 piggie
.style
.display
= "block";
293 notify("I loveded it!!!");
295 piggie
.style
.display
= "none";
300 function validateOpmlImport() {
302 var opml_file
= document
.getElementById("opml_file");
304 if (opml_file
.value
.length
== 0) {
305 notify("Please select OPML file to upload.");
317 document
.getElementById("prefContent").innerHTML
=
318 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
319 "to function properly. Your browser doesn't seem to support it.";
324 document
.onkeydown
= hotkey_handler
;