]>
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;
10 var active_label
= false;
11 var active_user
= false;
13 var active_tab
= false;
16 /*@if (@_jscript_version >= 5)
17 // JScript gives us Conditional compilation, we can cope with old IE versions.
18 // and security blocked creation of the objects.
20 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
23 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
30 if (!xmlhttp
&& typeof XMLHttpRequest
!='undefined') {
31 xmlhttp
= new XMLHttpRequest();
34 function feedlist_callback() {
35 var container
= document
.getElementById('prefContent');
36 if (xmlhttp
.readyState
== 4) {
37 container
.innerHTML
=xmlhttp
.responseText
;
39 var row
= document
.getElementById("FEEDR-" + active_feed
);
41 if (!row
.className
.match("Selected")) {
42 row
.className
= row
.className
+ "Selected";
45 var checkbox
= document
.getElementById("FRCHK-" + active_feed
);
47 checkbox
.checked
= true;
54 function filterlist_callback() {
55 var container
= document
.getElementById('prefContent');
56 if (xmlhttp
.readyState
== 4) {
58 container
.innerHTML
=xmlhttp
.responseText
;
61 var row
= document
.getElementById("FILRR-" + active_filter
);
63 if (!row
.className
.match("Selected")) {
64 row
.className
= row
.className
+ "Selected";
67 var checkbox
= document
.getElementById("FICHK-" + active_filter
);
70 checkbox
.checked
= true;
77 function labellist_callback() {
78 var container
= document
.getElementById('prefContent');
79 if (xmlhttp
.readyState
== 4) {
80 container
.innerHTML
=xmlhttp
.responseText
;
83 var row
= document
.getElementById("LILRR-" + active_label
);
85 if (!row
.className
.match("Selected")) {
86 row
.className
= row
.className
+ "Selected";
89 var checkbox
= document
.getElementById("LICHK-" + active_label
);
92 checkbox
.checked
= true;
99 function userlist_callback() {
100 var container
= document
.getElementById('prefContent');
101 if (xmlhttp
.readyState
== 4) {
102 container
.innerHTML
=xmlhttp
.responseText
;
105 var row
= document
.getElementById("UMRR-" + active_user
);
107 if (!row
.className
.match("Selected")) {
108 row
.className
= row
.className
+ "Selected";
111 var checkbox
= document
.getElementById("UMCHK-" + active_user
);
114 checkbox
.checked
= true;
122 function infobox_callback() {
123 if (xmlhttp
.readyState
== 4) {
124 var box
= document
.getElementById('infoBox');
125 var shadow
= document
.getElementById('infoBoxShadow');
128 box
.innerHTML
=xmlhttp
.responseText
;
130 shadow
.style
.display
= "block";
132 box
.style
.display
= "block";
139 function prefslist_callback() {
140 var container
= document
.getElementById('prefContent');
141 if (xmlhttp
.readyState
== 4) {
143 container
.innerHTML
=xmlhttp
.responseText
;
149 function gethelp_callback() {
150 var container
= document
.getElementById('prefHelpBox');
151 if (xmlhttp
.readyState
== 4) {
153 container
.innerHTML
= xmlhttp
.responseText
;
154 container
.style
.display
= "block";
160 function notify_callback() {
161 var container
= document
.getElementById('notify');
162 if (xmlhttp
.readyState
== 4) {
163 container
.innerHTML
=xmlhttp
.responseText
;
168 function updateFeedList() {
170 if (!xmlhttp_ready(xmlhttp
)) {
175 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
177 p_notify("Loading, please wait...");
179 xmlhttp
.open("GET", "backend.php?op=pref-feeds", true);
180 xmlhttp
.onreadystatechange
=feedlist_callback
;
185 function updateUsersList() {
187 if (!xmlhttp_ready(xmlhttp
)) {
192 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
194 p_notify("Loading, please wait...");
196 xmlhttp
.open("GET", "backend.php?op=pref-users", true);
197 xmlhttp
.onreadystatechange
=userlist_callback
;
202 function toggleSelectRow(sender
) {
203 var parent_row
= sender
.parentNode
.parentNode
;
205 if (sender
.checked
) {
206 if (!parent_row
.className
.match("Selected")) {
207 parent_row
.className
= parent_row
.className
+ "Selected";
210 if (parent_row
.className
.match("Selected")) {
211 parent_row
.className
= parent_row
.className
.replace("Selected", "");
216 function addLabel() {
218 if (!xmlhttp_ready(xmlhttp
)) {
223 var sqlexp
= document
.getElementById("ladd_expr");
225 if (sqlexp
.value
.length
== 0) {
226 notify("Missing SQL expression.");
228 notify("Adding label...");
230 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=add&exp=" +
231 param_escape(sqlexp
.value
), true);
233 xmlhttp
.onreadystatechange
=labellist_callback
;
241 function addFilter() {
243 if (!xmlhttp_ready(xmlhttp
)) {
248 var regexp
= document
.getElementById("fadd_regexp");
249 var match
= document
.getElementById("fadd_match");
251 if (regexp
.value
.length
== 0) {
252 notify("Missing filter expression.");
254 notify("Adding filter...");
256 var v_match
= match
[match
.selectedIndex
].text
;
258 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=add®exp=" +
259 param_escape(regexp
.value
) + "&match=" + v_match
, true);
261 xmlhttp
.onreadystatechange
=filterlist_callback
;
271 if (!xmlhttp_ready(xmlhttp
)) {
276 var link
= document
.getElementById("fadd_link");
278 if (link
.value
.length
== 0) {
279 notify("Missing feed URL.");
281 notify("Adding feed...");
283 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&link=" +
284 param_escape(link
.value
), true);
285 xmlhttp
.onreadystatechange
=feedlist_callback
;
296 if (!xmlhttp_ready(xmlhttp
)) {
301 var sqlexp
= document
.getElementById("uadd_box");
303 if (sqlexp
.value
.length
== 0) {
304 notify("Missing user login.");
306 notify("Adding user...");
308 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=add&login=" +
309 param_escape(sqlexp
.value
), true);
311 xmlhttp
.onreadystatechange
=userlist_callback
;
319 function editLabel(id
) {
321 if (!xmlhttp_ready(xmlhttp
)) {
328 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
329 param_escape(id
), true);
330 xmlhttp
.onreadystatechange
=labellist_callback
;
335 function editUser(id
) {
337 if (!xmlhttp_ready(xmlhttp
)) {
344 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
345 param_escape(id
), true);
346 xmlhttp
.onreadystatechange
=userlist_callback
;
351 function editFilter(id
) {
353 if (!xmlhttp_ready(xmlhttp
)) {
360 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" +
361 param_escape(id
), true);
362 xmlhttp
.onreadystatechange
=filterlist_callback
;
367 function editFeed(feed
) {
369 // notify("Editing feed...");
371 if (!xmlhttp_ready(xmlhttp
)) {
378 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=edit&id=" +
379 param_escape(feed
), true);
380 xmlhttp
.onreadystatechange
=feedlist_callback
;
385 function getSelectedLabels() {
387 var content
= document
.getElementById("prefLabelList");
389 var sel_rows
= new Array();
391 for (i
= 0; i
< content
.rows
.length
; i
++) {
392 if (content
.rows
[i
].className
.match("Selected")) {
393 var row_id
= content
.rows
[i
].id
.replace("LILRR-", "");
394 sel_rows
.push(row_id
);
401 function getSelectedUsers() {
403 var content
= document
.getElementById("prefUserList");
405 var sel_rows
= new Array();
407 for (i
= 0; i
< content
.rows
.length
; i
++) {
408 if (content
.rows
[i
].className
.match("Selected")) {
409 var row_id
= content
.rows
[i
].id
.replace("UMRR-", "");
410 sel_rows
.push(row_id
);
418 function getSelectedFilters() {
420 var content
= document
.getElementById("prefFilterList");
422 var sel_rows
= new Array();
424 for (i
= 0; i
< content
.rows
.length
; i
++) {
425 if (content
.rows
[i
].className
.match("Selected")) {
426 var row_id
= content
.rows
[i
].id
.replace("FILRR-", "");
427 sel_rows
.push(row_id
);
434 function getSelectedFeeds() {
436 var content
= document
.getElementById("prefFeedList");
438 var sel_rows
= new Array();
440 for (i
= 0; i
< content
.rows
.length
; i
++) {
441 if (content
.rows
[i
].className
.match("Selected")) {
442 var row_id
= content
.rows
[i
].id
.replace("FEEDR-", "");
443 sel_rows
.push(row_id
);
450 function readSelectedFeeds() {
452 if (!xmlhttp_ready(xmlhttp
)) {
457 var sel_rows
= getSelectedFeeds();
459 if (sel_rows
.length
> 0) {
461 notify("Marking selected feeds as read...");
463 xmlhttp
.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+
464 param_escape(sel_rows
.toString()), true);
465 xmlhttp
.onreadystatechange
=notify_callback
;
470 notify("Please select some feeds first.");
475 function unreadSelectedFeeds() {
477 if (!xmlhttp_ready(xmlhttp
)) {
482 var sel_rows
= getSelectedFeeds();
484 if (sel_rows
.length
> 0) {
486 notify("Marking selected feeds as unread...");
488 xmlhttp
.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+
489 param_escape(sel_rows
.toString()), true);
490 xmlhttp
.onreadystatechange
=notify_callback
;
495 notify("Please select some feeds first.");
500 function removeSelectedLabels() {
502 if (!xmlhttp_ready(xmlhttp
)) {
507 var sel_rows
= getSelectedLabels();
509 if (sel_rows
.length
> 0) {
511 notify("Removing selected labels...");
513 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
514 param_escape(sel_rows
.toString()), true);
515 xmlhttp
.onreadystatechange
=labellist_callback
;
519 notify("Please select some labels first.");
523 function removeSelectedUsers() {
525 if (!xmlhttp_ready(xmlhttp
)) {
530 var sel_rows
= getSelectedUsers();
532 if (sel_rows
.length
> 0) {
534 notify("Removing selected users...");
536 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
537 param_escape(sel_rows
.toString()), true);
538 xmlhttp
.onreadystatechange
=userlist_callback
;
542 notify("Please select some labels first.");
546 function removeSelectedFilters() {
548 if (!xmlhttp_ready(xmlhttp
)) {
553 var sel_rows
= getSelectedFilters();
555 if (sel_rows
.length
> 0) {
557 notify("Removing selected filters...");
559 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
560 param_escape(sel_rows
.toString()), true);
561 xmlhttp
.onreadystatechange
=filterlist_callback
;
565 notify("Please select some filters first.");
570 function removeSelectedFeeds() {
572 if (!xmlhttp_ready(xmlhttp
)) {
577 var sel_rows
= getSelectedFeeds();
579 if (sel_rows
.length
> 0) {
581 notify("Removing selected feeds...");
583 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
584 param_escape(sel_rows
.toString()), true);
585 xmlhttp
.onreadystatechange
=feedlist_callback
;
590 notify("Please select some feeds first.");
596 function feedEditCancel() {
598 if (!xmlhttp_ready(xmlhttp
)) {
605 notify("Operation cancelled.");
607 xmlhttp
.open("GET", "backend.php?op=pref-feeds", true);
608 xmlhttp
.onreadystatechange
=feedlist_callback
;
613 function feedEditSave() {
615 var feed
= active_feed
;
617 if (!xmlhttp_ready(xmlhttp
)) {
622 var link
= document
.getElementById("iedit_link").value
;
623 var title
= document
.getElementById("iedit_title").value
;
624 var upd_intl
= document
.getElementById("iedit_updintl").value
;
625 var purge_intl
= document
.getElementById("iedit_purgintl").value
;
627 // notify("Saving feed.");
629 /* if (upd_intl < 0) {
630 notify("Update interval must be >= 0 (0 = default)");
634 if (purge_intl < 0) {
635 notify("Purge days must be >= 0 (0 = default)");
639 if (link
.length
== 0) {
640 notify("Feed link cannot be blank.");
644 if (title
.length
== 0) {
645 notify("Feed title cannot be blank.");
653 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editSave&id=" +
654 feed
+ "&l=" + param_escape(link
) + "&t=" + param_escape(title
) +
655 "&ui=" + param_escape(upd_intl
) + "&pi=" + param_escape(purge_intl
), true);
656 xmlhttp
.onreadystatechange
=feedlist_callback
;
661 function labelEditCancel() {
663 if (!xmlhttp_ready(xmlhttp
)) {
668 active_label
= false;
670 notify("Operation cancelled.");
672 xmlhttp
.open("GET", "backend.php?op=pref-labels", true);
673 xmlhttp
.onreadystatechange
=labellist_callback
;
678 function userEditCancel() {
680 if (!xmlhttp_ready(xmlhttp
)) {
687 notify("Operation cancelled.");
689 xmlhttp
.open("GET", "backend.php?op=pref-users", true);
690 xmlhttp
.onreadystatechange
=userlist_callback
;
695 function filterEditCancel() {
697 if (!xmlhttp_ready(xmlhttp
)) {
702 active_filter
= false;
704 notify("Operation cancelled.");
706 xmlhttp
.open("GET", "backend.php?op=pref-filters", true);
707 xmlhttp
.onreadystatechange
=filterlist_callback
;
712 function labelEditSave() {
714 var label
= active_label
;
716 if (!xmlhttp_ready(xmlhttp
)) {
721 var sqlexp
= document
.getElementById("iedit_expr").value
;
722 var descr
= document
.getElementById("iedit_descr").value
;
724 // notify("Saving label " + sqlexp + ": " + descr);
726 if (sqlexp
.length
== 0) {
727 notify("SQL expression cannot be blank.");
731 if (descr
.length
== 0) {
732 notify("Caption cannot be blank.");
738 active_label
= false;
740 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=editSave&id=" +
741 label
+ "&s=" + param_escape(sqlexp
) + "&d=" + param_escape(descr
),
744 xmlhttp
.onreadystatechange
=labellist_callback
;
749 function userEditSave() {
751 var user
= active_user
;
753 if (!xmlhttp_ready(xmlhttp
)) {
758 var login
= document
.getElementById("iedit_ulogin").value
;
759 var level
= document
.getElementById("iedit_ulevel").value
;
761 if (login
.length
== 0) {
762 notify("Login cannot be blank.");
766 if (level
.length
== 0) {
767 notify("User level cannot be blank.");
775 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=editSave&id=" +
776 user
+ "&l=" + param_escape(login
) + "&al=" + param_escape(level
),
779 xmlhttp
.onreadystatechange
=userlist_callback
;
785 function filterEditSave() {
787 var filter
= active_filter
;
789 if (!xmlhttp_ready(xmlhttp
)) {
794 var regexp
= document
.getElementById("iedit_regexp").value
;
795 var descr
= document
.getElementById("iedit_descr").value
;
796 var match
= document
.getElementById("iedit_match");
798 var v_match
= match
[match
.selectedIndex
].text
;
800 // notify("Saving filter " + filter + ": " + regexp + ", " + descr + ", " + match);
802 if (regexp
.length
== 0) {
803 notify("Filter expression cannot be blank.");
807 active_filter
= false;
809 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=editSave&id=" +
810 filter
+ "&r=" + param_escape(regexp
) + "&d=" + param_escape(descr
) +
811 "&m=" + param_escape(v_match
), true);
815 xmlhttp
.onreadystatechange
=filterlist_callback
;
820 function editSelectedLabel() {
821 var rows
= getSelectedLabels();
823 if (rows
.length
== 0) {
824 notify("No labels are selected.");
828 if (rows
.length
> 1) {
829 notify("Please select one label.");
839 function editSelectedUser() {
840 var rows
= getSelectedUsers();
842 if (rows
.length
== 0) {
843 notify("No users are selected.");
847 if (rows
.length
> 1) {
848 notify("Please select one user.");
857 function resetSelectedUserPass() {
858 var rows
= getSelectedUsers();
860 if (rows
.length
== 0) {
861 notify("No users are selected.");
865 if (rows
.length
> 1) {
866 notify("Please select one user.");
870 notify("Resetting password for selected user...");
874 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
875 param_escape(id
), true);
876 xmlhttp
.onreadystatechange
=userlist_callback
;
881 function selectedUserDetails() {
883 if (!xmlhttp_ready(xmlhttp
)) {
888 var rows
= getSelectedUsers();
890 if (rows
.length
== 0) {
891 notify("No users are selected.");
895 if (rows
.length
> 1) {
896 notify("Please select one user.");
904 xmlhttp
.open("GET", "backend.php?op=user-details&id=" + id
, true);
905 xmlhttp
.onreadystatechange
=infobox_callback
;
910 function selectedFeedDetails() {
912 if (!xmlhttp_ready(xmlhttp
)) {
917 var rows
= getSelectedFeeds();
919 if (rows
.length
== 0) {
920 notify("No feeds are selected.");
924 if (rows
.length
> 1) {
925 notify("Please select one feed.");
933 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" + id
, true);
934 xmlhttp
.onreadystatechange
=infobox_callback
;
939 function editSelectedFilter() {
940 var rows
= getSelectedFilters();
942 if (rows
.length
== 0) {
943 notify("No filters are selected.");
947 if (rows
.length
> 1) {
948 notify("Please select one filter.");
959 function editSelectedFeed() {
960 var rows
= getSelectedFeeds();
962 if (rows
.length
== 0) {
963 notify("No feeds are selected.");
967 if (rows
.length
> 1) {
968 notify("Please select one feed.");
978 function localPiggieFunction(enable
) {
980 piggie
.style
.display
= "block";
982 notify("I loveded it!!!");
984 piggie
.style
.display
= "none";
989 function validateOpmlImport() {
991 var opml_file
= document
.getElementById("opml_file");
993 if (opml_file
.value
.length
== 0) {
994 notify("Please select OPML file to upload.");
1001 function updateFilterList() {
1003 if (!xmlhttp_ready(xmlhttp
)) {
1004 printLockingError();
1008 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1010 p_notify("Loading, please wait...");
1012 xmlhttp
.open("GET", "backend.php?op=pref-filters", true);
1013 xmlhttp
.onreadystatechange
=filterlist_callback
;
1018 function updateLabelList() {
1020 if (!xmlhttp_ready(xmlhttp
)) {
1021 printLockingError();
1025 p_notify("Loading, please wait...");
1027 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1029 xmlhttp
.open("GET", "backend.php?op=pref-labels", true);
1030 xmlhttp
.onreadystatechange
=labellist_callback
;
1034 function updatePrefsList() {
1036 if (!xmlhttp_ready(xmlhttp
)) {
1037 printLockingError();
1041 p_notify("Loading, please wait...");
1043 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1044 xmlhttp
.onreadystatechange
=prefslist_callback
;
1049 function selectTab(id
) {
1051 if (!xmlhttp_ready(xmlhttp
)) {
1052 printLockingError();
1056 if (id
== "feedConfig") {
1058 } else if (id
== "filterConfig") {
1060 } else if (id
== "labelConfig") {
1062 } else if (id
== "genConfig") {
1064 } else if (id
== "userConfig") {
1068 var tab
= document
.getElementById(active_tab
+ "Tab");
1071 if (tab
.className
.match("Selected")) {
1072 tab
.className
= "prefsTab";
1076 tab
= document
.getElementById(id
+ "Tab");
1079 if (!tab
.className
.match("Selected")) {
1080 tab
.className
= tab
.className
+ "Selected";
1093 document
.getElementById("prefContent").innerHTML
=
1094 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1095 "to function properly. Your browser doesn't seem to support it.";
1099 selectTab("genConfig");
1101 document
.onkeydown
= hotkey_handler
;
1107 var help_topic_id = false;
1109 function do_dispOptionHelp() {
1111 if (!xmlhttp_ready(xmlhttp))
1114 xmlhttp.open("GET", "backend.php?op=pref-prefs&subop=getHelp&pn=" +
1115 param_escape(help_topic_id), true);
1116 xmlhttp.onreadystatechange=gethelp_callback;
1121 function dispOptionHelp(event, sender) {
1123 help_topic_id = sender.id;
1125 // document.setTimeout("do_dispOptionHelp()", 100);
1129 function closeInfoBox() {
1130 var box
= document
.getElementById('infoBox');
1131 var shadow
= document
.getElementById('infoBoxShadow');
1134 shadow
.style
.display
= "none";
1136 box
.style
.display
= "none";