]> git.wh0rd.org - tt-rss.git/commitdiff
feed editor, xmlhttp locking in preferences, try to initialize xmlhttp_rpc via Active...
authorAndrew Dolgov <fox@madoka.spb.ru>
Wed, 24 Aug 2005 08:02:58 +0000 (09:02 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Wed, 24 Aug 2005 08:02:58 +0000 (09:02 +0100)
backend.php
functions.js
prefs.js
prefs.php
tt-rss.css
tt-rss.js

index 9697c0e01795bc5f09e477c5ea6b8252e96469f1..027c7060dcc730844aa07b9c5fa95ed0ba8bef88 100644 (file)
                $subop = $_GET["subop"];
 
                if ($subop == "edit") {
-                       print "<p>[Edit feed placeholder]</p>";
+
+                       $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 "<table class=\"prefAddFeed\">
+                       <td>Title:</td><td><input id=\"fedit_title\" value=\"$fedit_title\"></td></tr>
+                       <td>Link:</td><td><input id=\"fedit_link\" value=\"$fedit_link\"></td></tr>             
+                       <tr><td colspan=\"2\" align=\"right\">
+                               <a class=\"button\" href=\"javascript:feedEditCancel()\">Cancel</a>
+                               <a class=\"button\" href=\"javascript:feedEditSave($feed_id)\">Save</a>
+                               </td></tr>
+                       </table>";
+
+               } else {
+
+                       print "<table class=\"prefAddFeed\">
+                       <td><input id=\"fadd_link\"></td>
+                       <td colspan=\"4\" align=\"right\">
+                               <a class=\"button\" href=\"javascript:addFeed()\">Add feed</a></td></tr>
+                       </table>";
+
+               }
+
+               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") {
index 25a19908b3bd536ba61f0af27bad63bf6bab5d5b..b634974abf2475a12eb3d3b151d345eba60c8541 100644 (file)
@@ -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)<gap) {
+               now=new Date().getTime();
+       }
+}
 
 function notify(msg) {
 
@@ -27,4 +35,8 @@ function notify(msg) {
 
 }
 
+function printLockingError() {
+       notify("Please wait until operation finishes");
+}
+
 
index f9170665b566d9285d524d16280aa9c3d152e4a6..c01ba4ebbd85b50ec5aebfeabcc9403031ec4185 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -42,6 +42,11 @@ function notify_callback() {
 
 function updateFeedList() {
 
+       if (xmlhttp.readyState != 4 && xmlhttp.readyState != 0) {
+               printLockingError();
+               return
+       }
+
        document.getElementById("feeds").innerHTML = "Loading feeds, please wait...";
 
        xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
@@ -66,6 +71,11 @@ function toggleSelectRow(sender) {
 
 function addFeed() {
 
+       if (xmlhttp.readyState != 4 && xmlhttp.readyState != 0) {
+               printLockingError();
+               return
+       }
+
        var link = document.getElementById("fadd_link");
 
        if (link.value.length == 0) {
@@ -86,7 +96,12 @@ function addFeed() {
 
 function editFeed(feed) {
 
-       notify("Editing feed...");
+//     notify("Editing feed...");
+
+       if (xmlhttp.readyState != 4 && xmlhttp.readyState != 0) {
+               printLockingError();
+               return
+       }
 
        xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=edit&id=" +
                param_escape(feed), true);
@@ -113,6 +128,11 @@ function getSelectedFeeds() {
 
 function readSelectedFeeds() {
 
+       if (xmlhttp.readyState != 4 && xmlhttp.readyState != 0) {
+               printLockingError();
+               return
+       }
+
        var sel_rows = getSelectedFeeds();
 
        if (sel_rows.length > 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("");
 
 }
index 1a85bf3c483b431b380e4a8e5f027b901cd6354b..fa67a45eed39bbd557ded01a2db2d8257d1fdd1c 100644 (file)
--- a/prefs.php
+++ b/prefs.php
        <td class="prefContent" valign="top" colspan="2">
                <h2>Feed Configuration</h2>
 
+<!--
                <table class="prefAddFeed">
                        <td><input id="fadd_link"></td>
                        <td colspan="4" align="right">
                                <a class="button" href="javascript:addFeed()">Add feed</a></td></tr>
-               </table>
+               </table> 
+-->
+               <div id="piggie">&nbsp;</div>
 
                <div id="feeds">&nbsp;</div>
 
                <p>Selection:&nbsp;
+                       <a class="button" 
+                               href="javascript:editSelectedFeed()">Edit</a>&nbsp;
                        <a class="buttonWarn" 
                                href="javascript:removeSelectedFeeds()">Remove</a>&nbsp;
                        <a class="button" 
index a02f81a76f682034d617098114e7526db39fed91..d5f88276b7d51f5ec73ca0e25db55268081284cf 100644 (file)
@@ -148,6 +148,7 @@ table.main td.prefContent {
        border-width : 1px 0px 0px 0px;
        border-color : #c0c0c0;
        border-style : solid;
+
 }
 
 table.main td.content {
@@ -320,3 +321,21 @@ table.postTable td.post {
        padding : 20px;
 
 }
+
+#piggie {
+       width : 400;
+       height : 400;
+       left : 50;
+       background-color : white;
+       display : none;
+       z-index : 3;
+       background-image : url("http://madoka.spb.ru/stuff/fox/piggie.png");
+       background-position : center center;
+       background-repeat : no-repeat;
+       position : absolute;
+       border : 1px solid pink;        
+       margin-left : auto;
+       margin-right : auto;
+       -moz-border-radius : 10px;
+       opacity : 0.8;
+}
index 2ed413a97bad9e0b09cbddada0454054219024f1..16ca4cf1af64cf0f41f4236478fd66faed5312f9 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -18,8 +18,10 @@ try {
 } catch (e) {
        try {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
+               xmlhttp_rpc = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (E) {
                xmlhttp = false;
+               xmlhttp_rpc = false;
        }
 }
 @end @*/
@@ -30,10 +32,6 @@ if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 
 }
 
-function printLockingError() {
-       notify("Please wait until operation finishes");
-}
-
 function notify_callback() {
        var container = document.getElementById('notify');
        if (xmlhttp.readyState == 4) {