]>
git.wh0rd.org - tt-rss.git/blob - prefs.js
df49f85be1dacd2e103c2a4d752c215c04dd7935
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;
10 var active_label
= false;
12 var active_tab
= false;
15 /*@if (@_jscript_version >= 5)
16 // JScript gives us Conditional compilation, we can cope with old IE versions.
17 // and security blocked creation of the objects.
19 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
22 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
29 if (!xmlhttp
&& typeof XMLHttpRequest
!='undefined') {
30 xmlhttp
= new XMLHttpRequest();
33 function feedlist_callback() {
34 var container
= document
.getElementById('prefContent');
35 if (xmlhttp
.readyState
== 4) {
36 container
.innerHTML
=xmlhttp
.responseText
;
38 var row
= document
.getElementById("FEEDR-" + active_feed
);
40 if (!row
.className
.match("Selected")) {
41 row
.className
= row
.className
+ "Selected";
44 var checkbox
= document
.getElementById("FRCHK-" + active_feed
);
46 checkbox
.checked
= true;
53 function filterlist_callback() {
54 var container
= document
.getElementById('prefContent');
55 if (xmlhttp
.readyState
== 4) {
57 container
.innerHTML
=xmlhttp
.responseText
;
60 var row
= document
.getElementById("FILRR-" + active_filter
);
62 if (!row
.className
.match("Selected")) {
63 row
.className
= row
.className
+ "Selected";
66 var checkbox
= document
.getElementById("FICHK-" + active_filter
);
69 checkbox
.checked
= true;
76 function labellist_callback() {
77 var container
= document
.getElementById('prefContent');
78 if (xmlhttp
.readyState
== 4) {
79 container
.innerHTML
=xmlhttp
.responseText
;
82 var row
= document
.getElementById("LILRR-" + active_label
);
84 if (!row
.className
.match("Selected")) {
85 row
.className
= row
.className
+ "Selected";
88 var checkbox
= document
.getElementById("LICHK-" + active_label
);
91 checkbox
.checked
= true;
98 function prefslist_callback() {
99 var container
= document
.getElementById('prefContent');
100 if (xmlhttp
.readyState
== 4) {
102 container
.innerHTML
=xmlhttp
.responseText
;
108 function gethelp_callback() {
109 var container
= document
.getElementById('prefHelpBox');
110 if (xmlhttp
.readyState
== 4) {
112 container
.innerHTML
= xmlhttp
.responseText
;
113 container
.style
.display
= "block";
119 function notify_callback() {
120 var container
= document
.getElementById('notify');
121 if (xmlhttp
.readyState
== 4) {
122 container
.innerHTML
=xmlhttp
.responseText
;
127 function updateFeedList() {
129 if (!xmlhttp_ready(xmlhttp
)) {
134 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
136 p_notify("Loading, please wait...");
138 xmlhttp
.open("GET", "backend.php?op=pref-feeds", true);
139 xmlhttp
.onreadystatechange
=feedlist_callback
;
144 function toggleSelectRow(sender
) {
145 var parent_row
= sender
.parentNode
.parentNode
;
147 if (sender
.checked
) {
148 if (!parent_row
.className
.match("Selected")) {
149 parent_row
.className
= parent_row
.className
+ "Selected";
152 if (parent_row
.className
.match("Selected")) {
153 parent_row
.className
= parent_row
.className
.replace("Selected", "");
158 function addLabel() {
160 if (!xmlhttp_ready(xmlhttp
)) {
165 var sqlexp
= document
.getElementById("ladd_expr");
167 if (sqlexp
.value
.length
== 0) {
168 notify("Missing SQL expression.");
170 notify("Adding label...");
172 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=add&exp=" +
173 param_escape(sqlexp
.value
), true);
175 xmlhttp
.onreadystatechange
=labellist_callback
;
183 function addFilter() {
185 if (!xmlhttp_ready(xmlhttp
)) {
190 var regexp
= document
.getElementById("fadd_regexp");
191 var match
= document
.getElementById("fadd_match");
193 if (regexp
.value
.length
== 0) {
194 notify("Missing filter expression.");
196 notify("Adding filter...");
198 var v_match
= match
[match
.selectedIndex
].text
;
200 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=add®exp=" +
201 param_escape(regexp
.value
) + "&match=" + v_match
, true);
203 xmlhttp
.onreadystatechange
=filterlist_callback
;
213 if (!xmlhttp_ready(xmlhttp
)) {
218 var link
= document
.getElementById("fadd_link");
220 if (link
.value
.length
== 0) {
221 notify("Missing feed URL.");
223 notify("Adding feed...");
225 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&link=" +
226 param_escape(link
.value
), true);
227 xmlhttp
.onreadystatechange
=feedlist_callback
;
236 function editLabel(id
) {
238 if (!xmlhttp_ready(xmlhttp
)) {
245 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
246 param_escape(id
), true);
247 xmlhttp
.onreadystatechange
=labellist_callback
;
252 function editFilter(id
) {
254 if (!xmlhttp_ready(xmlhttp
)) {
261 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" +
262 param_escape(id
), true);
263 xmlhttp
.onreadystatechange
=filterlist_callback
;
268 function editFeed(feed
) {
270 // notify("Editing feed...");
272 if (!xmlhttp_ready(xmlhttp
)) {
279 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=edit&id=" +
280 param_escape(feed
), true);
281 xmlhttp
.onreadystatechange
=feedlist_callback
;
286 function getSelectedLabels() {
288 var content
= document
.getElementById("prefLabelList");
290 var sel_rows
= new Array();
292 for (i
= 0; i
< content
.rows
.length
; i
++) {
293 if (content
.rows
[i
].className
.match("Selected")) {
294 var row_id
= content
.rows
[i
].id
.replace("LILRR-", "");
295 sel_rows
.push(row_id
);
303 function getSelectedFilters() {
305 var content
= document
.getElementById("prefFilterList");
307 var sel_rows
= new Array();
309 for (i
= 0; i
< content
.rows
.length
; i
++) {
310 if (content
.rows
[i
].className
.match("Selected")) {
311 var row_id
= content
.rows
[i
].id
.replace("FILRR-", "");
312 sel_rows
.push(row_id
);
319 function getSelectedFeeds() {
321 var content
= document
.getElementById("prefFeedList");
323 var sel_rows
= new Array();
325 for (i
= 0; i
< content
.rows
.length
; i
++) {
326 if (content
.rows
[i
].className
.match("Selected")) {
327 var row_id
= content
.rows
[i
].id
.replace("FEEDR-", "");
328 sel_rows
.push(row_id
);
335 function readSelectedFeeds() {
337 if (!xmlhttp_ready(xmlhttp
)) {
342 var sel_rows
= getSelectedFeeds();
344 if (sel_rows
.length
> 0) {
346 notify("Marking selected feeds as read...");
348 xmlhttp
.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+
349 param_escape(sel_rows
.toString()), true);
350 xmlhttp
.onreadystatechange
=notify_callback
;
355 notify("Please select some feeds first.");
360 function unreadSelectedFeeds() {
362 if (!xmlhttp_ready(xmlhttp
)) {
367 var sel_rows
= getSelectedFeeds();
369 if (sel_rows
.length
> 0) {
371 notify("Marking selected feeds as unread...");
373 xmlhttp
.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+
374 param_escape(sel_rows
.toString()), true);
375 xmlhttp
.onreadystatechange
=notify_callback
;
380 notify("Please select some feeds first.");
385 function removeSelectedLabels() {
387 if (!xmlhttp_ready(xmlhttp
)) {
392 var sel_rows
= getSelectedLabels();
394 if (sel_rows
.length
> 0) {
396 notify("Removing selected labels...");
398 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
399 param_escape(sel_rows
.toString()), true);
400 xmlhttp
.onreadystatechange
=labellist_callback
;
404 notify("Please select some labels first.");
408 function removeSelectedFilters() {
410 if (!xmlhttp_ready(xmlhttp
)) {
415 var sel_rows
= getSelectedFilters();
417 if (sel_rows
.length
> 0) {
419 notify("Removing selected filters...");
421 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
422 param_escape(sel_rows
.toString()), true);
423 xmlhttp
.onreadystatechange
=filterlist_callback
;
427 notify("Please select some filters first.");
432 function removeSelectedFeeds() {
434 if (!xmlhttp_ready(xmlhttp
)) {
439 var sel_rows
= getSelectedFeeds();
441 if (sel_rows
.length
> 0) {
443 notify("Removing selected feeds...");
445 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
446 param_escape(sel_rows
.toString()), true);
447 xmlhttp
.onreadystatechange
=feedlist_callback
;
452 notify("Please select some feeds first.");
458 function feedEditCancel() {
460 if (!xmlhttp_ready(xmlhttp
)) {
467 notify("Operation cancelled.");
469 xmlhttp
.open("GET", "backend.php?op=pref-feeds", true);
470 xmlhttp
.onreadystatechange
=feedlist_callback
;
475 function feedEditSave() {
477 var feed
= active_feed
;
479 if (!xmlhttp_ready(xmlhttp
)) {
484 var link
= document
.getElementById("iedit_link").value
;
485 var title
= document
.getElementById("iedit_title").value
;
486 var upd_intl
= document
.getElementById("iedit_updintl").value
;
487 var purge_intl
= document
.getElementById("iedit_purgintl").value
;
489 // notify("Saving feed.");
491 /* if (upd_intl < 0) {
492 notify("Update interval must be >= 0 (0 = default)");
496 if (purge_intl < 0) {
497 notify("Purge days must be >= 0 (0 = default)");
501 if (link
.length
== 0) {
502 notify("Feed link cannot be blank.");
506 if (title
.length
== 0) {
507 notify("Feed title cannot be blank.");
513 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editSave&id=" +
514 feed
+ "&l=" + param_escape(link
) + "&t=" + param_escape(title
) +
515 "&ui=" + param_escape(upd_intl
) + "&pi=" + param_escape(purge_intl
), true);
516 xmlhttp
.onreadystatechange
=feedlist_callback
;
521 function labelEditCancel() {
523 if (!xmlhttp_ready(xmlhttp
)) {
528 active_label
= false;
530 notify("Operation cancelled.");
532 xmlhttp
.open("GET", "backend.php?op=pref-labels", true);
533 xmlhttp
.onreadystatechange
=labellist_callback
;
539 function filterEditCancel() {
541 if (!xmlhttp_ready(xmlhttp
)) {
546 active_filter
= false;
548 notify("Operation cancelled.");
550 xmlhttp
.open("GET", "backend.php?op=pref-filters", true);
551 xmlhttp
.onreadystatechange
=filterlist_callback
;
556 function labelEditSave() {
558 var label
= active_label
;
560 if (!xmlhttp_ready(xmlhttp
)) {
565 var sqlexp
= document
.getElementById("iedit_expr").value
;
566 var descr
= document
.getElementById("iedit_descr").value
;
568 // notify("Saving label " + sqlexp + ": " + descr);
570 if (sqlexp
.length
== 0) {
571 notify("SQL expression cannot be blank.");
575 if (descr
.length
== 0) {
576 notify("Caption cannot be blank.");
580 active_label
= false;
582 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=editSave&id=" +
583 label
+ "&s=" + param_escape(sqlexp
) + "&d=" + param_escape(descr
),
586 xmlhttp
.onreadystatechange
=labellist_callback
;
591 function filterEditSave() {
593 var filter
= active_filter
;
595 if (!xmlhttp_ready(xmlhttp
)) {
600 var regexp
= document
.getElementById("iedit_regexp").value
;
601 var descr
= document
.getElementById("iedit_descr").value
;
602 var match
= document
.getElementById("iedit_match");
604 var v_match
= match
[match
.selectedIndex
].text
;
606 // notify("Saving filter " + filter + ": " + regexp + ", " + descr + ", " + match);
608 if (regexp
.length
== 0) {
609 notify("Filter expression cannot be blank.");
613 active_filter
= false;
615 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=editSave&id=" +
616 filter
+ "&r=" + param_escape(regexp
) + "&d=" + param_escape(descr
) +
617 "&m=" + param_escape(v_match
), true);
619 xmlhttp
.onreadystatechange
=filterlist_callback
;
624 function editSelectedLabel() {
625 var rows
= getSelectedLabels();
627 if (rows
.length
== 0) {
628 notify("No labels are selected.");
632 if (rows
.length
> 1) {
633 notify("Please select one label.");
642 function editSelectedFilter() {
643 var rows
= getSelectedFilters();
645 if (rows
.length
== 0) {
646 notify("No filters are selected.");
650 if (rows
.length
> 1) {
651 notify("Please select one filter.");
660 function editSelectedFeed() {
661 var rows
= getSelectedFeeds();
663 if (rows
.length
== 0) {
664 notify("No feeds are selected.");
668 if (rows
.length
> 1) {
669 notify("Please select one feed.");
677 function localPiggieFunction(enable
) {
679 piggie
.style
.display
= "block";
681 notify("I loveded it!!!");
683 piggie
.style
.display
= "none";
688 function validateOpmlImport() {
690 var opml_file
= document
.getElementById("opml_file");
692 if (opml_file
.value
.length
== 0) {
693 notify("Please select OPML file to upload.");
700 function updateFilterList() {
702 if (!xmlhttp_ready(xmlhttp
)) {
707 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
709 p_notify("Loading, please wait...");
711 xmlhttp
.open("GET", "backend.php?op=pref-filters", true);
712 xmlhttp
.onreadystatechange
=filterlist_callback
;
717 function updateLabelList() {
719 if (!xmlhttp_ready(xmlhttp
)) {
724 p_notify("Loading, please wait...");
726 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
728 xmlhttp
.open("GET", "backend.php?op=pref-labels", true);
729 xmlhttp
.onreadystatechange
=labellist_callback
;
733 function updatePrefsList() {
735 if (!xmlhttp_ready(xmlhttp
)) {
740 p_notify("Loading, please wait...");
742 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
743 xmlhttp
.onreadystatechange
=prefslist_callback
;
748 function selectTab(id
) {
750 if (id
== "feedConfig") {
752 } else if (id
== "filterConfig") {
754 } else if (id
== "labelConfig") {
756 } else if (id
== "genConfig") {
760 var tab
= document
.getElementById(active_tab
+ "Tab");
763 if (tab
.className
.match("Selected")) {
764 tab
.className
= "prefsTab";
768 tab
= document
.getElementById(id
+ "Tab");
771 if (!tab
.className
.match("Selected")) {
772 tab
.className
= tab
.className
+ "Selected";
785 document
.getElementById("prefContent").innerHTML
=
786 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
787 "to function properly. Your browser doesn't seem to support it.";
791 selectTab("genConfig");
793 document
.onkeydown
= hotkey_handler
;
799 var help_topic_id = false;
801 function do_dispOptionHelp() {
803 if (!xmlhttp_ready(xmlhttp))
806 xmlhttp.open("GET", "backend.php?op=pref-prefs&subop=getHelp&pn=" +
807 param_escape(help_topic_id), true);
808 xmlhttp.onreadystatechange=gethelp_callback;
813 function dispOptionHelp(event, sender) {
815 help_topic_id = sender.id;
817 // document.setTimeout("do_dispOptionHelp()", 100);