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