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