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