]> git.wh0rd.org - tt-rss.git/commitdiff
further javascript cleanups
authorAndrew Dolgov <fox@bah.spb.su>
Mon, 5 Sep 2005 12:41:59 +0000 (13:41 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Mon, 5 Sep 2005 12:41:59 +0000 (13:41 +0100)
backend.php
functions.js
functions.php
tt-rss.js
tt-rss.php
viewfeed.js

index a2236c3a60d8253a28e03c07c31349d377c89dbd..88d19641ff33f73c4cda1abdda21099aac463db2 100644 (file)
                // kludge, because iframe doesn't seem to support onload() 
                
                print "<script type=\"text/javascript\">
+                       document.onkeydown = hotkey_handler;
+
                        var feedr = parent.document.getElementById(\"FEEDR-\" + $feed);
                        var feedt = parent.document.getElementById(\"FEEDT-\" + $feed);
                        var feedu = parent.document.getElementById(\"FEEDU-\" + $feed);
index cb241ada6c2747834f204a19b574e31dbcc9230a..f0d76769d9a2663cf7d96ac481bb3e168dbe410f 100644 (file)
@@ -91,12 +91,15 @@ function hotkey_handler(e) {
 
        var piggie = document.getElementById("piggie");
 
-       if (seq.match("807371717369")) {
-               localPiggieFunction(true);
-       } else {
-               localPiggieFunction(false);
-       }
+       if (piggie) {
 
+               if (seq.match("807371717369")) {
+                       localPiggieFunction(true);
+               } else {
+                       localPiggieFunction(false);
+               }
+       }
+       
        if (typeof localHotkeyHandler != 'undefined') {
                localHotkeyHandler(keycode);
        }
index e6ef6589aecbc9fefc8f0bf96bbe776a524936db..b56e9a93aaef922c8d58893dd17bafe0a7aa7be6 100644 (file)
 
                                        $last_read_qpart = "";
 
-//                                     if ("$orig_title" != "$entry_title") {
-//                                             $last_read_qpart = 'last_read = null,';
-//                                     }
-                               
                                        if ($orig_content_hash != $content_hash) {
                                                if (UPDATE_POST_ON_CHECKSUM_CHANGE) {
                                                        $last_read_qpart = 'last_read = null,';
                                                $entry_is_modified = true;
                                        }
 
-//                                     if (!$no_orig_date && $orig_timestamp < $entry_timestamp) {
-//                                             $last_read_qpart = 'last_read = null,';
-//                                     }
-
                                        if ($entry_is_modified) {
 
                                                $entry_comments = pg_escape_string($entry_comments);
                                                $entry_title = pg_escape_string($entry_title);                                  
                                                $entry_link = pg_escape_string($entry_link);
 
-//                                             print "update object $entry_guid<br>";
-
                                                $query = "UPDATE ttrss_entries 
                                                        SET 
                                                                $last_read_qpart 
index 06c24916728fad8ffbbf952f2653f74f0d35e90c..9b18b79c2a9b2c08ca1d561b838d3407a8e48f4c 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -57,59 +57,6 @@ function feedlist_callback() {
        } 
 }
 
-/*
-function viewfeed_callback() {
-       var container = document.getElementById('headlines');
-       if (xmlhttp.readyState == 4) {
-               container.innerHTML = xmlhttp.responseText;
-
-               var factive = document.getElementById("FACTIVE");
-               var funread = document.getElementById("FUNREAD");
-               var ftotal = document.getElementById("FTOTAL");
-
-               if (_viewfeed_autoselect_first == true) {
-                       _viewfeed_autoselect_first = false;
-                       view(getFirstVisibleHeadlineId(), active_feed_id);
-               }
-
-               if (_viewfeed_autoselect_last == true) {
-                       _viewfeed_autoselect_last = false;
-                       view(getLastVisibleHeadlineId(), active_feed_id);
-               }
-
-               if (ftotal && factive && funread) {
-                       var feed_id = factive.innerHTML;
-
-                       var feedr = document.getElementById("FEEDR-" + feed_id);
-                       var feedt = document.getElementById("FEEDT-" + feed_id);
-                       var feedu = document.getElementById("FEEDU-" + feed_id);
-
-                       feedt.innerHTML = ftotal.innerHTML;
-                       feedu.innerHTML = funread.innerHTML;
-
-                       total_feed_entries = ftotal.innerHTML;  
-
-                       if (feedu.innerHTML > 0 && !feedr.className.match("Unread")) {
-                                       feedr.className = feedr.className + "Unread";
-                       } else if (feedu.innerHTML <= 0) {      
-                                       feedr.className = feedr.className.replace("Unread", "");
-                       }
-
-                       cleanSelected("feedsList");
-
-                       feedr.className = feedr.className + "Selected";
-               }
-
-               var searchbox = document.getElementById("searchbox");
-               searchbox.value = search_query;
-
-               markHeadline(active_post_id);
-
-               notify("");
-
-       }       
-} */
-
 function refetch_callback() {
 
        if (xmlhttp_rpc.readyState == 4) {
@@ -337,62 +284,6 @@ function viewfeed(feed, skip, subop) {
 
 }
 
-/*
-function view(id,feed_id) {
-
-       enableHotkeys();
-
-       if (!xmlhttp_ready(xmlhttp_view)) {
-               printLockingError();
-               return
-       }
-
-       var crow = document.getElementById("RROW-" + id);
-
-       if (crow.className.match("Unread")) {
-               var umark = document.getElementById("FEEDU-" + feed_id);
-               umark.innerHTML = umark.innerHTML - 1;
-               crow.className = crow.className.replace("Unread", "");
-
-               if (umark.innerHTML == "0") {
-                       var feedr = document.getElementById("FEEDR-" + feed_id);
-                       feedr.className = feedr.className.replace("Unread", "");
-               }
-
-               total_unread--;
-       }       
-
-       cleanSelected("headlinesList");
-//     crow.className = crow.className + "Selected";
-
-       var upd_img_pic = document.getElementById("FUPDPIC-" + id);
-
-       if (upd_img_pic) {
-               upd_img_pic.innerHTML = "";
-       } 
-
-//     document.getElementById('content').innerHTML='Loading, please wait...';         
-
-       var unread_rows = getVisibleUnreadHeadlines();
-
-       if (unread_rows.length == 0) {
-               var button = document.getElementById("btnCatchupPage");
-               if (button) {
-                       button.className = "disabledButton";
-                       button.href = "";
-               }
-       }
-
-       active_post_id = id;
-
-       var content = document.getElementById("content-frame");
-
-       content.src = "backend.php?op=view&addheader=true&id=" + param_escape(id);
-       markHeadline(active_post_id);
-
-}
-*/
-
 function timeout() {
        scheduleFeedUpdate(true);
        setTimeout("timeout()", 1800*1000);
index ec4e8b6ef693531a24d9a792aa4714e84063ea36..b30c4fcced0c2f57ea7dc68d25d5e58898b87230 100644 (file)
@@ -73,7 +73,7 @@
                <iframe name="headlines-frame" 
                        id="headlines-frame" class="headlinesFrame"> </iframe>
        </td>
-</tr>
+</tr><tr>
        <td class="content" id="content" valign="top">
                <iframe name="content-frame" id="content-frame" class="contentFrame"> </iframe>
        </td>
index e8b305dcf3ef7076de0f6ab2382b240d778f6ef3..6866c278cf02d646d5896b1b8f2b5e5df3cfb616 100644 (file)
@@ -1,4 +1,5 @@
-var active_post_id;
+var active_feed_id = false;
+var active_post_id = false;
 var total_unread = 0;
 
 var xmlhttp_rpc = false;
@@ -22,7 +23,7 @@ if (!xmlhttp_rpc && typeof XMLHttpRequest!='undefined') {
        xmlhttp_rpc = new XMLHttpRequest();
 }
 
-function view(id,feed_id) {
+function view(id, feed_id) {
 
        enableHotkeys();
 
@@ -60,6 +61,7 @@ function view(id,feed_id) {
        }
 
        active_post_id = id; 
+       active_feed_id = feed_id;
 
        var content = parent.document.getElementById("content-frame");
 
@@ -100,4 +102,53 @@ function toggleMark(id, toggle) {
 
 }
 
+function moveToPost(mode) {
 
+       var rows = getVisibleHeadlineIds();
+
+       var prev_id;
+       var next_id;
+
+       if (active_post_id == false) {
+               next_id = getFirstVisibleHeadlineId();
+               prev_id = getLastVisibleHeadlineId();
+       } else {        
+               for (var i = 0; i < rows.length; i++) {
+                       if (rows[i] == active_post_id) {
+                               prev_id = rows[i-1];
+                               next_id = rows[i+1];                    
+                       }
+               }
+       }
+
+       if (mode == "next") {
+               if (next_id != undefined) {
+                       view(next_id, active_feed_id);
+               }
+       }
+
+       if (mode == "prev") {
+               if ( prev_id != undefined) {
+                       view(prev_id, active_feed_id);
+               }
+       } 
+}
+
+function localHotkeyHandler(keycode) {
+
+       if (keycode == 78) {
+               return moveToPost('next');
+       }
+
+       if (keycode == 80) {
+               return moveToPost('prev');
+       } 
+
+// FIXME
+//     if (keycode == 85) {
+//             return viewfeed(active_feed_id, active_offset, "ForceUpdate");
+//     }
+
+//     alert("KC: " + keycode);
+
+}