]> git.wh0rd.org - tt-rss.git/blame - prefs.js
remove h1 from feed browser
[tt-rss.git] / prefs.js
CommitLineData
007bda35
AD
1var xmlhttp = false;
2
961513a3 3var active_feed = false;
91ff844a 4var active_feed_cat = false;
a0d53889 5var active_filter = false;
48f0adb0 6var active_label = false;
e6cb77a0 7var active_user = false;
f5a50b25 8var active_tab = false;
c6232e43 9var feed_to_expand = false;
f5a50b25 10
007bda35
AD
11/*@cc_on @*/
12/*@if (@_jscript_version >= 5)
13// JScript gives us Conditional compilation, we can cope with old IE versions.
14// and security blocked creation of the objects.
15try {
16 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
17} catch (e) {
18 try {
19 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
20 } catch (E) {
21 xmlhttp = false;
22 }
23}
24@end @*/
25
26if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
27 xmlhttp = new XMLHttpRequest();
28}
29
c6232e43
AD
30function expand_feed_callback() {
31 if (xmlhttp.readyState == 4) {
32 try {
33 var container = document.getElementById("BRDET-" + feed_to_expand);
34 container.innerHTML=xmlhttp.responseText;
35 container.style.display = "block";
36 p_notify("");
37 } catch (e) {
38 exception_error("expand_feed_callback", e);
39 }
40 }
41}
42
007bda35 43function feedlist_callback() {
007bda35 44 if (xmlhttp.readyState == 4) {
47c6c988
AD
45 try {
46 var container = document.getElementById('prefContent');
47 container.innerHTML=xmlhttp.responseText;
48 if (active_feed) {
49 var row = document.getElementById("FEEDR-" + active_feed);
50 if (row) {
51 if (!row.className.match("Selected")) {
52 row.className = row.className + "Selected";
53 }
54 }
55 var checkbox = document.getElementById("FRCHK-" + active_feed);
56 if (checkbox) {
57 checkbox.checked = true;
58 }
961513a3 59 }
47c6c988
AD
60 p_notify("");
61 } catch (e) {
62 exception_error("feedlist_callback", e);
961513a3 63 }
007bda35
AD
64 }
65}
66
a0d53889 67function filterlist_callback() {
f5a50b25 68 var container = document.getElementById('prefContent');
a0d53889 69 if (xmlhttp.readyState == 4) {
f5a50b25 70
a0d53889
AD
71 container.innerHTML=xmlhttp.responseText;
72
73 if (active_filter) {
74 var row = document.getElementById("FILRR-" + active_filter);
75 if (row) {
76 if (!row.className.match("Selected")) {
77 row.className = row.className + "Selected";
78 }
79 }
80 var checkbox = document.getElementById("FICHK-" + active_filter);
81
82 if (checkbox) {
83 checkbox.checked = true;
84 }
85 }
f5a50b25 86 p_notify("");
a0d53889
AD
87 }
88}
89
48f0adb0 90function labellist_callback() {
f5a50b25 91 var container = document.getElementById('prefContent');
48f0adb0
AD
92 if (xmlhttp.readyState == 4) {
93 container.innerHTML=xmlhttp.responseText;
94
967955b7 95 if (active_label) {
48f0adb0
AD
96 var row = document.getElementById("LILRR-" + active_label);
97 if (row) {
98 if (!row.className.match("Selected")) {
99 row.className = row.className + "Selected";
100 }
101 }
102 var checkbox = document.getElementById("LICHK-" + active_label);
103
104 if (checkbox) {
105 checkbox.checked = true;
106 }
107 }
f5a50b25 108 p_notify("");
48f0adb0
AD
109 }
110}
4255b24c 111
c6232e43
AD
112function feed_browser_callback() {
113 var container = document.getElementById('prefContent');
114 if (xmlhttp.readyState == 4) {
115 container.innerHTML=xmlhttp.responseText;
116 p_notify("");
117 }
118}
119
e6cb77a0
AD
120function userlist_callback() {
121 var container = document.getElementById('prefContent');
122 if (xmlhttp.readyState == 4) {
123 container.innerHTML=xmlhttp.responseText;
124
1a7572cb
AD
125 if (active_user) {
126 var row = document.getElementById("UMRR-" + active_user);
e6cb77a0
AD
127 if (row) {
128 if (!row.className.match("Selected")) {
129 row.className = row.className + "Selected";
130 }
131 }
1a7572cb 132 var checkbox = document.getElementById("UMCHK-" + active_user);
e6cb77a0
AD
133
134 if (checkbox) {
135 checkbox.checked = true;
136 }
1a7572cb
AD
137 }
138
e6cb77a0
AD
139 p_notify("");
140 }
141}
142
c6c3a07f 143function infobox_callback() {
1a7572cb 144 if (xmlhttp.readyState == 4) {
2317ffaa
AD
145 var box = document.getElementById('infoBox');
146 var shadow = document.getElementById('infoBoxShadow');
147
148 if (box) {
149 box.innerHTML=xmlhttp.responseText;
150 if (shadow) {
151 shadow.style.display = "block";
152 } else {
5e9188f2 153 box.style.display = "block";
2317ffaa 154 }
c6c3a07f 155 }
1a7572cb
AD
156 }
157}
158
159
4255b24c
AD
160function prefslist_callback() {
161 var container = document.getElementById('prefContent');
162 if (xmlhttp.readyState == 4) {
163
164 container.innerHTML=xmlhttp.responseText;
165
166 p_notify("");
167 }
168}
169
b1895692
AD
170function gethelp_callback() {
171 var container = document.getElementById('prefHelpBox');
172 if (xmlhttp.readyState == 4) {
173
174 container.innerHTML = xmlhttp.responseText;
175 container.style.display = "block";
176
177 }
178}
4255b24c
AD
179
180
0e091d38
AD
181function notify_callback() {
182 var container = document.getElementById('notify');
183 if (xmlhttp.readyState == 4) {
184 container.innerHTML=xmlhttp.responseText;
185 }
186}
187
b83c7545 188function updateFeedList(sort_key) {
007bda35 189
c0e5a40e 190 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
191 printLockingError();
192 return
193 }
194
f5a50b25
AD
195// document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
196
197 p_notify("Loading, please wait...");
007bda35 198
f932bc9f
AD
199 var feed_search = document.getElementById("feed_search");
200 var search = "";
201 if (feed_search) { search = feed_search.value; }
202
b83c7545 203 xmlhttp.open("GET", "backend.php?op=pref-feeds" +
f932bc9f
AD
204 "&sort=" + param_escape(sort_key) +
205 "&search=" + param_escape(search), true);
007bda35
AD
206 xmlhttp.onreadystatechange=feedlist_callback;
207 xmlhttp.send(null);
208
209}
210
e6cb77a0
AD
211function updateUsersList() {
212
213 if (!xmlhttp_ready(xmlhttp)) {
214 printLockingError();
215 return
216 }
217
218// document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
219
220 p_notify("Loading, please wait...");
221
222 xmlhttp.open("GET", "backend.php?op=pref-users", true);
223 xmlhttp.onreadystatechange=userlist_callback;
224 xmlhttp.send(null);
225
226}
227
48f0adb0
AD
228function addLabel() {
229
230 if (!xmlhttp_ready(xmlhttp)) {
231 printLockingError();
232 return
233 }
234
235 var sqlexp = document.getElementById("ladd_expr");
236
237 if (sqlexp.value.length == 0) {
238 notify("Missing SQL expression.");
239 } else {
240 notify("Adding label...");
241
242 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=add&exp=" +
243 param_escape(sqlexp.value), true);
244
245 xmlhttp.onreadystatechange=labellist_callback;
246 xmlhttp.send(null);
247
248 sqlexp.value = "";
249 }
250
251}
252
de435974
AD
253function addFilter() {
254
255 if (!xmlhttp_ready(xmlhttp)) {
256 printLockingError();
257 return
258 }
259
260 var regexp = document.getElementById("fadd_regexp");
261 var match = document.getElementById("fadd_match");
ead60402 262 var feed = document.getElementById("fadd_feed");
19c9cb11 263 var action = document.getElementById("fadd_action");
de435974
AD
264
265 if (regexp.value.length == 0) {
266 notify("Missing filter expression.");
267 } else {
268 notify("Adding filter...");
269
25cb5736 270 var v_match = match[match.selectedIndex].text;
ead60402 271 var feed_id = feed[feed.selectedIndex].id;
19c9cb11 272 var action_id = action[action.selectedIndex].id;
ead60402 273
de435974 274 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=add&regexp=" +
ead60402 275 param_escape(regexp.value) + "&match=" + v_match +
19c9cb11 276 "&fid=" + param_escape(feed_id) + "&aid=" + param_escape(action_id), true);
de435974
AD
277
278 xmlhttp.onreadystatechange=filterlist_callback;
279 xmlhttp.send(null);
280
281 regexp.value = "";
282 }
283
284}
48f0adb0 285
71ad3959
AD
286function addFeed() {
287
c0e5a40e 288 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
289 printLockingError();
290 return
291 }
292
331900c6
AD
293 var link = document.getElementById("fadd_link");
294
83fe4d6d 295 if (link.value.length == 0) {
c753cd32 296 notify("Missing feed URL.");
331900c6
AD
297 } else {
298 notify("Adding feed...");
299
300 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=add&link=" +
301 param_escape(link.value), true);
302 xmlhttp.onreadystatechange=feedlist_callback;
303 xmlhttp.send(null);
304
305 link.value = "";
306
307 }
308
309}
310
91ff844a
AD
311function addFeedCat() {
312
313 if (!xmlhttp_ready(xmlhttp)) {
314 printLockingError();
315 return
316 }
317
318 var cat = document.getElementById("fadd_cat");
319
320 if (cat.value.length == 0) {
321 notify("Missing feed category.");
322 } else {
323 notify("Adding feed category...");
324
325 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=addCat&cat=" +
326 param_escape(cat.value), true);
327 xmlhttp.onreadystatechange=feedlist_callback;
328 xmlhttp.send(null);
329
330 link.value = "";
331
332 }
333
334}
e6cb77a0
AD
335function addUser() {
336
337 if (!xmlhttp_ready(xmlhttp)) {
338 printLockingError();
339 return
340 }
341
342 var sqlexp = document.getElementById("uadd_box");
343
344 if (sqlexp.value.length == 0) {
345 notify("Missing user login.");
346 } else {
347 notify("Adding user...");
348
349 xmlhttp.open("GET", "backend.php?op=pref-users&subop=add&login=" +
350 param_escape(sqlexp.value), true);
351
352 xmlhttp.onreadystatechange=userlist_callback;
353 xmlhttp.send(null);
354
355 sqlexp.value = "";
356 }
357
358}
359
48f0adb0
AD
360function editLabel(id) {
361
362 if (!xmlhttp_ready(xmlhttp)) {
363 printLockingError();
364 return
365 }
366
367 active_label = id;
368
369 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
370 param_escape(id), true);
371 xmlhttp.onreadystatechange=labellist_callback;
372 xmlhttp.send(null);
373
374}
375
e6cb77a0
AD
376function editUser(id) {
377
378 if (!xmlhttp_ready(xmlhttp)) {
379 printLockingError();
380 return
381 }
382
383 active_user = id;
384
385 xmlhttp.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
386 param_escape(id), true);
387 xmlhttp.onreadystatechange=userlist_callback;
388 xmlhttp.send(null);
389
390}
391
a0d53889
AD
392function editFilter(id) {
393
394 if (!xmlhttp_ready(xmlhttp)) {
395 printLockingError();
396 return
397 }
398
399 active_filter = id;
400
401 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=edit&id=" +
402 param_escape(id), true);
403 xmlhttp.onreadystatechange=filterlist_callback;
404 xmlhttp.send(null);
405
406}
407
331900c6
AD
408function editFeed(feed) {
409
508a81e1
AD
410// notify("Editing feed...");
411
c0e5a40e 412 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
413 printLockingError();
414 return
415 }
331900c6 416
961513a3
AD
417 active_feed = feed;
418
0ea4fb50 419/* xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=edit&id=" +
331900c6
AD
420 param_escape(feed), true);
421 xmlhttp.onreadystatechange=feedlist_callback;
0ea4fb50
AD
422 xmlhttp.send(null); */
423
424 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
6c12c809
AD
425// selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-'+feed, 'FRCHK-'+feed,
426// true, false);
427
428 selectTableRowById('FEEDR-'+feed, 'FRCHK-'+feed, true);
0ea4fb50
AD
429
430 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
431 param_escape(active_feed), true);
432
433 xmlhttp.onreadystatechange=infobox_callback;
331900c6
AD
434 xmlhttp.send(null);
435
436}
437
91ff844a 438function editFeedCat(cat) {
48f0adb0 439
91ff844a
AD
440 if (!xmlhttp_ready(xmlhttp)) {
441 printLockingError();
442 return
48f0adb0
AD
443 }
444
91ff844a 445 active_feed_cat = cat;
e6cb77a0 446
91ff844a
AD
447 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCat&id=" +
448 param_escape(cat), true);
449 xmlhttp.onreadystatechange=feedlist_callback;
450 xmlhttp.send(null);
e6cb77a0 451
e6cb77a0
AD
452}
453
91ff844a
AD
454function getSelectedLabels() {
455 return getSelectedTableRowIds("prefLabelList", "LILRR");
456}
48f0adb0 457
91ff844a
AD
458function getSelectedUsers() {
459 return getSelectedTableRowIds("prefUserList", "UMRR");
a0d53889
AD
460}
461
83fe4d6d 462function getSelectedFeeds() {
91ff844a
AD
463 return getSelectedTableRowIds("prefFeedList", "FEEDR");
464}
331900c6 465
91ff844a
AD
466function getSelectedFilters() {
467 return getSelectedTableRowIds("prefFilterList", "FILRR");
468}
331900c6 469
91ff844a
AD
470function getSelectedFeedCats() {
471 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
83fe4d6d
AD
472}
473
91ff844a 474
4f3a84f4 475function readSelectedFeeds(read) {
83fe4d6d 476
c0e5a40e 477 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
478 printLockingError();
479 return
480 }
481
83fe4d6d
AD
482 var sel_rows = getSelectedFeeds();
483
484 if (sel_rows.length > 0) {
485
4f3a84f4
AD
486 if (!read) {
487 op = "unread";
488 } else {
489 op = "read";
490 }
83fe4d6d 491
4f3a84f4 492 notify("Marking selected feeds as " + op + "...");
83fe4d6d 493
4f3a84f4 494 xmlhttp.open("GET", "backend.php?op=pref-rpc&subop=" + op + "&ids="+
83fe4d6d 495 param_escape(sel_rows.toString()), true);
0e091d38 496 xmlhttp.onreadystatechange=notify_callback;
83fe4d6d
AD
497 xmlhttp.send(null);
498
499 } else {
500
c753cd32 501 notify("Please select some feeds first.");
83fe4d6d
AD
502
503 }
504}
505
48f0adb0
AD
506function removeSelectedLabels() {
507
508 if (!xmlhttp_ready(xmlhttp)) {
509 printLockingError();
510 return
511 }
512
513 var sel_rows = getSelectedLabels();
514
515 if (sel_rows.length > 0) {
516
69668465 517 var ok = confirm("Remove selected labels?");
48f0adb0 518
69668465
AD
519 if (ok) {
520 notify("Removing selected labels...");
521
522 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
523 param_escape(sel_rows.toString()), true);
524 xmlhttp.onreadystatechange=labellist_callback;
525 xmlhttp.send(null);
526 }
48f0adb0
AD
527 } else {
528 notify("Please select some labels first.");
529 }
530}
531
e6cb77a0
AD
532function removeSelectedUsers() {
533
534 if (!xmlhttp_ready(xmlhttp)) {
535 printLockingError();
536 return
537 }
538
539 var sel_rows = getSelectedUsers();
540
541 if (sel_rows.length > 0) {
542
69668465 543 var ok = confirm("Remove selected users?");
e6cb77a0 544
69668465
AD
545 if (ok) {
546 notify("Removing selected users...");
547
548 xmlhttp.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
549 param_escape(sel_rows.toString()), true);
550 xmlhttp.onreadystatechange=userlist_callback;
551 xmlhttp.send(null);
552 }
e6cb77a0
AD
553
554 } else {
555 notify("Please select some labels first.");
556 }
557}
558
48f0adb0
AD
559function removeSelectedFilters() {
560
561 if (!xmlhttp_ready(xmlhttp)) {
562 printLockingError();
563 return
564 }
565
566 var sel_rows = getSelectedFilters();
567
568 if (sel_rows.length > 0) {
569
69668465 570 var ok = confirm("Remove selected filters?");
48f0adb0 571
69668465
AD
572 if (ok) {
573 notify("Removing selected filters...");
574
575 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
576 param_escape(sel_rows.toString()), true);
577 xmlhttp.onreadystatechange=filterlist_callback;
578 xmlhttp.send(null);
579 }
48f0adb0
AD
580 } else {
581 notify("Please select some filters first.");
582 }
583}
584
585
83fe4d6d
AD
586function removeSelectedFeeds() {
587
c0e5a40e 588 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
589 printLockingError();
590 return
591 }
592
83fe4d6d
AD
593 var sel_rows = getSelectedFeeds();
594
331900c6
AD
595 if (sel_rows.length > 0) {
596
69668465 597 var ok = confirm("Remove selected feeds?");
331900c6 598
69668465
AD
599 if (ok) {
600
601 notify("Removing selected feeds...");
602
603 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
604 param_escape(sel_rows.toString()), true);
605 xmlhttp.onreadystatechange=feedlist_callback;
606 xmlhttp.send(null);
607 }
71ad3959 608
71ad3959 609 } else {
331900c6 610
c753cd32 611 notify("Please select some feeds first.");
331900c6 612
71ad3959
AD
613 }
614
615}
007bda35 616
91ff844a
AD
617function removeSelectedFeedCats() {
618
619 if (!xmlhttp_ready(xmlhttp)) {
620 printLockingError();
621 return
622 }
623
624 var sel_rows = getSelectedFeedCats();
625
626 if (sel_rows.length > 0) {
627
69668465 628 var ok = confirm("Remove selected categories?");
91ff844a 629
69668465
AD
630 if (ok) {
631 notify("Removing selected categories...");
632
633 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=removeCats&ids="+
634 param_escape(sel_rows.toString()), true);
635 xmlhttp.onreadystatechange=feedlist_callback;
636 xmlhttp.send(null);
637 }
91ff844a
AD
638
639 } else {
640
641 notify("Please select some feeds first.");
642
643 }
644
645}
646
508a81e1
AD
647function feedEditCancel() {
648
c0e5a40e 649 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
650 printLockingError();
651 return
652 }
653
327a3bbe
AD
654 closeInfoBox();
655
961513a3
AD
656 active_feed = false;
657
508a81e1
AD
658 notify("Operation cancelled.");
659
327a3bbe 660/* xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
508a81e1 661 xmlhttp.onreadystatechange=feedlist_callback;
327a3bbe 662 xmlhttp.send(null); */
508a81e1
AD
663
664}
665
91ff844a
AD
666function feedCatEditCancel() {
667
668 if (!xmlhttp_ready(xmlhttp)) {
669 printLockingError();
670 return
671 }
672
673 active_feed_cat = false;
674
675 notify("Operation cancelled.");
676
677 xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
678 xmlhttp.onreadystatechange=feedlist_callback;
679 xmlhttp.send(null);
680
681}
682
603c27f8
AD
683function feedEditSave() {
684
47c6c988 685 try {
d148926e 686
47c6c988
AD
687 var feed = active_feed;
688
689 if (!xmlhttp_ready(xmlhttp)) {
690 printLockingError();
691 return
692 }
693
694 var link = document.getElementById("iedit_link").value;
695 var title = document.getElementById("iedit_title").value;
696 var upd_intl = document.getElementById("iedit_updintl").value;
697 var purge_intl = document.getElementById("iedit_purgintl").value;
698 var fcat = document.getElementById("iedit_fcat");
e3c99f3b
AD
699
700 var private = document.getElementById("iedit_private").checked;
47c6c988 701
48fa05ad
AD
702 var fcat_id = 0;
703
704 if (fcat) {
705 fcat_id = fcat[fcat.selectedIndex].id;
706 }
1da7e457
AD
707
708 var pfeed = document.getElementById("iedit_parent_feed");
709 var parent_feed_id = pfeed[pfeed.selectedIndex].id;
47c6c988
AD
710
711 if (link.length == 0) {
712 notify("Feed link cannot be blank.");
713 return;
714 }
715
716 if (title.length == 0) {
717 notify("Feed title cannot be blank.");
718 return;
719 }
720
721 var auth_login = document.getElementById("iedit_login").value;
722 var auth_pass = document.getElementById("iedit_pass").value;
723
724 active_feed = false;
725
726 notify("Saving feed...");
d148926e 727
47c6c988
AD
728 var query = "op=pref-feeds&subop=editSave&id=" +
729 feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) +
730 "&ui=" + param_escape(upd_intl) + "&pi=" + param_escape(purge_intl) +
e3c99f3b
AD
731 "&catid=" + param_escape(fcat_id) + "&login=" + param_escape(auth_login) +
732 "&pfeed=" + param_escape(parent_feed_id) + "&pass=" + param_escape(auth_pass) +
733 "&private=" + param_escape(private);
508a81e1 734
47c6c988
AD
735 xmlhttp.open("POST", "backend.php", true);
736 xmlhttp.onreadystatechange=feedlist_callback;
737 xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
738 xmlhttp.send(query);
739
740 } catch (e) {
741 exception_error("feedEditSave", e);
508a81e1 742 }
508a81e1
AD
743}
744
5ddadb4c
AD
745function feedCatEditSave() {
746
747 if (!xmlhttp_ready(xmlhttp)) {
748 printLockingError();
749 return
750 }
751
f0e81ffe 752 notify("Saving category...");
5ddadb4c
AD
753
754 var cat_title = document.getElementById("iedit_title").value;
755
756 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=saveCat&id=" +
757 param_escape(active_feed_cat) + "&title=" + param_escape(cat_title),
758 true);
759 xmlhttp.onreadystatechange=feedlist_callback;
760 xmlhttp.send(null);
761
762 active_feed_cat = false;
763
764}
765
766
d9dde1d6
AD
767function labelTest() {
768
769 var sqlexp = document.getElementById("iedit_expr").value;
770 var descr = document.getElementById("iedit_descr").value;
771
772 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
773 param_escape(sqlexp) + "&descr=" + param_escape(descr), true);
774
775 xmlhttp.onreadystatechange=infobox_callback;
776 xmlhttp.send(null);
777
778}
779
01c9c74a
AD
780function displayHelpInfobox(topic_id) {
781
782 xmlhttp.open("GET", "backend.php?op=help&tid=" +
783 param_escape(topic_id) + "&noheaders=1", true);
784
785 xmlhttp.onreadystatechange=infobox_callback;
786 xmlhttp.send(null);
787
788}
789
48f0adb0
AD
790function labelEditCancel() {
791
792 if (!xmlhttp_ready(xmlhttp)) {
793 printLockingError();
794 return
795 }
796
797 active_label = false;
798
799 notify("Operation cancelled.");
800
801 xmlhttp.open("GET", "backend.php?op=pref-labels", true);
802 xmlhttp.onreadystatechange=labellist_callback;
803 xmlhttp.send(null);
804
805}
806
e6cb77a0
AD
807function userEditCancel() {
808
809 if (!xmlhttp_ready(xmlhttp)) {
810 printLockingError();
811 return
812 }
813
814 active_user = false;
815
816 notify("Operation cancelled.");
817
818 xmlhttp.open("GET", "backend.php?op=pref-users", true);
819 xmlhttp.onreadystatechange=userlist_callback;
820 xmlhttp.send(null);
821
822}
48f0adb0 823
a0d53889
AD
824function filterEditCancel() {
825
826 if (!xmlhttp_ready(xmlhttp)) {
827 printLockingError();
828 return
829 }
830
831 active_filter = false;
832
833 notify("Operation cancelled.");
834
835 xmlhttp.open("GET", "backend.php?op=pref-filters", true);
836 xmlhttp.onreadystatechange=filterlist_callback;
837 xmlhttp.send(null);
838
839}
840
48f0adb0
AD
841function labelEditSave() {
842
843 var label = active_label;
844
845 if (!xmlhttp_ready(xmlhttp)) {
846 printLockingError();
847 return
848 }
849
850 var sqlexp = document.getElementById("iedit_expr").value;
851 var descr = document.getElementById("iedit_descr").value;
852
853// notify("Saving label " + sqlexp + ": " + descr);
854
855 if (sqlexp.length == 0) {
856 notify("SQL expression cannot be blank.");
857 return;
858 }
859
860 if (descr.length == 0) {
861 notify("Caption cannot be blank.");
862 return;
863 }
864
f0e81ffe 865 notify("Saving label...");
dbd9e2f1 866
48f0adb0
AD
867 active_label = false;
868
869 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=editSave&id=" +
870 label + "&s=" + param_escape(sqlexp) + "&d=" + param_escape(descr),
871 true);
872
873 xmlhttp.onreadystatechange=labellist_callback;
874 xmlhttp.send(null);
875
876}
877
e6cb77a0
AD
878function userEditSave() {
879
880 var user = active_user;
881
882 if (!xmlhttp_ready(xmlhttp)) {
883 printLockingError();
884 return
885 }
886
887 var login = document.getElementById("iedit_ulogin").value;
888 var level = document.getElementById("iedit_ulevel").value;
72932a75 889 var email = document.getElementById("iedit_email").value;
e6cb77a0
AD
890
891 if (login.length == 0) {
892 notify("Login cannot be blank.");
893 return;
894 }
895
896 if (level.length == 0) {
897 notify("User level cannot be blank.");
898 return;
899 }
900
901 active_user = false;
902
f0e81ffe 903 notify("Saving user...");
dbd9e2f1 904
e6cb77a0 905 xmlhttp.open("GET", "backend.php?op=pref-users&subop=editSave&id=" +
72932a75
AD
906 user + "&l=" + param_escape(login) + "&al=" + param_escape(level) +
907 "&e=" + param_escape(email), true);
e6cb77a0 908
dbd9e2f1 909 xmlhttp.onreadystatechange=userlist_callback;
e6cb77a0
AD
910 xmlhttp.send(null);
911
912}
913
914
a0d53889
AD
915function filterEditSave() {
916
917 var filter = active_filter;
918
919 if (!xmlhttp_ready(xmlhttp)) {
920 printLockingError();
921 return
922 }
923
924 var regexp = document.getElementById("iedit_regexp").value;
925 var descr = document.getElementById("iedit_descr").value;
25cb5736 926 var match = document.getElementById("iedit_match");
19c9cb11 927
25cb5736 928 var v_match = match[match.selectedIndex].text;
a0d53889 929
ead60402
AD
930 var feed = document.getElementById("iedit_feed");
931 var feed_id = feed[feed.selectedIndex].id;
932
19c9cb11
AD
933 var action = document.getElementById("iedit_filter_action");
934 var action_id = action[action.selectedIndex].id;
935
a0d53889
AD
936// notify("Saving filter " + filter + ": " + regexp + ", " + descr + ", " + match);
937
938 if (regexp.length == 0) {
939 notify("Filter expression cannot be blank.");
940 return;
941 }
942
943 active_filter = false;
944
945 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=editSave&id=" +
946 filter + "&r=" + param_escape(regexp) + "&d=" + param_escape(descr) +
19c9cb11
AD
947 "&m=" + param_escape(v_match) + "&fid=" + param_escape(feed_id) +
948 "&aid=" + param_escape(action_id), true);
dbd9e2f1 949
f0e81ffe 950 notify("Saving filter...");
dbd9e2f1 951
a0d53889
AD
952 xmlhttp.onreadystatechange=filterlist_callback;
953 xmlhttp.send(null);
954
955}
956
48f0adb0
AD
957function editSelectedLabel() {
958 var rows = getSelectedLabels();
a0d53889 959
48f0adb0
AD
960 if (rows.length == 0) {
961 notify("No labels are selected.");
962 return;
a0d53889
AD
963 }
964
48f0adb0
AD
965 if (rows.length > 1) {
966 notify("Please select one label.");
967 return;
968 }
a0d53889 969
dbd9e2f1
AD
970 notify("");
971
48f0adb0 972 editLabel(rows[0]);
a0d53889 973
a0d53889
AD
974}
975
e6cb77a0
AD
976function editSelectedUser() {
977 var rows = getSelectedUsers();
978
979 if (rows.length == 0) {
980 notify("No users are selected.");
981 return;
982 }
983
984 if (rows.length > 1) {
985 notify("Please select one user.");
986 return;
987 }
988
dbd9e2f1
AD
989 notify("");
990
e6cb77a0
AD
991 editUser(rows[0]);
992}
993
994function resetSelectedUserPass() {
995 var rows = getSelectedUsers();
996
997 if (rows.length == 0) {
998 notify("No users are selected.");
999 return;
1000 }
1001
1002 if (rows.length > 1) {
1003 notify("Please select one user.");
1004 return;
1005 }
1006
69668465 1007 var ok = confirm("Reset password of selected user?");
e6cb77a0 1008
69668465
AD
1009 if (ok) {
1010 notify("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 }
e6cb77a0
AD
1019}
1020
717f5e64 1021function selectedUserDetails() {
e6cb77a0 1022
1a7572cb
AD
1023 if (!xmlhttp_ready(xmlhttp)) {
1024 printLockingError();
1025 return
1026 }
1027
717f5e64
AD
1028 var rows = getSelectedUsers();
1029
1030 if (rows.length == 0) {
1031 notify("No users are selected.");
1032 return;
1033 }
1034
1035 if (rows.length > 1) {
1036 notify("Please select one user.");
1037 return;
1038 }
1039
1040 var id = rows[0];
1041
dbd9e2f1
AD
1042 notify("");
1043
1a7572cb 1044 xmlhttp.open("GET", "backend.php?op=user-details&id=" + id, true);
c6c3a07f
AD
1045 xmlhttp.onreadystatechange=infobox_callback;
1046 xmlhttp.send(null);
1047
1048}
1049
1050function selectedFeedDetails() {
1051
1052 if (!xmlhttp_ready(xmlhttp)) {
1053 printLockingError();
1054 return
1055 }
1056
1057 var rows = getSelectedFeeds();
1058
1059 if (rows.length == 0) {
1060 notify("No feeds are selected.");
1061 return;
1062 }
1063
df268d47
AD
1064// if (rows.length > 1) {
1065// notify("Please select one feed.");
1066// return;
1067// }
c6c3a07f 1068
df268d47 1069// var id = rows[0];
c6c3a07f 1070
dbd9e2f1
AD
1071 notify("");
1072
df268d47
AD
1073 xmlhttp.open("GET", "backend.php?op=feed-details&id=" +
1074 param_escape(rows.toString()), true);
c6c3a07f 1075 xmlhttp.onreadystatechange=infobox_callback;
1a7572cb 1076 xmlhttp.send(null);
717f5e64
AD
1077
1078}
a0d53889
AD
1079
1080function editSelectedFilter() {
1081 var rows = getSelectedFilters();
1082
1083 if (rows.length == 0) {
1084 notify("No filters are selected.");
1085 return;
1086 }
1087
1088 if (rows.length > 1) {
1089 notify("Please select one filter.");
1090 return;
1091 }
1092
dbd9e2f1
AD
1093 notify("");
1094
a0d53889
AD
1095 editFilter(rows[0]);
1096
1097}
1098
1099
508a81e1
AD
1100function editSelectedFeed() {
1101 var rows = getSelectedFeeds();
1102
1103 if (rows.length == 0) {
1104 notify("No feeds are selected.");
1105 return;
1106 }
1107
1108 if (rows.length > 1) {
1109 notify("Please select one feed.");
1110 return;
1111 }
1112
dbd9e2f1
AD
1113 notify("");
1114
508a81e1 1115 editFeed(rows[0]);
91ff844a
AD
1116
1117}
1118
1119function editSelectedFeedCat() {
1120 var rows = getSelectedFeedCats();
1121
1122 if (rows.length == 0) {
1123 notify("No categories are selected.");
1124 return;
1125 }
1126
1127 if (rows.length > 1) {
1128 notify("Please select one category.");
1129 return;
1130 }
1131
1132 notify("");
1133
1134 editFeedCat(rows[0]);
508a81e1
AD
1135
1136}
1137
13ad9102
AD
1138function localPiggieFunction(enable) {
1139 if (enable) {
508a81e1
AD
1140 piggie.style.display = "block";
1141 seq = "";
1142 notify("I loveded it!!!");
1143 } else {
1144 piggie.style.display = "none";
1145 notify("");
1146 }
508a81e1
AD
1147}
1148
9f311df6
AD
1149function validateOpmlImport() {
1150
1151 var opml_file = document.getElementById("opml_file");
1152
1153 if (opml_file.value.length == 0) {
1154 notify("Please select OPML file to upload.");
1155 return false;
1156 } else {
1157 return true;
1158 }
1159}
1160
a0d53889
AD
1161function updateFilterList() {
1162
1163 if (!xmlhttp_ready(xmlhttp)) {
1164 printLockingError();
1165 return
1166 }
1167
f5a50b25
AD
1168// document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1169
1170 p_notify("Loading, please wait...");
a0d53889
AD
1171
1172 xmlhttp.open("GET", "backend.php?op=pref-filters", true);
1173 xmlhttp.onreadystatechange=filterlist_callback;
1174 xmlhttp.send(null);
1175
1176}
1177
48f0adb0
AD
1178function updateLabelList() {
1179
1180 if (!xmlhttp_ready(xmlhttp)) {
1181 printLockingError();
1182 return
1183 }
1184
f5a50b25
AD
1185 p_notify("Loading, please wait...");
1186
1187// document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
48f0adb0
AD
1188
1189 xmlhttp.open("GET", "backend.php?op=pref-labels", true);
1190 xmlhttp.onreadystatechange=labellist_callback;
1191 xmlhttp.send(null);
48f0adb0
AD
1192}
1193
4255b24c
AD
1194function updatePrefsList() {
1195
1196 if (!xmlhttp_ready(xmlhttp)) {
1197 printLockingError();
1198 return
1199 }
1200
1201 p_notify("Loading, please wait...");
1202
1203 xmlhttp.open("GET", "backend.php?op=pref-prefs", true);
1204 xmlhttp.onreadystatechange=prefslist_callback;
1205 xmlhttp.send(null);
1206
1207}
1208
f5a50b25 1209function selectTab(id) {
48f0adb0 1210
c6c3a07f
AD
1211 if (!xmlhttp_ready(xmlhttp)) {
1212 printLockingError();
1213 return
1214 }
1215
f5a50b25 1216 if (id == "feedConfig") {
a0d53889 1217 updateFeedList();
f5a50b25 1218 } else if (id == "filterConfig") {
a0d53889 1219 updateFilterList();
f5a50b25 1220 } else if (id == "labelConfig") {
48f0adb0 1221 updateLabelList();
4255b24c
AD
1222 } else if (id == "genConfig") {
1223 updatePrefsList();
e6cb77a0
AD
1224 } else if (id == "userConfig") {
1225 updateUsersList();
c6232e43
AD
1226 } else if (id == "feedBrowser") {
1227 updateBigFeedBrowser();
a0d53889 1228 }
f5a50b25
AD
1229
1230 var tab = document.getElementById(active_tab + "Tab");
1231
1232 if (tab) {
1233 if (tab.className.match("Selected")) {
1234 tab.className = "prefsTab";
1235 }
1236 }
1237
1238 tab = document.getElementById(id + "Tab");
1239
1240 if (tab) {
1241 if (!tab.className.match("Selected")) {
1242 tab.className = tab.className + "Selected";
1243 }
1244 }
1245
1246 active_tab = id;
1247
4da47970
AD
1248 setCookie('ttrss_pref_acttab', active_tab);
1249
a0d53889
AD
1250}
1251
007bda35 1252function init() {
e2ec66a8 1253
7719618b
AD
1254 try {
1255
1256 // IE kludge
1257 if (!xmlhttp) {
1258 document.getElementById("prefContent").innerHTML =
1259 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1260 "to function properly. Your browser doesn't seem to support it.";
1261 return;
1262 }
4da47970
AD
1263
1264 active_tab = getCookie("ttrss_pref_acttab");
1265 if (!active_tab) active_tab = "genConfig";
1266 selectTab(active_tab);
7719618b
AD
1267
1268 document.onkeydown = hotkey_handler;
1269 notify("");
1270 } catch (e) {
1271 exception_error("init", e);
e2ec66a8 1272 }
007bda35 1273}
b1895692 1274
c6c3a07f 1275function closeInfoBox() {
2317ffaa
AD
1276 var box = document.getElementById('infoBox');
1277 var shadow = document.getElementById('infoBoxShadow');
1278
1279 if (shadow) {
1280 shadow.style.display = "none";
1281 } else if (box) {
1282 box.style.display = "none";
1283 }
1a7572cb 1284}
f932bc9f
AD
1285
1286function categorizeSelectedFeeds() {
1287
1288 if (!xmlhttp_ready(xmlhttp)) {
1289 printLockingError();
1290 return
1291 }
1292
1293 var sel_rows = getSelectedFeeds();
1294
1295 var cat_sel = document.getElementById("sfeed_set_fcat");
1296 var cat_id = cat_sel[cat_sel.selectedIndex].id;
1297
1298 if (sel_rows.length > 0) {
1299
1300 notify("Changing category of selected feeds...");
1301
1302 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1303 param_escape(sel_rows.toString()) + "&cat_id=" + param_escape(cat_id), true);
1304 xmlhttp.onreadystatechange=feedlist_callback;
1305 xmlhttp.send(null);
1306
1307 } else {
1308
1309 notify("Please select some feeds first.");
1310
1311 }
1312
1313}
69668465
AD
1314
1315function validatePrefsReset() {
1316 return confirm("Reset to defaults?");
1317}
f9cb39ac
AD
1318
1319function browseFeeds() {
1320
1321 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1322 xmlhttp.onreadystatechange=infobox_callback;
1323 xmlhttp.send(null);
1324
1325}
a0476535
AD
1326
1327function feedBrowserSubscribe() {
1328 try {
1329 var list = document.getElementById("browseFeedList");
1330
1331 var selected = new Array();
1332
1333 for (i = 0; i < list.childNodes.length; i++) {
1334 var child = list.childNodes[i];
1335 if (child.id && child.id.match("FBROW-")) {
1336 var id = child.id.replace("FBROW-", "");
1337
1338 var cb = document.getElementById("FBCHK-" + id);
1339
1340 if (cb.checked) {
1341 selected.push(id);
1342 }
1343 }
1344 }
1345
1346 if (selected.length > 0) {
1347 closeInfoBox();
1348 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1349 param_escape(selected.toString()), true);
1350 xmlhttp.onreadystatechange=feedlist_callback;
1351 xmlhttp.send(null);
1352 } else {
1353 alert("No feeds are selected.");
1354 }
1355
1356 } catch (e) {
1357 exception_error("feedBrowserSubscribe", e);
1358 }
1359}
c6232e43
AD
1360
1361function updateBigFeedBrowser() {
1362
1363 if (!xmlhttp_ready(xmlhttp)) {
1364 printLockingError();
1365 return
1366 }
1367
1368 p_notify("Loading, please wait...");
1369
1370 xmlhttp.open("GET", "backend.php?op=pref-feed-browser", true);
1371 xmlhttp.onreadystatechange=feed_browser_callback;
1372 xmlhttp.send(null);
1373
1374}
1375
1376function browserExpand(id) {
1377 try {
1378/* if (feed_to_expand && feed_to_expand != id) {
1379 var d = document.getElementById("BRDET-" + feed_to_expand);
1380 d.style.display = "none";
1381 } */
1382
1383 feed_to_expand = id;
1384
1385 xmlhttp.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1386 + param_escape(id), true);
1387 xmlhttp.onreadystatechange=expand_feed_callback;
1388 xmlhttp.send(null);
1389
1390 } catch (e) {
1391 exception_error("browserExpand", e);
1392 }
1393}