]>
Commit | Line | Data |
---|---|---|
1 | var init_params = new Array(); | |
2 | ||
3 | var hotkey_prefix = false; | |
4 | var hotkey_prefix_pressed = false; | |
5 | ||
6 | var seq = ""; | |
7 | ||
8 | function feedlist_callback2(transport) { | |
9 | try { | |
10 | dijit.byId('feedConfigTab').attr('content', transport.responseText); | |
11 | selectTab("feedConfig", true); | |
12 | notify(""); | |
13 | } catch (e) { | |
14 | exception_error("feedlist_callback2", e); | |
15 | } | |
16 | } | |
17 | ||
18 | function filterlist_callback2(transport) { | |
19 | dijit.byId('filterConfigTab').attr('content', transport.responseText); | |
20 | notify(""); | |
21 | } | |
22 | ||
23 | function labellist_callback2(transport) { | |
24 | try { | |
25 | dijit.byId('labelConfigTab').attr('content', transport.responseText); | |
26 | notify(""); | |
27 | } catch (e) { | |
28 | exception_error("labellist_callback2", e); | |
29 | } | |
30 | } | |
31 | ||
32 | function userlist_callback2(transport) { | |
33 | try { | |
34 | dijit.byId('userConfigTab').attr('content', transport.responseText); | |
35 | ||
36 | notify(""); | |
37 | } catch (e) { | |
38 | exception_error("userlist_callback2", e); | |
39 | } | |
40 | } | |
41 | ||
42 | function prefslist_callback2(transport) { | |
43 | try { | |
44 | dijit.byId('genConfigTab').attr('content', transport.responseText); | |
45 | ||
46 | notify(""); | |
47 | } catch (e) { | |
48 | exception_error("prefslist_callback2", e); | |
49 | } | |
50 | } | |
51 | ||
52 | function notify_callback2(transport) { | |
53 | notify_info(transport.responseText); | |
54 | } | |
55 | ||
56 | function updateFeedList(sort_key) { | |
57 | new Ajax.Request("backend.php", { | |
58 | parameters: "?op=pref-feeds", | |
59 | onComplete: function(transport) { | |
60 | feedlist_callback2(transport); | |
61 | } }); | |
62 | } | |
63 | ||
64 | function updateUsersList(sort_key) { | |
65 | ||
66 | try { | |
67 | ||
68 | var user_search = $("user_search"); | |
69 | var search = ""; | |
70 | if (user_search) { search = user_search.value; } | |
71 | ||
72 | var query = "?op=pref-users&sort=" | |
73 | + param_escape(sort_key) + | |
74 | "&search=" + param_escape(search); | |
75 | ||
76 | new Ajax.Request("backend.php", { | |
77 | parameters: query, | |
78 | onComplete: function(transport) { | |
79 | userlist_callback2(transport); | |
80 | } }); | |
81 | ||
82 | } catch (e) { | |
83 | exception_error("updateUsersList", e); | |
84 | } | |
85 | } | |
86 | ||
87 | function addUser() { | |
88 | ||
89 | try { | |
90 | ||
91 | var login = prompt(__("Please enter login:"), ""); | |
92 | ||
93 | if (login == null) { | |
94 | return false; | |
95 | } | |
96 | ||
97 | if (login == "") { | |
98 | alert(__("Can't create user: no login specified.")); | |
99 | return false; | |
100 | } | |
101 | ||
102 | notify_progress("Adding user..."); | |
103 | ||
104 | var query = "?op=pref-users&subop=add&login=" + | |
105 | param_escape(login); | |
106 | ||
107 | new Ajax.Request("backend.php", { | |
108 | parameters: query, | |
109 | onComplete: function(transport) { | |
110 | userlist_callback2(transport); | |
111 | } }); | |
112 | ||
113 | } catch (e) { | |
114 | exception_error("addUser", e); | |
115 | } | |
116 | } | |
117 | ||
118 | function editUser(id, event) { | |
119 | ||
120 | try { | |
121 | if (!event || !event.ctrlKey) { | |
122 | ||
123 | notify_progress("Loading, please wait..."); | |
124 | ||
125 | selectTableRows('prefUserList', 'none'); | |
126 | selectTableRowById('UMRR-'+id, 'UMCHK-'+id, true); | |
127 | ||
128 | var query = "?op=pref-users&subop=edit&id=" + | |
129 | param_escape(id); | |
130 | ||
131 | new Ajax.Request("backend.php", { | |
132 | parameters: query, | |
133 | onComplete: function(transport) { | |
134 | infobox_callback2(transport); | |
135 | document.forms['user_edit_form'].login.focus(); | |
136 | } }); | |
137 | ||
138 | } else if (event.ctrlKey) { | |
139 | var cb = $('UMCHK-' + id); | |
140 | cb.checked = !cb.checked; | |
141 | toggleSelectRow(cb); | |
142 | } | |
143 | ||
144 | } catch (e) { | |
145 | exception_error("editUser", e); | |
146 | } | |
147 | ||
148 | } | |
149 | ||
150 | function editFilter(id) { | |
151 | try { | |
152 | ||
153 | var query = "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id); | |
154 | ||
155 | if (dijit.byId("filterEditDlg")) | |
156 | dijit.byId("filterEditDlg").destroyRecursive(); | |
157 | ||
158 | dialog = new dijit.Dialog({ | |
159 | id: "filterEditDlg", | |
160 | title: __("Edit Filter"), | |
161 | style: "width: 600px", | |
162 | removeFilter: function() { | |
163 | var title = this.attr('value').reg_exp; | |
164 | var msg = __("Remove filter %s?").replace("%s", title); | |
165 | ||
166 | if (confirm(msg)) { | |
167 | this.hide(); | |
168 | ||
169 | notify_progress("Removing filter..."); | |
170 | ||
171 | var id = this.attr('value').id; | |
172 | ||
173 | var query = "?op=pref-filters&subop=remove&ids="+ | |
174 | param_escape(id); | |
175 | ||
176 | new Ajax.Request("backend.php", { | |
177 | parameters: query, | |
178 | onComplete: function(transport) { | |
179 | updateFilterList(); | |
180 | } }); | |
181 | } | |
182 | }, | |
183 | ||
184 | execute: function() { | |
185 | if (this.validate()) { | |
186 | ||
187 | var query = "?op=rpc&subop=verifyRegexp®_exp=" + | |
188 | param_escape(dialog.attr('value').reg_exp); | |
189 | ||
190 | notify_progress("Verifying regular expression..."); | |
191 | ||
192 | new Ajax.Request("backend.php", { | |
193 | parameters: query, | |
194 | onComplete: function(transport) { | |
195 | var reply = JSON.parse(transport.responseText); | |
196 | ||
197 | if (reply) { | |
198 | notify(''); | |
199 | ||
200 | if (!reply['status']) { | |
201 | alert("Match regular expression seems to be invalid."); | |
202 | return; | |
203 | } else { | |
204 | notify_progress("Saving data...", true); | |
205 | ||
206 | console.log(dojo.objectToQuery(dialog.attr('value'))); | |
207 | ||
208 | new Ajax.Request("backend.php", { | |
209 | parameters: dojo.objectToQuery(dialog.attr('value')), | |
210 | onComplete: function(transport) { | |
211 | dialog.hide(); | |
212 | updateFilterList(); | |
213 | }}) | |
214 | } | |
215 | } | |
216 | }}); | |
217 | } | |
218 | }, | |
219 | href: query}); | |
220 | ||
221 | dialog.show(); | |
222 | ||
223 | ||
224 | } catch (e) { | |
225 | exception_error("editFilter", e); | |
226 | } | |
227 | } | |
228 | ||
229 | function getSelectedLabels() { | |
230 | var tree = dijit.byId("labelTree"); | |
231 | var items = tree.model.getCheckedItems(); | |
232 | var rv = []; | |
233 | ||
234 | items.each(function(item) { | |
235 | rv.push(tree.model.store.getValue(item, 'bare_id')); | |
236 | }); | |
237 | ||
238 | return rv; | |
239 | } | |
240 | ||
241 | function getSelectedUsers() { | |
242 | return getSelectedTableRowIds("prefUserList"); | |
243 | } | |
244 | ||
245 | function getSelectedFeeds() { | |
246 | var tree = dijit.byId("feedTree"); | |
247 | var items = tree.model.getCheckedItems(); | |
248 | var rv = []; | |
249 | ||
250 | items.each(function(item) { | |
251 | rv.push(tree.model.store.getValue(item, 'bare_id')); | |
252 | }); | |
253 | ||
254 | return rv; | |
255 | } | |
256 | ||
257 | function getSelectedFilters() { | |
258 | var tree = dijit.byId("filterTree"); | |
259 | var items = tree.model.getCheckedItems(); | |
260 | var rv = []; | |
261 | ||
262 | items.each(function(item) { | |
263 | rv.push(tree.model.store.getValue(item, 'bare_id')); | |
264 | }); | |
265 | ||
266 | return rv; | |
267 | ||
268 | } | |
269 | ||
270 | /* function getSelectedFeedCats() { | |
271 | return getSelectedTableRowIds("prefFeedCatList"); | |
272 | } */ | |
273 | ||
274 | function removeSelectedLabels() { | |
275 | ||
276 | var sel_rows = getSelectedLabels(); | |
277 | ||
278 | if (sel_rows.length > 0) { | |
279 | ||
280 | var ok = confirm(__("Remove selected labels?")); | |
281 | ||
282 | if (ok) { | |
283 | notify_progress("Removing selected labels..."); | |
284 | ||
285 | var query = "?op=pref-labels&subop=remove&ids="+ | |
286 | param_escape(sel_rows.toString()); | |
287 | ||
288 | new Ajax.Request("backend.php", { | |
289 | parameters: query, | |
290 | onComplete: function(transport) { | |
291 | labellist_callback2(transport); | |
292 | } }); | |
293 | ||
294 | } | |
295 | } else { | |
296 | alert(__("No labels are selected.")); | |
297 | } | |
298 | ||
299 | return false; | |
300 | } | |
301 | ||
302 | function removeSelectedUsers() { | |
303 | ||
304 | try { | |
305 | ||
306 | var sel_rows = getSelectedUsers(); | |
307 | ||
308 | if (sel_rows.length > 0) { | |
309 | ||
310 | var ok = confirm(__("Remove selected users? Neither default admin nor your account will be removed.")); | |
311 | ||
312 | if (ok) { | |
313 | notify_progress("Removing selected users..."); | |
314 | ||
315 | var query = "?op=pref-users&subop=remove&ids="+ | |
316 | param_escape(sel_rows.toString()); | |
317 | ||
318 | new Ajax.Request("backend.php", { | |
319 | parameters: query, | |
320 | onComplete: function(transport) { | |
321 | userlist_callback2(transport); | |
322 | } }); | |
323 | ||
324 | } | |
325 | ||
326 | } else { | |
327 | alert(__("No users are selected.")); | |
328 | } | |
329 | ||
330 | } catch (e) { | |
331 | exception_error("removeSelectedUsers", e); | |
332 | } | |
333 | ||
334 | return false; | |
335 | } | |
336 | ||
337 | function removeSelectedFilters() { | |
338 | ||
339 | try { | |
340 | ||
341 | var sel_rows = getSelectedFilters(); | |
342 | ||
343 | if (sel_rows.length > 0) { | |
344 | ||
345 | var ok = confirm(__("Remove selected filters?")); | |
346 | ||
347 | if (ok) { | |
348 | notify_progress("Removing selected filters..."); | |
349 | ||
350 | var query = "?op=pref-filters&subop=remove&ids="+ | |
351 | param_escape(sel_rows.toString()); | |
352 | ||
353 | new Ajax.Request("backend.php", { | |
354 | parameters: query, | |
355 | onComplete: function(transport) { | |
356 | updateFilterList(); | |
357 | } }); | |
358 | } | |
359 | } else { | |
360 | alert(__("No filters are selected.")); | |
361 | } | |
362 | ||
363 | } catch (e) { | |
364 | exception_error("removeSelectedFilters", e); | |
365 | } | |
366 | ||
367 | return false; | |
368 | } | |
369 | ||
370 | ||
371 | function removeSelectedFeeds() { | |
372 | ||
373 | try { | |
374 | ||
375 | var sel_rows = getSelectedFeeds(); | |
376 | ||
377 | if (sel_rows.length > 0) { | |
378 | ||
379 | var ok = confirm(__("Unsubscribe from selected feeds?")); | |
380 | ||
381 | if (ok) { | |
382 | ||
383 | notify_progress("Unsubscribing from selected feeds...", true); | |
384 | ||
385 | var query = "?op=pref-feeds&subop=remove&ids="+ | |
386 | param_escape(sel_rows.toString()); | |
387 | ||
388 | console.log(query); | |
389 | ||
390 | new Ajax.Request("backend.php", { | |
391 | parameters: query, | |
392 | onComplete: function(transport) { | |
393 | updateFeedList(); | |
394 | } }); | |
395 | } | |
396 | ||
397 | } else { | |
398 | alert(__("No feeds are selected.")); | |
399 | } | |
400 | ||
401 | } catch (e) { | |
402 | exception_error("removeSelectedFeeds", e); | |
403 | } | |
404 | ||
405 | return false; | |
406 | } | |
407 | ||
408 | function clearSelectedFeeds() { | |
409 | ||
410 | var sel_rows = getSelectedFeeds(); | |
411 | ||
412 | if (sel_rows.length > 1) { | |
413 | alert(__("Please select only one feed.")); | |
414 | return; | |
415 | } | |
416 | ||
417 | if (sel_rows.length > 0) { | |
418 | ||
419 | var ok = confirm(__("Erase all non-starred articles in selected feed?")); | |
420 | ||
421 | if (ok) { | |
422 | notify_progress("Clearing selected feed..."); | |
423 | clearFeedArticles(sel_rows[0]); | |
424 | } | |
425 | ||
426 | } else { | |
427 | ||
428 | alert(__("No feeds are selected.")); | |
429 | ||
430 | } | |
431 | ||
432 | return false; | |
433 | } | |
434 | ||
435 | function purgeSelectedFeeds() { | |
436 | ||
437 | var sel_rows = getSelectedFeeds(); | |
438 | ||
439 | if (sel_rows.length > 0) { | |
440 | ||
441 | var pr = prompt(__("How many days of articles to keep (0 - use default)?"), "0"); | |
442 | ||
443 | if (pr != undefined) { | |
444 | notify_progress("Purging selected feed..."); | |
445 | ||
446 | var query = "?op=rpc&subop=purge&ids="+ | |
447 | param_escape(sel_rows.toString()) + "&days=" + pr; | |
448 | ||
449 | console.log(query); | |
450 | ||
451 | new Ajax.Request("prefs.php", { | |
452 | parameters: query, | |
453 | onComplete: function(transport) { | |
454 | notify(''); | |
455 | } }); | |
456 | } | |
457 | ||
458 | } else { | |
459 | ||
460 | alert(__("No feeds are selected.")); | |
461 | ||
462 | } | |
463 | ||
464 | return false; | |
465 | } | |
466 | ||
467 | function userEditCancel() { | |
468 | closeInfoBox(); | |
469 | return false; | |
470 | } | |
471 | ||
472 | function userEditSave() { | |
473 | ||
474 | try { | |
475 | ||
476 | var login = document.forms["user_edit_form"].login.value; | |
477 | ||
478 | if (login.length == 0) { | |
479 | alert(__("Login field cannot be blank.")); | |
480 | return; | |
481 | } | |
482 | ||
483 | notify_progress("Saving user..."); | |
484 | ||
485 | closeInfoBox(); | |
486 | ||
487 | var query = Form.serialize("user_edit_form"); | |
488 | ||
489 | new Ajax.Request("backend.php", { | |
490 | parameters: query, | |
491 | onComplete: function(transport) { | |
492 | userlist_callback2(transport); | |
493 | } }); | |
494 | ||
495 | } catch (e) { | |
496 | exception_error("userEditSave", e); | |
497 | } | |
498 | ||
499 | return false; | |
500 | ||
501 | } | |
502 | ||
503 | ||
504 | function editSelectedUser() { | |
505 | var rows = getSelectedUsers(); | |
506 | ||
507 | if (rows.length == 0) { | |
508 | alert(__("No users are selected.")); | |
509 | return; | |
510 | } | |
511 | ||
512 | if (rows.length > 1) { | |
513 | alert(__("Please select only one user.")); | |
514 | return; | |
515 | } | |
516 | ||
517 | notify(""); | |
518 | ||
519 | editUser(rows[0]); | |
520 | } | |
521 | ||
522 | function resetSelectedUserPass() { | |
523 | ||
524 | try { | |
525 | ||
526 | var rows = getSelectedUsers(); | |
527 | ||
528 | if (rows.length == 0) { | |
529 | alert(__("No users are selected.")); | |
530 | return; | |
531 | } | |
532 | ||
533 | if (rows.length > 1) { | |
534 | alert(__("Please select only one user.")); | |
535 | return; | |
536 | } | |
537 | ||
538 | var ok = confirm(__("Reset password of selected user?")); | |
539 | ||
540 | if (ok) { | |
541 | notify_progress("Resetting password for selected user..."); | |
542 | ||
543 | var id = rows[0]; | |
544 | ||
545 | var query = "?op=pref-users&subop=resetPass&id=" + | |
546 | param_escape(id); | |
547 | ||
548 | new Ajax.Request("backend.php", { | |
549 | parameters: query, | |
550 | onComplete: function(transport) { | |
551 | userlist_callback2(transport); | |
552 | } }); | |
553 | ||
554 | } | |
555 | ||
556 | } catch (e) { | |
557 | exception_error("resetSelectedUserPass", e); | |
558 | } | |
559 | } | |
560 | ||
561 | function selectedUserDetails() { | |
562 | ||
563 | try { | |
564 | ||
565 | var rows = getSelectedUsers(); | |
566 | ||
567 | if (rows.length == 0) { | |
568 | alert(__("No users are selected.")); | |
569 | return; | |
570 | } | |
571 | ||
572 | if (rows.length > 1) { | |
573 | alert(__("Please select only one user.")); | |
574 | return; | |
575 | } | |
576 | ||
577 | notify_progress("Loading, please wait..."); | |
578 | ||
579 | var id = rows[0]; | |
580 | ||
581 | var query = "?op=pref-users&subop=user-details&id=" + id; | |
582 | ||
583 | new Ajax.Request("backend.php", { | |
584 | parameters: query, | |
585 | onComplete: function(transport) { | |
586 | infobox_callback2(transport); | |
587 | } }); | |
588 | } catch (e) { | |
589 | exception_error("selectedUserDetails", e); | |
590 | } | |
591 | } | |
592 | ||
593 | ||
594 | function editSelectedFilter() { | |
595 | var rows = getSelectedFilters(); | |
596 | ||
597 | if (rows.length == 0) { | |
598 | alert(__("No filters are selected.")); | |
599 | return; | |
600 | } | |
601 | ||
602 | if (rows.length > 1) { | |
603 | alert(__("Please select only one filter.")); | |
604 | return; | |
605 | } | |
606 | ||
607 | notify(""); | |
608 | ||
609 | editFilter(rows[0]); | |
610 | ||
611 | } | |
612 | ||
613 | ||
614 | function editSelectedFeed() { | |
615 | var rows = getSelectedFeeds(); | |
616 | ||
617 | if (rows.length == 0) { | |
618 | alert(__("No feeds are selected.")); | |
619 | return; | |
620 | } | |
621 | ||
622 | if (rows.length > 1) { | |
623 | return editSelectedFeeds(); | |
624 | } | |
625 | ||
626 | notify(""); | |
627 | ||
628 | editFeed(rows[0], {}); | |
629 | ||
630 | } | |
631 | ||
632 | function editSelectedFeeds() { | |
633 | ||
634 | try { | |
635 | var rows = getSelectedFeeds(); | |
636 | ||
637 | if (rows.length == 0) { | |
638 | alert(__("No feeds are selected.")); | |
639 | return; | |
640 | } | |
641 | ||
642 | notify(""); | |
643 | ||
644 | var query = "backend.php?op=pref-feeds&subop=editfeeds&ids=" + | |
645 | param_escape(rows.toString()); | |
646 | ||
647 | if (dijit.byId("feedEditDlg")) | |
648 | dijit.byId("feedEditDlg").destroyRecursive(); | |
649 | ||
650 | dialog = new dijit.Dialog({ | |
651 | id: "feedEditDlg", | |
652 | title: __("Edit Multiple Feeds"), | |
653 | style: "width: 600px", | |
654 | getChildByName: function (name) { | |
655 | var rv = null | |
656 | this.getChildren().each( | |
657 | function(child) { | |
658 | if (child.name == name) { | |
659 | rv = child; | |
660 | return; | |
661 | } | |
662 | }); | |
663 | return rv; | |
664 | }, | |
665 | toggleField: function (checkbox, elem, label) { | |
666 | this.getChildByName(elem).attr('disabled', !checkbox.checked); | |
667 | ||
668 | if ($(label)) | |
669 | if (checkbox.checked) | |
670 | $(label).removeClassName('insensitive'); | |
671 | else | |
672 | $(label).addClassName('insensitive'); | |
673 | ||
674 | }, | |
675 | execute: function() { | |
676 | if (this.validate() && confirm(__("Save changes to selected feeds?"))) { | |
677 | var query = dojo.objectToQuery(this.attr('value')); | |
678 | ||
679 | /* Form.serialize ignores unchecked checkboxes */ | |
680 | ||
681 | if (!query.match("&rtl_content=") && | |
682 | this.getChildByName('rtl_content').attr('disabled') == false) { | |
683 | query = query + "&rtl_content=false"; | |
684 | } | |
685 | ||
686 | if (!query.match("&private=") && | |
687 | this.getChildByName('private').attr('disabled') == false) { | |
688 | query = query + "&private=false"; | |
689 | } | |
690 | ||
691 | if (!query.match("&cache_images=") && | |
692 | this.getChildByName('cache_images').attr('disabled') == false) { | |
693 | query = query + "&cache_images=false"; | |
694 | } | |
695 | ||
696 | if (!query.match("&include_in_digest=") && | |
697 | this.getChildByName('include_in_digest').attr('disabled') == false) { | |
698 | query = query + "&include_in_digest=false"; | |
699 | } | |
700 | ||
701 | console.log(query); | |
702 | ||
703 | notify_progress("Saving data...", true); | |
704 | ||
705 | new Ajax.Request("backend.php", { | |
706 | parameters: query, | |
707 | onComplete: function(transport) { | |
708 | dialog.hide(); | |
709 | updateFeedList(); | |
710 | }}) | |
711 | } | |
712 | }, | |
713 | href: query}); | |
714 | ||
715 | dialog.show(); | |
716 | ||
717 | } catch (e) { | |
718 | exception_error("editSelectedFeeds", e); | |
719 | } | |
720 | } | |
721 | ||
722 | function piggie(enable) { | |
723 | if (enable) { | |
724 | console.log("I LOVEDED IT!"); | |
725 | var piggie = $("piggie"); | |
726 | ||
727 | Element.show(piggie); | |
728 | Position.Center(piggie); | |
729 | Effect.Puff(piggie); | |
730 | ||
731 | } | |
732 | } | |
733 | ||
734 | function opmlImportComplete(iframe) { | |
735 | try { | |
736 | if (!iframe.contentDocument.body.innerHTML) return false; | |
737 | ||
738 | notify(''); | |
739 | ||
740 | if (dijit.byId('opmlImportDlg')) | |
741 | dijit.byId('opmlImportDlg').destroyRecursive(); | |
742 | ||
743 | var content = iframe.contentDocument.body.innerHTML; | |
744 | ||
745 | dialog = new dijit.Dialog({ | |
746 | id: "opmlImportDlg", | |
747 | title: __("OPML Import"), | |
748 | style: "width: 600px", | |
749 | onCancel: function() { | |
750 | updateFeedList(); | |
751 | }, | |
752 | content: content}); | |
753 | ||
754 | dialog.show(); | |
755 | ||
756 | } catch (e) { | |
757 | exception_error("opmlImportComplete", e); | |
758 | } | |
759 | } | |
760 | ||
761 | function opmlImport() { | |
762 | ||
763 | var opml_file = $("opml_file"); | |
764 | ||
765 | if (opml_file.value.length == 0) { | |
766 | alert(__("Please choose an OPML file first.")); | |
767 | return false; | |
768 | } else { | |
769 | notify_progress("Importing, please wait...", true); | |
770 | return true; | |
771 | } | |
772 | } | |
773 | ||
774 | function updateFilterList() { | |
775 | new Ajax.Request("backend.php", { | |
776 | parameters: "?op=pref-filters", | |
777 | onComplete: function(transport) { | |
778 | filterlist_callback2(transport); | |
779 | } }); | |
780 | } | |
781 | ||
782 | function updateLabelList() { | |
783 | new Ajax.Request("backend.php", { | |
784 | parameters: "?op=pref-labels", | |
785 | onComplete: function(transport) { | |
786 | labellist_callback2(transport); | |
787 | } }); | |
788 | } | |
789 | ||
790 | function updatePrefsList() { | |
791 | new Ajax.Request("backend.php", { | |
792 | parameters: "?op=pref-prefs", | |
793 | onComplete: function(transport) { | |
794 | prefslist_callback2(transport); | |
795 | } }); | |
796 | } | |
797 | ||
798 | function selectTab(id, noupdate, subop) { | |
799 | try { | |
800 | if (!noupdate) { | |
801 | notify_progress("Loading, please wait..."); | |
802 | ||
803 | if (id == "feedConfig") { | |
804 | updateFeedList(); | |
805 | } else if (id == "filterConfig") { | |
806 | updateFilterList(); | |
807 | } else if (id == "labelConfig") { | |
808 | updateLabelList(); | |
809 | } else if (id == "genConfig") { | |
810 | updatePrefsList(); | |
811 | } else if (id == "userConfig") { | |
812 | updateUsersList(); | |
813 | } | |
814 | ||
815 | var tab = dijit.byId(id + "Tab"); | |
816 | dijit.byId("pref-tabs").selectChild(tab); | |
817 | ||
818 | } | |
819 | ||
820 | } catch (e) { | |
821 | exception_error("selectTab", e); | |
822 | } | |
823 | } | |
824 | ||
825 | function init_second_stage() { | |
826 | try { | |
827 | ||
828 | document.onkeydown = pref_hotkey_handler; | |
829 | loading_set_progress(50); | |
830 | notify(""); | |
831 | ||
832 | dojo.addOnLoad(function() { | |
833 | var tab = getURLParam('tab'); | |
834 | ||
835 | if (tab) { | |
836 | tab = dijit.byId(tab + "Tab"); | |
837 | if (tab) dijit.byId("pref-tabs").selectChild(tab); | |
838 | } | |
839 | ||
840 | var subop = getURLParam('subop'); | |
841 | ||
842 | if (subop == 'editFeed') { | |
843 | var param = getURLParam('subopparam'); | |
844 | ||
845 | window.setTimeout('editFeed(' + param + ')', 100); | |
846 | } | |
847 | }); | |
848 | ||
849 | setTimeout("hotkey_prefix_timeout()", 5*1000); | |
850 | ||
851 | } catch (e) { | |
852 | exception_error("init_second_stage", e); | |
853 | } | |
854 | } | |
855 | ||
856 | function init() { | |
857 | ||
858 | try { | |
859 | dojo.registerModulePath("lib", ".."); | |
860 | dojo.registerModulePath("fox", "../.."); | |
861 | ||
862 | dojo.require("lib.CheckBoxTree"); | |
863 | dojo.require("fox.PrefFeedTree"); | |
864 | dojo.require("fox.PrefFilterTree"); | |
865 | dojo.require("fox.PrefLabelTree"); | |
866 | ||
867 | dojo.parser.parse(); | |
868 | ||
869 | dojo.addOnLoad(function() { | |
870 | loading_set_progress(50); | |
871 | ||
872 | new Ajax.Request("backend.php", { | |
873 | parameters: {op: "rpc", subop: "sanityCheck"}, | |
874 | onComplete: function(transport) { | |
875 | backend_sanity_check_callback(transport); | |
876 | } }); | |
877 | }); | |
878 | ||
879 | } catch (e) { | |
880 | exception_error("init", e); | |
881 | } | |
882 | } | |
883 | ||
884 | function validatePrefsReset() { | |
885 | try { | |
886 | var ok = confirm(__("Reset to defaults?")); | |
887 | ||
888 | if (ok) { | |
889 | ||
890 | query = "?op=pref-prefs&subop=reset-config"; | |
891 | console.log(query); | |
892 | ||
893 | new Ajax.Request("backend.php", { | |
894 | parameters: query, | |
895 | onComplete: function(transport) { | |
896 | var msg = transport.responseText; | |
897 | if (msg.match("PREFS_THEME_CHANGED")) { | |
898 | window.location.reload(); | |
899 | } else { | |
900 | notify_info(msg); | |
901 | selectTab(); | |
902 | } | |
903 | } }); | |
904 | ||
905 | } | |
906 | ||
907 | } catch (e) { | |
908 | exception_error("validatePrefsReset", e); | |
909 | } | |
910 | ||
911 | return false; | |
912 | ||
913 | } | |
914 | ||
915 | ||
916 | function pref_hotkey_handler(e) { | |
917 | try { | |
918 | if (e.target.nodeName == "INPUT") return; | |
919 | ||
920 | var keycode; | |
921 | var shift_key = false; | |
922 | ||
923 | var cmdline = $('cmdline'); | |
924 | ||
925 | try { | |
926 | shift_key = e.shiftKey; | |
927 | } catch (e) { | |
928 | ||
929 | } | |
930 | ||
931 | if (window.event) { | |
932 | keycode = window.event.keyCode; | |
933 | } else if (e) { | |
934 | keycode = e.which; | |
935 | } | |
936 | ||
937 | var keychar = String.fromCharCode(keycode); | |
938 | ||
939 | if (keycode == 27) { // escape | |
940 | if (Element.visible("hotkey_help_overlay")) { | |
941 | Element.hide("hotkey_help_overlay"); | |
942 | } | |
943 | hotkey_prefix = false; | |
944 | closeInfoBox(); | |
945 | } | |
946 | ||
947 | if (keycode == 16) return; // ignore lone shift | |
948 | if (keycode == 17) return; // ignore lone ctrl | |
949 | ||
950 | if ((keycode == 67 || keycode == 71) && !hotkey_prefix) { | |
951 | hotkey_prefix = keycode; | |
952 | ||
953 | var date = new Date(); | |
954 | var ts = Math.round(date.getTime() / 1000); | |
955 | ||
956 | hotkey_prefix_pressed = ts; | |
957 | ||
958 | cmdline.innerHTML = keychar; | |
959 | Element.show(cmdline); | |
960 | ||
961 | console.log("KP: PREFIX=" + keycode + " CHAR=" + keychar); | |
962 | return; | |
963 | } | |
964 | ||
965 | if (Element.visible("hotkey_help_overlay")) { | |
966 | Element.hide("hotkey_help_overlay"); | |
967 | } | |
968 | ||
969 | if (keycode == 13 || keycode == 27) { | |
970 | seq = ""; | |
971 | } else { | |
972 | seq = seq + "" + keycode; | |
973 | } | |
974 | ||
975 | /* Global hotkeys */ | |
976 | ||
977 | Element.hide(cmdline); | |
978 | ||
979 | if (!hotkey_prefix) { | |
980 | ||
981 | if ((keycode == 191 || keychar == '?') && shift_key) { // ? | |
982 | if (!Element.visible("hotkey_help_overlay")) { | |
983 | //Element.show("hotkey_help_overlay"); | |
984 | Effect.Appear("hotkey_help_overlay", {duration : 0.3}); | |
985 | } else { | |
986 | Element.hide("hotkey_help_overlay"); | |
987 | } | |
988 | return false; | |
989 | } | |
990 | ||
991 | if (keycode == 191 || keychar == '/') { // / | |
992 | var search_boxes = new Array("label_search", | |
993 | "feed_search", "filter_search", "user_search", "feed_browser_search"); | |
994 | ||
995 | for (var i = 0; i < search_boxes.length; i++) { | |
996 | var elem = $(search_boxes[i]); | |
997 | if (elem) { | |
998 | $(search_boxes[i]).focus(); | |
999 | return false; | |
1000 | } | |
1001 | } | |
1002 | } | |
1003 | } | |
1004 | ||
1005 | /* Prefix c */ | |
1006 | ||
1007 | if (hotkey_prefix == 67) { // c | |
1008 | hotkey_prefix = false; | |
1009 | ||
1010 | if (keycode == 70) { // f | |
1011 | quickAddFilter(); | |
1012 | return false; | |
1013 | } | |
1014 | ||
1015 | if (keycode == 83) { // s | |
1016 | quickAddFeed(); | |
1017 | return false; | |
1018 | } | |
1019 | ||
1020 | if (keycode == 85) { // u | |
1021 | // no-op | |
1022 | } | |
1023 | ||
1024 | if (keycode == 67) { // c | |
1025 | editFeedCats(); | |
1026 | return false; | |
1027 | } | |
1028 | ||
1029 | if (keycode == 84 && shift_key) { // T | |
1030 | feedBrowser(); | |
1031 | return false; | |
1032 | } | |
1033 | ||
1034 | } | |
1035 | ||
1036 | /* Prefix g */ | |
1037 | ||
1038 | if (hotkey_prefix == 71) { // g | |
1039 | ||
1040 | hotkey_prefix = false; | |
1041 | ||
1042 | if (keycode == 49 && $("genConfigTab")) { // 1 | |
1043 | selectTab("genConfig"); | |
1044 | return false; | |
1045 | } | |
1046 | ||
1047 | if (keycode == 50 && $("feedConfigTab")) { // 2 | |
1048 | selectTab("feedConfig"); | |
1049 | return false; | |
1050 | } | |
1051 | ||
1052 | if (keycode == 51 && $("filterConfigTab")) { // 4 | |
1053 | selectTab("filterConfig"); | |
1054 | return false; | |
1055 | } | |
1056 | ||
1057 | if (keycode == 52 && $("labelConfigTab")) { // 5 | |
1058 | selectTab("labelConfig"); | |
1059 | return false; | |
1060 | } | |
1061 | ||
1062 | if (keycode == 53 && $("userConfigTab")) { // 6 | |
1063 | selectTab("userConfig"); | |
1064 | return false; | |
1065 | } | |
1066 | ||
1067 | if (keycode == 88) { // x | |
1068 | return gotoMain(); | |
1069 | } | |
1070 | ||
1071 | } | |
1072 | ||
1073 | if ($("piggie")) { | |
1074 | if (seq.match("8073717369")) { | |
1075 | seq = ""; | |
1076 | piggie(true); | |
1077 | } else { | |
1078 | piggie(false); | |
1079 | } | |
1080 | } | |
1081 | ||
1082 | if (hotkey_prefix) { | |
1083 | console.log("KP: PREFIX=" + hotkey_prefix + " CODE=" + keycode + " CHAR=" + keychar); | |
1084 | } else { | |
1085 | console.log("KP: CODE=" + keycode + " CHAR=" + keychar); | |
1086 | } | |
1087 | ||
1088 | } catch (e) { | |
1089 | exception_error("pref_hotkey_handler", e); | |
1090 | } | |
1091 | } | |
1092 | ||
1093 | function editFeedCats() { | |
1094 | try { | |
1095 | var query = "backend.php?op=pref-feeds&subop=editCats"; | |
1096 | ||
1097 | if (dijit.byId("feedCatEditDlg")) | |
1098 | dijit.byId("feedCatEditDlg").destroyRecursive(); | |
1099 | ||
1100 | dialog = new dijit.Dialog({ | |
1101 | id: "feedCatEditDlg", | |
1102 | title: __("Feed Categories"), | |
1103 | style: "width: 600px", | |
1104 | getSelectedCategories: function() { | |
1105 | return getSelectedTableRowIds("prefFeedCatList"); | |
1106 | }, | |
1107 | removeSelected: function() { | |
1108 | var sel_rows = this.getSelectedCategories(); | |
1109 | ||
1110 | if (sel_rows.length > 0) { | |
1111 | var ok = confirm(__("Remove selected categories?")); | |
1112 | ||
1113 | if (ok) { | |
1114 | notify_progress("Removing selected categories...", true); | |
1115 | ||
1116 | var query = "?op=pref-feeds&subop=editCats&action=remove&ids="+ | |
1117 | param_escape(sel_rows.toString()); | |
1118 | ||
1119 | new Ajax.Request("backend.php", { | |
1120 | parameters: query, | |
1121 | onComplete: function(transport) { | |
1122 | notify(''); | |
1123 | dialog.attr('content', transport.responseText); | |
1124 | updateFeedList(); | |
1125 | } }); | |
1126 | ||
1127 | } | |
1128 | ||
1129 | } else { | |
1130 | alert(__("No categories are selected.")); | |
1131 | } | |
1132 | }, | |
1133 | addCategory: function() { | |
1134 | if (this.validate()) { | |
1135 | notify_progress("Creating category..."); | |
1136 | ||
1137 | var query = "?op=pref-feeds&subop=editCats&action=add&cat=" + | |
1138 | param_escape(this.attr('value').newcat); | |
1139 | ||
1140 | new Ajax.Request("backend.php", { | |
1141 | parameters: query, | |
1142 | onComplete: function(transport) { | |
1143 | notify(''); | |
1144 | dialog.attr('content', transport.responseText); | |
1145 | updateFeedList(); | |
1146 | } }); | |
1147 | } | |
1148 | }, | |
1149 | execute: function() { | |
1150 | if (this.validate()) { | |
1151 | } | |
1152 | }, | |
1153 | href: query}); | |
1154 | ||
1155 | dialog.show(); | |
1156 | ||
1157 | } catch (e) { | |
1158 | exception_error("editFeedCats", e); | |
1159 | } | |
1160 | } | |
1161 | ||
1162 | function showInactiveFeeds() { | |
1163 | try { | |
1164 | var query = "backend.php?op=dlg&id=inactiveFeeds"; | |
1165 | ||
1166 | if (dijit.byId("inactiveFeedsDlg")) | |
1167 | dijit.byId("inactiveFeedsDlg").destroyRecursive(); | |
1168 | ||
1169 | dialog = new dijit.Dialog({ | |
1170 | id: "inactiveFeedsDlg", | |
1171 | title: __("Feeds without recent updates"), | |
1172 | style: "width: 600px", | |
1173 | getSelectedFeeds: function() { | |
1174 | return getSelectedTableRowIds("prefInactiveFeedList"); | |
1175 | }, | |
1176 | removeSelected: function() { | |
1177 | var sel_rows = this.getSelectedFeeds(); | |
1178 | ||
1179 | console.log(sel_rows); | |
1180 | ||
1181 | if (sel_rows.length > 0) { | |
1182 | var ok = confirm(__("Remove selected feeds?")); | |
1183 | ||
1184 | if (ok) { | |
1185 | notify_progress("Removing selected feeds...", true); | |
1186 | ||
1187 | var query = "?op=pref-feeds&subop=remove&ids="+ | |
1188 | param_escape(sel_rows.toString()); | |
1189 | ||
1190 | new Ajax.Request("backend.php", { | |
1191 | parameters: query, | |
1192 | onComplete: function(transport) { | |
1193 | notify(''); | |
1194 | dialog.hide(); | |
1195 | updateFeedList(); | |
1196 | } }); | |
1197 | } | |
1198 | ||
1199 | } else { | |
1200 | alert(__("No feeds are selected.")); | |
1201 | } | |
1202 | }, | |
1203 | execute: function() { | |
1204 | if (this.validate()) { | |
1205 | } | |
1206 | }, | |
1207 | href: query}); | |
1208 | ||
1209 | dialog.show(); | |
1210 | ||
1211 | } catch (e) { | |
1212 | exception_error("showInactiveFeeds", e); | |
1213 | } | |
1214 | ||
1215 | } | |
1216 | ||
1217 | function opmlRegenKey() { | |
1218 | ||
1219 | try { | |
1220 | var ok = confirm(__("Replace current OPML publishing address with a new one?")); | |
1221 | ||
1222 | if (ok) { | |
1223 | ||
1224 | notify_progress("Trying to change address...", true); | |
1225 | ||
1226 | var query = "?op=rpc&subop=regenOPMLKey"; | |
1227 | ||
1228 | new Ajax.Request("backend.php", { | |
1229 | parameters: query, | |
1230 | onComplete: function(transport) { | |
1231 | var reply = JSON.parse(transport.responseText); | |
1232 | ||
1233 | var new_link = reply.link; | |
1234 | ||
1235 | var e = $('pub_opml_url'); | |
1236 | ||
1237 | if (new_link) { | |
1238 | e.href = new_link; | |
1239 | e.innerHTML = new_link; | |
1240 | ||
1241 | new Effect.Highlight(e); | |
1242 | ||
1243 | notify(''); | |
1244 | ||
1245 | } else { | |
1246 | notify_error("Could not change feed URL."); | |
1247 | } | |
1248 | } }); | |
1249 | } | |
1250 | } catch (e) { | |
1251 | exception_error("opmlRegenKey", e); | |
1252 | } | |
1253 | return false; | |
1254 | } | |
1255 | ||
1256 | function feedActionChange() { | |
1257 | try { | |
1258 | var chooser = $("feedActionChooser"); | |
1259 | var opid = chooser[chooser.selectedIndex].value; | |
1260 | ||
1261 | chooser.selectedIndex = 0; | |
1262 | feedActionGo(opid); | |
1263 | } catch (e) { | |
1264 | exception_error("feedActionChange", e); | |
1265 | } | |
1266 | } | |
1267 | ||
1268 | function feedActionGo(op) { | |
1269 | try { | |
1270 | if (op == "facEdit") { | |
1271 | ||
1272 | var rows = getSelectedFeeds(); | |
1273 | ||
1274 | if (rows.length > 1) { | |
1275 | editSelectedFeeds(); | |
1276 | } else { | |
1277 | editSelectedFeed(); | |
1278 | } | |
1279 | } | |
1280 | ||
1281 | if (op == "facClear") { | |
1282 | clearSelectedFeeds(); | |
1283 | } | |
1284 | ||
1285 | if (op == "facPurge") { | |
1286 | purgeSelectedFeeds(); | |
1287 | } | |
1288 | ||
1289 | if (op == "facEditCats") { | |
1290 | editFeedCats(); | |
1291 | } | |
1292 | ||
1293 | if (op == "facRescore") { | |
1294 | rescoreSelectedFeeds(); | |
1295 | } | |
1296 | ||
1297 | if (op == "facUnsubscribe") { | |
1298 | removeSelectedFeeds(); | |
1299 | } | |
1300 | ||
1301 | } catch (e) { | |
1302 | exception_error("feedActionGo", e); | |
1303 | ||
1304 | } | |
1305 | } | |
1306 | ||
1307 | function clearFeedArticles(feed_id) { | |
1308 | ||
1309 | notify_progress("Clearing feed..."); | |
1310 | ||
1311 | var query = "?op=pref-feeds&quiet=1&subop=clear&id=" + feed_id; | |
1312 | ||
1313 | new Ajax.Request("backend.php", { | |
1314 | parameters: query, | |
1315 | onComplete: function(transport) { | |
1316 | notify(''); | |
1317 | } }); | |
1318 | ||
1319 | return false; | |
1320 | } | |
1321 | ||
1322 | function rescoreSelectedFeeds() { | |
1323 | ||
1324 | var sel_rows = getSelectedFeeds(); | |
1325 | ||
1326 | if (sel_rows.length > 0) { | |
1327 | ||
1328 | //var ok = confirm(__("Rescore last 100 articles in selected feeds?")); | |
1329 | var ok = confirm(__("Rescore articles in selected feeds?")); | |
1330 | ||
1331 | if (ok) { | |
1332 | notify_progress("Rescoring selected feeds...", true); | |
1333 | ||
1334 | var query = "?op=pref-feeds&subop=rescore&quiet=1&ids="+ | |
1335 | param_escape(sel_rows.toString()); | |
1336 | ||
1337 | new Ajax.Request("backend.php", { | |
1338 | parameters: query, | |
1339 | onComplete: function(transport) { | |
1340 | notify_callback2(transport); | |
1341 | } }); | |
1342 | ||
1343 | } | |
1344 | } else { | |
1345 | alert(__("No feeds are selected.")); | |
1346 | } | |
1347 | ||
1348 | return false; | |
1349 | } | |
1350 | ||
1351 | function rescore_all_feeds() { | |
1352 | var ok = confirm(__("Rescore all articles? This operation may take a lot of time.")); | |
1353 | ||
1354 | if (ok) { | |
1355 | notify_progress("Rescoring feeds...", true); | |
1356 | ||
1357 | var query = "?op=pref-feeds&subop=rescoreAll&quiet=1"; | |
1358 | ||
1359 | new Ajax.Request("backend.php", { | |
1360 | parameters: query, | |
1361 | onComplete: function(transport) { | |
1362 | notify_callback2(transport); | |
1363 | } }); | |
1364 | } | |
1365 | } | |
1366 | ||
1367 | function labelColorReset() { | |
1368 | try { | |
1369 | var labels = getSelectedLabels(); | |
1370 | ||
1371 | if (labels.length > 0) { | |
1372 | var ok = confirm(__("Reset selected labels to default colors?")); | |
1373 | ||
1374 | if (ok) { | |
1375 | var query = "?op=pref-labels&subop=color-reset&ids="+ | |
1376 | param_escape(labels.toString()); | |
1377 | ||
1378 | new Ajax.Request("backend.php", { | |
1379 | parameters: query, | |
1380 | onComplete: function(transport) { | |
1381 | labellist_callback2(transport); | |
1382 | } }); | |
1383 | } | |
1384 | ||
1385 | } else { | |
1386 | alert(__("No labels are selected.")); | |
1387 | } | |
1388 | ||
1389 | } catch (e) { | |
1390 | exception_error("labelColorReset", e); | |
1391 | } | |
1392 | } | |
1393 | ||
1394 | ||
1395 | function inPreferences() { | |
1396 | return true; | |
1397 | } | |
1398 | ||
1399 | function editProfiles() { | |
1400 | try { | |
1401 | ||
1402 | if (dijit.byId("profileEditDlg")) | |
1403 | dijit.byId("profileEditDlg").destroyRecursive(); | |
1404 | ||
1405 | var query = "backend.php?op=dlg&id=editPrefProfiles"; | |
1406 | ||
1407 | dialog = new dijit.Dialog({ | |
1408 | id: "profileEditDlg", | |
1409 | title: __("Settings Profiles"), | |
1410 | style: "width: 600px", | |
1411 | getSelectedProfiles: function() { | |
1412 | return getSelectedTableRowIds("prefFeedProfileList"); | |
1413 | }, | |
1414 | removeSelected: function() { | |
1415 | var sel_rows = this.getSelectedProfiles(); | |
1416 | ||
1417 | if (sel_rows.length > 0) { | |
1418 | var ok = confirm(__("Remove selected profiles? Active and default profiles will not be removed.")); | |
1419 | ||
1420 | if (ok) { | |
1421 | notify_progress("Removing selected profiles...", true); | |
1422 | ||
1423 | var query = "?op=rpc&subop=remprofiles&ids="+ | |
1424 | param_escape(sel_rows.toString()); | |
1425 | ||
1426 | new Ajax.Request("backend.php", { | |
1427 | parameters: query, | |
1428 | onComplete: function(transport) { | |
1429 | notify(''); | |
1430 | editProfiles(); | |
1431 | } }); | |
1432 | ||
1433 | } | |
1434 | ||
1435 | } else { | |
1436 | alert(__("No profiles are selected.")); | |
1437 | } | |
1438 | }, | |
1439 | activateProfile: function() { | |
1440 | var sel_rows = this.getSelectedProfiles(); | |
1441 | ||
1442 | if (sel_rows.length == 1) { | |
1443 | ||
1444 | var ok = confirm(__("Activate selected profile?")); | |
1445 | ||
1446 | if (ok) { | |
1447 | notify_progress("Loading, please wait..."); | |
1448 | ||
1449 | var query = "?op=rpc&subop=setprofile&id="+ | |
1450 | param_escape(sel_rows.toString()); | |
1451 | ||
1452 | new Ajax.Request("backend.php", { | |
1453 | parameters: query, | |
1454 | onComplete: function(transport) { | |
1455 | window.location.reload(); | |
1456 | } }); | |
1457 | } | |
1458 | ||
1459 | } else { | |
1460 | alert(__("Please choose a profile to activate.")); | |
1461 | } | |
1462 | }, | |
1463 | addProfile: function() { | |
1464 | if (this.validate()) { | |
1465 | notify_progress("Creating profile...", true); | |
1466 | ||
1467 | var query = "?op=rpc&subop=addprofile&title=" + | |
1468 | param_escape(dialog.attr('value').newprofile); | |
1469 | ||
1470 | new Ajax.Request("backend.php", { | |
1471 | parameters: query, | |
1472 | onComplete: function(transport) { | |
1473 | notify(''); | |
1474 | editProfiles(); | |
1475 | } }); | |
1476 | ||
1477 | } | |
1478 | }, | |
1479 | execute: function() { | |
1480 | if (this.validate()) { | |
1481 | } | |
1482 | }, | |
1483 | href: query}); | |
1484 | ||
1485 | dialog.show(); | |
1486 | } catch (e) { | |
1487 | exception_error("editProfiles", e); | |
1488 | } | |
1489 | } | |
1490 | ||
1491 | function activatePrefProfile() { | |
1492 | ||
1493 | var sel_rows = getSelectedFeedCats(); | |
1494 | ||
1495 | if (sel_rows.length == 1) { | |
1496 | ||
1497 | var ok = confirm(__("Activate selected profile?")); | |
1498 | ||
1499 | if (ok) { | |
1500 | notify_progress("Loading, please wait..."); | |
1501 | ||
1502 | var query = "?op=rpc&subop=setprofile&id="+ | |
1503 | param_escape(sel_rows.toString()); | |
1504 | ||
1505 | new Ajax.Request("backend.php", { | |
1506 | parameters: query, | |
1507 | onComplete: function(transport) { | |
1508 | window.location.reload(); | |
1509 | } }); | |
1510 | } | |
1511 | ||
1512 | } else { | |
1513 | alert(__("Please choose a profile to activate.")); | |
1514 | } | |
1515 | ||
1516 | return false; | |
1517 | } | |
1518 | ||
1519 | function clearFeedAccessKeys() { | |
1520 | ||
1521 | var ok = confirm(__("This will invalidate all previously generated feed URLs. Continue?")); | |
1522 | ||
1523 | if (ok) { | |
1524 | notify_progress("Clearing URLs..."); | |
1525 | ||
1526 | var query = "?op=rpc&subop=clearKeys"; | |
1527 | ||
1528 | new Ajax.Request("backend.php", { | |
1529 | parameters: query, | |
1530 | onComplete: function(transport) { | |
1531 | notify_info("Generated URLs cleared."); | |
1532 | } }); | |
1533 | } | |
1534 | ||
1535 | return false; | |
1536 | } | |
1537 | ||
1538 | function resetFeedOrder() { | |
1539 | try { | |
1540 | notify_progress("Loading, please wait..."); | |
1541 | ||
1542 | new Ajax.Request("backend.php", { | |
1543 | parameters: "?op=pref-feeds&subop=feedsortreset", | |
1544 | onComplete: function(transport) { | |
1545 | updateFeedList(); | |
1546 | } }); | |
1547 | ||
1548 | ||
1549 | } catch (e) { | |
1550 | exception_error("resetFeedOrder"); | |
1551 | } | |
1552 | } | |
1553 | ||
1554 | function resetCatOrder() { | |
1555 | try { | |
1556 | notify_progress("Loading, please wait..."); | |
1557 | ||
1558 | new Ajax.Request("backend.php", { | |
1559 | parameters: "?op=pref-feeds&subop=catsortreset", | |
1560 | onComplete: function(transport) { | |
1561 | updateFeedList(); | |
1562 | } }); | |
1563 | ||
1564 | ||
1565 | } catch (e) { | |
1566 | exception_error("resetCatOrder"); | |
1567 | } | |
1568 | } | |
1569 | ||
1570 | function editCat(id, item, event) { | |
1571 | try { | |
1572 | var new_name = prompt(__('Rename category to:'), item.name); | |
1573 | ||
1574 | if (new_name && new_name != item.name) { | |
1575 | ||
1576 | notify_progress("Loading, please wait..."); | |
1577 | ||
1578 | new Ajax.Request("backend.php", { | |
1579 | parameters: { | |
1580 | op: 'pref-feeds', | |
1581 | subop: 'renamecat', | |
1582 | id: id, | |
1583 | title: new_name, | |
1584 | }, | |
1585 | onComplete: function(transport) { | |
1586 | updateFeedList(); | |
1587 | } }); | |
1588 | } | |
1589 | ||
1590 | } catch (e) { | |
1591 | exception_error("editCat", e); | |
1592 | } | |
1593 | } | |
1594 | ||
1595 | function editLabel(id, event) { | |
1596 | try { | |
1597 | var query = "backend.php?op=pref-labels&subop=edit&id=" + | |
1598 | param_escape(id); | |
1599 | ||
1600 | if (dijit.byId("labelEditDlg")) | |
1601 | dijit.byId("labelEditDlg").destroyRecursive(); | |
1602 | ||
1603 | dialog = new dijit.Dialog({ | |
1604 | id: "labelEditDlg", | |
1605 | title: __("Label Editor"), | |
1606 | style: "width: 600px", | |
1607 | setLabelColor: function(id, fg, bg) { | |
1608 | ||
1609 | var kind = ''; | |
1610 | var color = ''; | |
1611 | ||
1612 | if (fg && bg) { | |
1613 | kind = 'both'; | |
1614 | } else if (fg) { | |
1615 | kind = 'fg'; | |
1616 | color = fg; | |
1617 | } else if (bg) { | |
1618 | kind = 'bg'; | |
1619 | color = bg; | |
1620 | } | |
1621 | ||
1622 | var query = "?op=pref-labels&subop=color-set&kind="+kind+ | |
1623 | "&ids=" + param_escape(id) + "&fg=" + param_escape(fg) + | |
1624 | "&bg=" + param_escape(bg) + "&color=" + param_escape(color); | |
1625 | ||
1626 | // console.log(query); | |
1627 | ||
1628 | var e = $("LICID-" + id); | |
1629 | ||
1630 | if (e) { | |
1631 | if (fg) e.style.color = fg; | |
1632 | if (bg) e.style.backgroundColor = bg; | |
1633 | } | |
1634 | ||
1635 | new Ajax.Request("backend.php", { parameters: query }); | |
1636 | ||
1637 | updateFilterList(); | |
1638 | }, | |
1639 | execute: function() { | |
1640 | if (this.validate()) { | |
1641 | var caption = this.attr('value').id; | |
1642 | var caption = this.attr('value').caption; | |
1643 | var fg_color = this.attr('value').fg_color; | |
1644 | var bg_color = this.attr('value').bg_color; | |
1645 | var query = dojo.objectToQuery(this.attr('value')); | |
1646 | ||
1647 | dijit.byId('labelTree').setNameById(id, caption); | |
1648 | this.setLabelColor(id, fg_color, bg_color); | |
1649 | this.hide(); | |
1650 | ||
1651 | new Ajax.Request("backend.php", { | |
1652 | parameters: query, | |
1653 | onComplete: function(transport) { | |
1654 | updateFilterList(); | |
1655 | } }); | |
1656 | } | |
1657 | }, | |
1658 | href: query}); | |
1659 | ||
1660 | dialog.show(); | |
1661 | ||
1662 | } catch (e) { | |
1663 | exception_error("editLabel", e); | |
1664 | } | |
1665 | } | |
1666 | ||
1667 | function clearTwitterCredentials() { | |
1668 | try { | |
1669 | var ok = confirm(__("This will clear your stored authentication information for Twitter. Continue?")); | |
1670 | ||
1671 | if (ok) { | |
1672 | notify_progress("Clearing credentials..."); | |
1673 | ||
1674 | var query = "?op=pref-feeds&subop=remtwitterinfo"; | |
1675 | ||
1676 | new Ajax.Request("backend.php", { | |
1677 | parameters: query, | |
1678 | onComplete: function(transport) { | |
1679 | notify_info("Twitter credentials have been cleared."); | |
1680 | updateFeedList(); | |
1681 | } }); | |
1682 | } | |
1683 | ||
1684 | } catch (e) { | |
1685 | exception_error("clearTwitterCredentials", e); | |
1686 | } | |
1687 | } | |
1688 | ||
1689 | function customizeCSS() { | |
1690 | try { | |
1691 | var query = "backend.php?op=dlg&id=customizeCSS"; | |
1692 | ||
1693 | if (dijit.byId("cssEditDlg")) | |
1694 | dijit.byId("cssEditDlg").destroyRecursive(); | |
1695 | ||
1696 | dialog = new dijit.Dialog({ | |
1697 | id: "cssEditDlg", | |
1698 | title: __("Customize stylesheet"), | |
1699 | style: "width: 600px", | |
1700 | execute: function() { | |
1701 | notify_progress('Saving data...', true); | |
1702 | new Ajax.Request("backend.php", { | |
1703 | parameters: dojo.objectToQuery(this.attr('value')), | |
1704 | onComplete: function(transport) { | |
1705 | notify(''); | |
1706 | window.location.reload(); | |
1707 | } }); | |
1708 | ||
1709 | }, | |
1710 | href: query}); | |
1711 | ||
1712 | dialog.show(); | |
1713 | ||
1714 | } catch (e) { | |
1715 | exception_error("customizeCSS", e); | |
1716 | } | |
1717 | } | |
1718 | ||
1719 | function insertSSLserial(value) { | |
1720 | try { | |
1721 | dijit.byId("SSL_CERT_SERIAL").attr('value', value); | |
1722 | } catch (e) { | |
1723 | exception_error("insertSSLcerial", e); | |
1724 | } | |
1725 | } |