From 508a81e1b6502ac275a95831befe14d92c9ad55c Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 24 Aug 2005 09:02:58 +0100 Subject: [PATCH] feed editor, xmlhttp locking in preferences, try to initialize xmlhttp_rpc via ActiveX and a big piggie --- backend.php | 37 ++++++++++++++- functions.js | 12 +++++ prefs.js | 125 ++++++++++++++++++++++++++++++++++++++++++++++++++- prefs.php | 7 ++- tt-rss.css | 19 ++++++++ tt-rss.js | 6 +-- 6 files changed, 198 insertions(+), 8 deletions(-) diff --git a/backend.php b/backend.php index 9697c0e01..027c7060d 100644 --- a/backend.php +++ b/backend.php @@ -356,7 +356,42 @@ $subop = $_GET["subop"]; if ($subop == "edit") { - print "

[Edit feed placeholder]

"; + + $feed_id = $_GET["id"]; + + $result = pg_query("SELECT title,feed_url + FROM ttrss_feeds WHERE id = '$feed_id'"); + + $fedit_link = pg_fetch_result($result, 0, "feed_url"); + $fedit_title = pg_fetch_result($result, 0, "title"); + + print " + + + +
Title:
Link:
+ Cancel + Save +
"; + + } else { + + print " + + +
+ Add feed
"; + + } + + if ($subop == "editSave") { + $feed_title = pg_escape_string($_GET["t"]); + $feed_link = pg_escape_string($_GET["l"]); + $feed_id = $_GET["id"]; + + $result = pg_query("UPDATE ttrss_feeds SET + title = '$feed_title', feed_url = '$feed_link' WHERE id = '$feed_id'"); + } if ($subop == "remove") { diff --git a/functions.js b/functions.js index 25a19908b..b634974ab 100644 --- a/functions.js +++ b/functions.js @@ -12,6 +12,14 @@ function param_unescape(arg) { return unescape(arg); } +function delay(gap) { + var then,now; + then=new Date().getTime(); + now=then; + while((now-then) 0) { @@ -133,6 +153,11 @@ function readSelectedFeeds() { function unreadSelectedFeeds() { + if (xmlhttp.readyState != 4 && xmlhttp.readyState != 0) { + printLockingError(); + return + } + var sel_rows = getSelectedFeeds(); if (sel_rows.length > 0) { @@ -153,6 +178,11 @@ function unreadSelectedFeeds() { function removeSelectedFeeds() { + if (xmlhttp.readyState != 4 && xmlhttp.readyState != 0) { + printLockingError(); + return + } + var sel_rows = getSelectedFeeds(); if (sel_rows.length > 0) { @@ -172,10 +202,101 @@ function removeSelectedFeeds() { } +function feedEditCancel() { + + if (xmlhttp.readyState != 4 && xmlhttp.readyState != 0) { + printLockingError(); + return + } + + notify("Operation cancelled."); + + xmlhttp.open("GET", "backend.php?op=pref-feeds", true); + xmlhttp.onreadystatechange=feedlist_callback; + xmlhttp.send(null); + +} + +function feedEditSave(feed) { + + if (xmlhttp.readyState != 4 && xmlhttp.readyState != 0) { + printLockingError(); + return + } + + notify("Saving feed."); + + var link = document.getElementById("fedit_link").value; + var title = document.getElementById("fedit_title").value; + + if (link.length == 0) { + notify("Feed link cannot be blank."); + return; + } + + if (title.length == 0) { + notify("Feed title cannot be blank."); + return; + } + + xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editSave&id=" + + feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) ,true); + xmlhttp.onreadystatechange=feedlist_callback; + xmlhttp.send(null); + +} + +function editSelectedFeed() { + var rows = getSelectedFeeds(); + + if (rows.length == 0) { + notify("No feeds are selected."); + return; + } + + if (rows.length > 1) { + notify("Please select one feed."); + return; + } + + editFeed(rows[0]); + +} + +var seq = ""; + +function hotkey_handler(e) { + var keycode; + + if (window.event) { + keycode = window.event.keyCode; + } else if (e) { + keycode = e.which; + } + + if (keycode == 13 || keycode == 27) { + seq = ""; + } else { + seq = seq + "" + keycode; + } + + var piggie = document.getElementById("piggie"); + + if (seq.match("807371717369")) { + piggie.style.display = "block"; + seq = ""; + notify("I loveded it!!!"); + } else { + piggie.style.display = "none"; + notify(""); + } + +} + function init() { updateFeedList(); - + document.onkeydown = hotkey_handler; notify(""); } diff --git a/prefs.php b/prefs.php index 1a85bf3c4..fa67a45ee 100644 --- a/prefs.php +++ b/prefs.php @@ -29,15 +29,20 @@

Feed Configuration

+ +
 
 

Selection:  + Edit  Remove