]>
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;
9 var active_filter
= false;
12 /*@if (@_jscript_version >= 5)
13 // JScript gives us Conditional compilation, we can cope with old IE versions.
14 // and security blocked creation of the objects.
16 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
19 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
26 if (!xmlhttp
&& typeof XMLHttpRequest
!='undefined') {
27 xmlhttp
= new XMLHttpRequest();
30 function feedlist_callback() {
31 var container
= document
.getElementById('feedConfPane');
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 filterlist_callback() {
51 var container
= document
.getElementById('filterConfPane');
52 if (xmlhttp
.readyState
== 4) {
53 container
.innerHTML
=xmlhttp
.responseText
;
56 var row
= document
.getElementById("FILRR-" + active_filter
);
58 if (!row
.className
.match("Selected")) {
59 row
.className
= row
.className
+ "Selected";
62 var checkbox
= document
.getElementById("FICHK-" + active_filter
);
65 checkbox
.checked
= true;
71 function notify_callback() {
72 var container
= document
.getElementById('notify');
73 if (xmlhttp
.readyState
== 4) {
74 container
.innerHTML
=xmlhttp
.responseText
;
79 function updateFeedList() {
81 if (!xmlhttp_ready(xmlhttp
)) {
86 document
.getElementById("feedConfPane").innerHTML
= "Loading feeds, please wait...";
88 xmlhttp
.open("GET", "backend.php?op=pref-feeds", true);
89 xmlhttp
.onreadystatechange
=feedlist_callback
;
94 function toggleSelectRow(sender
) {
95 var parent_row
= sender
.parentNode
.parentNode
;
98 if (!parent_row
.className
.match("Selected")) {
99 parent_row
.className
= parent_row
.className
+ "Selected";
102 if (parent_row
.className
.match("Selected")) {
103 parent_row
.className
= parent_row
.className
.replace("Selected", "");
108 function addFilter() {
110 if (!xmlhttp_ready(xmlhttp
)) {
115 var regexp
= document
.getElementById("fadd_regexp");
116 var match
= document
.getElementById("fadd_match");
118 if (regexp
.value
.length
== 0) {
119 notify("Missing filter expression.");
121 notify("Adding filter...");
123 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=add®exp=" +
124 param_escape(regexp
.value
) + "&match=" + match
.value
, true);
126 xmlhttp
.onreadystatechange
=filterlist_callback
;
135 if (!xmlhttp_ready(xmlhttp
)) {
140 var link
= document
.getElementById("fadd_link");
142 if (link
.value
.length
== 0) {
143 notify("Missing feed URL.");
145 notify("Adding feed...");
147 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&link=" +
148 param_escape(link
.value
), true);
149 xmlhttp
.onreadystatechange
=feedlist_callback
;
158 function editFilter(id
) {
160 if (!xmlhttp_ready(xmlhttp
)) {
167 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" +
168 param_escape(id
), true);
169 xmlhttp
.onreadystatechange
=filterlist_callback
;
174 function editFeed(feed
) {
176 // notify("Editing feed...");
178 if (!xmlhttp_ready(xmlhttp
)) {
185 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=edit&id=" +
186 param_escape(feed
), true);
187 xmlhttp
.onreadystatechange
=feedlist_callback
;
192 function getSelectedFilters() {
194 var content
= document
.getElementById("prefFilterList");
196 var sel_rows
= new Array();
198 for (i
= 0; i
< content
.rows
.length
; i
++) {
199 if (content
.rows
[i
].className
.match("Selected")) {
200 var row_id
= content
.rows
[i
].id
.replace("FILRR-", "");
201 sel_rows
.push(row_id
);
208 function getSelectedFeeds() {
210 var content
= document
.getElementById("prefFeedList");
212 var sel_rows
= new Array();
214 for (i
= 0; i
< content
.rows
.length
; i
++) {
215 if (content
.rows
[i
].className
.match("Selected")) {
216 var row_id
= content
.rows
[i
].id
.replace("FEEDR-", "");
217 sel_rows
.push(row_id
);
224 function readSelectedFeeds() {
226 if (!xmlhttp_ready(xmlhttp
)) {
231 var sel_rows
= getSelectedFeeds();
233 if (sel_rows
.length
> 0) {
235 notify("Marking selected feeds as read...");
237 xmlhttp
.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+
238 param_escape(sel_rows
.toString()), true);
239 xmlhttp
.onreadystatechange
=notify_callback
;
244 notify("Please select some feeds first.");
249 function unreadSelectedFeeds() {
251 if (!xmlhttp_ready(xmlhttp
)) {
256 var sel_rows
= getSelectedFeeds();
258 if (sel_rows
.length
> 0) {
260 notify("Marking selected feeds as unread...");
262 xmlhttp
.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+
263 param_escape(sel_rows
.toString()), true);
264 xmlhttp
.onreadystatechange
=notify_callback
;
269 notify("Please select some feeds first.");
274 function removeSelectedFeeds() {
276 if (!xmlhttp_ready(xmlhttp
)) {
281 var sel_rows
= getSelectedFeeds();
283 if (sel_rows
.length
> 0) {
285 notify("Removing selected feeds...");
287 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
288 param_escape(sel_rows
.toString()), true);
289 xmlhttp
.onreadystatechange
=feedlist_callback
;
294 notify("Please select some feeds first.");
300 function feedEditCancel() {
302 if (!xmlhttp_ready(xmlhttp
)) {
309 notify("Operation cancelled.");
311 xmlhttp
.open("GET", "backend.php?op=pref-feeds", true);
312 xmlhttp
.onreadystatechange
=feedlist_callback
;
317 function feedEditSave() {
319 var feed
= active_feed
;
321 if (!xmlhttp_ready(xmlhttp
)) {
326 var link
= document
.getElementById("iedit_link").value
;
327 var title
= document
.getElementById("iedit_title").value
;
329 // notify("Saving feed.");
331 if (link
.length
== 0) {
332 notify("Feed link cannot be blank.");
336 if (title
.length
== 0) {
337 notify("Feed title cannot be blank.");
343 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editSave&id=" +
344 feed
+ "&l=" + param_escape(link
) + "&t=" + param_escape(title
) ,true);
345 xmlhttp
.onreadystatechange
=feedlist_callback
;
350 function filterEditCancel() {
352 if (!xmlhttp_ready(xmlhttp
)) {
357 active_filter
= false;
359 notify("Operation cancelled.");
361 xmlhttp
.open("GET", "backend.php?op=pref-filters", true);
362 xmlhttp
.onreadystatechange
=filterlist_callback
;
367 function filterEditSave() {
369 var filter
= active_filter
;
371 if (!xmlhttp_ready(xmlhttp
)) {
376 var regexp
= document
.getElementById("iedit_regexp").value
;
377 var descr
= document
.getElementById("iedit_descr").value
;
378 var match
= document
.getElementById("iedit_match").value
;
380 // notify("Saving filter " + filter + ": " + regexp + ", " + descr + ", " + match);
382 if (regexp
.length
== 0) {
383 notify("Filter expression cannot be blank.");
387 active_filter
= false;
389 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=editSave&id=" +
390 filter
+ "&r=" + param_escape(regexp
) + "&d=" + param_escape(descr
) +
391 "&m=" + param_escape(match
), true);
393 xmlhttp
.onreadystatechange
=filterlist_callback
;
398 function removeSelectedFilters() {
400 if (!xmlhttp_ready(xmlhttp
)) {
405 var sel_rows
= getSelectedFilters();
407 if (sel_rows
.length
> 0) {
409 notify("Removing selected filters...");
411 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
412 param_escape(sel_rows
.toString()), true);
413 xmlhttp
.onreadystatechange
=filterlist_callback
;
417 notify("Please select some filters first.");
422 function editSelectedFilter() {
423 var rows
= getSelectedFilters();
425 if (rows
.length
== 0) {
426 notify("No filters are selected.");
430 if (rows
.length
> 1) {
431 notify("Please select one filter.");
440 function editSelectedFeed() {
441 var rows
= getSelectedFeeds();
443 if (rows
.length
== 0) {
444 notify("No feeds are selected.");
448 if (rows
.length
> 1) {
449 notify("Please select one feed.");
457 function localPiggieFunction(enable
) {
459 piggie
.style
.display
= "block";
461 notify("I loveded it!!!");
463 piggie
.style
.display
= "none";
468 function validateOpmlImport() {
470 var opml_file
= document
.getElementById("opml_file");
472 if (opml_file
.value
.length
== 0) {
473 notify("Please select OPML file to upload.");
480 function updateFilterList() {
482 if (!xmlhttp_ready(xmlhttp
)) {
487 document
.getElementById("filterConfPane").innerHTML
= "Loading filters, please wait...";
489 xmlhttp
.open("GET", "backend.php?op=pref-filters", true);
490 xmlhttp
.onreadystatechange
=filterlist_callback
;
495 function expandPane(id
) {
499 container
= document
.getElementById(id
);
501 if (id
== "feedConfPane") {
503 } else if (id
== "filterConfPane") {
513 document
.getElementById("prefContent").innerHTML
=
514 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
515 "to function properly. Your browser doesn't seem to support it.";
520 document
.onkeydown
= hotkey_handler
;