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