]>
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;
148 function prefslist_callback() {
149 var container
= document
.getElementById('prefContent');
150 if (xmlhttp
.readyState
== 4) {
152 container
.innerHTML
=xmlhttp
.responseText
;
158 function gethelp_callback() {
159 var container
= document
.getElementById('prefHelpBox');
160 if (xmlhttp
.readyState
== 4) {
162 container
.innerHTML
= xmlhttp
.responseText
;
163 container
.style
.display
= "block";
169 function notify_callback() {
170 var container
= document
.getElementById('notify');
171 if (xmlhttp
.readyState
== 4) {
172 container
.innerHTML
=xmlhttp
.responseText
;
176 function updateFeedList(sort_key
) {
178 if (!xmlhttp_ready(xmlhttp
)) {
183 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
185 // p_notify("Loading, please wait...");
187 var feed_search
= document
.getElementById("feed_search");
189 if (feed_search
) { search
= feed_search
.value
; }
191 xmlhttp
.open("GET", "backend.php?op=pref-feeds" +
192 "&sort=" + param_escape(sort_key
) +
193 "&search=" + param_escape(search
), true);
194 xmlhttp
.onreadystatechange
=feedlist_callback
;
199 function updateUsersList() {
201 if (!xmlhttp_ready(xmlhttp
)) {
206 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
208 // p_notify("Loading, please wait...");
210 xmlhttp
.open("GET", "backend.php?op=pref-users", true);
211 xmlhttp
.onreadystatechange
=userlist_callback
;
216 function addLabel() {
218 if (!xmlhttp_ready(xmlhttp
)) {
223 var sqlexp
= document
.getElementById("ladd_expr");
225 if (sqlexp
.value
.length
== 0) {
226 alert("Can't add label: 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");
250 var feed
= document
.getElementById("fadd_feed");
251 var action
= document
.getElementById("fadd_action");
253 if (regexp
.value
.length
== 0) {
254 alert("Can't add filter: missing filter expression.");
256 notify("Adding filter...");
258 var v_match
= match
[match
.selectedIndex
].text
;
259 var feed_id
= feed
[feed
.selectedIndex
].id
;
260 var action_id
= action
[action
.selectedIndex
].id
;
262 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=add®exp=" +
263 param_escape(regexp
.value
) + "&match=" + v_match
+
264 "&fid=" + param_escape(feed_id
) + "&aid=" + param_escape(action_id
), true);
266 xmlhttp
.onreadystatechange
=filterlist_callback
;
276 if (!xmlhttp_ready(xmlhttp
)) {
281 var link
= document
.getElementById("fadd_link");
283 if (link
.value
.length
== 0) {
284 alert("Error: No feed URL given.");
285 } else if (!isValidURL(link
.value
)) {
286 alert("Error: Invalid feed URL.");
288 notify("Adding feed...");
290 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&link=" +
291 param_escape(link
.value
), true);
292 xmlhttp
.onreadystatechange
=feedlist_callback
;
301 function addFeedCat() {
303 if (!xmlhttp_ready(xmlhttp
)) {
308 var cat
= document
.getElementById("fadd_cat");
310 if (cat
.value
.length
== 0) {
311 alert("Can't add category: no name specified.");
313 notify("Adding feed category...");
315 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=addCat&cat=" +
316 param_escape(cat
.value
), true);
317 xmlhttp
.onreadystatechange
=feedlist_callback
;
327 if (!xmlhttp_ready(xmlhttp
)) {
332 var sqlexp
= document
.getElementById("uadd_box");
334 if (sqlexp
.value
.length
== 0) {
335 alert("Can't add user: no login specified.");
337 notify("Adding user...");
339 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=add&login=" +
340 param_escape(sqlexp
.value
), true);
342 xmlhttp
.onreadystatechange
=userlist_callback
;
350 function editLabel(id
) {
352 if (!xmlhttp_ready(xmlhttp
)) {
359 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
360 param_escape(id
), true);
361 xmlhttp
.onreadystatechange
=labellist_callback
;
366 function editUser(id
) {
368 if (!xmlhttp_ready(xmlhttp
)) {
375 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
376 param_escape(id
), true);
377 xmlhttp
.onreadystatechange
=userlist_callback
;
382 function editFilter(id
) {
384 if (!xmlhttp_ready(xmlhttp
)) {
391 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" +
392 param_escape(id
), true);
393 xmlhttp
.onreadystatechange
=filterlist_callback
;
398 function editFeed(feed
) {
400 // notify("Editing feed...");
402 if (!xmlhttp_ready(xmlhttp
)) {
409 /* xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=edit&id=" +
410 param_escape(feed), true);
411 xmlhttp.onreadystatechange=feedlist_callback;
412 xmlhttp.send(null); */
414 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
415 // selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-'+feed, 'FRCHK-'+feed,
418 selectTableRowById('FEEDR-'+feed
, 'FRCHK-'+feed
, true);
420 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
421 param_escape(active_feed
), true);
423 xmlhttp
.onreadystatechange
=infobox_callback
;
428 function editFeedCat(cat
) {
430 if (!xmlhttp_ready(xmlhttp
)) {
435 active_feed_cat
= cat
;
437 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCat&id=" +
438 param_escape(cat
), true);
439 xmlhttp
.onreadystatechange
=feedlist_callback
;
444 function getSelectedLabels() {
445 return getSelectedTableRowIds("prefLabelList", "LILRR");
448 function getSelectedUsers() {
449 return getSelectedTableRowIds("prefUserList", "UMRR");
452 function getSelectedFeeds() {
453 return getSelectedTableRowIds("prefFeedList", "FEEDR");
456 function getSelectedFilters() {
457 return getSelectedTableRowIds("prefFilterList", "FILRR");
460 function getSelectedFeedCats() {
461 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
464 function getSelectedFeedsFromBrowser() {
466 var list
= document
.getElementById("browseFeedList");
467 if (!list
) list
= document
.getElementById("browseBigFeedList");
469 var selected
= new Array();
471 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
472 var child
= list
.childNodes
[i
];
473 if (child
.id
&& child
.id
.match("FBROW-")) {
474 var id
= child
.id
.replace("FBROW-", "");
476 var cb
= document
.getElementById("FBCHK-" + id
);
488 /*function readSelectedFeeds(read) {
490 if (!xmlhttp_ready(xmlhttp)) {
495 var sel_rows = getSelectedFeeds();
497 if (sel_rows.length > 0) {
505 notify("Marking selected feeds as " + op + "...");
507 xmlhttp.open("GET", "backend.php?op=pref-rpc&subop=" + op + "&ids="+
508 param_escape(sel_rows.toString()), true);
509 xmlhttp.onreadystatechange=notify_callback;
514 alert("No feeds are selected.");
519 function removeSelectedLabels() {
521 if (!xmlhttp_ready(xmlhttp
)) {
526 var sel_rows
= getSelectedLabels();
528 if (sel_rows
.length
> 0) {
530 var ok
= confirm("Remove selected labels?");
533 notify("Removing selected labels...");
535 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
536 param_escape(sel_rows
.toString()), true);
537 xmlhttp
.onreadystatechange
=labellist_callback
;
541 alert("No labels are selected.");
545 function removeSelectedUsers() {
547 if (!xmlhttp_ready(xmlhttp
)) {
552 var sel_rows
= getSelectedUsers();
554 if (sel_rows
.length
> 0) {
556 var ok
= confirm("Remove selected users?");
559 notify("Removing selected users...");
561 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
562 param_escape(sel_rows
.toString()), true);
563 xmlhttp
.onreadystatechange
=userlist_callback
;
568 alert("No users are selected.");
572 function removeSelectedFilters() {
574 if (!xmlhttp_ready(xmlhttp
)) {
579 var sel_rows
= getSelectedFilters();
581 if (sel_rows
.length
> 0) {
583 var ok
= confirm("Remove selected filters?");
586 notify("Removing selected filters...");
588 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
589 param_escape(sel_rows
.toString()), true);
590 xmlhttp
.onreadystatechange
=filterlist_callback
;
594 alert("No filters are selected.");
599 function removeSelectedFeeds() {
601 if (!xmlhttp_ready(xmlhttp
)) {
606 var sel_rows
= getSelectedFeeds();
608 if (sel_rows
.length
> 0) {
610 var ok
= confirm("Unsubscribe from selected feeds?");
614 notify("Unsubscribing from selected feeds...");
616 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
617 param_escape(sel_rows
.toString()), true);
618 xmlhttp
.onreadystatechange
=feedlist_callback
;
624 alert("No feeds are selected.");
630 function removeSelectedFeedCats() {
632 if (!xmlhttp_ready(xmlhttp
)) {
637 var sel_rows
= getSelectedFeedCats();
639 if (sel_rows
.length
> 0) {
641 var ok
= confirm("Remove selected categories?");
644 notify("Removing selected categories...");
646 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=removeCats&ids="+
647 param_escape(sel_rows
.toString()), true);
648 xmlhttp
.onreadystatechange
=feedlist_callback
;
654 alert("No categories are selected.");
660 function feedEditCancel() {
662 if (!xmlhttp_ready(xmlhttp
)) {
671 // notify("Operation cancelled.");
673 /* xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
674 xmlhttp.onreadystatechange=feedlist_callback;
675 xmlhttp.send(null); */
679 function feedCatEditCancel() {
681 if (!xmlhttp_ready(xmlhttp
)) {
686 active_feed_cat
= false;
688 // notify("Operation cancelled.");
690 xmlhttp
.open("GET", "backend.php?op=pref-feeds", true);
691 xmlhttp
.onreadystatechange
=feedlist_callback
;
696 function feedEditSave() {
700 var feed
= active_feed
;
702 if (!xmlhttp_ready(xmlhttp
)) {
707 var link
= document
.getElementById("iedit_link").value
;
708 var title
= document
.getElementById("iedit_title").value
;
709 var upd_intl
= document
.getElementById("iedit_updintl");
711 upd_intl
= upd_intl
[upd_intl
.selectedIndex
].id
;
713 var purge_intl
= document
.getElementById("iedit_purgintl");
715 purge_intl
= purge_intl
[purge_intl
.selectedIndex
].id
;
717 var fcat
= document
.getElementById("iedit_fcat");
719 var is_pvt
= document
.getElementById("iedit_private");
720 var is_rtl
= document
.getElementById("iedit_rtl");
723 is_pvt
= is_pvt
.checked
;
727 is_rtl
= is_rtl
.checked
;
733 fcat_id
= fcat
[fcat
.selectedIndex
].id
;
736 var pfeed
= document
.getElementById("iedit_parent_feed");
737 var parent_feed_id
= pfeed
[pfeed
.selectedIndex
].id
;
739 if (link
.length
== 0) {
740 notify("Feed link cannot be blank.");
744 if (title
.length
== 0) {
745 notify("Feed title cannot be blank.");
749 if (!isValidURL(link
)) {
750 alert("Feed URL is invalid.");
754 var auth_login
= document
.getElementById("iedit_login").value
;
755 var auth_pass
= document
.getElementById("iedit_pass").value
;
759 notify("Saving feed...");
761 var query
= "op=pref-feeds&subop=editSave&id=" +
762 feed
+ "&l=" + param_escape(link
) + "&t=" + param_escape(title
) +
763 "&ui=" + param_escape(upd_intl
) + "&pi=" + param_escape(purge_intl
) +
764 "&catid=" + param_escape(fcat_id
) + "&login=" + param_escape(auth_login
) +
765 "&pfeed=" + param_escape(parent_feed_id
) + "&pass=" + param_escape(auth_pass
) +
766 "&is_pvt=" + param_escape(is_pvt
) + "&is_rtl=" + param_escape(is_rtl
);
768 xmlhttp
.open("POST", "backend.php", true);
769 xmlhttp
.onreadystatechange
=feedlist_callback
;
770 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
774 exception_error("feedEditSave", e
);
778 function feedCatEditSave() {
780 if (!xmlhttp_ready(xmlhttp
)) {
785 notify("Saving category...");
787 var cat_title
= document
.getElementById("iedit_title").value
;
789 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=saveCat&id=" +
790 param_escape(active_feed_cat
) + "&title=" + param_escape(cat_title
),
792 xmlhttp
.onreadystatechange
=feedlist_callback
;
795 active_feed_cat
= false;
800 function labelTest() {
802 var sqlexp
= document
.getElementById("iedit_expr").value
;
803 var descr
= document
.getElementById("iedit_descr").value
;
805 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
806 param_escape(sqlexp
) + "&descr=" + param_escape(descr
), true);
808 xmlhttp
.onreadystatechange
=infobox_callback
;
813 function displayHelpInfobox(topic_id
) {
815 xmlhttp
.open("GET", "backend.php?op=help&tid=" +
816 param_escape(topic_id
) + "&noheaders=1", true);
818 xmlhttp
.onreadystatechange
=infobox_callback
;
823 function labelEditCancel() {
825 if (!xmlhttp_ready(xmlhttp
)) {
830 active_label
= false;
832 // notify("Operation cancelled.");
834 xmlhttp
.open("GET", "backend.php?op=pref-labels", true);
835 xmlhttp
.onreadystatechange
=labellist_callback
;
840 function userEditCancel() {
842 if (!xmlhttp_ready(xmlhttp
)) {
849 // notify("Operation cancelled.");
851 xmlhttp
.open("GET", "backend.php?op=pref-users", true);
852 xmlhttp
.onreadystatechange
=userlist_callback
;
857 function filterEditCancel() {
859 if (!xmlhttp_ready(xmlhttp
)) {
864 active_filter
= false;
866 // notify("Operation cancelled.");
868 xmlhttp
.open("GET", "backend.php?op=pref-filters", true);
869 xmlhttp
.onreadystatechange
=filterlist_callback
;
874 function labelEditSave() {
876 var label
= active_label
;
878 if (!xmlhttp_ready(xmlhttp
)) {
883 var sqlexp
= document
.getElementById("iedit_expr").value
;
884 var descr
= document
.getElementById("iedit_descr").value
;
886 // notify("Saving label " + sqlexp + ": " + descr);
888 if (sqlexp
.length
== 0) {
889 notify("SQL expression cannot be blank.");
893 if (descr
.length
== 0) {
894 notify("Caption cannot be blank.");
898 notify("Saving label...");
900 active_label
= false;
902 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=editSave&id=" +
903 label
+ "&s=" + param_escape(sqlexp
) + "&d=" + param_escape(descr
),
906 xmlhttp
.onreadystatechange
=labellist_callback
;
911 function userEditSave() {
913 var user
= active_user
;
915 if (!xmlhttp_ready(xmlhttp
)) {
920 var login
= document
.getElementById("iedit_ulogin").value
;
921 var level
= document
.getElementById("iedit_ulevel");
923 level
= level
[level
.selectedIndex
].id
;
925 var email
= document
.getElementById("iedit_email").value
;
927 if (login
.length
== 0) {
928 notify("Login cannot be blank.");
932 if (level
.length
== 0) {
933 notify("User level cannot be blank.");
939 notify("Saving user...");
941 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=editSave&id=" +
942 user
+ "&l=" + param_escape(login
) + "&al=" + param_escape(level
) +
943 "&e=" + param_escape(email
), true);
945 xmlhttp
.onreadystatechange
=userlist_callback
;
951 function filterEditSave() {
953 var filter
= active_filter
;
955 if (!xmlhttp_ready(xmlhttp
)) {
960 var regexp
= document
.getElementById("iedit_regexp").value
;
961 var match
= document
.getElementById("iedit_match");
963 var v_match
= match
[match
.selectedIndex
].text
;
965 var feed
= document
.getElementById("iedit_feed");
966 var feed_id
= feed
[feed
.selectedIndex
].id
;
968 var action
= document
.getElementById("iedit_filter_action");
969 var action_id
= action
[action
.selectedIndex
].id
;
971 if (regexp
.length
== 0) {
972 alert("Can't save filter: match expression is blank.");
976 active_filter
= false;
978 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=editSave&id=" +
979 filter
+ "&r=" + param_escape(regexp
) + "&m=" + param_escape(v_match
) +
980 "&fid=" + param_escape(feed_id
) + "&aid=" + param_escape(action_id
), true);
982 notify("Saving filter...");
984 xmlhttp
.onreadystatechange
=filterlist_callback
;
989 function editSelectedLabel() {
990 var rows
= getSelectedLabels();
992 if (rows
.length
== 0) {
993 alert("No labels are selected.");
997 if (rows
.length
> 1) {
998 alert("Please select only one label.");
1008 function editSelectedUser() {
1009 var rows
= getSelectedUsers();
1011 if (rows
.length
== 0) {
1012 alert("No users are selected.");
1016 if (rows
.length
> 1) {
1017 alert("Please select only one user.");
1026 function resetSelectedUserPass() {
1027 var rows
= getSelectedUsers();
1029 if (rows
.length
== 0) {
1030 alert("No users are selected.");
1034 if (rows
.length
> 1) {
1035 alert("Please select only one user.");
1039 var ok
= confirm("Reset password of selected user?");
1042 notify("Resetting password for selected user...");
1046 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
1047 param_escape(id
), true);
1048 xmlhttp
.onreadystatechange
=userlist_callback
;
1053 function selectedUserDetails() {
1055 if (!xmlhttp_ready(xmlhttp
)) {
1056 printLockingError();
1060 var rows
= getSelectedUsers();
1062 if (rows
.length
== 0) {
1063 alert("No users are selected.");
1067 if (rows
.length
> 1) {
1068 alert("Please select only one user.");
1076 xmlhttp
.open("GET", "backend.php?op=user-details&id=" + id
, true);
1077 xmlhttp
.onreadystatechange
=infobox_callback
;
1082 function selectedFeedDetails() {
1084 if (!xmlhttp_ready(xmlhttp
)) {
1085 printLockingError();
1089 var rows
= getSelectedFeeds();
1091 if (rows
.length
== 0) {
1092 alert("No feeds are selected.");
1096 if (rows
.length
> 1) {
1097 notify("Please select only one feed.");
1101 // var id = rows[0];
1105 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
1106 param_escape(rows
.toString()), true);
1107 xmlhttp
.onreadystatechange
=infobox_callback
;
1112 function editSelectedFilter() {
1113 var rows
= getSelectedFilters();
1115 if (rows
.length
== 0) {
1116 alert("No filters are selected.");
1120 if (rows
.length
> 1) {
1121 alert("Please select only one filter.");
1127 editFilter(rows
[0]);
1132 function editSelectedFeed() {
1133 var rows
= getSelectedFeeds();
1135 if (rows
.length
== 0) {
1136 notify("No feeds are selected.");
1140 if (rows
.length
> 1) {
1141 notify("Please select one feed.");
1151 function editSelectedFeedCat() {
1152 var rows
= getSelectedFeedCats();
1154 if (rows
.length
== 0) {
1155 alert("No categories are selected.");
1159 if (rows
.length
> 1) {
1160 alert("Please select only one category.");
1166 editFeedCat(rows
[0]);
1170 function piggie_callback() {
1171 var piggie
= document
.getElementById("piggie");
1173 piggie
.style
.top
= piggie_top
;
1174 piggie
.style
.backgroundColor
= "white";
1175 piggie
.style
.borderWidth
= "1px";
1177 if (piggie_fwd
&& piggie_top
< 0) {
1178 setTimeout("piggie_callback()", 50);
1179 piggie_top
= piggie_top
+ 10;
1180 } else if (piggie_fwd
&& piggie_top
>= 0) {
1182 setTimeout("piggie_callback()", 50);
1183 } else if (!piggie_fwd
&& piggie_top
> -400) {
1184 setTimeout("piggie_callback()", 50);
1185 piggie_top
= piggie_top
- 10;
1186 } else if (!piggie_fwd
&& piggie_top
<= -400) {
1187 piggie
.style
.display
= "none";
1192 var piggie_opacity
= 0;
1194 function piggie2_callback() {
1195 var piggie
= document
.getElementById("piggie");
1196 piggie
.style
.top
= 0;
1197 piggie
.style
.opacity
= piggie_opacity
;
1198 piggie
.style
.backgroundColor
= "transparent";
1199 piggie
.style
.borderWidth
= "0px";
1201 if (piggie_fwd
&& piggie_opacity
< 1) {
1202 setTimeout("piggie2_callback()", 50);
1203 piggie_opacity
= piggie_opacity
+ 0.03;
1204 } else if (piggie_fwd
&& piggie_opacity
>= 1) {
1206 setTimeout("piggie2_callback()", 50);
1207 } else if (!piggie_fwd
&& piggie_opacity
> 0) {
1208 setTimeout("piggie2_callback()", 50);
1209 piggie_opacity
= piggie_opacity
- 0.03;
1210 } else if (!piggie_fwd
&& piggie_opacity
<= 0) {
1211 piggie
.style
.display
= "none";
1216 function localPiggieFunction(enable
) {
1218 var piggie
= document
.getElementById("piggie");
1219 piggie
.style
.display
= "block";
1221 if (navigator
.userAgent
.match("Gecko") && Math
.random(1) > 0.5) {
1229 function validateOpmlImport() {
1231 var opml_file
= document
.getElementById("opml_file");
1233 if (opml_file
.value
.length
== 0) {
1234 alert("No OPML file to upload.");
1241 function updateFilterList() {
1243 if (!xmlhttp_ready(xmlhttp
)) {
1244 printLockingError();
1248 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1250 // p_notify("Loading, please wait...");
1252 xmlhttp
.open("GET", "backend.php?op=pref-filters", true);
1253 xmlhttp
.onreadystatechange
=filterlist_callback
;
1258 function updateLabelList() {
1260 if (!xmlhttp_ready(xmlhttp
)) {
1261 printLockingError();
1265 // p_notify("Loading, please wait...");
1267 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1269 xmlhttp
.open("GET", "backend.php?op=pref-labels", true);
1270 xmlhttp
.onreadystatechange
=labellist_callback
;
1274 function updatePrefsList() {
1276 if (!xmlhttp_ready(xmlhttp
)) {
1277 printLockingError();
1281 // p_notify("Loading, please wait...");
1283 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1284 xmlhttp
.onreadystatechange
=prefslist_callback
;
1289 function selectTab(id
, noupdate
) {
1293 if (!xmlhttp_ready(xmlhttp
)) {
1294 printLockingError();
1300 if (id
== "feedConfig") {
1302 } else if (id
== "filterConfig") {
1304 } else if (id
== "labelConfig") {
1306 } else if (id
== "genConfig") {
1308 } else if (id
== "userConfig") {
1310 } else if (id
== "feedBrowser") {
1311 updateBigFeedBrowser();
1315 var tab
= document
.getElementById(active_tab
+ "Tab");
1318 if (tab
.className
.match("Selected")) {
1319 tab
.className
= "prefsTab";
1323 tab
= document
.getElementById(id
+ "Tab");
1326 if (!tab
.className
.match("Selected")) {
1327 tab
.className
= tab
.className
+ "Selected";
1333 setCookie('ttrss_pref_acttab', active_tab
);
1341 if (arguments
.callee
.done
) return;
1342 arguments
.callee
.done
= true;
1346 document
.getElementById("prefContent").innerHTML
=
1347 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1348 "to function properly. Your browser doesn't seem to support it.";
1352 active_tab
= getCookie("ttrss_pref_acttab");
1353 if (!active_tab
) active_tab
= "genConfig";
1354 selectTab(active_tab
);
1356 document
.onkeydown
= hotkey_handler
;
1359 exception_error("init", e
);
1363 function categorizeSelectedFeeds() {
1365 if (!xmlhttp_ready(xmlhttp
)) {
1366 printLockingError();
1370 var sel_rows
= getSelectedFeeds();
1372 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1373 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].id
;
1375 if (sel_rows
.length
> 0) {
1377 notify("Changing category of selected feeds...");
1379 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1380 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1381 xmlhttp
.onreadystatechange
=feedlist_callback
;
1386 alert("No feeds are selected.");
1392 function validatePrefsReset() {
1393 return confirm("Reset to defaults?");
1396 function browseFeeds(limit
) {
1398 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1399 xmlhttp
.onreadystatechange
=infobox_callback
;
1404 function feedBrowserSubscribe() {
1407 var selected
= getSelectedFeedsFromBrowser();
1409 if (selected
.length
> 0) {
1411 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1412 param_escape(selected
.toString()), true);
1413 xmlhttp
.onreadystatechange
=feedlist_callback
;
1416 alert("No feeds are selected.");
1420 exception_error("feedBrowserSubscribe", e
);
1424 function updateBigFeedBrowser(limit
) {
1426 if (!xmlhttp_ready(xmlhttp
)) {
1427 printLockingError();
1431 // p_notify("Loading, please wait...");
1433 var query
= "backend.php?op=pref-feed-browser";
1435 var limit_sel
= document
.getElementById("feedBrowserLimit");
1438 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1439 query
= query
+ "&limit=" + param_escape(limit
);
1442 xmlhttp
.open("GET", query
, true);
1443 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1447 function browserToggleExpand(id
) {
1449 /* if (feed_to_expand && feed_to_expand != id) {
1450 var d = document.getElementById("BRDET-" + feed_to_expand);
1451 d.style.display = "none";
1454 var d
= document
.getElementById("BRDET-" + id
);
1456 if (d
.style
.display
== "block") {
1457 d
.style
.display
= "none";
1461 feed_to_expand
= id
;
1463 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1464 + param_escape(id
), true);
1465 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1470 exception_error("browserExpand", e
);
1474 function validateNewPassword(form
) {
1475 if (form
.OLD_PASSWORD
.value
== "") {
1476 alert("Current password cannot be blank");
1479 if (form
.NEW_PASSWORD
.value
== "") {
1480 alert("New password cannot be blank");
1486 function selectPrefRows(kind
, select
) {
1489 var opbarid
= false;
1494 if (kind
== "feed") {
1495 opbarid
= "feedOpToolbar";
1498 lname
= "prefFeedList";
1499 } else if (kind
== "fcat") {
1500 opbarid
= "catOpToolbar";
1503 lname
= "prefFeedCatList";
1504 } else if (kind
== "filter") {
1505 opbarid
= "filterOpToolbar";
1508 lname
= "prefFilterList";
1509 } else if (kind
== "label") {
1510 opbarid
= "labelOpToolbar";
1513 lname
= "prefLabelList";
1514 } else if (kind
== "user") {
1515 opbarid
= "userOpToolbar";
1518 lname
= "prefUserList";
1522 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1523 disableContainerChildren(opbarid
, !select
);
1530 function toggleSelectPrefRow(sender
, kind
) {
1532 toggleSelectRow(sender
);
1535 var opbarid
= false;
1538 if (kind
== "feed") {
1539 opbarid
= "feedOpToolbar";
1540 nsel
= getSelectedFeeds();
1541 } else if (kind
== "fcat") {
1542 opbarid
= "catOpToolbar";
1543 nsel
= getSelectedFeedCats();
1544 } else if (kind
== "filter") {
1545 opbarid
= "filterOpToolbar";
1546 nsel
= getSelectedFilters();
1547 } else if (kind
== "label") {
1548 opbarid
= "labelOpToolbar";
1549 nsel
= getSelectedLabels();
1550 } else if (kind
== "user") {
1551 opbarid
= "userOpToolbar";
1552 nsel
= getSelectedUsers();
1555 if (opbarid
&& nsel
!= -1) {
1556 disableContainerChildren(opbarid
, nsel
== false);
1562 function toggleSelectFBListRow(sender
) {
1563 toggleSelectListRow(sender
);
1564 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);