]>
Commit | Line | Data |
---|---|---|
007bda35 AD |
1 | var xmlhttp = false; |
2 | ||
91ff844a | 3 | var active_feed_cat = false; |
f5a50b25 AD |
4 | var active_tab = false; |
5 | ||
a58069db | 6 | var xmlhttp = Ajax.getTransport(); |
007bda35 | 7 | |
a7565293 AD |
8 | var init_params = new Array(); |
9 | ||
e513a74a | 10 | var caller_subop = false; |
7a09510c | 11 | var sanity_check_done = false; |
746dcf42 | 12 | var hotkey_prefix = false; |
7a09510c | 13 | |
288487e4 AD |
14 | function infobox_callback() { |
15 | if (xmlhttp.readyState == 4) { | |
16 | infobox_callback2(xmlhttp); | |
17 | } | |
18 | } | |
19 | ||
20 | function infobox_submit_callback() { | |
21 | if (xmlhttp.readyState == 4) { | |
22 | infobox_submit_callback2(xmlhttp); | |
23 | } | |
24 | } | |
25 | ||
26 | ||
e4f4b46f | 27 | function replace_pubkey_callback() { |
c6232e43 AD |
28 | if (xmlhttp.readyState == 4) { |
29 | try { | |
e4f4b46f AD |
30 | var link = document.getElementById("pubGenAddress"); |
31 | ||
32 | if (xmlhttp.responseXML) { | |
33 | ||
945c243e AD |
34 | var new_link = xmlhttp.responseXML.getElementsByTagName("link")[0]; |
35 | ||
36 | if (new_link) { | |
37 | link.href = new_link.firstChild.nodeValue; | |
e635d56a | 38 | //link.innerHTML = new_link.firstChild.nodeValue; |
945c243e | 39 | |
3076c7b8 AD |
40 | new Effect.Highlight(link); |
41 | ||
e635d56a | 42 | notify_info("Published feed URL changed."); |
945c243e | 43 | } else { |
e635d56a | 44 | notify_error("Could not change feed URL."); |
945c243e | 45 | } |
e4f4b46f AD |
46 | |
47 | } else { | |
e635d56a | 48 | notify_error("Could not change feed URL."); |
e4f4b46f | 49 | } |
c6232e43 | 50 | } catch (e) { |
e4f4b46f | 51 | exception_error("replace_pubkey_callback", e); |
c6232e43 AD |
52 | } |
53 | } | |
945c243e | 54 | } |
c6232e43 | 55 | |
007bda35 | 56 | function feedlist_callback() { |
007bda35 | 57 | if (xmlhttp.readyState == 4) { |
47c6c988 AD |
58 | try { |
59 | var container = document.getElementById('prefContent'); | |
60 | container.innerHTML=xmlhttp.responseText; | |
a7f22b70 | 61 | selectTab("feedConfig", true); |
e513a74a AD |
62 | |
63 | if (caller_subop) { | |
64 | var tuple = caller_subop.split(":"); | |
65 | if (tuple[0] == 'editFeed') { | |
66 | window.setTimeout('editFeed('+tuple[1]+')', 100); | |
67 | } | |
68 | ||
69 | caller_subop = false; | |
70 | } | |
23943c9b AD |
71 | if (typeof correctPNG != 'undefined') { |
72 | correctPNG(); | |
73 | } | |
7f74a9da | 74 | notify(""); |
08827aaf AD |
75 | remove_splash(); |
76 | ||
47c6c988 AD |
77 | } catch (e) { |
78 | exception_error("feedlist_callback", e); | |
961513a3 | 79 | } |
007bda35 AD |
80 | } |
81 | } | |
82 | ||
442d77f1 AD |
83 | /* stub for subscription dialog */ |
84 | ||
288487e4 | 85 | function dlg_frefresh_callback(transport) { |
442d77f1 | 86 | |
288487e4 AD |
87 | try { |
88 | var container = document.getElementById('prefContent'); | |
89 | container.innerHTML=transport.responseText; | |
90 | selectTab("feedConfig", true); | |
442d77f1 | 91 | |
288487e4 AD |
92 | if (caller_subop) { |
93 | var tuple = caller_subop.split(":"); | |
94 | if (tuple[0] == 'editFeed') { | |
95 | window.setTimeout('editFeed('+tuple[1]+')', 100); | |
96 | } | |
442d77f1 | 97 | |
288487e4 | 98 | caller_subop = false; |
442d77f1 | 99 | } |
288487e4 AD |
100 | if (typeof correctPNG != 'undefined') { |
101 | correctPNG(); | |
102 | } | |
103 | notify(""); | |
104 | } catch (e) { | |
105 | exception_error("feedlist_callback", e); | |
442d77f1 | 106 | } |
288487e4 | 107 | |
442d77f1 AD |
108 | } |
109 | ||
a0d53889 | 110 | function filterlist_callback() { |
f5a50b25 | 111 | var container = document.getElementById('prefContent'); |
a0d53889 AD |
112 | if (xmlhttp.readyState == 4) { |
113 | container.innerHTML=xmlhttp.responseText; | |
23943c9b AD |
114 | if (typeof correctPNG != 'undefined') { |
115 | correctPNG(); | |
116 | } | |
7f74a9da | 117 | notify(""); |
08827aaf | 118 | remove_splash(); |
a0d53889 AD |
119 | } |
120 | } | |
121 | ||
48f0adb0 | 122 | function labellist_callback() { |
ceb30ba4 AD |
123 | |
124 | try { | |
125 | ||
126 | var container = document.getElementById('prefContent'); | |
127 | if (xmlhttp.readyState == 4) { | |
128 | closeInfoBox(); | |
129 | container.innerHTML=xmlhttp.responseText; | |
130 | ||
131 | if (document.getElementById("prefLabelList")) { | |
132 | var elems = document.getElementById("prefLabelList").getElementsByTagName("SPAN"); | |
133 | ||
134 | for (var i = 0; i < elems.length; i++) { | |
135 | if (elems[i].id && elems[i].id.match("LILT-")) { | |
136 | ||
137 | var id = elems[i].id.replace("LILT-", ""); | |
138 | new Ajax.InPlaceEditor(elems[i], | |
9c5e85fe AD |
139 | 'backend.php?op=pref-labels&subop=save&id=' + id, |
140 | {cols: 20, rows: 1}); | |
ceb30ba4 AD |
141 | } |
142 | } | |
48f0adb0 | 143 | } |
ceb30ba4 AD |
144 | |
145 | if (typeof correctPNG != 'undefined') { | |
146 | correctPNG(); | |
48f0adb0 | 147 | } |
ceb30ba4 AD |
148 | notify(""); |
149 | remove_splash(); | |
48f0adb0 | 150 | } |
ceb30ba4 AD |
151 | |
152 | } catch (e) { | |
153 | exception_error("labellist_callback", e); | |
48f0adb0 AD |
154 | } |
155 | } | |
4255b24c | 156 | |
c6232e43 AD |
157 | function feed_browser_callback() { |
158 | var container = document.getElementById('prefContent'); | |
159 | if (xmlhttp.readyState == 4) { | |
160 | container.innerHTML=xmlhttp.responseText; | |
7f74a9da | 161 | notify(""); |
08827aaf | 162 | remove_splash(); |
c6232e43 AD |
163 | } |
164 | } | |
165 | ||
e6cb77a0 AD |
166 | function userlist_callback() { |
167 | var container = document.getElementById('prefContent'); | |
168 | if (xmlhttp.readyState == 4) { | |
169 | container.innerHTML=xmlhttp.responseText; | |
7f74a9da | 170 | notify(""); |
08827aaf | 171 | remove_splash(); |
e6cb77a0 AD |
172 | } |
173 | } | |
174 | ||
4255b24c AD |
175 | function prefslist_callback() { |
176 | var container = document.getElementById('prefContent'); | |
177 | if (xmlhttp.readyState == 4) { | |
4255b24c | 178 | container.innerHTML=xmlhttp.responseText; |
7f74a9da | 179 | notify(""); |
08827aaf | 180 | remove_splash(); |
4255b24c AD |
181 | } |
182 | } | |
183 | ||
b1895692 AD |
184 | function gethelp_callback() { |
185 | var container = document.getElementById('prefHelpBox'); | |
186 | if (xmlhttp.readyState == 4) { | |
187 | ||
188 | container.innerHTML = xmlhttp.responseText; | |
189 | container.style.display = "block"; | |
190 | ||
191 | } | |
192 | } | |
4255b24c | 193 | |
0e091d38 | 194 | function notify_callback() { |
0e091d38 | 195 | if (xmlhttp.readyState == 4) { |
42c32916 AD |
196 | notify_info(xmlhttp.responseText); |
197 | } | |
0e091d38 AD |
198 | } |
199 | ||
b652c1b7 AD |
200 | function prefs_reset_callback() { |
201 | if (xmlhttp.readyState == 4) { | |
202 | notify_info(xmlhttp.responseText); | |
203 | selectTab(); | |
204 | } | |
205 | } | |
206 | ||
d95bd220 AD |
207 | |
208 | function changepass_callback() { | |
42395d28 AD |
209 | try { |
210 | if (xmlhttp.readyState == 4) { | |
211 | ||
212 | if (xmlhttp.responseText.indexOf("ERROR: ") == 0) { | |
213 | notify_error(xmlhttp.responseText.replace("ERROR: ", "")); | |
214 | } else { | |
215 | notify_info(xmlhttp.responseText); | |
216 | var warn = document.getElementById("default_pass_warning"); | |
217 | if (warn) warn.style.display = "none"; | |
218 | } | |
219 | ||
220 | document.forms['change_pass_form'].reset(); | |
d95bd220 | 221 | |
42395d28 AD |
222 | } |
223 | } catch (e) { | |
224 | exception_error("changepass_callback", e); | |
225 | } | |
d95bd220 AD |
226 | } |
227 | ||
8f708155 AD |
228 | function init_cat_inline_editor() { |
229 | try { | |
11f083e7 | 230 | |
8f708155 AD |
231 | if (document.getElementById("prefFeedCatList")) { |
232 | var elems = document.getElementById("prefFeedCatList").getElementsByTagName("SPAN"); | |
11f083e7 | 233 | |
8f708155 AD |
234 | for (var i = 0; i < elems.length; i++) { |
235 | if (elems[i].id && elems[i].id.match("FCATT-")) { | |
236 | var cat_id = elems[i].id.replace("FCATT-", ""); | |
11f083e7 | 237 | new Ajax.InPlaceEditor(elems[i], |
8f708155 | 238 | 'backend.php?op=pref-feeds&subop=editCats&action=save&cid=' + cat_id); |
11f083e7 AD |
239 | } |
240 | } | |
8f708155 AD |
241 | } |
242 | ||
243 | } catch (e) { | |
244 | exception_error("init_cat_inline_editor", e); | |
245 | } | |
246 | } | |
247 | ||
248 | function infobox_feed_cat_callback() { | |
249 | if (xmlhttp.readyState == 4) { | |
250 | try { | |
251 | ||
252 | infobox_callback(); | |
253 | init_cat_inline_editor(); | |
11f083e7 AD |
254 | |
255 | } catch (e) { | |
256 | exception_error("infobox_feed_cat_callback", e); | |
257 | } | |
258 | } | |
259 | } | |
260 | ||
b83c7545 | 261 | function updateFeedList(sort_key) { |
007bda35 | 262 | |
c0e5a40e | 263 | if (!xmlhttp_ready(xmlhttp)) { |
508a81e1 AD |
264 | printLockingError(); |
265 | return | |
266 | } | |
267 | ||
f932bc9f AD |
268 | var feed_search = document.getElementById("feed_search"); |
269 | var search = ""; | |
270 | if (feed_search) { search = feed_search.value; } | |
271 | ||
400b60d8 AD |
272 | var slat = document.getElementById("show_last_article_times"); |
273 | ||
274 | var slat_checked = false; | |
275 | if (slat) { | |
276 | slat_checked = slat.checked; | |
277 | } | |
278 | ||
b83c7545 | 279 | xmlhttp.open("GET", "backend.php?op=pref-feeds" + |
f932bc9f | 280 | "&sort=" + param_escape(sort_key) + |
400b60d8 | 281 | "&slat=" + param_escape(slat_checked) + |
f932bc9f | 282 | "&search=" + param_escape(search), true); |
007bda35 AD |
283 | xmlhttp.onreadystatechange=feedlist_callback; |
284 | xmlhttp.send(null); | |
285 | ||
286 | } | |
287 | ||
79ec0f2f | 288 | function updateUsersList(sort_key) { |
e6cb77a0 AD |
289 | |
290 | if (!xmlhttp_ready(xmlhttp)) { | |
291 | printLockingError(); | |
292 | return | |
293 | } | |
294 | ||
a5bd7bf0 AD |
295 | var user_search = document.getElementById("user_search"); |
296 | var search = ""; | |
297 | if (user_search) { search = user_search.value; } | |
298 | ||
79ec0f2f | 299 | xmlhttp.open("GET", "backend.php?op=pref-users&sort=" |
a5bd7bf0 AD |
300 | + param_escape(sort_key) + |
301 | "&search=" + param_escape(search), true); | |
e6cb77a0 AD |
302 | xmlhttp.onreadystatechange=userlist_callback; |
303 | xmlhttp.send(null); | |
304 | ||
305 | } | |
306 | ||
48f0adb0 AD |
307 | function addLabel() { |
308 | ||
ceb30ba4 AD |
309 | try { |
310 | ||
48f0adb0 AD |
311 | if (!xmlhttp_ready(xmlhttp)) { |
312 | printLockingError(); | |
313 | return | |
314 | } | |
315 | ||
ceb30ba4 | 316 | var caption = prompt(__("Please enter label caption:"), ""); |
48f0adb0 | 317 | |
4264f0b5 AD |
318 | if (caption == null) { |
319 | return false; | |
320 | } | |
321 | ||
ceb30ba4 | 322 | if (caption == "") { |
89cb787e | 323 | alert(__("Can't create label: missing caption.")); |
f156fd00 | 324 | return false; |
de435974 AD |
325 | } |
326 | ||
6068d33b AD |
327 | // we can be called from some other tab |
328 | active_tab = "labelConfig"; | |
329 | ||
ceb30ba4 AD |
330 | var query = "caption=" + param_escape(caption); |
331 | ||
f156fd00 AD |
332 | xmlhttp.open("GET", "backend.php?op=pref-labels&subop=add&" + query, true); |
333 | xmlhttp.onreadystatechange=infobox_submit_callback; | |
334 | xmlhttp.send(null); | |
ceb30ba4 AD |
335 | |
336 | } catch (e) { | |
337 | exception_error("addLabel", e); | |
338 | } | |
de435974 | 339 | } |
48f0adb0 | 340 | |
71ad3959 AD |
341 | function addFeed() { |
342 | ||
c0e5a40e | 343 | if (!xmlhttp_ready(xmlhttp)) { |
508a81e1 AD |
344 | printLockingError(); |
345 | return | |
346 | } | |
347 | ||
331900c6 AD |
348 | var link = document.getElementById("fadd_link"); |
349 | ||
83fe4d6d | 350 | if (link.value.length == 0) { |
f3977cf5 | 351 | alert(__("Error: No feed URL given.")); |
605f7d46 | 352 | } else if (!isValidURL(link.value)) { |
f3977cf5 | 353 | alert(__("Error: Invalid feed URL.")); |
331900c6 | 354 | } else { |
42c32916 | 355 | notify_progress("Adding feed..."); |
331900c6 | 356 | |
e513a74a | 357 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=add&from=tt-rss&feed_url=" + |
331900c6 AD |
358 | param_escape(link.value), true); |
359 | xmlhttp.onreadystatechange=feedlist_callback; | |
360 | xmlhttp.send(null); | |
361 | ||
362 | link.value = ""; | |
363 | ||
364 | } | |
365 | ||
366 | } | |
367 | ||
91ff844a AD |
368 | function addFeedCat() { |
369 | ||
370 | if (!xmlhttp_ready(xmlhttp)) { | |
371 | printLockingError(); | |
372 | return | |
373 | } | |
374 | ||
375 | var cat = document.getElementById("fadd_cat"); | |
376 | ||
377 | if (cat.value.length == 0) { | |
f3977cf5 | 378 | alert(__("Can't add category: no name specified.")); |
91ff844a | 379 | } else { |
42c32916 | 380 | notify_progress("Adding feed category..."); |
91ff844a | 381 | |
9c483746 | 382 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" + |
91ff844a | 383 | param_escape(cat.value), true); |
8f708155 | 384 | xmlhttp.onreadystatechange=infobox_feed_cat_callback; |
91ff844a AD |
385 | xmlhttp.send(null); |
386 | ||
387 | link.value = ""; | |
388 | ||
389 | } | |
390 | ||
391 | } | |
e6cb77a0 AD |
392 | function addUser() { |
393 | ||
394 | if (!xmlhttp_ready(xmlhttp)) { | |
395 | printLockingError(); | |
396 | return | |
397 | } | |
398 | ||
399 | var sqlexp = document.getElementById("uadd_box"); | |
400 | ||
401 | if (sqlexp.value.length == 0) { | |
89cb787e | 402 | alert(__("Can't add user: no login specified.")); |
e6cb77a0 | 403 | } else { |
42c32916 | 404 | notify_progress("Adding user..."); |
e6cb77a0 AD |
405 | |
406 | xmlhttp.open("GET", "backend.php?op=pref-users&subop=add&login=" + | |
407 | param_escape(sqlexp.value), true); | |
408 | ||
409 | xmlhttp.onreadystatechange=userlist_callback; | |
410 | xmlhttp.send(null); | |
411 | ||
412 | sqlexp.value = ""; | |
413 | } | |
414 | ||
415 | } | |
416 | ||
e6cb77a0 AD |
417 | function editUser(id) { |
418 | ||
419 | if (!xmlhttp_ready(xmlhttp)) { | |
420 | printLockingError(); | |
421 | return | |
422 | } | |
423 | ||
6068d33b AD |
424 | disableHotkeys(); |
425 | ||
9e31e1b9 AD |
426 | notify_progress("Loading, please wait..."); |
427 | ||
3c5783b7 AD |
428 | selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false); |
429 | selectTableRowById('UMRR-'+id, 'UMCHK-'+id, true); | |
e6cb77a0 | 430 | |
3e36a4f4 AD |
431 | disableContainerChildren("userOpToolbar", false); |
432 | ||
e6cb77a0 AD |
433 | xmlhttp.open("GET", "backend.php?op=pref-users&subop=edit&id=" + |
434 | param_escape(id), true); | |
3c5783b7 | 435 | xmlhttp.onreadystatechange=infobox_callback; |
e6cb77a0 AD |
436 | xmlhttp.send(null); |
437 | ||
438 | } | |
439 | ||
a0d53889 AD |
440 | function editFilter(id) { |
441 | ||
442 | if (!xmlhttp_ready(xmlhttp)) { | |
443 | printLockingError(); | |
444 | return | |
445 | } | |
446 | ||
6068d33b AD |
447 | disableHotkeys(); |
448 | ||
9e31e1b9 AD |
449 | notify_progress("Loading, please wait..."); |
450 | ||
38bb1ceb | 451 | // document.getElementById("create_filter_btn").disabled = true; |
4220b0bd | 452 | |
3e36a4f4 AD |
453 | disableContainerChildren("filterOpToolbar", false); |
454 | ||
07164479 AD |
455 | selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false); |
456 | selectTableRowById('FILRR-'+id, 'FICHK-'+id, true); | |
a0d53889 | 457 | |
07164479 AD |
458 | xmlhttp.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id), true); |
459 | xmlhttp.onreadystatechange=infobox_callback; | |
a0d53889 | 460 | xmlhttp.send(null); |
a0d53889 AD |
461 | } |
462 | ||
331900c6 AD |
463 | function editFeed(feed) { |
464 | ||
508a81e1 AD |
465 | // notify("Editing feed..."); |
466 | ||
c0e5a40e | 467 | if (!xmlhttp_ready(xmlhttp)) { |
508a81e1 AD |
468 | printLockingError(); |
469 | return | |
470 | } | |
331900c6 | 471 | |
6068d33b AD |
472 | disableHotkeys(); |
473 | ||
9e31e1b9 AD |
474 | notify_progress("Loading, please wait..."); |
475 | ||
38bb1ceb | 476 | /* document.getElementById("subscribe_to_feed_btn").disabled = true; |
a349077c AD |
477 | |
478 | try { | |
479 | document.getElementById("top25_feeds_btn").disabled = true; | |
480 | } catch (e) { | |
481 | // this button is not always available, no-op if not found | |
38bb1ceb | 482 | } */ |
a349077c | 483 | |
673d54ca | 484 | // clean selection from all rows & select row being edited |
0ea4fb50 | 485 | selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false); |
6c12c809 | 486 | selectTableRowById('FEEDR-'+feed, 'FRCHK-'+feed, true); |
0ea4fb50 | 487 | |
3e36a4f4 AD |
488 | disableContainerChildren("feedOpToolbar", false); |
489 | ||
0ea4fb50 | 490 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" + |
3c5783b7 | 491 | param_escape(feed), true); |
0ea4fb50 AD |
492 | |
493 | xmlhttp.onreadystatechange=infobox_callback; | |
331900c6 AD |
494 | xmlhttp.send(null); |
495 | ||
496 | } | |
497 | ||
91ff844a | 498 | function editFeedCat(cat) { |
48f0adb0 | 499 | |
91ff844a AD |
500 | if (!xmlhttp_ready(xmlhttp)) { |
501 | printLockingError(); | |
502 | return | |
48f0adb0 AD |
503 | } |
504 | ||
6068d33b AD |
505 | disableHotkeys(); |
506 | ||
9e31e1b9 AD |
507 | notify_progress("Loading, please wait..."); |
508 | ||
91ff844a | 509 | active_feed_cat = cat; |
e6cb77a0 | 510 | |
9c483746 | 511 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=edit&id=" + |
91ff844a | 512 | param_escape(cat), true); |
9c483746 | 513 | xmlhttp.onreadystatechange=infobox_callback; |
91ff844a | 514 | xmlhttp.send(null); |
e6cb77a0 | 515 | |
e6cb77a0 AD |
516 | } |
517 | ||
91ff844a AD |
518 | function getSelectedLabels() { |
519 | return getSelectedTableRowIds("prefLabelList", "LILRR"); | |
520 | } | |
48f0adb0 | 521 | |
91ff844a AD |
522 | function getSelectedUsers() { |
523 | return getSelectedTableRowIds("prefUserList", "UMRR"); | |
a0d53889 AD |
524 | } |
525 | ||
83fe4d6d | 526 | function getSelectedFeeds() { |
91ff844a AD |
527 | return getSelectedTableRowIds("prefFeedList", "FEEDR"); |
528 | } | |
331900c6 | 529 | |
91ff844a AD |
530 | function getSelectedFilters() { |
531 | return getSelectedTableRowIds("prefFilterList", "FILRR"); | |
532 | } | |
331900c6 | 533 | |
91ff844a AD |
534 | function getSelectedFeedCats() { |
535 | return getSelectedTableRowIds("prefFeedCatList", "FCATR"); | |
83fe4d6d AD |
536 | } |
537 | ||
c0ae0fdb | 538 | |
48f0adb0 AD |
539 | function removeSelectedLabels() { |
540 | ||
541 | if (!xmlhttp_ready(xmlhttp)) { | |
542 | printLockingError(); | |
543 | return | |
544 | } | |
545 | ||
546 | var sel_rows = getSelectedLabels(); | |
547 | ||
548 | if (sel_rows.length > 0) { | |
549 | ||
f56e3080 | 550 | var ok = confirm(__("Remove selected labels?")); |
48f0adb0 | 551 | |
69668465 | 552 | if (ok) { |
42c32916 | 553 | notify_progress("Removing selected labels..."); |
69668465 AD |
554 | |
555 | xmlhttp.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+ | |
556 | param_escape(sel_rows.toString()), true); | |
557 | xmlhttp.onreadystatechange=labellist_callback; | |
558 | xmlhttp.send(null); | |
559 | } | |
48f0adb0 | 560 | } else { |
89cb787e | 561 | alert(__("No labels are selected.")); |
48f0adb0 | 562 | } |
90ac84df AD |
563 | |
564 | return false; | |
48f0adb0 AD |
565 | } |
566 | ||
e6cb77a0 AD |
567 | function removeSelectedUsers() { |
568 | ||
569 | if (!xmlhttp_ready(xmlhttp)) { | |
570 | printLockingError(); | |
571 | return | |
572 | } | |
573 | ||
574 | var sel_rows = getSelectedUsers(); | |
575 | ||
576 | if (sel_rows.length > 0) { | |
577 | ||
f56e3080 | 578 | var ok = confirm(__("Remove selected users?")); |
e6cb77a0 | 579 | |
69668465 | 580 | if (ok) { |
42c32916 | 581 | notify_progress("Removing selected users..."); |
69668465 AD |
582 | |
583 | xmlhttp.open("GET", "backend.php?op=pref-users&subop=remove&ids="+ | |
584 | param_escape(sel_rows.toString()), true); | |
585 | xmlhttp.onreadystatechange=userlist_callback; | |
586 | xmlhttp.send(null); | |
587 | } | |
e6cb77a0 AD |
588 | |
589 | } else { | |
89cb787e | 590 | alert(__("No users are selected.")); |
e6cb77a0 | 591 | } |
90ac84df AD |
592 | |
593 | return false; | |
e6cb77a0 AD |
594 | } |
595 | ||
48f0adb0 AD |
596 | function removeSelectedFilters() { |
597 | ||
598 | if (!xmlhttp_ready(xmlhttp)) { | |
599 | printLockingError(); | |
600 | return | |
601 | } | |
602 | ||
603 | var sel_rows = getSelectedFilters(); | |
604 | ||
605 | if (sel_rows.length > 0) { | |
606 | ||
f56e3080 | 607 | var ok = confirm(__("Remove selected filters?")); |
48f0adb0 | 608 | |
69668465 | 609 | if (ok) { |
42c32916 | 610 | notify_progress("Removing selected filters..."); |
69668465 AD |
611 | |
612 | xmlhttp.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+ | |
613 | param_escape(sel_rows.toString()), true); | |
614 | xmlhttp.onreadystatechange=filterlist_callback; | |
615 | xmlhttp.send(null); | |
616 | } | |
48f0adb0 | 617 | } else { |
89cb787e | 618 | alert(__("No filters are selected.")); |
48f0adb0 | 619 | } |
90ac84df AD |
620 | |
621 | return false; | |
48f0adb0 AD |
622 | } |
623 | ||
624 | ||
83fe4d6d AD |
625 | function removeSelectedFeeds() { |
626 | ||
c0e5a40e | 627 | if (!xmlhttp_ready(xmlhttp)) { |
508a81e1 AD |
628 | printLockingError(); |
629 | return | |
630 | } | |
631 | ||
83fe4d6d AD |
632 | var sel_rows = getSelectedFeeds(); |
633 | ||
331900c6 AD |
634 | if (sel_rows.length > 0) { |
635 | ||
f56e3080 | 636 | var ok = confirm(__("Unsubscribe from selected feeds?")); |
331900c6 | 637 | |
69668465 AD |
638 | if (ok) { |
639 | ||
42c32916 | 640 | notify_progress("Unsubscribing from selected feeds..."); |
69668465 AD |
641 | |
642 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+ | |
643 | param_escape(sel_rows.toString()), true); | |
644 | xmlhttp.onreadystatechange=feedlist_callback; | |
645 | xmlhttp.send(null); | |
646 | } | |
71ad3959 | 647 | |
71ad3959 | 648 | } else { |
331900c6 | 649 | |
89cb787e | 650 | alert(__("No feeds are selected.")); |
331900c6 | 651 | |
71ad3959 | 652 | } |
90ac84df AD |
653 | |
654 | return false; | |
71ad3959 | 655 | } |
007bda35 | 656 | |
c4a36709 AD |
657 | function clearSelectedFeeds() { |
658 | ||
659 | if (!xmlhttp_ready(xmlhttp)) { | |
660 | printLockingError(); | |
661 | return | |
662 | } | |
663 | ||
664 | var sel_rows = getSelectedFeeds(); | |
665 | ||
666 | if (sel_rows.length > 1) { | |
667 | alert(__("Please select only one feed.")); | |
668 | return; | |
669 | } | |
670 | ||
671 | if (sel_rows.length > 0) { | |
672 | ||
673 | var ok = confirm(__("Erase all non-starred articles in selected feed?")); | |
674 | ||
675 | if (ok) { | |
676 | notify_progress("Clearing selected feed..."); | |
677 | clearFeedArticles(sel_rows[0]); | |
678 | } | |
679 | ||
680 | } else { | |
681 | ||
682 | alert(__("No feeds are selected.")); | |
683 | ||
684 | } | |
685 | ||
686 | return false; | |
687 | } | |
688 | ||
e88a65f4 AD |
689 | function purgeSelectedFeeds() { |
690 | ||
691 | if (!xmlhttp_ready(xmlhttp)) { | |
692 | printLockingError(); | |
693 | return | |
694 | } | |
695 | ||
696 | var sel_rows = getSelectedFeeds(); | |
697 | ||
698 | if (sel_rows.length > 0) { | |
699 | ||
700 | var pr = prompt(__("How many days of articles to keep (0 - use default)?"), "0"); | |
701 | ||
702 | if (pr != undefined) { | |
703 | notify_progress("Purging selected feed..."); | |
704 | ||
705 | var query = "backend.php?op=rpc&subop=purge&ids="+ | |
706 | param_escape(sel_rows.toString()) + "&days=" + pr; | |
707 | ||
708 | debug(query); | |
709 | ||
710 | new Ajax.Request(query, { | |
711 | onComplete: function(transport) { | |
712 | notify(''); | |
713 | } }); | |
714 | } | |
715 | ||
716 | } else { | |
717 | ||
718 | alert(__("No feeds are selected.")); | |
719 | ||
720 | } | |
721 | ||
722 | return false; | |
723 | } | |
724 | ||
91ff844a AD |
725 | function removeSelectedFeedCats() { |
726 | ||
727 | if (!xmlhttp_ready(xmlhttp)) { | |
728 | printLockingError(); | |
729 | return | |
730 | } | |
731 | ||
732 | var sel_rows = getSelectedFeedCats(); | |
733 | ||
734 | if (sel_rows.length > 0) { | |
735 | ||
f56e3080 | 736 | var ok = confirm(__("Remove selected categories?")); |
91ff844a | 737 | |
69668465 | 738 | if (ok) { |
42c32916 | 739 | notify_progress("Removing selected categories..."); |
69668465 | 740 | |
9c483746 | 741 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+ |
69668465 | 742 | param_escape(sel_rows.toString()), true); |
8f708155 | 743 | xmlhttp.onreadystatechange=infobox_feed_cat_callback; |
69668465 AD |
744 | xmlhttp.send(null); |
745 | } | |
91ff844a AD |
746 | |
747 | } else { | |
748 | ||
89cb787e | 749 | alert(__("No categories are selected.")); |
91ff844a AD |
750 | |
751 | } | |
752 | ||
90ac84df | 753 | return false; |
91ff844a AD |
754 | } |
755 | ||
508a81e1 AD |
756 | function feedEditCancel() { |
757 | ||
c0e5a40e | 758 | if (!xmlhttp_ready(xmlhttp)) { |
508a81e1 AD |
759 | printLockingError(); |
760 | return | |
761 | } | |
762 | ||
a349077c | 763 | try { |
57f734c8 | 764 | document.getElementById("subscribe_to_feed_btn").disabled = false; |
a349077c AD |
765 | document.getElementById("top25_feeds_btn").disabled = false; |
766 | } catch (e) { | |
767 | // this button is not always available, no-op if not found | |
768 | } | |
769 | ||
327a3bbe AD |
770 | closeInfoBox(); |
771 | ||
673d54ca | 772 | selectPrefRows('feed', false); // cleanup feed selection |
508a81e1 | 773 | |
90ac84df | 774 | return false; |
508a81e1 AD |
775 | } |
776 | ||
91ff844a AD |
777 | function feedCatEditCancel() { |
778 | ||
779 | if (!xmlhttp_ready(xmlhttp)) { | |
780 | printLockingError(); | |
781 | return | |
782 | } | |
783 | ||
784 | active_feed_cat = false; | |
785 | ||
3381c755 AD |
786 | try { |
787 | document.getElementById("subscribe_to_feed_btn").disabled = false; | |
788 | document.getElementById("top25_feeds_btn").disabled = false; | |
789 | } catch (e) { | |
790 | // this button is not always available, no-op if not found | |
791 | } | |
91ff844a | 792 | |
9c483746 AD |
793 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats", true); |
794 | xmlhttp.onreadystatechange=infobox_callback; | |
91ff844a AD |
795 | xmlhttp.send(null); |
796 | ||
90ac84df | 797 | return false; |
91ff844a AD |
798 | } |
799 | ||
603c27f8 AD |
800 | function feedEditSave() { |
801 | ||
47c6c988 | 802 | try { |
47c6c988 AD |
803 | |
804 | if (!xmlhttp_ready(xmlhttp)) { | |
805 | printLockingError(); | |
806 | return | |
807 | } | |
ad815c71 | 808 | |
14f69488 | 809 | // FIXME: add parameter validation |
e3c99f3b | 810 | |
14f69488 | 811 | var query = Form.serialize("edit_feed_form"); |
b0da3a7b | 812 | |
42c32916 | 813 | notify_progress("Saving feed..."); |
673d54ca | 814 | |
47c6c988 AD |
815 | xmlhttp.open("POST", "backend.php", true); |
816 | xmlhttp.onreadystatechange=feedlist_callback; | |
817 | xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); | |
14f69488 AD |
818 | xmlhttp.send(query); |
819 | ||
59a543f0 AD |
820 | closeInfoBox(); |
821 | ||
c14b5566 AD |
822 | return false; |
823 | ||
47c6c988 AD |
824 | } catch (e) { |
825 | exception_error("feedEditSave", e); | |
b0da3a7b | 826 | } |
508a81e1 AD |
827 | } |
828 | ||
e6cb77a0 AD |
829 | function userEditCancel() { |
830 | ||
831 | if (!xmlhttp_ready(xmlhttp)) { | |
832 | printLockingError(); | |
833 | return | |
834 | } | |
835 | ||
3c5783b7 | 836 | selectPrefRows('user', false); // cleanup feed selection |
3c5783b7 | 837 | closeInfoBox(); |
90ac84df AD |
838 | |
839 | return false; | |
e6cb77a0 | 840 | } |
48f0adb0 | 841 | |
a0d53889 AD |
842 | function filterEditCancel() { |
843 | ||
844 | if (!xmlhttp_ready(xmlhttp)) { | |
845 | printLockingError(); | |
846 | return | |
847 | } | |
4220b0bd | 848 | |
57f734c8 AD |
849 | try { |
850 | document.getElementById("create_filter_btn").disabled = false; | |
851 | selectPrefRows('filter', false); // cleanup feed selection | |
852 | } catch (e) { } | |
853 | ||
07164479 | 854 | closeInfoBox(); |
90ac84df AD |
855 | |
856 | return false; | |
a0d53889 AD |
857 | } |
858 | ||
e6cb77a0 AD |
859 | function userEditSave() { |
860 | ||
e6cb77a0 AD |
861 | if (!xmlhttp_ready(xmlhttp)) { |
862 | printLockingError(); | |
863 | return | |
864 | } | |
865 | ||
3c5783b7 | 866 | var login = document.forms["user_edit_form"].login.value; |
e6cb77a0 AD |
867 | |
868 | if (login.length == 0) { | |
89cb787e | 869 | alert(__("Login field cannot be blank.")); |
e6cb77a0 AD |
870 | return; |
871 | } | |
3c5783b7 | 872 | |
42c32916 | 873 | notify_progress("Saving user..."); |
4220b0bd AD |
874 | |
875 | closeInfoBox(); | |
876 | ||
3c5783b7 AD |
877 | var query = Form.serialize("user_edit_form"); |
878 | ||
879 | xmlhttp.open("GET", "backend.php?" + query, true); | |
dbd9e2f1 | 880 | xmlhttp.onreadystatechange=userlist_callback; |
e6cb77a0 | 881 | xmlhttp.send(null); |
90ac84df AD |
882 | |
883 | return false; | |
e6cb77a0 AD |
884 | } |
885 | ||
886 | ||
a0d53889 AD |
887 | function filterEditSave() { |
888 | ||
a0d53889 AD |
889 | if (!xmlhttp_ready(xmlhttp)) { |
890 | printLockingError(); | |
891 | return | |
892 | } | |
893 | ||
9ee3ac59 | 894 | /* if (!is_opera()) { |
7c620da8 AD |
895 | var reg_exp = document.forms["filter_edit_form"].reg_exp.value; |
896 | ||
897 | if (reg_exp.length == 0) { | |
898 | alert("Filter expression field cannot be blank."); | |
899 | return; | |
900 | } | |
9ee3ac59 | 901 | } */ |
a0d53889 | 902 | |
42c32916 | 903 | notify_progress("Saving filter..."); |
a0d53889 | 904 | |
7e939457 | 905 | var query = Form.serialize("filter_edit_form"); |
dbd9e2f1 | 906 | |
07164479 AD |
907 | closeInfoBox(); |
908 | ||
4220b0bd AD |
909 | document.getElementById("create_filter_btn").disabled = false; |
910 | ||
7e939457 | 911 | xmlhttp.open("GET", "backend.php?" + query, true); |
a0d53889 | 912 | xmlhttp.onreadystatechange=filterlist_callback; |
7e939457 | 913 | xmlhttp.send(null); |
a0d53889 | 914 | |
90ac84df | 915 | return false; |
a0d53889 AD |
916 | } |
917 | ||
a0d53889 | 918 | |
e6cb77a0 AD |
919 | function editSelectedUser() { |
920 | var rows = getSelectedUsers(); | |
921 | ||
922 | if (rows.length == 0) { | |
f3977cf5 | 923 | alert(__("No users are selected.")); |
e6cb77a0 AD |
924 | return; |
925 | } | |
926 | ||
927 | if (rows.length > 1) { | |
f3977cf5 | 928 | alert(__("Please select only one user.")); |
e6cb77a0 AD |
929 | return; |
930 | } | |
931 | ||
dbd9e2f1 AD |
932 | notify(""); |
933 | ||
e6cb77a0 AD |
934 | editUser(rows[0]); |
935 | } | |
936 | ||
937 | function resetSelectedUserPass() { | |
938 | var rows = getSelectedUsers(); | |
939 | ||
940 | if (rows.length == 0) { | |
f3977cf5 | 941 | alert(__("No users are selected.")); |
e6cb77a0 AD |
942 | return; |
943 | } | |
944 | ||
945 | if (rows.length > 1) { | |
f3977cf5 | 946 | alert(__("Please select only one user.")); |
e6cb77a0 AD |
947 | return; |
948 | } | |
949 | ||
f3977cf5 | 950 | var ok = confirm(__("Reset password of selected user?")); |
e6cb77a0 | 951 | |
69668465 | 952 | if (ok) { |
42c32916 | 953 | notify_progress("Resetting password for selected user..."); |
69668465 AD |
954 | |
955 | var id = rows[0]; | |
956 | ||
957 | xmlhttp.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" + | |
958 | param_escape(id), true); | |
959 | xmlhttp.onreadystatechange=userlist_callback; | |
960 | xmlhttp.send(null); | |
961 | } | |
e6cb77a0 AD |
962 | } |
963 | ||
717f5e64 | 964 | function selectedUserDetails() { |
e6cb77a0 | 965 | |
1a7572cb AD |
966 | if (!xmlhttp_ready(xmlhttp)) { |
967 | printLockingError(); | |
968 | return | |
969 | } | |
970 | ||
717f5e64 AD |
971 | var rows = getSelectedUsers(); |
972 | ||
973 | if (rows.length == 0) { | |
f3977cf5 | 974 | alert(__("No users are selected.")); |
717f5e64 AD |
975 | return; |
976 | } | |
977 | ||
978 | if (rows.length > 1) { | |
f3977cf5 | 979 | alert(__("Please select only one user.")); |
717f5e64 AD |
980 | return; |
981 | } | |
982 | ||
0077a65c | 983 | notify_progress("Loading, please wait..."); |
717f5e64 | 984 | |
0077a65c | 985 | var id = rows[0]; |
dbd9e2f1 | 986 | |
5a437c88 | 987 | xmlhttp.open("GET", "backend.php?op=pref-users&subop=user-details&id=" + id, true); |
c6c3a07f AD |
988 | xmlhttp.onreadystatechange=infobox_callback; |
989 | xmlhttp.send(null); | |
990 | ||
991 | } | |
992 | ||
993 | function selectedFeedDetails() { | |
994 | ||
995 | if (!xmlhttp_ready(xmlhttp)) { | |
996 | printLockingError(); | |
997 | return | |
998 | } | |
999 | ||
1000 | var rows = getSelectedFeeds(); | |
1001 | ||
1002 | if (rows.length == 0) { | |
f3977cf5 | 1003 | alert(__("No feeds are selected.")); |
c6c3a07f AD |
1004 | return; |
1005 | } | |
1006 | ||
01b3e191 | 1007 | if (rows.length > 1) { |
f3977cf5 | 1008 | alert(__("Please select only one feed.")); |
01b3e191 AD |
1009 | return; |
1010 | } | |
c6c3a07f | 1011 | |
df268d47 | 1012 | // var id = rows[0]; |
c6c3a07f | 1013 | |
dbd9e2f1 AD |
1014 | notify(""); |
1015 | ||
df268d47 AD |
1016 | xmlhttp.open("GET", "backend.php?op=feed-details&id=" + |
1017 | param_escape(rows.toString()), true); | |
c6c3a07f | 1018 | xmlhttp.onreadystatechange=infobox_callback; |
1a7572cb | 1019 | xmlhttp.send(null); |
717f5e64 AD |
1020 | |
1021 | } | |
a0d53889 AD |
1022 | |
1023 | function editSelectedFilter() { | |
1024 | var rows = getSelectedFilters(); | |
1025 | ||
1026 | if (rows.length == 0) { | |
f3977cf5 | 1027 | alert(__("No filters are selected.")); |
a0d53889 AD |
1028 | return; |
1029 | } | |
1030 | ||
1031 | if (rows.length > 1) { | |
f3977cf5 | 1032 | alert(__("Please select only one filter.")); |
a0d53889 AD |
1033 | return; |
1034 | } | |
1035 | ||
dbd9e2f1 AD |
1036 | notify(""); |
1037 | ||
a0d53889 AD |
1038 | editFilter(rows[0]); |
1039 | ||
1040 | } | |
1041 | ||
1042 | ||
508a81e1 AD |
1043 | function editSelectedFeed() { |
1044 | var rows = getSelectedFeeds(); | |
1045 | ||
1046 | if (rows.length == 0) { | |
f3977cf5 | 1047 | alert(__("No feeds are selected.")); |
508a81e1 AD |
1048 | return; |
1049 | } | |
1050 | ||
1051 | if (rows.length > 1) { | |
f3977cf5 | 1052 | alert(__("Please select one feed.")); |
508a81e1 AD |
1053 | return; |
1054 | } | |
1055 | ||
dbd9e2f1 AD |
1056 | notify(""); |
1057 | ||
508a81e1 | 1058 | editFeed(rows[0]); |
91ff844a AD |
1059 | |
1060 | } | |
1061 | ||
758e1c4a AD |
1062 | function editSelectedFeeds() { |
1063 | ||
1064 | if (!xmlhttp_ready(xmlhttp)) { | |
1065 | printLockingError(); | |
1066 | return | |
1067 | } | |
1068 | ||
1069 | var rows = getSelectedFeeds(); | |
1070 | ||
1071 | if (rows.length == 0) { | |
1072 | alert(__("No feeds are selected.")); | |
1073 | return; | |
1074 | } | |
1075 | ||
1076 | notify(""); | |
1077 | ||
1078 | disableHotkeys(); | |
1079 | ||
1080 | notify_progress("Loading, please wait..."); | |
1081 | ||
1082 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editfeeds&ids=" + | |
1083 | param_escape(rows.toString()), true); | |
1084 | ||
1085 | xmlhttp.onreadystatechange=infobox_callback; | |
1086 | xmlhttp.send(null); | |
1087 | ||
1088 | } | |
1089 | ||
91ff844a AD |
1090 | function editSelectedFeedCat() { |
1091 | var rows = getSelectedFeedCats(); | |
1092 | ||
1093 | if (rows.length == 0) { | |
f3977cf5 | 1094 | alert(__("No categories are selected.")); |
91ff844a AD |
1095 | return; |
1096 | } | |
1097 | ||
1098 | if (rows.length > 1) { | |
f3977cf5 | 1099 | alert(__("Please select only one category.")); |
91ff844a AD |
1100 | return; |
1101 | } | |
1102 | ||
1103 | notify(""); | |
1104 | ||
1105 | editFeedCat(rows[0]); | |
508a81e1 AD |
1106 | |
1107 | } | |
1108 | ||
eec498c3 | 1109 | function piggie(enable) { |
13ad9102 | 1110 | if (enable) { |
d437c8cf | 1111 | debug("I LOVEDED IT!"); |
1cac3c31 | 1112 | var piggie = document.getElementById("piggie"); |
33377ef3 | 1113 | |
537625c6 AD |
1114 | Element.show(piggie); |
1115 | Position.Center(piggie); | |
1116 | Effect.Puff(piggie); | |
1117 | ||
508a81e1 | 1118 | } |
508a81e1 AD |
1119 | } |
1120 | ||
9f311df6 AD |
1121 | function validateOpmlImport() { |
1122 | ||
1123 | var opml_file = document.getElementById("opml_file"); | |
1124 | ||
1125 | if (opml_file.value.length == 0) { | |
f3977cf5 | 1126 | alert(__("No OPML file to upload.")); |
9f311df6 AD |
1127 | return false; |
1128 | } else { | |
1129 | return true; | |
1130 | } | |
1131 | } | |
1132 | ||
0e317f9d | 1133 | function updateFilterList(sort_key) { |
a0d53889 AD |
1134 | |
1135 | if (!xmlhttp_ready(xmlhttp)) { | |
1136 | printLockingError(); | |
1137 | return | |
1138 | } | |
1139 | ||
9c87d75c AD |
1140 | var filter_search = document.getElementById("filter_search"); |
1141 | var search = ""; | |
1142 | if (filter_search) { search = filter_search.value; } | |
1143 | ||
e161a2cc | 1144 | xmlhttp.open("GET", "backend.php?op=pref-filters&sort=" + |
9c87d75c AD |
1145 | param_escape(sort_key) + |
1146 | "&search=" + param_escape(search), true); | |
a0d53889 AD |
1147 | xmlhttp.onreadystatechange=filterlist_callback; |
1148 | xmlhttp.send(null); | |
1149 | ||
1150 | } | |
1151 | ||
e161a2cc | 1152 | function updateLabelList(sort_key) { |
48f0adb0 AD |
1153 | |
1154 | if (!xmlhttp_ready(xmlhttp)) { | |
1155 | printLockingError(); | |
1156 | return | |
1157 | } | |
1158 | ||
112d2aec AD |
1159 | var label_search = document.getElementById("label_search"); |
1160 | var search = ""; | |
1161 | if (label_search) { search = label_search.value; } | |
1162 | ||
e161a2cc | 1163 | xmlhttp.open("GET", "backend.php?op=pref-labels&sort=" + |
112d2aec AD |
1164 | param_escape(sort_key) + |
1165 | "&search=" + param_escape(search), true); | |
48f0adb0 AD |
1166 | xmlhttp.onreadystatechange=labellist_callback; |
1167 | xmlhttp.send(null); | |
48f0adb0 AD |
1168 | } |
1169 | ||
4255b24c AD |
1170 | function updatePrefsList() { |
1171 | ||
1172 | if (!xmlhttp_ready(xmlhttp)) { | |
1173 | printLockingError(); | |
1174 | return | |
1175 | } | |
1176 | ||
4255b24c AD |
1177 | xmlhttp.open("GET", "backend.php?op=pref-prefs", true); |
1178 | xmlhttp.onreadystatechange=prefslist_callback; | |
1179 | xmlhttp.send(null); | |
1180 | ||
1181 | } | |
1182 | ||
e513a74a | 1183 | function selectTab(id, noupdate, subop) { |
a7f22b70 AD |
1184 | |
1185 | // alert(id); | |
48f0adb0 | 1186 | |
b2caf812 | 1187 | if (!id) id = active_tab; |
7f74a9da | 1188 | |
b2caf812 | 1189 | try { |
59a543f0 | 1190 | |
b2caf812 AD |
1191 | if (!xmlhttp_ready(xmlhttp)) { |
1192 | printLockingError(); | |
1193 | return | |
a7f22b70 | 1194 | } |
f5a50b25 | 1195 | |
a422968f AD |
1196 | try { |
1197 | var c = document.getElementById('prefContent'); | |
1198 | c.scrollTop = 0; | |
1199 | } catch (e) { }; | |
1200 | ||
b2caf812 | 1201 | if (!noupdate) { |
f5a50b25 | 1202 | |
b2caf812 AD |
1203 | debug("selectTab: " + id + "(NU: " + noupdate + ")"); |
1204 | ||
9e31e1b9 | 1205 | notify_progress("Loading, please wait..."); |
b2caf812 AD |
1206 | |
1207 | // close active infobox if needed | |
1208 | closeInfoBox(); | |
1209 | ||
1210 | // clean up all current selections, just in case | |
1211 | active_feed_cat = false; | |
d15f8675 AD |
1212 | |
1213 | // Effect.Fade("prefContent", {duration: 1, to: 0.01, | |
1214 | // queue: { position:'end', scope: 'FEED_TAB', limit: 1 } } ); | |
1215 | ||
b2caf812 AD |
1216 | if (id == "feedConfig") { |
1217 | updateFeedList(); | |
1218 | } else if (id == "filterConfig") { | |
1219 | updateFilterList(); | |
1220 | } else if (id == "labelConfig") { | |
1221 | updateLabelList(); | |
1222 | } else if (id == "genConfig") { | |
1223 | updatePrefsList(); | |
1224 | } else if (id == "userConfig") { | |
1225 | updateUsersList(); | |
b2caf812 | 1226 | } |
f5a50b25 | 1227 | } |
6068d33b AD |
1228 | |
1229 | /* clean selection from all tabs */ | |
b2caf812 | 1230 | |
6068d33b AD |
1231 | var tabs_holder = document.getElementById("prefTabs"); |
1232 | var tab = tabs_holder.firstChild; | |
1233 | ||
1234 | while (tab) { | |
1235 | if (tab.className && tab.className.match("prefsTabSelected")) { | |
b2caf812 AD |
1236 | tab.className = "prefsTab"; |
1237 | } | |
6068d33b | 1238 | tab = tab.nextSibling; |
f5a50b25 | 1239 | } |
6068d33b AD |
1240 | |
1241 | /* mark new tab as selected */ | |
1242 | ||
b2caf812 AD |
1243 | tab = document.getElementById(id + "Tab"); |
1244 | ||
1245 | if (tab) { | |
1246 | if (!tab.className.match("Selected")) { | |
1247 | tab.className = tab.className + "Selected"; | |
1248 | } | |
1249 | } | |
1250 | ||
b2caf812 | 1251 | active_tab = id; |
f5a50b25 | 1252 | |
b2caf812 AD |
1253 | } catch (e) { |
1254 | exception_error("selectTab", e); | |
a7565293 | 1255 | } |
a7565293 AD |
1256 | } |
1257 | ||
1258 | function backend_sanity_check_callback() { | |
f5a50b25 | 1259 | |
a7565293 AD |
1260 | if (xmlhttp.readyState == 4) { |
1261 | ||
1262 | try { | |
7a09510c AD |
1263 | |
1264 | if (sanity_check_done) { | |
81352b54 AD |
1265 | fatalError(11, "Sanity check request received twice. This can indicate "+ |
1266 | "presence of Firebug or some other disrupting extension. "+ | |
1267 | "Please disable it and try again."); | |
7a09510c AD |
1268 | return; |
1269 | } | |
1270 | ||
a7565293 | 1271 | if (!xmlhttp.responseXML) { |
64b3069d AD |
1272 | fatalError(3, "Sanity Check: Received reply is not XML", |
1273 | xmlhttp.responseText); | |
a7565293 AD |
1274 | return; |
1275 | } | |
1276 | ||
1277 | var reply = xmlhttp.responseXML.firstChild.firstChild; | |
1278 | ||
1279 | if (!reply) { | |
64b3069d | 1280 | fatalError(3, "Sanity Check: Invalid RPC reply", xmlhttp.responseText); |
a7565293 AD |
1281 | return; |
1282 | } | |
1283 | ||
1284 | var error_code = reply.getAttribute("error-code"); | |
1285 | ||
1286 | if (error_code && error_code != 0) { | |
1287 | return fatalError(error_code, reply.getAttribute("error-msg")); | |
1288 | } | |
1289 | ||
1290 | debug("sanity check ok"); | |
1291 | ||
1292 | var params = reply.nextSibling; | |
1293 | ||
1294 | if (params) { | |
1295 | debug('reading init-params...'); | |
1296 | var param = params.firstChild; | |
1297 | ||
1298 | while (param) { | |
1299 | var k = param.getAttribute("key"); | |
1300 | var v = param.getAttribute("value"); | |
1301 | debug(k + " => " + v); | |
1302 | init_params[k] = v; | |
1303 | param = param.nextSibling; | |
1304 | } | |
1305 | } | |
1306 | ||
7a09510c AD |
1307 | sanity_check_done = true; |
1308 | ||
a7565293 AD |
1309 | init_second_stage(); |
1310 | ||
1311 | } catch (e) { | |
1312 | exception_error("backend_sanity_check_callback", e); | |
1313 | } | |
1314 | } | |
1315 | } | |
1316 | ||
1317 | function init_second_stage() { | |
1318 | ||
b2caf812 AD |
1319 | try { |
1320 | active_tab = getInitParam("prefs_active_tab"); | |
e8375afe | 1321 | if (!document.getElementById(active_tab+"Tab")) active_tab = "genConfig"; |
fe8d2059 | 1322 | if (!active_tab || active_tab == '0') active_tab = "genConfig"; |
4da47970 | 1323 | |
d437c8cf AD |
1324 | document.onkeydown = pref_hotkey_handler; |
1325 | ||
e513a74a AD |
1326 | var tab = getURLParam('tab'); |
1327 | ||
1328 | caller_subop = getURLParam('subop'); | |
1329 | ||
6906f145 AD |
1330 | if (getURLParam("subopparam")) { |
1331 | caller_subop = caller_subop + ":" + getURLParam("subopparam"); | |
1332 | } | |
1333 | ||
e513a74a AD |
1334 | if (tab) { |
1335 | active_tab = tab; | |
1336 | } | |
1337 | ||
b2caf812 AD |
1338 | if (navigator.userAgent.match("Opera")) { |
1339 | setTimeout("selectTab()", 500); | |
1340 | } else { | |
1341 | selectTab(active_tab); | |
1342 | } | |
1343 | notify(""); | |
08827aaf AD |
1344 | |
1345 | loading_set_progress(60); | |
1346 | ||
b2caf812 AD |
1347 | } catch (e) { |
1348 | exception_error("init_second_stage", e); | |
1349 | } | |
a0d53889 AD |
1350 | } |
1351 | ||
007bda35 | 1352 | function init() { |
e2ec66a8 | 1353 | |
7719618b AD |
1354 | try { |
1355 | ||
97dcd654 AD |
1356 | if (arguments.callee.done) return; |
1357 | arguments.callee.done = true; | |
1358 | ||
a7565293 | 1359 | if (getURLParam('debug')) { |
8836613c | 1360 | Element.show("debug_output"); |
a7565293 AD |
1361 | debug('debug mode activated'); |
1362 | } | |
1363 | ||
7719618b AD |
1364 | // IE kludge |
1365 | if (!xmlhttp) { | |
1366 | document.getElementById("prefContent").innerHTML = | |
1367 | "<b>Fatal error:</b> This program needs XmlHttpRequest " + | |
1368 | "to function properly. Your browser doesn't seem to support it."; | |
1369 | return; | |
1370 | } | |
4da47970 | 1371 | |
08827aaf AD |
1372 | loading_set_progress(30); |
1373 | ||
a7565293 AD |
1374 | xmlhttp.open("GET", "backend.php?op=rpc&subop=sanityCheck", true); |
1375 | xmlhttp.onreadystatechange=backend_sanity_check_callback; | |
1376 | xmlhttp.send(null); | |
1377 | ||
7719618b AD |
1378 | } catch (e) { |
1379 | exception_error("init", e); | |
e2ec66a8 | 1380 | } |
007bda35 | 1381 | } |
b1895692 | 1382 | |
f932bc9f AD |
1383 | function categorizeSelectedFeeds() { |
1384 | ||
1385 | if (!xmlhttp_ready(xmlhttp)) { | |
1386 | printLockingError(); | |
1387 | return | |
1388 | } | |
1389 | ||
1390 | var sel_rows = getSelectedFeeds(); | |
1391 | ||
1392 | var cat_sel = document.getElementById("sfeed_set_fcat"); | |
79f3553b | 1393 | var cat_id = cat_sel[cat_sel.selectedIndex].value; |
f932bc9f AD |
1394 | |
1395 | if (sel_rows.length > 0) { | |
1396 | ||
42c32916 | 1397 | notify_progress("Changing category of selected feeds..."); |
f932bc9f AD |
1398 | |
1399 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+ | |
1400 | param_escape(sel_rows.toString()) + "&cat_id=" + param_escape(cat_id), true); | |
1401 | xmlhttp.onreadystatechange=feedlist_callback; | |
1402 | xmlhttp.send(null); | |
1403 | ||
1404 | } else { | |
1405 | ||
f3977cf5 | 1406 | alert(__("No feeds are selected.")); |
f932bc9f AD |
1407 | |
1408 | } | |
1409 | ||
1410 | } | |
69668465 AD |
1411 | |
1412 | function validatePrefsReset() { | |
b652c1b7 AD |
1413 | try { |
1414 | var ok = confirm(__("Reset to defaults?")); | |
1415 | ||
1416 | if (ok) { | |
1417 | ||
1418 | var query = Form.serialize("pref_prefs_form"); | |
1419 | query = query + "&subop=reset-config"; | |
1420 | debug(query); | |
1421 | ||
1422 | xmlhttp.open("POST", "backend.php", true); | |
1423 | xmlhttp.onreadystatechange=prefs_reset_callback; | |
1424 | xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); | |
1425 | xmlhttp.send(query); | |
1426 | } | |
1427 | ||
1428 | } catch (e) { | |
1429 | exception_error("validatePrefsSave", e); | |
1430 | } | |
1431 | ||
1432 | return false; | |
1433 | ||
69668465 | 1434 | } |
f9cb39ac | 1435 | |
6311acbe | 1436 | function browseFeeds(limit) { |
f9cb39ac AD |
1437 | |
1438 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=browse", true); | |
1439 | xmlhttp.onreadystatechange=infobox_callback; | |
1440 | xmlhttp.send(null); | |
1441 | ||
1442 | } | |
a0476535 AD |
1443 | |
1444 | function feedBrowserSubscribe() { | |
1445 | try { | |
a0476535 | 1446 | |
c0ae0fdb | 1447 | var selected = getSelectedFeedsFromBrowser(); |
a0476535 AD |
1448 | |
1449 | if (selected.length > 0) { | |
1450 | closeInfoBox(); | |
1451 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+ | |
1452 | param_escape(selected.toString()), true); | |
1453 | xmlhttp.onreadystatechange=feedlist_callback; | |
1454 | xmlhttp.send(null); | |
1455 | } else { | |
89cb787e | 1456 | alert(__("No feeds are selected.")); |
a0476535 AD |
1457 | } |
1458 | ||
1459 | } catch (e) { | |
1460 | exception_error("feedBrowserSubscribe", e); | |
1461 | } | |
1462 | } | |
c6232e43 | 1463 | |
ce8de904 AD |
1464 | function updateBigFeedBrowserBtn() { |
1465 | notify_progress("Loading, please wait..."); | |
1466 | return updateBigFeedBrowser(); | |
1467 | } | |
1468 | ||
ce3bf408 AD |
1469 | function selectPrefRows(kind, select) { |
1470 | ||
1471 | if (kind) { | |
1472 | var opbarid = false; | |
1473 | var nchk = false; | |
1474 | var nrow = false; | |
1475 | var lname = false; | |
1476 | ||
1477 | if (kind == "feed") { | |
1478 | opbarid = "feedOpToolbar"; | |
1479 | nrow = "FEEDR-"; | |
1480 | nchk = "FRCHK-"; | |
1481 | lname = "prefFeedList"; | |
1482 | } else if (kind == "fcat") { | |
1483 | opbarid = "catOpToolbar"; | |
1484 | nrow = "FCATR-"; | |
9c483746 | 1485 | nchk = "FCCHK-"; |
ce3bf408 AD |
1486 | lname = "prefFeedCatList"; |
1487 | } else if (kind == "filter") { | |
1488 | opbarid = "filterOpToolbar"; | |
1489 | nrow = "FILRR-"; | |
1490 | nchk = "FICHK-"; | |
1491 | lname = "prefFilterList"; | |
1492 | } else if (kind == "label") { | |
1493 | opbarid = "labelOpToolbar"; | |
1494 | nrow = "LILRR-"; | |
a4dbc524 | 1495 | nchk = "LICHK-"; |
ce3bf408 AD |
1496 | lname = "prefLabelList"; |
1497 | } else if (kind == "user") { | |
1498 | opbarid = "userOpToolbar"; | |
1499 | nrow = "UMRR-"; | |
1500 | nchk = "UMCHK-"; | |
1501 | lname = "prefUserList"; | |
1502 | } | |
1503 | ||
1504 | if (opbarid) { | |
1505 | selectTableRowsByIdPrefix(lname, nrow, nchk, select); | |
1506 | disableContainerChildren(opbarid, !select); | |
1507 | } | |
1508 | ||
1509 | } | |
1510 | } | |
1511 | ||
1512 | ||
1513 | function toggleSelectPrefRow(sender, kind) { | |
1514 | ||
1515 | toggleSelectRow(sender); | |
1516 | ||
1517 | if (kind) { | |
1518 | var opbarid = false; | |
1519 | var nsel = -1; | |
1520 | ||
1521 | if (kind == "feed") { | |
1522 | opbarid = "feedOpToolbar"; | |
1523 | nsel = getSelectedFeeds(); | |
1524 | } else if (kind == "fcat") { | |
1525 | opbarid = "catOpToolbar"; | |
1526 | nsel = getSelectedFeedCats(); | |
1527 | } else if (kind == "filter") { | |
1528 | opbarid = "filterOpToolbar"; | |
1529 | nsel = getSelectedFilters(); | |
1530 | } else if (kind == "label") { | |
1531 | opbarid = "labelOpToolbar"; | |
1532 | nsel = getSelectedLabels(); | |
1533 | } else if (kind == "user") { | |
1534 | opbarid = "userOpToolbar"; | |
1535 | nsel = getSelectedUsers(); | |
1536 | } | |
1537 | ||
1538 | if (opbarid && nsel != -1) { | |
1539 | disableContainerChildren(opbarid, nsel == false); | |
1540 | } | |
1541 | ||
1542 | } | |
1543 | } | |
1544 | ||
c0ae0fdb AD |
1545 | function toggleSelectFBListRow(sender) { |
1546 | toggleSelectListRow(sender); | |
1547 | disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0); | |
1548 | } | |
d437c8cf AD |
1549 | |
1550 | var seq = ""; | |
1551 | ||
1552 | function pref_hotkey_handler(e) { | |
1553 | try { | |
1554 | ||
1555 | var keycode; | |
746dcf42 AD |
1556 | var shift_key = false; |
1557 | ||
1558 | try { | |
1559 | shift_key = e.shiftKey; | |
1560 | } catch (e) { | |
1561 | ||
1562 | } | |
1563 | ||
d437c8cf AD |
1564 | if (window.event) { |
1565 | keycode = window.event.keyCode; | |
1566 | } else if (e) { | |
1567 | keycode = e.which; | |
1568 | } | |
746dcf42 | 1569 | |
eec498c3 AD |
1570 | var keychar = String.fromCharCode(keycode); |
1571 | ||
746dcf42 AD |
1572 | if (keycode == 27) { // escape |
1573 | if (Element.visible("hotkey_help_overlay")) { | |
1574 | Element.hide("hotkey_help_overlay"); | |
1575 | } | |
1576 | hotkey_prefix = false; | |
1577 | closeInfoBox(); | |
1578 | } | |
1579 | ||
1580 | if (!hotkeys_enabled) { | |
1581 | debug("hotkeys disabled"); | |
1582 | return; | |
1583 | } | |
1584 | ||
1585 | if (keycode == 16) return; // ignore lone shift | |
1586 | ||
6068d33b AD |
1587 | if ((keycode == 67 || keycode == 71) && !hotkey_prefix) { |
1588 | hotkey_prefix = keycode; | |
eec498c3 | 1589 | debug("KP: PREFIX=" + keycode + " CHAR=" + keychar); |
6068d33b AD |
1590 | return; |
1591 | } | |
1592 | ||
746dcf42 AD |
1593 | if (Element.visible("hotkey_help_overlay")) { |
1594 | Element.hide("hotkey_help_overlay"); | |
1595 | } | |
1596 | ||
d437c8cf AD |
1597 | if (keycode == 13 || keycode == 27) { |
1598 | seq = ""; | |
1599 | } else { | |
1600 | seq = seq + "" + keycode; | |
1601 | } | |
1602 | ||
746dcf42 | 1603 | /* Global hotkeys */ |
d437c8cf | 1604 | |
746dcf42 AD |
1605 | if (!hotkey_prefix) { |
1606 | ||
1607 | if (keycode == 68 && shift_key) { // d | |
8836613c AD |
1608 | if (!Element.visible("debug_output")) { |
1609 | Element.show("debug_output"); | |
746dcf42 AD |
1610 | debug('debug mode activated'); |
1611 | } else { | |
8836613c | 1612 | Element.hide("debug_output"); |
746dcf42 | 1613 | } |
746dcf42 AD |
1614 | return; |
1615 | } | |
1616 | ||
eec498c3 | 1617 | if ((keycode == 191 || keychar == '?') && shift_key) { // ? |
746dcf42 | 1618 | if (!Element.visible("hotkey_help_overlay")) { |
86deaa0e AD |
1619 | //Element.show("hotkey_help_overlay"); |
1620 | Effect.Appear("hotkey_help_overlay", {duration : 0.3}); | |
746dcf42 AD |
1621 | } else { |
1622 | Element.hide("hotkey_help_overlay"); | |
1623 | } | |
eec498c3 | 1624 | return false; |
746dcf42 AD |
1625 | } |
1626 | ||
eec498c3 | 1627 | if (keycode == 191 || keychar == '/') { // / |
477402d8 | 1628 | var search_boxes = new Array("label_search", |
e8be0f5b | 1629 | "feed_search", "filter_search", "user_search", "feed_browser_search"); |
477402d8 AD |
1630 | |
1631 | for (var i = 0; i < search_boxes.length; i++) { | |
1632 | var elem = document.getElementById(search_boxes[i]); | |
1633 | if (elem) { | |
eec498c3 AD |
1634 | focus_element(search_boxes[i]); |
1635 | return false; | |
477402d8 AD |
1636 | } |
1637 | } | |
477402d8 | 1638 | } |
6068d33b AD |
1639 | } |
1640 | ||
1641 | /* Prefix c */ | |
1642 | ||
1643 | if (hotkey_prefix == 67) { // c | |
1644 | hotkey_prefix = false; | |
1645 | ||
1646 | if (keycode == 70) { // f | |
eec498c3 AD |
1647 | displayDlg("quickAddFilter"); |
1648 | return false; | |
6068d33b AD |
1649 | } |
1650 | ||
1651 | if (keycode == 83) { // s | |
eec498c3 AD |
1652 | displayDlg("quickAddFeed"); |
1653 | return false; | |
6068d33b AD |
1654 | } |
1655 | ||
ceb30ba4 | 1656 | /* if (keycode == 76) { // l |
eec498c3 AD |
1657 | displayDlg("quickAddLabel"); |
1658 | return false; | |
ceb30ba4 | 1659 | } */ |
6068d33b AD |
1660 | |
1661 | if (keycode == 85) { // u | |
1662 | // no-op | |
1663 | } | |
1664 | ||
57f734c8 | 1665 | if (keycode == 67) { // c |
eec498c3 AD |
1666 | editFeedCats(); |
1667 | return false; | |
57f734c8 AD |
1668 | } |
1669 | ||
a80b05ea | 1670 | if (keycode == 84 && shift_key) { // T |
eec498c3 AD |
1671 | browseFeeds(); |
1672 | return false; | |
a80b05ea AD |
1673 | } |
1674 | ||
6068d33b AD |
1675 | } |
1676 | ||
1677 | /* Prefix g */ | |
1678 | ||
1679 | if (hotkey_prefix == 71) { // g | |
1680 | ||
1681 | hotkey_prefix = false; | |
1682 | ||
1683 | if (keycode == 49 && document.getElementById("genConfigTab")) { // 1 | |
746dcf42 | 1684 | selectTab("genConfig"); |
eec498c3 | 1685 | return false; |
746dcf42 AD |
1686 | } |
1687 | ||
1688 | if (keycode == 50 && document.getElementById("feedConfigTab")) { // 2 | |
eec498c3 AD |
1689 | selectTab("feedConfig"); |
1690 | return false; | |
746dcf42 AD |
1691 | } |
1692 | ||
3a6521f0 | 1693 | if (keycode == 51 && document.getElementById("filterConfigTab")) { // 4 |
eec498c3 AD |
1694 | selectTab("filterConfig"); |
1695 | return false; | |
746dcf42 AD |
1696 | } |
1697 | ||
3a6521f0 | 1698 | if (keycode == 52 && document.getElementById("labelConfigTab")) { // 5 |
eec498c3 AD |
1699 | selectTab("labelConfig"); |
1700 | return false; | |
746dcf42 AD |
1701 | } |
1702 | ||
3a6521f0 | 1703 | if (keycode == 53 && document.getElementById("userConfigTab")) { // 6 |
eec498c3 AD |
1704 | selectTab("userConfig"); |
1705 | return false; | |
746dcf42 AD |
1706 | } |
1707 | ||
8d727bfc AD |
1708 | if (keycode == 88) { // x |
1709 | return gotoMain(); | |
1710 | } | |
1711 | ||
746dcf42 AD |
1712 | } |
1713 | ||
1714 | if (document.getElementById("piggie")) { | |
1715 | ||
1716 | if (seq.match("807371717369")) { | |
1717 | seq = ""; | |
eec498c3 | 1718 | piggie(true); |
746dcf42 | 1719 | } else { |
eec498c3 | 1720 | piggie(false); |
746dcf42 AD |
1721 | } |
1722 | } | |
1723 | ||
1724 | if (hotkey_prefix) { | |
eec498c3 | 1725 | debug("KP: PREFIX=" + hotkey_prefix + " CODE=" + keycode + " CHAR=" + keychar); |
d437c8cf | 1726 | } else { |
eec498c3 | 1727 | debug("KP: CODE=" + keycode + " CHAR=" + keychar); |
d437c8cf | 1728 | } |
d437c8cf AD |
1729 | |
1730 | } catch (e) { | |
1731 | exception_error("pref_hotkey_handler", e); | |
1732 | } | |
1733 | } | |
1734 | ||
9c483746 AD |
1735 | function editFeedCats() { |
1736 | if (!xmlhttp_ready(xmlhttp)) { | |
1737 | printLockingError(); | |
1738 | return | |
1739 | } | |
1740 | ||
a349077c AD |
1741 | document.getElementById("subscribe_to_feed_btn").disabled = true; |
1742 | ||
1743 | try { | |
1744 | document.getElementById("top25_feeds_btn").disabled = true; | |
1745 | } catch (e) { | |
1746 | // this button is not always available, no-op if not found | |
1747 | } | |
1748 | ||
9c483746 | 1749 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats", true); |
11f083e7 | 1750 | xmlhttp.onreadystatechange=infobox_feed_cat_callback; |
9c483746 AD |
1751 | xmlhttp.send(null); |
1752 | } | |
a3656a41 AD |
1753 | |
1754 | function showFeedsWithErrors() { | |
1755 | displayDlg('feedUpdateErrors'); | |
1756 | } | |
073ca0e6 | 1757 | |
d95bd220 AD |
1758 | function changeUserPassword() { |
1759 | ||
1760 | try { | |
1761 | ||
1762 | if (!xmlhttp_ready(xmlhttp)) { | |
1763 | printLockingError(); | |
1764 | return false; | |
1765 | } | |
1766 | ||
ae661a8c AD |
1767 | var f = document.forms["change_pass_form"]; |
1768 | ||
1769 | if (f) { | |
1770 | if (f.OLD_PASSWORD.value == "") { | |
1771 | new Effect.Highlight(f.OLD_PASSWORD); | |
1772 | notify_error("Old password cannot be blank."); | |
1773 | return false; | |
1774 | } | |
1775 | ||
1776 | if (f.NEW_PASSWORD.value == "") { | |
1777 | new Effect.Highlight(f.NEW_PASSWORD); | |
1778 | notify_error("New password cannot be blank."); | |
1779 | return false; | |
1780 | } | |
1781 | ||
1782 | if (f.CONFIRM_PASSWORD.value == "") { | |
1783 | new Effect.Highlight(f.CONFIRM_PASSWORD); | |
1784 | notify_error("Entered passwords do not match."); | |
1785 | return false; | |
1786 | } | |
1787 | ||
1788 | if (f.CONFIRM_PASSWORD.value != f.NEW_PASSWORD.value) { | |
1789 | new Effect.Highlight(f.CONFIRM_PASSWORD); | |
1790 | new Effect.Highlight(f.NEW_PASSWORD); | |
1791 | notify_error("Entered passwords do not match."); | |
1792 | return false; | |
1793 | } | |
1794 | ||
1795 | } | |
1796 | ||
d95bd220 AD |
1797 | var query = Form.serialize("change_pass_form"); |
1798 | ||
1799 | notify_progress("Trying to change password..."); | |
1800 | ||
1801 | xmlhttp.open("POST", "backend.php", true); | |
1802 | xmlhttp.onreadystatechange=changepass_callback; | |
1803 | xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); | |
1804 | xmlhttp.send(query); | |
1805 | ||
1806 | } catch (e) { | |
1807 | exception_error("changeUserPassword", e); | |
1808 | } | |
1809 | ||
1810 | return false; | |
1811 | } | |
073ca0e6 | 1812 | |
42395d28 AD |
1813 | function changeUserEmail() { |
1814 | ||
1815 | try { | |
1816 | ||
1817 | if (!xmlhttp_ready(xmlhttp)) { | |
1818 | printLockingError(); | |
1819 | return false; | |
1820 | } | |
1821 | ||
1822 | var query = Form.serialize("change_email_form"); | |
1823 | ||
1824 | notify_progress("Trying to change e-mail..."); | |
1825 | ||
1826 | xmlhttp.open("POST", "backend.php", true); | |
1827 | xmlhttp.onreadystatechange=notify_callback; | |
1828 | xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); | |
1829 | xmlhttp.send(query); | |
1830 | ||
1831 | } catch (e) { | |
1832 | exception_error("changeUserPassword", e); | |
1833 | } | |
1834 | ||
1835 | return false; | |
1836 | ||
1837 | } | |
400b60d8 AD |
1838 | |
1839 | function feedlistToggleSLAT() { | |
1840 | notify_progress("Loading, please wait..."); | |
1841 | updateFeedList() | |
1842 | } | |
bc0ed820 | 1843 | |
e4f4b46f AD |
1844 | function pubRegenKey() { |
1845 | ||
bc0ed820 AD |
1846 | if (!xmlhttp_ready(xmlhttp)) { |
1847 | printLockingError(); | |
e4f4b46f | 1848 | return false; |
bc0ed820 AD |
1849 | } |
1850 | ||
f56e3080 | 1851 | var ok = confirm(__("Replace current publishing address with a new one?")); |
bc0ed820 | 1852 | |
e4f4b46f AD |
1853 | if (ok) { |
1854 | ||
1855 | notify_progress("Trying to change address..."); | |
1856 | ||
945c243e | 1857 | xmlhttp.open("GET", "backend.php?op=rpc&subop=regenPubKey"); |
e4f4b46f AD |
1858 | xmlhttp.onreadystatechange=replace_pubkey_callback; |
1859 | xmlhttp.send(null); | |
1860 | } | |
1861 | ||
1862 | return false; | |
945c243e | 1863 | } |
b652c1b7 | 1864 | |
e635d56a AD |
1865 | function pubToClipboard() { |
1866 | ||
1867 | try { | |
1868 | ||
1869 | if (!xmlhttp_ready(xmlhttp)) { | |
1870 | printLockingError(); | |
1871 | return false; | |
1872 | } | |
1873 | ||
1874 | var link = document.getElementById("pubGenAddress"); | |
1875 | alert(link.href); | |
1876 | ||
1877 | } catch (e) { | |
1878 | exception_error("pubToClipboard", e); | |
1879 | } | |
1880 | ||
1881 | return false; | |
1882 | } | |
1883 | ||
b652c1b7 AD |
1884 | function validatePrefsSave() { |
1885 | try { | |
1886 | ||
1887 | var ok = confirm(__("Save current configuration?")); | |
1888 | ||
1889 | if (ok) { | |
1890 | ||
1891 | var query = Form.serialize("pref_prefs_form"); | |
1892 | query = query + "&subop=save-config"; | |
1893 | debug(query); | |
1894 | ||
1895 | xmlhttp.open("POST", "backend.php", true); | |
1896 | xmlhttp.onreadystatechange=notify_callback; | |
1897 | xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); | |
1898 | xmlhttp.send(query); | |
1899 | } | |
1900 | ||
1901 | } catch (e) { | |
1902 | exception_error("validatePrefsSave", e); | |
1903 | } | |
1904 | ||
1905 | return false; | |
1906 | } | |
c4a36709 AD |
1907 | |
1908 | function feedActionChange() { | |
1909 | try { | |
1910 | var chooser = document.getElementById("feedActionChooser"); | |
1911 | var opid = chooser[chooser.selectedIndex].value; | |
1912 | ||
1913 | chooser.selectedIndex = 0; | |
1914 | feedActionGo(opid); | |
1915 | } catch (e) { | |
1916 | exception_error("feedActionChange", e); | |
1917 | } | |
1918 | } | |
1919 | ||
1920 | function feedActionGo(op) { | |
1921 | try { | |
1922 | if (op == "facEdit") { | |
cd935c42 AD |
1923 | |
1924 | var rows = getSelectedFeeds(); | |
1925 | ||
1926 | if (rows.length > 1) { | |
1927 | editSelectedFeeds(); | |
1928 | } else { | |
1929 | editSelectedFeed(); | |
1930 | } | |
c4a36709 AD |
1931 | } |
1932 | ||
1933 | if (op == "facClear") { | |
1934 | clearSelectedFeeds(); | |
1935 | } | |
1936 | ||
1937 | if (op == "facPurge") { | |
1938 | purgeSelectedFeeds(); | |
1939 | } | |
1940 | ||
e88a65f4 AD |
1941 | if (op == "facEditCats") { |
1942 | editFeedCats(); | |
1943 | } | |
1944 | ||
fee840fb AD |
1945 | if (op == "facRescore") { |
1946 | rescoreSelectedFeeds(); | |
1947 | } | |
1948 | ||
c4a36709 AD |
1949 | if (op == "facUnsubscribe") { |
1950 | removeSelectedFeeds(); | |
1951 | } | |
1952 | ||
1953 | } catch (e) { | |
1954 | exception_error("feedActionGo", e); | |
1955 | ||
1956 | } | |
1957 | } | |
1958 | ||
1959 | function clearFeedArticles(feed_id) { | |
1960 | ||
1961 | notify_progress("Clearing feed..."); | |
1962 | ||
1963 | var query = "backend.php?op=pref-feeds&quiet=1&subop=clear&id=" + feed_id; | |
1964 | ||
1965 | new Ajax.Request(query, { | |
1966 | onComplete: function(transport) { | |
1967 | notify(''); | |
1968 | } }); | |
1969 | ||
1970 | return false; | |
1971 | } | |
1972 | ||
fee840fb AD |
1973 | function rescoreSelectedFeeds() { |
1974 | ||
1975 | if (!xmlhttp_ready(xmlhttp)) { | |
1976 | printLockingError(); | |
1977 | return | |
1978 | } | |
1979 | ||
1980 | var sel_rows = getSelectedFeeds(); | |
1981 | ||
1982 | if (sel_rows.length > 0) { | |
1983 | ||
ef1b0366 AD |
1984 | //var ok = confirm(__("Rescore last 100 articles in selected feeds?")); |
1985 | var ok = confirm(__("Rescore articles in selected feeds?")); | |
fee840fb AD |
1986 | |
1987 | if (ok) { | |
3df4869b | 1988 | notify_progress("Rescoring selected feeds...", true); |
fee840fb AD |
1989 | |
1990 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=rescore&quiet=1&ids="+ | |
1991 | param_escape(sel_rows.toString()), true); | |
1992 | xmlhttp.onreadystatechange=notify_callback; | |
1993 | xmlhttp.send(null); | |
1994 | } | |
1995 | } else { | |
1996 | alert(__("No feeds are selected.")); | |
1997 | } | |
1998 | ||
1999 | return false; | |
2000 | } | |
c4a36709 | 2001 | |
95a948a5 AD |
2002 | function rescore_all_feeds() { |
2003 | var ok = confirm(__("Rescore all articles? This operation may take a lot of time.")); | |
2004 | ||
2005 | if (ok) { | |
3df4869b | 2006 | notify_progress("Rescoring feeds...", true); |
95a948a5 AD |
2007 | |
2008 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=rescoreAll&quiet=1", true); | |
2009 | xmlhttp.onreadystatechange=notify_callback; | |
2010 | xmlhttp.send(null); | |
2011 | } | |
a80b05ea | 2012 | } |
a44db887 AD |
2013 | |
2014 | function removeFilter(id, title) { | |
2015 | ||
2016 | if (!xmlhttp_ready(xmlhttp)) { | |
2017 | printLockingError(); | |
2018 | return | |
2019 | } | |
2020 | ||
2021 | var msg = __("Remove filter %s?").replace("%s", title); | |
2022 | ||
2023 | var ok = confirm(msg); | |
2024 | ||
2025 | if (ok) { | |
2026 | closeInfoBox(); | |
2027 | ||
2028 | notify_progress("Removing filter..."); | |
2029 | ||
2030 | xmlhttp.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+ | |
2031 | param_escape(id), true); | |
2032 | xmlhttp.onreadystatechange=filterlist_callback; | |
2033 | xmlhttp.send(null); | |
2034 | } | |
2035 | ||
2036 | return false; | |
2037 | } | |
2038 | ||
c8d5dcfe AD |
2039 | function unsubscribeFeed(id, title) { |
2040 | ||
2041 | if (!xmlhttp_ready(xmlhttp)) { | |
2042 | printLockingError(); | |
2043 | return | |
2044 | } | |
2045 | ||
2046 | var msg = __("Unsubscribe from %s?").replace("%s", title); | |
2047 | ||
2048 | var ok = confirm(msg); | |
2049 | ||
2050 | if (ok) { | |
2051 | closeInfoBox(); | |
2052 | ||
2053 | notify_progress("Removing feed..."); | |
2054 | ||
2055 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+ | |
2056 | param_escape(id), true); | |
2057 | xmlhttp.onreadystatechange=filterlist_callback; | |
2058 | xmlhttp.send(null); | |
2059 | } | |
2060 | ||
2061 | return false; | |
2062 | ||
2063 | return false; | |
2064 | ||
2065 | } | |
2066 | ||
758e1c4a AD |
2067 | function feedsEditSave() { |
2068 | try { | |
2069 | ||
2070 | if (!xmlhttp_ready(xmlhttp)) { | |
2071 | printLockingError(); | |
2072 | return | |
2073 | } | |
2074 | ||
cd935c42 | 2075 | var ok = confirm(__("Save changes to selected feeds?")); |
758e1c4a | 2076 | |
b0f015a2 AD |
2077 | if (ok) { |
2078 | ||
5d538f4f AD |
2079 | var f = document.forms["batch_edit_feed_form"]; |
2080 | ||
b0f015a2 | 2081 | var query = Form.serialize("batch_edit_feed_form"); |
5d538f4f AD |
2082 | |
2083 | /* Form.serialize ignores unchecked checkboxes */ | |
2084 | ||
cd935c42 | 2085 | if (!query.match("&hidden=") && |
5d538f4f AD |
2086 | f.hidden.disabled == false) { |
2087 | query = query + "&hidden=false"; | |
2088 | } | |
2089 | ||
cd935c42 | 2090 | if (!query.match("&rtl_content=") && |
5d538f4f AD |
2091 | f.rtl_content.disabled == false) { |
2092 | query = query + "&rtl_content=false"; | |
2093 | } | |
2094 | ||
cd935c42 | 2095 | if (!query.match("&private=") && |
5d538f4f AD |
2096 | f.private.disabled == false) { |
2097 | query = query + "&private=false"; | |
2098 | } | |
2099 | ||
cd935c42 | 2100 | if (!query.match("&cache_images=") && |
5d538f4f AD |
2101 | f.cache_images.disabled == false) { |
2102 | query = query + "&cache_images=false"; | |
2103 | } | |
2104 | ||
cd935c42 | 2105 | if (!query.match("&include_in_digest=") && |
5d538f4f AD |
2106 | f.include_in_digest.disabled == false) { |
2107 | query = query + "&include_in_digest=false"; | |
2108 | } | |
b0f015a2 AD |
2109 | |
2110 | closeInfoBox(); | |
2111 | ||
2112 | notify_progress("Saving feeds..."); | |
2113 | ||
2114 | xmlhttp.open("POST", "backend.php", true); | |
2115 | xmlhttp.onreadystatechange=feedlist_callback; | |
2116 | xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); | |
2117 | xmlhttp.send(query); | |
2118 | } | |
758e1c4a AD |
2119 | |
2120 | return false; | |
2121 | } catch (e) { | |
2122 | exception_error("feedsEditSave", e); | |
2123 | } | |
2124 | } | |
2125 | ||
2126 | function batchFeedsToggleField(cb, elem, label) { | |
2127 | try { | |
2128 | var f = document.forms["batch_edit_feed_form"]; | |
2129 | var l = document.getElementById(label); | |
2130 | ||
2131 | if (cb.checked) { | |
2132 | f[elem].disabled = false; | |
2133 | ||
2134 | if (l) { | |
2135 | l.className = ""; | |
2136 | }; | |
2137 | ||
2138 | // new Effect.Highlight(f[elem], {duration: 1, startcolor: "#fff7d5", | |
2139 | // queue: { position:'end', scope: 'BPEFQ', limit: 1 } } ); | |
2140 | ||
2141 | } else { | |
2142 | f[elem].disabled = true; | |
2143 | ||
2144 | if (l) { | |
2145 | l.className = "insensitive"; | |
2146 | }; | |
2147 | ||
2148 | } | |
2149 | } catch (e) { | |
2150 | exception_error("batchFeedsToggleField", e); | |
2151 | } | |
2152 | } | |
2153 | ||
b56465dd | 2154 |