]> git.wh0rd.org Git - tt-rss.git/blob - prefs.js
set utf-8 as default charset just in case
[tt-rss.git] / prefs.js
1 var xmlhttp = false;
2
3 var active_feed_cat = false;
4 var active_label = false;
5 var active_tab = false;
6 var feed_to_expand = false;
7
8 var xmlhttp = Ajax.getTransport();
9
10 var init_params = new Array();
11
12 var caller_subop = false;
13
14 var sanity_check_done = false;
15
16 function replace_pubkey_callback() {
17         if (xmlhttp.readyState == 4) {
18                 try {   
19                         var link = document.getElementById("pubGenAddress");
20
21                         if (xmlhttp.responseXML) {
22
23                                 var new_link = xmlhttp.responseXML.getElementsByTagName("link")[0];
24
25                                 if (new_link) {
26                                         link.href = new_link.firstChild.nodeValue;
27                                         link.innerHTML = new_link.firstChild.nodeValue;
28
29                                         new Effect.Highlight(link);
30
31                                         notify_info("Address changed.");
32                                 } else {
33                                         notify_error("Could not change address.");
34                                 }
35
36                         } else {
37                                 notify_error("Could not change address.");
38                         }
39                 } catch (e) {
40                         exception_error("replace_pubkey_callback", e);
41                 }
42         }
43 }
44
45 function expand_feed_callback() {
46         if (xmlhttp.readyState == 4) {
47                 try {   
48                         var container = document.getElementById("BRDET-" + feed_to_expand);     
49                         container.innerHTML=xmlhttp.responseText;
50 //                      container.style.display = "block";
51 //                      p_notify("");
52                         Effect.Appear(container, {duration : 0.5});
53                 } catch (e) {
54                         exception_error("expand_feed_callback", e);
55                 }
56         }
57 }
58
59 function feedlist_callback() {
60         if (xmlhttp.readyState == 4) {
61                 try {   
62                         var container = document.getElementById('prefContent'); 
63                         container.innerHTML=xmlhttp.responseText;
64                         selectTab("feedConfig", true);
65
66                         if (caller_subop) {
67                                 var tuple = caller_subop.split(":");
68                                 if (tuple[0] == 'editFeed') {
69                                         window.setTimeout('editFeed('+tuple[1]+')', 100);
70                                 }                               
71
72                                 caller_subop = false;
73                         }
74                         if (typeof correctPNG != 'undefined') {
75                                 correctPNG();
76                         }
77                         notify("");
78                 } catch (e) {
79                         exception_error("feedlist_callback", e);
80                 }
81         }
82 }
83
84 /* stub for subscription dialog */
85
86 function dlg_frefresh_callback() {
87         if (xmlhttp.readyState == 4) {          
88         //      setTimeout("updateFeedList()", 500);
89
90                 try {
91                         var container = document.getElementById('prefContent'); 
92                         container.innerHTML=xmlhttp.responseText;
93                         selectTab("feedConfig", true);
94
95                         if (caller_subop) {
96                                 var tuple = caller_subop.split(":");
97                                 if (tuple[0] == 'editFeed') {
98                                         window.setTimeout('editFeed('+tuple[1]+')', 100);
99                                 }                               
100
101                                 caller_subop = false;
102                         }
103                         if (typeof correctPNG != 'undefined') {
104                                 correctPNG();
105                         }
106                         notify("");
107                 } catch (e) {
108                         exception_error("feedlist_callback", e);
109                 }
110         }
111 }
112
113 function filterlist_callback() {
114         var container = document.getElementById('prefContent');
115         if (xmlhttp.readyState == 4) {
116                 container.innerHTML=xmlhttp.responseText;
117                 if (typeof correctPNG != 'undefined') {
118                         correctPNG();
119                 }
120                 notify("");
121         }
122 }
123
124 function labellist_callback() {
125         var container = document.getElementById('prefContent');
126         if (xmlhttp.readyState == 4) {
127                 closeInfoBox();
128                 container.innerHTML=xmlhttp.responseText;
129                 if (active_label) {
130                         var row = document.getElementById("LILRR-" + active_label);
131                         if (row) {
132                                 if (!row.className.match("Selected")) {
133                                         row.className = row.className + "Selected";
134                                 }               
135                         }
136                         var checkbox = document.getElementById("LICHK-" + active_label);
137                         
138                         if (checkbox) {
139                                 checkbox.checked = true;
140                         }
141                 }
142                 if (typeof correctPNG != 'undefined') {
143                         correctPNG();
144                 }
145                 notify("");
146         }
147 }
148
149 function feed_browser_callback() {
150         var container = document.getElementById('prefContent');
151         if (xmlhttp.readyState == 4) {
152                 container.innerHTML=xmlhttp.responseText;
153                 notify("");
154         }
155 }
156
157 function userlist_callback() {
158         var container = document.getElementById('prefContent');
159         if (xmlhttp.readyState == 4) {
160                 container.innerHTML=xmlhttp.responseText;
161                 notify("");
162         }
163 }
164
165 function prefslist_callback() {
166         var container = document.getElementById('prefContent');
167         if (xmlhttp.readyState == 4) {
168
169                 container.innerHTML=xmlhttp.responseText;
170                 
171                 notify("");
172         }
173 }
174
175 function gethelp_callback() {
176         var container = document.getElementById('prefHelpBox');
177         if (xmlhttp.readyState == 4) {
178
179                 container.innerHTML = xmlhttp.responseText;
180                 container.style.display = "block";
181
182         }
183 }
184
185 function notify_callback() {
186         if (xmlhttp.readyState == 4) {
187                 notify_info(xmlhttp.responseText);
188         } 
189 }
190
191 function prefs_reset_callback() {
192         if (xmlhttp.readyState == 4) {
193                 notify_info(xmlhttp.responseText);
194                 selectTab();
195         } 
196 }
197
198
199 function changepass_callback() {
200         try {
201                 if (xmlhttp.readyState == 4) {
202         
203                         if (xmlhttp.responseText.indexOf("ERROR: ") == 0) {
204                                 notify_error(xmlhttp.responseText.replace("ERROR: ", ""));
205                         } else {
206                                 notify_info(xmlhttp.responseText);
207                                 var warn = document.getElementById("default_pass_warning");
208                                 if (warn) warn.style.display = "none";
209                         }
210         
211                         document.forms['change_pass_form'].reset();
212
213                 } 
214         } catch (e) {
215                 exception_error("changepass_callback", e);
216         }
217 }
218
219 function infobox_feed_cat_callback() {
220         if (xmlhttp.readyState == 4) {
221                 try {
222
223                         infobox_callback();
224
225                         if (document.getElementById("prefFeedCatList")) {
226                                 var elems = document.getElementById("prefFeedCatList").getElementsByTagName("SPAN");
227
228                                 for (var i = 0; i < elems.length; i++) {
229                                         if (elems[i].id && elems[i].id.match("FCATT-")) {
230                                                 var cat_id = elems[i].id.replace("FCATT-", "");
231
232                                                 new Ajax.InPlaceEditor(elems[i],
233                                                         'backend.php?op=pref-feeds&subop=editCats&action=save&cid=' + cat_id);
234                                         }
235                                 }
236                         }
237
238                 } catch (e) {
239                         exception_error("infobox_feed_cat_callback", e);
240                 }
241         }
242 }
243
244 function updateFeedList(sort_key) {
245
246         if (!xmlhttp_ready(xmlhttp)) {
247                 printLockingError();
248                 return
249         }
250
251 //      document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
252
253 //      p_notify("Loading, please wait...");
254
255         var feed_search = document.getElementById("feed_search");
256         var search = "";
257         if (feed_search) { search = feed_search.value; }
258
259         var slat = document.getElementById("show_last_article_times");
260
261         var slat_checked = false;
262         if (slat) {
263                 slat_checked = slat.checked;
264         }
265
266         xmlhttp.open("GET", "backend.php?op=pref-feeds" +
267                 "&sort=" + param_escape(sort_key) + 
268                 "&slat=" + param_escape(slat_checked) +
269                 "&search=" + param_escape(search), true);
270         xmlhttp.onreadystatechange=feedlist_callback;
271         xmlhttp.send(null);
272
273 }
274
275 function updateUsersList(sort_key) {
276
277         if (!xmlhttp_ready(xmlhttp)) {
278                 printLockingError();
279                 return
280         }
281
282 //      document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
283
284 //      p_notify("Loading, please wait...");
285
286         xmlhttp.open("GET", "backend.php?op=pref-users&sort="
287                 + param_escape(sort_key), true);
288         xmlhttp.onreadystatechange=userlist_callback;
289         xmlhttp.send(null);
290
291 }
292
293 function addLabel() {
294
295         if (!xmlhttp_ready(xmlhttp)) {
296                 printLockingError();
297                 return
298         }
299
300         var form = document.forms['label_edit_form'];
301
302         var sql_exp = form.sql_exp.value;
303         var description = form.description.value;
304
305         if (sql_exp == "") {
306                 alert(__("Can't create label: missing SQL expression."));
307                 return false;
308         }
309
310         if (description == "") {
311                 alert(__("Can't create label: missing caption."));
312                 return false;
313         }
314
315         var query = Form.serialize("label_edit_form");
316
317         xmlhttp.open("GET", "backend.php?op=pref-labels&subop=add&" + query, true);                     
318         xmlhttp.onreadystatechange=infobox_submit_callback;
319         xmlhttp.send(null);
320 }
321
322 function addFeed() {
323
324         if (!xmlhttp_ready(xmlhttp)) {
325                 printLockingError();
326                 return
327         }
328
329         var link = document.getElementById("fadd_link");
330
331         if (link.value.length == 0) {
332                 alert(__("Error: No feed URL given."));
333         } else if (!isValidURL(link.value)) {
334                 alert(__("Error: Invalid feed URL."));
335         } else {
336                 notify_progress("Adding feed...");
337
338                 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=add&from=tt-rss&feed_url=" +
339                         param_escape(link.value), true);
340                 xmlhttp.onreadystatechange=feedlist_callback;
341                 xmlhttp.send(null);
342
343                 link.value = "";
344
345         }
346
347 }
348
349 function addFeedCat() {
350
351         if (!xmlhttp_ready(xmlhttp)) {
352                 printLockingError();
353                 return
354         }
355
356         var cat = document.getElementById("fadd_cat");
357
358         if (cat.value.length == 0) {
359                 alert(__("Can't add category: no name specified."));
360         } else {
361                 notify_progress("Adding feed category...");
362
363                 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" +
364                         param_escape(cat.value), true);
365                 xmlhttp.onreadystatechange=infobox_callback;
366                 xmlhttp.send(null);
367
368                 link.value = "";
369
370         }
371
372 }
373 function addUser() {
374
375         if (!xmlhttp_ready(xmlhttp)) {
376                 printLockingError();
377                 return
378         }
379
380         var sqlexp = document.getElementById("uadd_box");
381
382         if (sqlexp.value.length == 0) {
383                 alert(__("Can't add user: no login specified."));
384         } else {
385                 notify_progress("Adding user...");
386
387                 xmlhttp.open("GET", "backend.php?op=pref-users&subop=add&login=" +
388                         param_escape(sqlexp.value), true);                      
389                         
390                 xmlhttp.onreadystatechange=userlist_callback;
391                 xmlhttp.send(null);
392
393                 sqlexp.value = "";
394         }
395
396 }
397
398 function editLabel(id) {
399
400         if (!xmlhttp_ready(xmlhttp)) {
401                 printLockingError();
402                 return
403         }
404
405         notify_progress("Loading, please wait...");
406
407         document.getElementById("label_create_btn").disabled = true;
408
409         active_label = id;
410
411         selectTableRowsByIdPrefix('prefLabelList', 'LILRR-', 'LICHK-', false);
412         selectTableRowById('LILRR-'+id, 'LICHK-'+id, true);
413
414         xmlhttp.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
415                 param_escape(id), true);
416         xmlhttp.onreadystatechange=infobox_callback;
417         xmlhttp.send(null);
418
419 }
420
421 function editUser(id) {
422
423         if (!xmlhttp_ready(xmlhttp)) {
424                 printLockingError();
425                 return
426         }
427
428         notify_progress("Loading, please wait...");
429
430         selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false);
431         selectTableRowById('UMRR-'+id, 'UMCHK-'+id, true);
432
433         xmlhttp.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
434                 param_escape(id), true);
435         xmlhttp.onreadystatechange=infobox_callback;
436         xmlhttp.send(null);
437
438 }
439
440 function editFilter(id) {
441
442         if (!xmlhttp_ready(xmlhttp)) {
443                 printLockingError();
444                 return
445         }
446
447         notify_progress("Loading, please wait...");
448
449         document.getElementById("create_filter_btn").disabled = true;
450
451         selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
452         selectTableRowById('FILRR-'+id, 'FICHK-'+id, true);
453
454         xmlhttp.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id), true);
455         xmlhttp.onreadystatechange=infobox_callback;
456         xmlhttp.send(null);
457 }
458
459 function editFeed(feed) {
460
461 //      notify("Editing feed...");
462
463         if (!xmlhttp_ready(xmlhttp)) {
464                 printLockingError();
465                 return
466         }
467
468         notify_progress("Loading, please wait...");
469
470         document.getElementById("subscribe_to_feed_btn").disabled = true;
471
472         try {
473                 document.getElementById("top25_feeds_btn").disabled = true;
474         } catch (e) {
475                 // this button is not always available, no-op if not found
476         }
477
478         // clean selection from all rows & select row being edited
479         selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
480         selectTableRowById('FEEDR-'+feed, 'FRCHK-'+feed, true);
481
482         xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
483                 param_escape(feed), true);
484
485         xmlhttp.onreadystatechange=infobox_callback;
486         xmlhttp.send(null);
487
488 }
489
490 function editFeedCat(cat) {
491
492         if (!xmlhttp_ready(xmlhttp)) {
493                 printLockingError();
494                 return
495         }
496
497         notify_progress("Loading, please wait...");
498
499         active_feed_cat = cat;
500
501         xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=edit&id=" +
502                 param_escape(cat), true);
503         xmlhttp.onreadystatechange=infobox_callback;
504         xmlhttp.send(null);
505
506 }
507
508 function getSelectedLabels() {
509         return getSelectedTableRowIds("prefLabelList", "LILRR");
510 }
511
512 function getSelectedUsers() {
513         return getSelectedTableRowIds("prefUserList", "UMRR");
514 }
515
516 function getSelectedFeeds() {
517         return getSelectedTableRowIds("prefFeedList", "FEEDR");
518 }
519
520 function getSelectedFilters() {
521         return getSelectedTableRowIds("prefFilterList", "FILRR");
522 }
523
524 function getSelectedFeedCats() {
525         return getSelectedTableRowIds("prefFeedCatList", "FCATR");
526 }
527
528 function getSelectedFeedsFromBrowser() {
529
530         var list = document.getElementById("browseFeedList");
531         if (!list) list = document.getElementById("browseBigFeedList");
532
533         var selected = new Array();
534         
535         for (i = 0; i < list.childNodes.length; i++) {
536                 var child = list.childNodes[i];
537                 if (child.id && child.id.match("FBROW-")) {
538                         var id = child.id.replace("FBROW-", "");
539                         
540                         var cb = document.getElementById("FBCHK-" + id);
541
542                         if (cb.checked) {
543                                 selected.push(id);
544                         }
545                 }
546         }
547
548         return selected;
549 }
550
551 function removeSelectedLabels() {
552
553         if (!xmlhttp_ready(xmlhttp)) {
554                 printLockingError();
555                 return
556         }
557
558         var sel_rows = getSelectedLabels();
559
560         if (sel_rows.length > 0) {
561
562                 var ok = confirm(__("Remove selected labels?"));
563
564                 if (ok) {
565                         notify_progress("Removing selected labels...");
566         
567                         xmlhttp.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
568                                 param_escape(sel_rows.toString()), true);
569                         xmlhttp.onreadystatechange=labellist_callback;
570                         xmlhttp.send(null);
571                 }
572         } else {
573                 alert(__("No labels are selected."));
574         }
575
576         return false;
577 }
578
579 function removeSelectedUsers() {
580
581         if (!xmlhttp_ready(xmlhttp)) {
582                 printLockingError();
583                 return
584         }
585
586         var sel_rows = getSelectedUsers();
587
588         if (sel_rows.length > 0) {
589
590                 var ok = confirm(__("Remove selected users?"));
591
592                 if (ok) {
593                         notify_progress("Removing selected users...");
594         
595                         xmlhttp.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
596                                 param_escape(sel_rows.toString()), true);
597                         xmlhttp.onreadystatechange=userlist_callback;
598                         xmlhttp.send(null);
599                 }
600
601         } else {
602                 alert(__("No users are selected."));
603         }
604
605         return false;
606 }
607
608 function removeSelectedFilters() {
609
610         if (!xmlhttp_ready(xmlhttp)) {
611                 printLockingError();
612                 return
613         }
614
615         var sel_rows = getSelectedFilters();
616
617         if (sel_rows.length > 0) {
618
619                 var ok = confirm(__("Remove selected filters?"));
620
621                 if (ok) {
622                         notify_progress("Removing selected filters...");
623         
624                         xmlhttp.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
625                                 param_escape(sel_rows.toString()), true);
626                         xmlhttp.onreadystatechange=filterlist_callback;
627                         xmlhttp.send(null);
628                 }
629         } else {
630                 alert(__("No filters are selected."));
631         }
632
633         return false;
634 }
635
636
637 function removeSelectedFeeds() {
638
639         if (!xmlhttp_ready(xmlhttp)) {
640                 printLockingError();
641                 return
642         }
643
644         var sel_rows = getSelectedFeeds();
645
646         if (sel_rows.length > 0) {
647
648                 var ok = confirm(__("Unsubscribe from selected feeds?"));
649
650                 if (ok) {
651
652                         notify_progress("Unsubscribing from selected feeds...");
653         
654                         xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
655                                 param_escape(sel_rows.toString()), true);
656                         xmlhttp.onreadystatechange=feedlist_callback;
657                         xmlhttp.send(null);
658                 }
659
660         } else {
661
662                 alert(__("No feeds are selected."));
663
664         }
665         
666         return false;
667 }
668
669 function removeSelectedFeedCats() {
670
671         if (!xmlhttp_ready(xmlhttp)) {
672                 printLockingError();
673                 return
674         }
675
676         var sel_rows = getSelectedFeedCats();
677
678         if (sel_rows.length > 0) {
679
680                 var ok = confirm(__("Remove selected categories?"));
681
682                 if (ok) {
683                         notify_progress("Removing selected categories...");
684         
685                         xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+
686                                 param_escape(sel_rows.toString()), true);
687                         xmlhttp.onreadystatechange=infobox_callback;
688                         xmlhttp.send(null);
689                 }
690
691         } else {
692
693                 alert(__("No categories are selected."));
694
695         }
696
697         return false;
698 }
699
700 function feedEditCancel() {
701
702         if (!xmlhttp_ready(xmlhttp)) {
703                 printLockingError();
704                 return
705         }
706
707         document.getElementById("subscribe_to_feed_btn").disabled = false;
708
709         try {
710                 document.getElementById("top25_feeds_btn").disabled = false;
711         } catch (e) {
712                 // this button is not always available, no-op if not found
713         }
714
715         closeInfoBox();
716
717         selectPrefRows('feed', false); // cleanup feed selection
718
719         return false;
720 }
721
722 function feedCatEditCancel() {
723
724         if (!xmlhttp_ready(xmlhttp)) {
725                 printLockingError();
726                 return
727         }
728
729         active_feed_cat = false;
730
731 //      notify("Operation cancelled.");
732
733         xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
734         xmlhttp.onreadystatechange=infobox_callback;
735         xmlhttp.send(null);
736
737         return false;
738 }
739
740 function feedEditSave() {
741
742         try {
743         
744                 if (!xmlhttp_ready(xmlhttp)) {
745                         printLockingError();
746                         return
747                 }
748
749                 // FIXME: add parameter validation
750
751                 var query = Form.serialize("edit_feed_form");
752
753                 notify_progress("Saving feed...");
754
755                 xmlhttp.open("POST", "backend.php", true);
756                 xmlhttp.onreadystatechange=feedlist_callback;
757                 xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
758                 xmlhttp.send(query);
759
760                 closeInfoBox();
761
762                 return false;
763
764         } catch (e) {
765                 exception_error("feedEditSave", e);
766         } 
767 }
768
769 function feedCatEditSave() {
770
771         if (!xmlhttp_ready(xmlhttp)) {
772                 printLockingError();
773                 return
774         }
775
776         notify_progress("Saving category...");
777
778         var query = Form.serialize("feed_cat_edit_form");
779
780         xmlhttp.open("GET", "backend.php?" + query, true);
781         xmlhttp.onreadystatechange=infobox_callback;
782         xmlhttp.send(null);
783
784         active_feed_cat = false;
785
786         return false;
787 }
788
789
790
791 function displayHelpInfobox(topic_id) {
792
793 /*      if (!xmlhttp_ready(xmlhttp)) {
794                 printLockingError();
795                 return
796         }
797
798         notify_progress("Loading help...");
799
800         xmlhttp.open("GET", "backend.php?op=help&tid=" +
801                 param_escape(topic_id), true);
802
803         xmlhttp.onreadystatechange=helpbox_callback;
804         xmlhttp.send(null); */
805
806         var url = "backend.php?op=help&tid=" + param_escape(topic_id);
807
808         var w = window.open(url, "ttrss_help", 
809                 "status=0,toolbar=0,location=0,width=400,height=450,menubar=0");
810
811 }
812
813 function labelEditCancel() {
814
815         if (!xmlhttp_ready(xmlhttp)) {
816                 printLockingError();
817                 return
818         }
819
820         document.getElementById("label_create_btn").disabled = false;
821
822         active_label = false;
823
824         selectPrefRows('label', false); // cleanup feed selection
825         closeInfoBox();
826
827         return false;
828 }
829
830 function userEditCancel() {
831
832         if (!xmlhttp_ready(xmlhttp)) {
833                 printLockingError();
834                 return
835         }
836
837         selectPrefRows('user', false); // cleanup feed selection
838         closeInfoBox();
839
840         return false;
841 }
842
843 function filterEditCancel() {
844
845         if (!xmlhttp_ready(xmlhttp)) {
846                 printLockingError();
847                 return
848         }
849
850         document.getElementById("create_filter_btn").disabled = false;
851         
852         selectPrefRows('filter', false); // cleanup feed selection
853         closeInfoBox();
854
855         return false;
856 }
857
858 function labelEditSave() {
859
860         var label = active_label;
861
862         if (!xmlhttp_ready(xmlhttp)) {
863                 printLockingError();
864                 return
865         }
866
867 /*      if (!is_opera()) {
868
869                 var sql_exp = document.forms["label_edit_form"].sql_exp.value;
870                 var description = document.forms["label_edit_form"].description.value;
871         
872                 if (sql_exp.length == 0) {
873                         alert("SQL Expression cannot be blank.");
874                         return false;
875                 }
876         
877                 if (description.length == 0) {
878                         alert("Caption field cannot be blank.");
879                         return false;
880                 }
881         } */
882
883         closeInfoBox();
884
885         notify_progress("Saving label...");
886
887         active_label = false;
888
889         query = Form.serialize("label_edit_form");
890
891         xmlhttp.open("GET", "backend.php?" + query, true);              
892         xmlhttp.onreadystatechange=labellist_callback;
893         xmlhttp.send(null);
894
895         return false;
896 }
897
898 function userEditSave() {
899
900         if (!xmlhttp_ready(xmlhttp)) {
901                 printLockingError();
902                 return
903         }
904
905         var login = document.forms["user_edit_form"].login.value;
906
907         if (login.length == 0) {
908                 alert(__("Login field cannot be blank."));
909                 return;
910         }
911         
912         notify_progress("Saving user...");
913
914         closeInfoBox();
915
916         var query = Form.serialize("user_edit_form");
917         
918         xmlhttp.open("GET", "backend.php?" + query, true);                      
919         xmlhttp.onreadystatechange=userlist_callback;
920         xmlhttp.send(null);
921
922         return false;
923 }
924
925
926 function filterEditSave() {
927
928         if (!xmlhttp_ready(xmlhttp)) {
929                 printLockingError();
930                 return
931         }
932
933 /*      if (!is_opera()) {
934                 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
935         
936                 if (reg_exp.length == 0) {
937                         alert("Filter expression field cannot be blank.");
938                         return;
939                 }
940         } */
941
942         notify_progress("Saving filter...");
943
944         var query = Form.serialize("filter_edit_form");
945
946         closeInfoBox();
947
948         document.getElementById("create_filter_btn").disabled = false;
949
950         xmlhttp.open("GET", "backend.php?" + query, true);
951         xmlhttp.onreadystatechange=filterlist_callback;
952         xmlhttp.send(null);
953
954         return false;
955 }
956
957 function editSelectedLabel() {
958         var rows = getSelectedLabels();
959
960         if (rows.length == 0) {
961                 alert(__("No labels are selected."));
962                 return;
963         }
964
965         if (rows.length > 1) {
966                 alert(__("Please select only one label."));
967                 return;
968         }
969
970         notify("");
971
972         editLabel(rows[0]);
973
974 }
975
976 function editSelectedUser() {
977         var rows = getSelectedUsers();
978
979         if (rows.length == 0) {
980                 alert(__("No users are selected."));
981                 return;
982         }
983
984         if (rows.length > 1) {
985                 alert(__("Please select only one user."));
986                 return;
987         }
988
989         notify("");
990
991         editUser(rows[0]);
992 }
993
994 function resetSelectedUserPass() {
995         var rows = getSelectedUsers();
996
997         if (rows.length == 0) {
998                 alert(__("No users are selected."));
999                 return;
1000         }
1001
1002         if (rows.length > 1) {
1003                 alert(__("Please select only one user."));
1004                 return;
1005         }
1006
1007         var ok = confirm(__("Reset password of selected user?"));
1008
1009         if (ok) {
1010                 notify_progress("Resetting password for selected user...");
1011         
1012                 var id = rows[0];
1013         
1014                 xmlhttp.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
1015                         param_escape(id), true);
1016                 xmlhttp.onreadystatechange=userlist_callback;
1017                 xmlhttp.send(null);
1018         }
1019 }
1020
1021 function selectedUserDetails() {
1022
1023         if (!xmlhttp_ready(xmlhttp)) {
1024                 printLockingError();
1025                 return
1026         }
1027
1028         var rows = getSelectedUsers();
1029
1030         if (rows.length == 0) {
1031                 alert(__("No users are selected."));
1032                 return;
1033         }
1034
1035         if (rows.length > 1) {
1036                 alert(__("Please select only one user."));
1037                 return;
1038         }
1039
1040         notify_progress("Loading, please wait...");
1041
1042         var id = rows[0];
1043
1044         xmlhttp.open("GET", "backend.php?op=user-details&id=" + id, true);
1045         xmlhttp.onreadystatechange=infobox_callback;
1046         xmlhttp.send(null);
1047
1048 }
1049
1050 function selectedFeedDetails() {
1051
1052         if (!xmlhttp_ready(xmlhttp)) {
1053                 printLockingError();
1054                 return
1055         }
1056
1057         var rows = getSelectedFeeds();
1058
1059         if (rows.length == 0) {
1060                 alert(__("No feeds are selected."));
1061                 return;
1062         }
1063
1064         if (rows.length > 1) {
1065                 alert(__("Please select only one feed."));
1066                 return;
1067         }
1068
1069 //      var id = rows[0];
1070
1071         notify("");
1072
1073         xmlhttp.open("GET", "backend.php?op=feed-details&id=" + 
1074                 param_escape(rows.toString()), true);
1075         xmlhttp.onreadystatechange=infobox_callback;
1076         xmlhttp.send(null);
1077
1078 }
1079
1080 function editSelectedFilter() {
1081         var rows = getSelectedFilters();
1082
1083         if (rows.length == 0) {
1084                 alert(__("No filters are selected."));
1085                 return;
1086         }
1087
1088         if (rows.length > 1) {
1089                 alert(__("Please select only one filter."));
1090                 return;
1091         }
1092
1093         notify("");
1094
1095         editFilter(rows[0]);
1096
1097 }
1098
1099
1100 function editSelectedFeed() {
1101         var rows = getSelectedFeeds();
1102
1103         if (rows.length == 0) {
1104                 alert(__("No feeds are selected."));
1105                 return;
1106         }
1107
1108         if (rows.length > 1) {
1109                 alert(__("Please select one feed."));
1110                 return;
1111         }
1112
1113         notify("");
1114
1115         editFeed(rows[0]);
1116
1117 }
1118
1119 function editSelectedFeedCat() {
1120         var rows = getSelectedFeedCats();
1121
1122         if (rows.length == 0) {
1123                 alert(__("No categories are selected."));
1124                 return;
1125         }
1126
1127         if (rows.length > 1) {
1128                 alert(__("Please select only one category."));
1129                 return;
1130         }
1131
1132         notify("");
1133
1134         editFeedCat(rows[0]);
1135
1136 }
1137
1138 function localPiggieFunction(enable) {
1139         if (enable) {
1140                 debug("I LOVEDED IT!");
1141                 var piggie = document.getElementById("piggie");
1142
1143                 Element.show(piggie);
1144                 Position.Center(piggie);
1145                 Effect.Puff(piggie);
1146
1147         }
1148 }
1149
1150 function validateOpmlImport() {
1151         
1152         var opml_file = document.getElementById("opml_file");
1153
1154         if (opml_file.value.length == 0) {
1155                 alert(__("No OPML file to upload."));
1156                 return false;
1157         } else {
1158                 return true;
1159         }
1160 }
1161
1162 function updateFilterList(sort_key) {
1163
1164         if (!xmlhttp_ready(xmlhttp)) {
1165                 printLockingError();
1166                 return
1167         }
1168
1169 //      document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1170
1171 //      p_notify("Loading, please wait...");
1172
1173         xmlhttp.open("GET", "backend.php?op=pref-filters&sort=" + 
1174                 param_escape(sort_key), true);
1175         xmlhttp.onreadystatechange=filterlist_callback;
1176         xmlhttp.send(null);
1177
1178 }
1179
1180 function updateLabelList(sort_key) {
1181
1182         if (!xmlhttp_ready(xmlhttp)) {
1183                 printLockingError();
1184                 return
1185         }
1186
1187 //      p_notify("Loading, please wait...");
1188
1189 //      document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1190
1191         xmlhttp.open("GET", "backend.php?op=pref-labels&sort=" + 
1192                 param_escape(sort_key), true);
1193         xmlhttp.onreadystatechange=labellist_callback;
1194         xmlhttp.send(null);
1195 }
1196
1197 function updatePrefsList() {
1198
1199         if (!xmlhttp_ready(xmlhttp)) {
1200                 printLockingError();
1201                 return
1202         }
1203
1204 //      p_notify("Loading, please wait...");
1205
1206         xmlhttp.open("GET", "backend.php?op=pref-prefs", true);
1207         xmlhttp.onreadystatechange=prefslist_callback;
1208         xmlhttp.send(null);
1209
1210 }
1211
1212 function selectTab(id, noupdate, subop) {
1213
1214 //      alert(id);
1215
1216         if (!id) id = active_tab;
1217
1218         try {
1219
1220                 if (!xmlhttp_ready(xmlhttp)) {
1221                         printLockingError();
1222                         return
1223                 }
1224
1225                 try {
1226                         var c = document.getElementById('prefContent'); 
1227                         c.scrollTop = 0;
1228                 } catch (e) { };
1229
1230                 if (!noupdate) {
1231
1232                         debug("selectTab: " + id + "(NU: " + noupdate + ")");
1233         
1234                         notify_progress("Loading, please wait...");
1235         
1236                         // close active infobox if needed
1237                         closeInfoBox();
1238         
1239                         // clean up all current selections, just in case
1240                         active_feed_cat = false;
1241                         active_label = false;
1242         
1243                         if (id == "feedConfig") {
1244                                 updateFeedList();
1245                         } else if (id == "filterConfig") {
1246                                 updateFilterList();
1247                         } else if (id == "labelConfig") {
1248                                 updateLabelList();
1249                         } else if (id == "genConfig") {
1250                                 updatePrefsList();
1251                         } else if (id == "userConfig") {
1252                                 updateUsersList();
1253                         } else if (id == "feedBrowser") {
1254                                 updateBigFeedBrowser();
1255                         }
1256                 }
1257         
1258                 var tab = document.getElementById(active_tab + "Tab");
1259         
1260                 if (tab) {
1261                         if (tab.className.match("Selected")) {
1262                                 tab.className = "prefsTab";
1263                         }
1264                 }
1265         
1266                 tab = document.getElementById(id + "Tab");
1267         
1268                 if (tab) {
1269                         if (!tab.className.match("Selected")) {
1270                                 tab.className = tab.className + "Selected";
1271                         }
1272                 }
1273         
1274                 active_tab = id;
1275
1276         } catch (e) {
1277                 exception_error("selectTab", e);
1278         }
1279 }
1280
1281 function backend_sanity_check_callback() {
1282
1283         if (xmlhttp.readyState == 4) {
1284
1285                 try {
1286
1287                         if (sanity_check_done) {
1288                                 fatalError(11, "Sanity check request received twice. This can indicate "+
1289                               "presence of Firebug or some other disrupting extension. "+
1290                                         "Please disable it and try again.");
1291                                 return;
1292                         }
1293
1294                         if (!xmlhttp.responseXML) {
1295                                 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp.responseText);
1296                                 return;
1297                         }
1298         
1299                         var reply = xmlhttp.responseXML.firstChild.firstChild;
1300         
1301                         if (!reply) {
1302                                 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp.responseText);
1303                                 return;
1304                         }
1305         
1306                         var error_code = reply.getAttribute("error-code");
1307                 
1308                         if (error_code && error_code != 0) {
1309                                 return fatalError(error_code, reply.getAttribute("error-msg"));
1310                         }
1311         
1312                         debug("sanity check ok");
1313
1314                         var params = reply.nextSibling;
1315
1316                         if (params) {
1317                                 debug('reading init-params...');
1318                                 var param = params.firstChild;
1319
1320                                 while (param) {
1321                                         var k = param.getAttribute("key");
1322                                         var v = param.getAttribute("value");
1323                                         debug(k + " => " + v);
1324                                         init_params[k] = v;                                     
1325                                         param = param.nextSibling;
1326                                 }
1327                         }
1328
1329                         sanity_check_done = true;
1330
1331                         init_second_stage();
1332
1333                 } catch (e) {
1334                         exception_error("backend_sanity_check_callback", e);
1335                 }
1336         } 
1337 }
1338
1339 function init_second_stage() {
1340
1341         try {
1342                 active_tab = getInitParam("prefs_active_tab");
1343                 if (!active_tab || active_tab == '0') active_tab = "genConfig";
1344
1345                 document.onkeydown = pref_hotkey_handler;
1346
1347                 var tab = getURLParam('tab');
1348                 
1349                 caller_subop = getURLParam('subop');
1350
1351                 if (tab) {
1352                         active_tab = tab;
1353                 }
1354
1355                 if (navigator.userAgent.match("Opera")) {       
1356                         setTimeout("selectTab()", 500);
1357                 } else {
1358                         selectTab(active_tab);
1359                 }
1360                 notify("");
1361         } catch (e) {
1362                 exception_error("init_second_stage", e);
1363         }
1364 }
1365
1366 function init() {
1367
1368         try {
1369         
1370                 if (arguments.callee.done) return;
1371                 arguments.callee.done = true;           
1372
1373                 if (getURLParam('debug')) {
1374                         document.getElementById('debug_output').style.display = 'block';
1375                         debug('debug mode activated');
1376                 }
1377
1378                 // IE kludge
1379                 if (!xmlhttp) {
1380                         document.getElementById("prefContent").innerHTML = 
1381                                 "<b>Fatal error:</b> This program needs XmlHttpRequest " + 
1382                                 "to function properly. Your browser doesn't seem to support it.";
1383                         return;
1384                 }
1385
1386                 xmlhttp.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1387                 xmlhttp.onreadystatechange=backend_sanity_check_callback;
1388                 xmlhttp.send(null);
1389
1390         } catch (e) {
1391                 exception_error("init", e);
1392         }
1393 }
1394
1395 function categorizeSelectedFeeds() {
1396
1397         if (!xmlhttp_ready(xmlhttp)) {
1398                 printLockingError();
1399                 return
1400         }
1401
1402         var sel_rows = getSelectedFeeds();
1403
1404         var cat_sel = document.getElementById("sfeed_set_fcat");
1405         var cat_id = cat_sel[cat_sel.selectedIndex].value;
1406
1407         if (sel_rows.length > 0) {
1408
1409                 notify_progress("Changing category of selected feeds...");
1410
1411                 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1412                         param_escape(sel_rows.toString()) + "&cat_id=" + param_escape(cat_id), true);
1413                 xmlhttp.onreadystatechange=feedlist_callback;
1414                 xmlhttp.send(null);
1415
1416         } else {
1417
1418                 alert(__("No feeds are selected."));
1419
1420         }
1421
1422 }
1423
1424 function validatePrefsReset() {
1425         try {
1426                 var ok = confirm(__("Reset to defaults?"));
1427
1428                 if (ok) {
1429
1430                         var query = Form.serialize("pref_prefs_form");
1431                         query = query + "&subop=reset-config";
1432                         debug(query);
1433
1434                         xmlhttp.open("POST", "backend.php", true);
1435                         xmlhttp.onreadystatechange=prefs_reset_callback;
1436                         xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1437                         xmlhttp.send(query);
1438                 }
1439
1440         } catch (e) {
1441                 exception_error("validatePrefsSave", e);
1442         }
1443
1444         return false;
1445
1446 }
1447
1448 function browseFeeds(limit) {
1449
1450         xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1451         xmlhttp.onreadystatechange=infobox_callback;
1452         xmlhttp.send(null);
1453
1454 }
1455
1456 function feedBrowserSubscribe() {
1457         try {
1458
1459                 var selected = getSelectedFeedsFromBrowser();
1460
1461                 if (selected.length > 0) {
1462                         closeInfoBox();
1463                         xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1464                                 param_escape(selected.toString()), true);
1465                         xmlhttp.onreadystatechange=feedlist_callback;
1466                         xmlhttp.send(null);
1467                 } else {
1468                         alert(__("No feeds are selected."));
1469                 }
1470
1471         } catch (e) {
1472                 exception_error("feedBrowserSubscribe", e);
1473         }
1474 }
1475
1476 function updateBigFeedBrowser(limit) {
1477
1478         if (!xmlhttp_ready(xmlhttp)) {
1479                 printLockingError();
1480                 return
1481         }
1482
1483 //      p_notify("Loading, please wait...");
1484
1485         var query = "backend.php?op=pref-feed-browser";
1486
1487         var limit_sel = document.getElementById("feedBrowserLimit");
1488
1489         if (limit_sel) {
1490                 var limit = limit_sel[limit_sel.selectedIndex].value;
1491                 query = query + "&limit=" + param_escape(limit);
1492         }
1493
1494         xmlhttp.open("GET", query, true);
1495         xmlhttp.onreadystatechange=feed_browser_callback;
1496         xmlhttp.send(null);
1497 }
1498
1499 function browserToggleExpand(id) {
1500         try {
1501 /*              if (feed_to_expand && feed_to_expand != id) {
1502                         var d = document.getElementById("BRDET-" + feed_to_expand);
1503                         d.style.display = "none";
1504                 } */
1505
1506                 if (!xmlhttp_ready(xmlhttp)) {
1507                         printLockingError();
1508                         return
1509                 }
1510
1511 /*              if (feed_to_expand && id != feed_to_expand) {
1512                         Effect.Fade('BRDET-' + feed_to_expand, {duration : 0.5});
1513                 } */
1514
1515                 var d = document.getElementById("BRDET-" + id);
1516         
1517                 if (Element.visible(d)) {
1518                         Effect.Fade(d, {duration : 0.5});
1519                 } else {
1520                         feed_to_expand = id;
1521
1522                         xmlhttp.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1523                                 + param_escape(id), true);
1524                         xmlhttp.onreadystatechange=expand_feed_callback;
1525                         xmlhttp.send(null);
1526                 }
1527
1528         } catch (e) {
1529                 exception_error("browserToggleExpand", e);
1530         }
1531 }
1532
1533 function selectPrefRows(kind, select) {
1534
1535         if (kind) {
1536                 var opbarid = false;    
1537                 var nchk = false;
1538                 var nrow = false;
1539                 var lname = false;
1540
1541                 if (kind == "feed") {
1542                         opbarid = "feedOpToolbar";
1543                         nrow = "FEEDR-";
1544                         nchk = "FRCHK-";                        
1545                         lname = "prefFeedList";
1546                 } else if (kind == "fcat") {
1547                         opbarid = "catOpToolbar";
1548                         nrow = "FCATR-";
1549                         nchk = "FCCHK-";
1550                         lname = "prefFeedCatList";
1551                 } else if (kind == "filter") {
1552                         opbarid = "filterOpToolbar";
1553                         nrow = "FILRR-";
1554                         nchk = "FICHK-";
1555                         lname = "prefFilterList";
1556                 } else if (kind == "label") {
1557                         opbarid = "labelOpToolbar";
1558                         nrow = "LILRR-";
1559                         nchk = "LICHK-";
1560                         lname = "prefLabelList";
1561                 } else if (kind == "user") {
1562                         opbarid = "userOpToolbar";
1563                         nrow = "UMRR-";
1564                         nchk = "UMCHK-";
1565                         lname = "prefUserList";
1566                 }
1567
1568                 if (opbarid) {
1569                         selectTableRowsByIdPrefix(lname, nrow, nchk, select);
1570                         disableContainerChildren(opbarid, !select);
1571                 }
1572
1573         } 
1574 }
1575
1576
1577 function toggleSelectPrefRow(sender, kind) {
1578
1579         toggleSelectRow(sender);
1580
1581         if (kind) {
1582                 var opbarid = false;    
1583                 var nsel = -1;
1584                 
1585                 if (kind == "feed") {
1586                         opbarid = "feedOpToolbar";
1587                         nsel = getSelectedFeeds();
1588                 } else if (kind == "fcat") {
1589                         opbarid = "catOpToolbar";
1590                         nsel = getSelectedFeedCats();
1591                 } else if (kind == "filter") {
1592                         opbarid = "filterOpToolbar";
1593                         nsel = getSelectedFilters();
1594                 } else if (kind == "label") {
1595                         opbarid = "labelOpToolbar";
1596                         nsel = getSelectedLabels();
1597                 } else if (kind == "user") {
1598                         opbarid = "userOpToolbar";
1599                         nsel = getSelectedUsers();
1600                 }
1601
1602                 if (opbarid && nsel != -1) {
1603                         disableContainerChildren(opbarid, nsel == false);
1604                 }
1605
1606         } 
1607 }
1608
1609 function toggleSelectFBListRow(sender) {
1610         toggleSelectListRow(sender);
1611         disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1612 }
1613
1614 var seq = "";
1615
1616 function pref_hotkey_handler(e) {
1617         try {
1618
1619                 var keycode;
1620         
1621                 if (!hotkeys_enabled) return;
1622         
1623                 if (window.event) {
1624                         keycode = window.event.keyCode;
1625                 } else if (e) {
1626                         keycode = e.which;
1627                 }
1628         
1629                 if (keycode == 13 || keycode == 27) {
1630                         seq = "";
1631                 } else {
1632                         seq = seq + "" + keycode;
1633                 }
1634
1635
1636         if (document.getElementById("piggie")) {
1637         
1638                 if (seq.match("807371717369")) {
1639                         seq = "";
1640                         localPiggieFunction(true);
1641                 } else {
1642                         localPiggieFunction(false);
1643                 }
1644         }
1645
1646         } catch (e) {
1647                 exception_error("pref_hotkey_handler", e);
1648         }
1649 }
1650
1651 function userSwitch() {
1652         var chooser = document.getElementById("userSwitch");
1653         var user = chooser[chooser.selectedIndex].value;
1654         window.location = "prefs.php?swu=" + user;
1655 }
1656
1657 function editFeedCats() {
1658         if (!xmlhttp_ready(xmlhttp)) {
1659                 printLockingError();
1660                 return
1661         }
1662
1663         document.getElementById("subscribe_to_feed_btn").disabled = true;
1664
1665         try {
1666                 document.getElementById("top25_feeds_btn").disabled = true;
1667         } catch (e) {
1668                 // this button is not always available, no-op if not found
1669         }
1670
1671         xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
1672         xmlhttp.onreadystatechange=infobox_feed_cat_callback;
1673         xmlhttp.send(null);
1674 }
1675
1676 function showFeedsWithErrors() {
1677         displayDlg('feedUpdateErrors');
1678 }
1679
1680 function changeUserPassword() {
1681
1682         try {
1683
1684                 if (!xmlhttp_ready(xmlhttp)) {
1685                         printLockingError();
1686                         return false;
1687                 }
1688         
1689                 var f = document.forms["change_pass_form"];
1690
1691                 if (f) {
1692                         if (f.OLD_PASSWORD.value == "") {
1693                                 new Effect.Highlight(f.OLD_PASSWORD);
1694                                 notify_error("Old password cannot be blank.");
1695                                 return false;
1696                         }
1697
1698                         if (f.NEW_PASSWORD.value == "") {
1699                                 new Effect.Highlight(f.NEW_PASSWORD);
1700                                 notify_error("New password cannot be blank.");
1701                                 return false;
1702                         }
1703
1704                         if (f.CONFIRM_PASSWORD.value == "") {
1705                                 new Effect.Highlight(f.CONFIRM_PASSWORD);
1706                                 notify_error("Entered passwords do not match.");
1707                                 return false;
1708                         }
1709
1710                         if (f.CONFIRM_PASSWORD.value != f.NEW_PASSWORD.value) {
1711                                 new Effect.Highlight(f.CONFIRM_PASSWORD);
1712                                 new Effect.Highlight(f.NEW_PASSWORD);
1713                                 notify_error("Entered passwords do not match.");
1714                                 return false;
1715                         }
1716
1717                 }
1718
1719                 var query = Form.serialize("change_pass_form");
1720         
1721                 notify_progress("Trying to change password...");
1722         
1723                 xmlhttp.open("POST", "backend.php", true);
1724                 xmlhttp.onreadystatechange=changepass_callback;
1725                 xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1726                 xmlhttp.send(query);
1727
1728         } catch (e) {
1729                 exception_error("changeUserPassword", e);
1730         }
1731         
1732         return false;
1733 }
1734
1735 function changeUserEmail() {
1736
1737         try {
1738
1739                 if (!xmlhttp_ready(xmlhttp)) {
1740                         printLockingError();
1741                         return false;
1742                 }
1743         
1744                 var query = Form.serialize("change_email_form");
1745         
1746                 notify_progress("Trying to change e-mail...");
1747         
1748                 xmlhttp.open("POST", "backend.php", true);
1749                 xmlhttp.onreadystatechange=notify_callback;
1750                 xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1751                 xmlhttp.send(query);
1752
1753         } catch (e) {
1754                 exception_error("changeUserPassword", e);
1755         }
1756         
1757         return false;
1758
1759 }
1760
1761 function feedlistToggleSLAT() {
1762         notify_progress("Loading, please wait...");
1763         updateFeedList()
1764 }
1765
1766 function pubRegenKey() {
1767
1768         if (!xmlhttp_ready(xmlhttp)) {
1769                 printLockingError();
1770                 return false;
1771         }
1772
1773         var ok = confirm(__("Replace current publishing address with a new one?"));
1774
1775         if (ok) {
1776
1777                 notify_progress("Trying to change address...");
1778
1779                 xmlhttp.open("GET", "backend.php?op=rpc&subop=regenPubKey");
1780                 xmlhttp.onreadystatechange=replace_pubkey_callback;
1781                 xmlhttp.send(null);
1782         }
1783
1784         return false;
1785 }
1786
1787 function validatePrefsSave() {
1788         try {
1789
1790                 var ok = confirm(__("Save current configuration?"));
1791
1792                 if (ok) {
1793
1794                         var query = Form.serialize("pref_prefs_form");
1795                         query = query + "&subop=save-config";
1796                         debug(query);
1797
1798                         xmlhttp.open("POST", "backend.php", true);
1799                         xmlhttp.onreadystatechange=notify_callback;
1800                         xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1801                         xmlhttp.send(query);
1802                 }
1803
1804         } catch (e) {
1805                 exception_error("validatePrefsSave", e);
1806         }
1807
1808         return false;
1809 }