From 331900c642bbea3f8b7e242975fae4cfec459433 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 22 Aug 2005 05:56:40 +0100 Subject: basic functionality pass 10 --- prefs.js | 86 ++++++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 54 insertions(+), 32 deletions(-) (limited to 'prefs.js') diff --git a/prefs.js b/prefs.js index b068e01be..7fb4562f7 100644 --- a/prefs.js +++ b/prefs.js @@ -24,33 +24,6 @@ if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp = new XMLHttpRequest(); } -function param_escape(arg) { - if (typeof encodeURIComponent != 'undefined') - return encodeURIComponent(arg); - else - return escape(arg); -} - -function param_unescape(arg) { - if (typeof decodeURIComponent != 'undefined') - return decodeURIComponent(arg); - else - return unescape(arg); -} - -function notify(msg) { - - var n = document.getElementById("notify"); - - n.innerHTML = msg; - - if (msg.length == 0) { - n.style.display = "none"; - } else { - n.style.display = "block"; - } - -} function feedlist_callback() { var container = document.getElementById('feeds'); @@ -85,13 +58,62 @@ function toggleSelectRow(sender) { function addFeed() { - var link = document.getElementById("fadd_link").value; - var title = document.getElementById("fadd_title").value; + var link = document.getElementById("fadd_link"); + + if (link.length == 0) { + notify("Missing feed URL."); + } else { + notify("Adding feed..."); + + xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=add&link=" + + param_escape(link.value), true); + xmlhttp.onreadystatechange=feedlist_callback; + xmlhttp.send(null); + + link.value = ""; + + } + +} + +function editFeed(feed) { + + notify("Editing feed..."); + + xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=edit&id=" + + param_escape(feed), true); + xmlhttp.onreadystatechange=feedlist_callback; + xmlhttp.send(null); + +} + + +function removeSelectedFeeds() { + + var content = document.getElementById("prefFeedList"); + + var sel_rows = new Array(); + + for (i = 0; i < content.rows.length; i++) { + if (content.rows[i].className.match("Selected")) { + var row_id = content.rows[i].id.replace("FEEDR-", ""); + sel_rows.push(row_id); + } + } + + if (sel_rows.length > 0) { + + notify("Removing selected feeds..."); + + xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+ + param_escape(sel_rows.toString()), true); + xmlhttp.onreadystatechange=feedlist_callback; + xmlhttp.send(null); - if (link.length == 0 || title.length == 0) { - notify("Error: all fields must be filled in."); } else { - notify("addFeed : " + link + ", " + title); + + notify("Please select some feeds first."); + } } -- cgit v1.2.3