2 This program is Copyright (c) 2003-2005 Andrew Dolgov <cthulhoo@gmail.com>
3 Licensed under GPL v.2 or (at your preference) any later version.
8 var active_feed = false;
9 var active_filter = false;
10 var active_pane = false;
13 /*@if (@_jscript_version >= 5)
14 // JScript gives us Conditional compilation, we can cope with old IE versions.
15 // and security blocked creation of the objects.
17 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
20 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
27 if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
28 xmlhttp = new XMLHttpRequest();
31 function feedlist_callback() {
32 var container = document.getElementById('feedConfPane');
33 if (xmlhttp.readyState == 4) {
34 container.innerHTML=xmlhttp.responseText;
37 var row = document.getElementById("FEEDR-" + active_feed);
39 if (!row.className.match("Selected")) {
40 row.className = row.className + "Selected";
43 var checkbox = document.getElementById("FRCHK-" + active_feed);
45 checkbox.checked = true;
51 function filterlist_callback() {
52 var container = document.getElementById('filterConfPane');
53 if (xmlhttp.readyState == 4) {
54 container.innerHTML=xmlhttp.responseText;
57 var row = document.getElementById("FILRR-" + active_filter);
59 if (!row.className.match("Selected")) {
60 row.className = row.className + "Selected";
63 var checkbox = document.getElementById("FICHK-" + active_filter);
66 checkbox.checked = true;
72 function notify_callback() {
73 var container = document.getElementById('notify');
74 if (xmlhttp.readyState == 4) {
75 container.innerHTML=xmlhttp.responseText;
80 function updateFeedList() {
82 if (!xmlhttp_ready(xmlhttp)) {
87 document.getElementById("feedConfPane").innerHTML = "Loading feeds, please wait...";
89 xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
90 xmlhttp.onreadystatechange=feedlist_callback;
95 function toggleSelectRow(sender) {
96 var parent_row = sender.parentNode.parentNode;
99 if (!parent_row.className.match("Selected")) {
100 parent_row.className = parent_row.className + "Selected";
103 if (parent_row.className.match("Selected")) {
104 parent_row.className = parent_row.className.replace("Selected", "");
111 if (!xmlhttp_ready(xmlhttp)) {
116 var link = document.getElementById("fadd_link");
118 if (link.value.length == 0) {
119 notify("Missing feed URL.");
121 notify("Adding feed...");
123 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=add&link=" +
124 param_escape(link.value), true);
125 xmlhttp.onreadystatechange=feedlist_callback;
134 function editFilter(id) {
136 if (!xmlhttp_ready(xmlhttp)) {
143 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=edit&id=" +
144 param_escape(id), true);
145 xmlhttp.onreadystatechange=filterlist_callback;
150 function editFeed(feed) {
152 // notify("Editing feed...");
154 if (!xmlhttp_ready(xmlhttp)) {
161 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=edit&id=" +
162 param_escape(feed), true);
163 xmlhttp.onreadystatechange=feedlist_callback;
168 function getSelectedFilters() {
170 var content = document.getElementById("prefFilterList");
172 var sel_rows = new Array();
174 for (i = 0; i < content.rows.length; i++) {
175 if (content.rows[i].className.match("Selected")) {
176 var row_id = content.rows[i].id.replace("FILRR-", "");
177 sel_rows.push(row_id);
184 function getSelectedFeeds() {
186 var content = document.getElementById("prefFeedList");
188 var sel_rows = new Array();
190 for (i = 0; i < content.rows.length; i++) {
191 if (content.rows[i].className.match("Selected")) {
192 var row_id = content.rows[i].id.replace("FEEDR-", "");
193 sel_rows.push(row_id);
200 function readSelectedFeeds() {
202 if (!xmlhttp_ready(xmlhttp)) {
207 var sel_rows = getSelectedFeeds();
209 if (sel_rows.length > 0) {
211 notify("Marking selected feeds as read...");
213 xmlhttp.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+
214 param_escape(sel_rows.toString()), true);
215 xmlhttp.onreadystatechange=notify_callback;
220 notify("Please select some feeds first.");
225 function unreadSelectedFeeds() {
227 if (!xmlhttp_ready(xmlhttp)) {
232 var sel_rows = getSelectedFeeds();
234 if (sel_rows.length > 0) {
236 notify("Marking selected feeds as unread...");
238 xmlhttp.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+
239 param_escape(sel_rows.toString()), true);
240 xmlhttp.onreadystatechange=notify_callback;
245 notify("Please select some feeds first.");
250 function removeSelectedFeeds() {
252 if (!xmlhttp_ready(xmlhttp)) {
257 var sel_rows = getSelectedFeeds();
259 if (sel_rows.length > 0) {
261 notify("Removing selected feeds...");
263 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
264 param_escape(sel_rows.toString()), true);
265 xmlhttp.onreadystatechange=feedlist_callback;
270 notify("Please select some feeds first.");
276 function feedEditCancel() {
278 if (!xmlhttp_ready(xmlhttp)) {
285 notify("Operation cancelled.");
287 xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
288 xmlhttp.onreadystatechange=feedlist_callback;
293 function feedEditSave() {
295 var feed = active_feed;
297 if (!xmlhttp_ready(xmlhttp)) {
302 var link = document.getElementById("iedit_link").value;
303 var title = document.getElementById("iedit_title").value;
305 // notify("Saving feed.");
307 if (link.length == 0) {
308 notify("Feed link cannot be blank.");
312 if (title.length == 0) {
313 notify("Feed title cannot be blank.");
319 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editSave&id=" +
320 feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) ,true);
321 xmlhttp.onreadystatechange=feedlist_callback;
326 function filterEditCancel() {
328 if (!xmlhttp_ready(xmlhttp)) {
333 active_filter = false;
335 notify("Operation cancelled.");
337 xmlhttp.open("GET", "backend.php?op=pref-filters", true);
338 xmlhttp.onreadystatechange=filterlist_callback;
343 function filterEditSave() {
345 var filter = active_filter;
347 if (!xmlhttp_ready(xmlhttp)) {
352 var regexp = document.getElementById("iedit_regexp").value;
353 var descr = document.getElementById("iedit_descr").value;
354 var match = document.getElementById("iedit_match").value;
356 // notify("Saving filter " + filter + ": " + regexp + ", " + descr + ", " + match);
358 if (regexp.length == 0) {
359 notify("Filter expression cannot be blank.");
363 active_filter = false;
365 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=editSave&id=" +
366 filter + "&r=" + param_escape(regexp) + "&d=" + param_escape(descr) +
367 "&m=" + param_escape(match), true);
369 xmlhttp.onreadystatechange=filterlist_callback;
374 function removeSelectedFilters() {
376 if (!xmlhttp_ready(xmlhttp)) {
381 var sel_rows = getSelectedFilters();
383 if (sel_rows.length > 0) {
385 notify("Removing selected filters...");
387 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
388 param_escape(sel_rows.toString()), true);
389 xmlhttp.onreadystatechange=filterlist_callback;
393 notify("Please select some filters first.");
398 function editSelectedFilter() {
399 var rows = getSelectedFilters();
401 if (rows.length == 0) {
402 notify("No filters are selected.");
406 if (rows.length > 1) {
407 notify("Please select one filter.");
416 function editSelectedFeed() {
417 var rows = getSelectedFeeds();
419 if (rows.length == 0) {
420 notify("No feeds are selected.");
424 if (rows.length > 1) {
425 notify("Please select one feed.");
433 function localPiggieFunction(enable) {
435 piggie.style.display = "block";
437 notify("I loveded it!!!");
439 piggie.style.display = "none";
444 function validateOpmlImport() {
446 var opml_file = document.getElementById("opml_file");
448 if (opml_file.value.length == 0) {
449 notify("Please select OPML file to upload.");
456 function updateFilterList() {
458 if (!xmlhttp_ready(xmlhttp)) {
463 document.getElementById("filterConfPane").innerHTML = "Loading filters, please wait...";
465 xmlhttp.open("GET", "backend.php?op=pref-filters", true);
466 xmlhttp.onreadystatechange=filterlist_callback;
471 function expandPane(id) {
475 /* if (active_pane) {
476 container = document.getElementById(active_pane);
477 container.innerHTML = "<a href=\"javascript:expandPane('" +
478 active_pane + "')\">Click to expand...</a>";
481 container = document.getElementById(id);
483 if (id == "feedConfPane") {
485 } else if (id == "filterConfPane") {
497 document.getElementById("prefContent").innerHTML =
498 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
499 "to function properly. Your browser doesn't seem to support it.";
504 document.onkeydown = hotkey_handler;