]>
git.wh0rd.org - tt-rss.git/blob - prefs.js
3 var active_feed
= false;
4 var active_feed_cat
= false;
5 var active_filter
= false;
6 var active_label
= false;
7 var active_user
= false;
8 var active_tab
= false;
9 var feed_to_expand
= false;
11 var piggie_top
= -400;
12 var piggie_fwd
= true;
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 expand_feed_callback() {
34 if (xmlhttp
.readyState
== 4) {
36 var container
= document
.getElementById("BRDET-" + feed_to_expand
);
37 container
.innerHTML
=xmlhttp
.responseText
;
38 container
.style
.display
= "block";
41 exception_error("expand_feed_callback", e
);
46 function feedlist_callback() {
47 if (xmlhttp
.readyState
== 4) {
49 var container
= document
.getElementById('prefContent');
50 container
.innerHTML
=xmlhttp
.responseText
;
51 selectTab("feedConfig", true);
54 var row
= document
.getElementById("FEEDR-" + active_feed
);
56 if (!row
.className
.match("Selected")) {
57 row
.className
= row
.className
+ "Selected";
60 var checkbox
= document
.getElementById("FRCHK-" + active_feed
);
62 checkbox
.checked
= true;
67 exception_error("feedlist_callback", e
);
72 function filterlist_callback() {
73 var container
= document
.getElementById('prefContent');
74 if (xmlhttp
.readyState
== 4) {
76 container
.innerHTML
=xmlhttp
.responseText
;
79 var row
= document
.getElementById("FILRR-" + active_filter
);
81 if (!row
.className
.match("Selected")) {
82 row
.className
= row
.className
+ "Selected";
85 var checkbox
= document
.getElementById("FICHK-" + active_filter
);
88 checkbox
.checked
= true;
95 function labellist_callback() {
96 var container
= document
.getElementById('prefContent');
97 if (xmlhttp
.readyState
== 4) {
98 container
.innerHTML
=xmlhttp
.responseText
;
101 var row
= document
.getElementById("LILRR-" + active_label
);
103 if (!row
.className
.match("Selected")) {
104 row
.className
= row
.className
+ "Selected";
107 var checkbox
= document
.getElementById("LICHK-" + active_label
);
110 checkbox
.checked
= true;
117 function feed_browser_callback() {
118 var container
= document
.getElementById('prefContent');
119 if (xmlhttp
.readyState
== 4) {
120 container
.innerHTML
=xmlhttp
.responseText
;
125 function userlist_callback() {
126 var container
= document
.getElementById('prefContent');
127 if (xmlhttp
.readyState
== 4) {
128 container
.innerHTML
=xmlhttp
.responseText
;
131 var row
= document
.getElementById("UMRR-" + active_user
);
133 if (!row
.className
.match("Selected")) {
134 row
.className
= row
.className
+ "Selected";
137 var checkbox
= document
.getElementById("UMCHK-" + active_user
);
140 checkbox
.checked
= true;
147 function prefslist_callback() {
148 var container
= document
.getElementById('prefContent');
149 if (xmlhttp
.readyState
== 4) {
151 container
.innerHTML
=xmlhttp
.responseText
;
157 function gethelp_callback() {
158 var container
= document
.getElementById('prefHelpBox');
159 if (xmlhttp
.readyState
== 4) {
161 container
.innerHTML
= xmlhttp
.responseText
;
162 container
.style
.display
= "block";
168 function notify_callback() {
169 var container
= document
.getElementById('notify');
170 if (xmlhttp
.readyState
== 4) {
171 container
.innerHTML
=xmlhttp
.responseText
;
175 function updateFeedList(sort_key
) {
177 if (!xmlhttp_ready(xmlhttp
)) {
182 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
184 // p_notify("Loading, please wait...");
186 var feed_search
= document
.getElementById("feed_search");
188 if (feed_search
) { search
= feed_search
.value
; }
190 xmlhttp
.open("GET", "backend.php?op=pref-feeds" +
191 "&sort=" + param_escape(sort_key
) +
192 "&search=" + param_escape(search
), true);
193 xmlhttp
.onreadystatechange
=feedlist_callback
;
198 function updateUsersList() {
200 if (!xmlhttp_ready(xmlhttp
)) {
205 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
207 // p_notify("Loading, please wait...");
209 xmlhttp
.open("GET", "backend.php?op=pref-users", true);
210 xmlhttp
.onreadystatechange
=userlist_callback
;
215 function addLabel() {
217 if (!xmlhttp_ready(xmlhttp
)) {
222 var sqlexp
= document
.getElementById("ladd_expr");
224 if (sqlexp
.value
.length
== 0) {
225 alert("Can't add label: missing SQL expression.");
227 notify("Adding label...");
229 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=add&exp=" +
230 param_escape(sqlexp
.value
), true);
232 xmlhttp
.onreadystatechange
=labellist_callback
;
240 function addFilter() {
242 if (!xmlhttp_ready(xmlhttp
)) {
247 var regexp
= document
.getElementById("fadd_regexp");
248 var match
= document
.getElementById("fadd_match");
249 var feed
= document
.getElementById("fadd_feed");
250 var action
= document
.getElementById("fadd_action");
252 if (regexp
.value
.length
== 0) {
253 alert("Can't add filter: missing filter expression.");
255 notify("Adding filter...");
257 var v_match
= match
[match
.selectedIndex
].text
;
258 var feed_id
= feed
[feed
.selectedIndex
].id
;
259 var action_id
= action
[action
.selectedIndex
].id
;
261 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=add®exp=" +
262 param_escape(regexp
.value
) + "&match=" + v_match
+
263 "&fid=" + param_escape(feed_id
) + "&aid=" + param_escape(action_id
), true);
265 xmlhttp
.onreadystatechange
=filterlist_callback
;
275 if (!xmlhttp_ready(xmlhttp
)) {
280 var link
= document
.getElementById("fadd_link");
282 if (link
.value
.length
== 0) {
283 alert("Error: No feed URL given.");
284 } else if (!isValidURL(link
.value
)) {
285 alert("Error: Invalid feed URL.");
287 notify("Adding feed...");
289 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&link=" +
290 param_escape(link
.value
), true);
291 xmlhttp
.onreadystatechange
=feedlist_callback
;
300 function addFeedCat() {
302 if (!xmlhttp_ready(xmlhttp
)) {
307 var cat
= document
.getElementById("fadd_cat");
309 if (cat
.value
.length
== 0) {
310 alert("Can't add category: no name specified.");
312 notify("Adding feed category...");
314 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=addCat&cat=" +
315 param_escape(cat
.value
), true);
316 xmlhttp
.onreadystatechange
=feedlist_callback
;
326 if (!xmlhttp_ready(xmlhttp
)) {
331 var sqlexp
= document
.getElementById("uadd_box");
333 if (sqlexp
.value
.length
== 0) {
334 alert("Can't add user: no login specified.");
336 notify("Adding user...");
338 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=add&login=" +
339 param_escape(sqlexp
.value
), true);
341 xmlhttp
.onreadystatechange
=userlist_callback
;
349 function editLabel(id
) {
351 if (!xmlhttp_ready(xmlhttp
)) {
358 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
359 param_escape(id
), true);
360 xmlhttp
.onreadystatechange
=labellist_callback
;
365 function editUser(id
) {
367 if (!xmlhttp_ready(xmlhttp
)) {
374 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
375 param_escape(id
), true);
376 xmlhttp
.onreadystatechange
=userlist_callback
;
381 function editFilter(id
) {
383 if (!xmlhttp_ready(xmlhttp
)) {
390 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" +
391 param_escape(id
), true);
392 xmlhttp
.onreadystatechange
=filterlist_callback
;
397 function editFeed(feed
) {
399 // notify("Editing feed...");
401 if (!xmlhttp_ready(xmlhttp
)) {
408 /* xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=edit&id=" +
409 param_escape(feed), true);
410 xmlhttp.onreadystatechange=feedlist_callback;
411 xmlhttp.send(null); */
413 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
414 // selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-'+feed, 'FRCHK-'+feed,
417 selectTableRowById('FEEDR-'+feed
, 'FRCHK-'+feed
, true);
419 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
420 param_escape(active_feed
), true);
422 xmlhttp
.onreadystatechange
=infobox_callback
;
427 function editFeedCat(cat
) {
429 if (!xmlhttp_ready(xmlhttp
)) {
434 active_feed_cat
= cat
;
436 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCat&id=" +
437 param_escape(cat
), true);
438 xmlhttp
.onreadystatechange
=feedlist_callback
;
443 function getSelectedLabels() {
444 return getSelectedTableRowIds("prefLabelList", "LILRR");
447 function getSelectedUsers() {
448 return getSelectedTableRowIds("prefUserList", "UMRR");
451 function getSelectedFeeds() {
452 return getSelectedTableRowIds("prefFeedList", "FEEDR");
455 function getSelectedFilters() {
456 return getSelectedTableRowIds("prefFilterList", "FILRR");
459 function getSelectedFeedCats() {
460 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
463 function getSelectedFeedsFromBrowser() {
465 var list
= document
.getElementById("browseFeedList");
466 if (!list
) list
= document
.getElementById("browseBigFeedList");
468 var selected
= new Array();
470 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
471 var child
= list
.childNodes
[i
];
472 if (child
.id
&& child
.id
.match("FBROW-")) {
473 var id
= child
.id
.replace("FBROW-", "");
475 var cb
= document
.getElementById("FBCHK-" + id
);
487 /*function readSelectedFeeds(read) {
489 if (!xmlhttp_ready(xmlhttp)) {
494 var sel_rows = getSelectedFeeds();
496 if (sel_rows.length > 0) {
504 notify("Marking selected feeds as " + op + "...");
506 xmlhttp.open("GET", "backend.php?op=pref-rpc&subop=" + op + "&ids="+
507 param_escape(sel_rows.toString()), true);
508 xmlhttp.onreadystatechange=notify_callback;
513 alert("No feeds are selected.");
518 function removeSelectedLabels() {
520 if (!xmlhttp_ready(xmlhttp
)) {
525 var sel_rows
= getSelectedLabels();
527 if (sel_rows
.length
> 0) {
529 var ok
= confirm("Remove selected labels?");
532 notify("Removing selected labels...");
534 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
535 param_escape(sel_rows
.toString()), true);
536 xmlhttp
.onreadystatechange
=labellist_callback
;
540 alert("No labels are selected.");
544 function removeSelectedUsers() {
546 if (!xmlhttp_ready(xmlhttp
)) {
551 var sel_rows
= getSelectedUsers();
553 if (sel_rows
.length
> 0) {
555 var ok
= confirm("Remove selected users?");
558 notify("Removing selected users...");
560 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
561 param_escape(sel_rows
.toString()), true);
562 xmlhttp
.onreadystatechange
=userlist_callback
;
567 alert("No users are selected.");
571 function removeSelectedFilters() {
573 if (!xmlhttp_ready(xmlhttp
)) {
578 var sel_rows
= getSelectedFilters();
580 if (sel_rows
.length
> 0) {
582 var ok
= confirm("Remove selected filters?");
585 notify("Removing selected filters...");
587 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
588 param_escape(sel_rows
.toString()), true);
589 xmlhttp
.onreadystatechange
=filterlist_callback
;
593 alert("No filters are selected.");
598 function removeSelectedFeeds() {
600 if (!xmlhttp_ready(xmlhttp
)) {
605 var sel_rows
= getSelectedFeeds();
607 if (sel_rows
.length
> 0) {
609 var ok
= confirm("Unsubscribe from selected feeds?");
613 notify("Unsubscribing from selected feeds...");
615 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
616 param_escape(sel_rows
.toString()), true);
617 xmlhttp
.onreadystatechange
=feedlist_callback
;
623 alert("No feeds are selected.");
629 function removeSelectedFeedCats() {
631 if (!xmlhttp_ready(xmlhttp
)) {
636 var sel_rows
= getSelectedFeedCats();
638 if (sel_rows
.length
> 0) {
640 var ok
= confirm("Remove selected categories?");
643 notify("Removing selected categories...");
645 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=removeCats&ids="+
646 param_escape(sel_rows
.toString()), true);
647 xmlhttp
.onreadystatechange
=feedlist_callback
;
653 alert("No categories are selected.");
659 function feedEditCancel() {
661 if (!xmlhttp_ready(xmlhttp
)) {
670 // notify("Operation cancelled.");
672 /* xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
673 xmlhttp.onreadystatechange=feedlist_callback;
674 xmlhttp.send(null); */
678 function feedCatEditCancel() {
680 if (!xmlhttp_ready(xmlhttp
)) {
685 active_feed_cat
= false;
687 // notify("Operation cancelled.");
689 xmlhttp
.open("GET", "backend.php?op=pref-feeds", true);
690 xmlhttp
.onreadystatechange
=feedlist_callback
;
695 function feedEditSave() {
699 var feed
= active_feed
;
701 if (!xmlhttp_ready(xmlhttp
)) {
706 var link
= document
.getElementById("iedit_link").value
;
707 var title
= document
.getElementById("iedit_title").value
;
708 var upd_intl
= document
.getElementById("iedit_updintl");
710 upd_intl
= upd_intl
[upd_intl
.selectedIndex
].id
;
712 var purge_intl
= document
.getElementById("iedit_purgintl");
714 purge_intl
= purge_intl
[purge_intl
.selectedIndex
].id
;
716 var fcat
= document
.getElementById("iedit_fcat");
718 var is_pvt
= document
.getElementById("iedit_private");
719 var is_rtl
= document
.getElementById("iedit_rtl");
722 is_pvt
= is_pvt
.checked
;
726 is_rtl
= is_rtl
.checked
;
732 fcat_id
= fcat
[fcat
.selectedIndex
].id
;
735 var pfeed
= document
.getElementById("iedit_parent_feed");
736 var parent_feed_id
= pfeed
[pfeed
.selectedIndex
].id
;
738 if (link
.length
== 0) {
739 notify("Feed link cannot be blank.");
743 if (title
.length
== 0) {
744 notify("Feed title cannot be blank.");
748 if (!isValidURL(link
)) {
749 alert("Feed URL is invalid.");
753 var auth_login
= document
.getElementById("iedit_login").value
;
754 var auth_pass
= document
.getElementById("iedit_pass").value
;
758 notify("Saving feed...");
760 var query
= "op=pref-feeds&subop=editSave&id=" +
761 feed
+ "&l=" + param_escape(link
) + "&t=" + param_escape(title
) +
762 "&ui=" + param_escape(upd_intl
) + "&pi=" + param_escape(purge_intl
) +
763 "&catid=" + param_escape(fcat_id
) + "&login=" + param_escape(auth_login
) +
764 "&pfeed=" + param_escape(parent_feed_id
) + "&pass=" + param_escape(auth_pass
) +
765 "&is_pvt=" + param_escape(is_pvt
) + "&is_rtl=" + param_escape(is_rtl
);
767 xmlhttp
.open("POST", "backend.php", true);
768 xmlhttp
.onreadystatechange
=feedlist_callback
;
769 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
773 exception_error("feedEditSave", e
);
777 function feedCatEditSave() {
779 if (!xmlhttp_ready(xmlhttp
)) {
784 notify("Saving category...");
786 var cat_title
= document
.getElementById("iedit_title").value
;
788 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=saveCat&id=" +
789 param_escape(active_feed_cat
) + "&title=" + param_escape(cat_title
),
791 xmlhttp
.onreadystatechange
=feedlist_callback
;
794 active_feed_cat
= false;
799 function labelTest() {
801 var sqlexp
= document
.getElementById("iedit_expr").value
;
802 var descr
= document
.getElementById("iedit_descr").value
;
804 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
805 param_escape(sqlexp
) + "&descr=" + param_escape(descr
), true);
807 xmlhttp
.onreadystatechange
=infobox_callback
;
812 function displayHelpInfobox(topic_id
) {
814 xmlhttp
.open("GET", "backend.php?op=help&tid=" +
815 param_escape(topic_id
) + "&noheaders=1", true);
817 xmlhttp
.onreadystatechange
=infobox_callback
;
822 function labelEditCancel() {
824 if (!xmlhttp_ready(xmlhttp
)) {
829 active_label
= false;
831 // notify("Operation cancelled.");
833 xmlhttp
.open("GET", "backend.php?op=pref-labels", true);
834 xmlhttp
.onreadystatechange
=labellist_callback
;
839 function userEditCancel() {
841 if (!xmlhttp_ready(xmlhttp
)) {
848 // notify("Operation cancelled.");
850 xmlhttp
.open("GET", "backend.php?op=pref-users", true);
851 xmlhttp
.onreadystatechange
=userlist_callback
;
856 function filterEditCancel() {
858 if (!xmlhttp_ready(xmlhttp
)) {
863 active_filter
= false;
865 // notify("Operation cancelled.");
867 xmlhttp
.open("GET", "backend.php?op=pref-filters", true);
868 xmlhttp
.onreadystatechange
=filterlist_callback
;
873 function labelEditSave() {
875 var label
= active_label
;
877 if (!xmlhttp_ready(xmlhttp
)) {
882 var sqlexp
= document
.getElementById("iedit_expr").value
;
883 var descr
= document
.getElementById("iedit_descr").value
;
885 // notify("Saving label " + sqlexp + ": " + descr);
887 if (sqlexp
.length
== 0) {
888 notify("SQL expression cannot be blank.");
892 if (descr
.length
== 0) {
893 notify("Caption cannot be blank.");
897 notify("Saving label...");
899 active_label
= false;
901 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=editSave&id=" +
902 label
+ "&s=" + param_escape(sqlexp
) + "&d=" + param_escape(descr
),
905 xmlhttp
.onreadystatechange
=labellist_callback
;
910 function userEditSave() {
912 var user
= active_user
;
914 if (!xmlhttp_ready(xmlhttp
)) {
919 var login
= document
.getElementById("iedit_ulogin").value
;
920 var level
= document
.getElementById("iedit_ulevel");
922 level
= level
[level
.selectedIndex
].id
;
924 var email
= document
.getElementById("iedit_email").value
;
926 if (login
.length
== 0) {
927 notify("Login cannot be blank.");
931 if (level
.length
== 0) {
932 notify("User level cannot be blank.");
938 notify("Saving user...");
940 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=editSave&id=" +
941 user
+ "&l=" + param_escape(login
) + "&al=" + param_escape(level
) +
942 "&e=" + param_escape(email
), true);
944 xmlhttp
.onreadystatechange
=userlist_callback
;
950 function filterEditSave() {
952 var filter
= active_filter
;
954 if (!xmlhttp_ready(xmlhttp
)) {
959 var regexp
= document
.getElementById("iedit_regexp").value
;
960 var match
= document
.getElementById("iedit_match");
962 var v_match
= match
[match
.selectedIndex
].text
;
964 var feed
= document
.getElementById("iedit_feed");
965 var feed_id
= feed
[feed
.selectedIndex
].id
;
967 var action
= document
.getElementById("iedit_filter_action");
968 var action_id
= action
[action
.selectedIndex
].id
;
970 if (regexp
.length
== 0) {
971 alert("Can't save filter: match expression is blank.");
975 active_filter
= false;
977 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=editSave&id=" +
978 filter
+ "&r=" + param_escape(regexp
) + "&m=" + param_escape(v_match
) +
979 "&fid=" + param_escape(feed_id
) + "&aid=" + param_escape(action_id
), true);
981 notify("Saving filter...");
983 xmlhttp
.onreadystatechange
=filterlist_callback
;
988 function editSelectedLabel() {
989 var rows
= getSelectedLabels();
991 if (rows
.length
== 0) {
992 alert("No labels are selected.");
996 if (rows
.length
> 1) {
997 alert("Please select only one label.");
1007 function editSelectedUser() {
1008 var rows
= getSelectedUsers();
1010 if (rows
.length
== 0) {
1011 alert("No users are selected.");
1015 if (rows
.length
> 1) {
1016 alert("Please select only one user.");
1025 function resetSelectedUserPass() {
1026 var rows
= getSelectedUsers();
1028 if (rows
.length
== 0) {
1029 alert("No users are selected.");
1033 if (rows
.length
> 1) {
1034 alert("Please select only one user.");
1038 var ok
= confirm("Reset password of selected user?");
1041 notify("Resetting password for selected user...");
1045 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
1046 param_escape(id
), true);
1047 xmlhttp
.onreadystatechange
=userlist_callback
;
1052 function selectedUserDetails() {
1054 if (!xmlhttp_ready(xmlhttp
)) {
1055 printLockingError();
1059 var rows
= getSelectedUsers();
1061 if (rows
.length
== 0) {
1062 alert("No users are selected.");
1066 if (rows
.length
> 1) {
1067 alert("Please select only one user.");
1075 xmlhttp
.open("GET", "backend.php?op=user-details&id=" + id
, true);
1076 xmlhttp
.onreadystatechange
=infobox_callback
;
1081 function selectedFeedDetails() {
1083 if (!xmlhttp_ready(xmlhttp
)) {
1084 printLockingError();
1088 var rows
= getSelectedFeeds();
1090 if (rows
.length
== 0) {
1091 alert("No feeds are selected.");
1095 if (rows
.length
> 1) {
1096 notify("Please select only one feed.");
1100 // var id = rows[0];
1104 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
1105 param_escape(rows
.toString()), true);
1106 xmlhttp
.onreadystatechange
=infobox_callback
;
1111 function editSelectedFilter() {
1112 var rows
= getSelectedFilters();
1114 if (rows
.length
== 0) {
1115 alert("No filters are selected.");
1119 if (rows
.length
> 1) {
1120 alert("Please select only one filter.");
1126 editFilter(rows
[0]);
1131 function editSelectedFeed() {
1132 var rows
= getSelectedFeeds();
1134 if (rows
.length
== 0) {
1135 notify("No feeds are selected.");
1139 if (rows
.length
> 1) {
1140 notify("Please select one feed.");
1150 function editSelectedFeedCat() {
1151 var rows
= getSelectedFeedCats();
1153 if (rows
.length
== 0) {
1154 alert("No categories are selected.");
1158 if (rows
.length
> 1) {
1159 alert("Please select only one category.");
1165 editFeedCat(rows
[0]);
1169 function piggie_callback() {
1170 var piggie
= document
.getElementById("piggie");
1172 piggie
.style
.top
= piggie_top
;
1173 piggie
.style
.backgroundColor
= "white";
1174 piggie
.style
.borderWidth
= "1px";
1176 if (piggie_fwd
&& piggie_top
< 0) {
1177 setTimeout("piggie_callback()", 50);
1178 piggie_top
= piggie_top
+ 10;
1179 } else if (piggie_fwd
&& piggie_top
>= 0) {
1181 setTimeout("piggie_callback()", 50);
1182 } else if (!piggie_fwd
&& piggie_top
> -400) {
1183 setTimeout("piggie_callback()", 50);
1184 piggie_top
= piggie_top
- 10;
1185 } else if (!piggie_fwd
&& piggie_top
<= -400) {
1186 piggie
.style
.display
= "none";
1191 var piggie_opacity
= 0;
1193 function piggie2_callback() {
1194 var piggie
= document
.getElementById("piggie");
1195 piggie
.style
.top
= 0;
1196 piggie
.style
.opacity
= piggie_opacity
;
1197 piggie
.style
.backgroundColor
= "transparent";
1198 piggie
.style
.borderWidth
= "0px";
1200 if (piggie_fwd
&& piggie_opacity
< 1) {
1201 setTimeout("piggie2_callback()", 50);
1202 piggie_opacity
= piggie_opacity
+ 0.03;
1203 } else if (piggie_fwd
&& piggie_opacity
>= 1) {
1205 setTimeout("piggie2_callback()", 50);
1206 } else if (!piggie_fwd
&& piggie_opacity
> 0) {
1207 setTimeout("piggie2_callback()", 50);
1208 piggie_opacity
= piggie_opacity
- 0.03;
1209 } else if (!piggie_fwd
&& piggie_opacity
<= 0) {
1210 piggie
.style
.display
= "none";
1215 function localPiggieFunction(enable
) {
1217 var piggie
= document
.getElementById("piggie");
1218 piggie
.style
.display
= "block";
1220 if (navigator
.userAgent
.match("Gecko") && Math
.random(1) > 0.5) {
1228 function validateOpmlImport() {
1230 var opml_file
= document
.getElementById("opml_file");
1232 if (opml_file
.value
.length
== 0) {
1233 alert("No OPML file to upload.");
1240 function updateFilterList() {
1242 if (!xmlhttp_ready(xmlhttp
)) {
1243 printLockingError();
1247 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1249 // p_notify("Loading, please wait...");
1251 xmlhttp
.open("GET", "backend.php?op=pref-filters", true);
1252 xmlhttp
.onreadystatechange
=filterlist_callback
;
1257 function updateLabelList() {
1259 if (!xmlhttp_ready(xmlhttp
)) {
1260 printLockingError();
1264 // p_notify("Loading, please wait...");
1266 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1268 xmlhttp
.open("GET", "backend.php?op=pref-labels", true);
1269 xmlhttp
.onreadystatechange
=labellist_callback
;
1273 function updatePrefsList() {
1275 if (!xmlhttp_ready(xmlhttp
)) {
1276 printLockingError();
1280 // p_notify("Loading, please wait...");
1282 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1283 xmlhttp
.onreadystatechange
=prefslist_callback
;
1288 function selectTab(id
, noupdate
) {
1292 if (!xmlhttp_ready(xmlhttp
)) {
1293 printLockingError();
1299 notify("Loading, please wait...", true);
1301 if (id
== "feedConfig") {
1303 } else if (id
== "filterConfig") {
1305 } else if (id
== "labelConfig") {
1307 } else if (id
== "genConfig") {
1309 } else if (id
== "userConfig") {
1311 } else if (id
== "feedBrowser") {
1312 updateBigFeedBrowser();
1316 var tab
= document
.getElementById(active_tab
+ "Tab");
1319 if (tab
.className
.match("Selected")) {
1320 tab
.className
= "prefsTab";
1324 tab
= document
.getElementById(id
+ "Tab");
1327 if (!tab
.className
.match("Selected")) {
1328 tab
.className
= tab
.className
+ "Selected";
1334 setCookie('ttrss_pref_acttab', active_tab
);
1342 if (arguments
.callee
.done
) return;
1343 arguments
.callee
.done
= true;
1347 document
.getElementById("prefContent").innerHTML
=
1348 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1349 "to function properly. Your browser doesn't seem to support it.";
1353 active_tab
= getCookie("ttrss_pref_acttab");
1354 if (!active_tab
) active_tab
= "genConfig";
1355 selectTab(active_tab
);
1357 document
.onkeydown
= hotkey_handler
;
1360 exception_error("init", e
);
1364 function categorizeSelectedFeeds() {
1366 if (!xmlhttp_ready(xmlhttp
)) {
1367 printLockingError();
1371 var sel_rows
= getSelectedFeeds();
1373 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1374 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].id
;
1376 if (sel_rows
.length
> 0) {
1378 notify("Changing category of selected feeds...");
1380 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1381 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1382 xmlhttp
.onreadystatechange
=feedlist_callback
;
1387 alert("No feeds are selected.");
1393 function validatePrefsReset() {
1394 return confirm("Reset to defaults?");
1397 function browseFeeds(limit
) {
1399 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1400 xmlhttp
.onreadystatechange
=infobox_callback
;
1405 function feedBrowserSubscribe() {
1408 var selected
= getSelectedFeedsFromBrowser();
1410 if (selected
.length
> 0) {
1412 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1413 param_escape(selected
.toString()), true);
1414 xmlhttp
.onreadystatechange
=feedlist_callback
;
1417 alert("No feeds are selected.");
1421 exception_error("feedBrowserSubscribe", e
);
1425 function updateBigFeedBrowser(limit
) {
1427 if (!xmlhttp_ready(xmlhttp
)) {
1428 printLockingError();
1432 // p_notify("Loading, please wait...");
1434 var query
= "backend.php?op=pref-feed-browser";
1436 var limit_sel
= document
.getElementById("feedBrowserLimit");
1439 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1440 query
= query
+ "&limit=" + param_escape(limit
);
1443 xmlhttp
.open("GET", query
, true);
1444 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1448 function browserToggleExpand(id
) {
1450 /* if (feed_to_expand && feed_to_expand != id) {
1451 var d = document.getElementById("BRDET-" + feed_to_expand);
1452 d.style.display = "none";
1455 if (!xmlhttp_ready(xmlhttp
)) {
1456 printLockingError();
1460 var d
= document
.getElementById("BRDET-" + id
);
1462 if (d
.style
.display
== "block") {
1463 d
.style
.display
= "none";
1467 feed_to_expand
= id
;
1469 d
.style
.display
= "block";
1470 d
.innerHTML
= "Loading, please wait...";
1472 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1473 + param_escape(id
), true);
1474 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1479 exception_error("browserExpand", e
);
1483 function validateNewPassword(form
) {
1484 if (form
.OLD_PASSWORD
.value
== "") {
1485 alert("Current password cannot be blank");
1488 if (form
.NEW_PASSWORD
.value
== "") {
1489 alert("New password cannot be blank");
1495 function selectPrefRows(kind
, select
) {
1498 var opbarid
= false;
1503 if (kind
== "feed") {
1504 opbarid
= "feedOpToolbar";
1507 lname
= "prefFeedList";
1508 } else if (kind
== "fcat") {
1509 opbarid
= "catOpToolbar";
1512 lname
= "prefFeedCatList";
1513 } else if (kind
== "filter") {
1514 opbarid
= "filterOpToolbar";
1517 lname
= "prefFilterList";
1518 } else if (kind
== "label") {
1519 opbarid
= "labelOpToolbar";
1522 lname
= "prefLabelList";
1523 } else if (kind
== "user") {
1524 opbarid
= "userOpToolbar";
1527 lname
= "prefUserList";
1531 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1532 disableContainerChildren(opbarid
, !select
);
1539 function toggleSelectPrefRow(sender
, kind
) {
1541 toggleSelectRow(sender
);
1544 var opbarid
= false;
1547 if (kind
== "feed") {
1548 opbarid
= "feedOpToolbar";
1549 nsel
= getSelectedFeeds();
1550 } else if (kind
== "fcat") {
1551 opbarid
= "catOpToolbar";
1552 nsel
= getSelectedFeedCats();
1553 } else if (kind
== "filter") {
1554 opbarid
= "filterOpToolbar";
1555 nsel
= getSelectedFilters();
1556 } else if (kind
== "label") {
1557 opbarid
= "labelOpToolbar";
1558 nsel
= getSelectedLabels();
1559 } else if (kind
== "user") {
1560 opbarid
= "userOpToolbar";
1561 nsel
= getSelectedUsers();
1564 if (opbarid
&& nsel
!= -1) {
1565 disableContainerChildren(opbarid
, nsel
== false);
1571 function toggleSelectFBListRow(sender
) {
1572 toggleSelectListRow(sender
);
1573 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);