]> git.wh0rd.org Git - tt-rss.git/commitdiff
headlines subtoolbar, misc api changes
authorAndrew Dolgov <fox@bah.spb.su>
Sun, 27 Nov 2005 14:56:10 +0000 (15:56 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Sun, 27 Nov 2005 14:56:10 +0000 (15:56 +0100)
backend.php
functions.js
prefs.js
tt-rss.css
tt-rss.php
viewfeed.js

index b357cb18bc8dff90c064ca20f0ffc52e8fb13e22..9d22a3d09332797fa5610796ae4c11386cc9d531 100644 (file)
 
        $fetch = $_GET["fetch"];
 
+       function getAllCounters($link) {
+               getLabelCounters($link);
+               getFeedCounters($link);
+               getTagCounters($link);
+               getGlobalCounters($link);
+       }       
+
        /* FIXME this needs reworking */
 
        function getGlobalCounters($link) {
 
                if ($subop == "getAllCounters") {
                        print "<rpc-reply>";
-                       getLabelCounters($link);
-                       getFeedCounters($link);
-                       getTagCounters($link);
-                       getGlobalCounters($link);
+                       getAllCounters($link);
                        print "</rpc-reply>";
                }
 
                        getGlobalCounters($link);
                        print "</rpc-reply>";
                }
-               
+       
+               /* GET["cmode"] = 0 - mark as read, 1 - as unread, 2 - toggle */
                if ($subop == "catchupSelected") {
 
                        $ids = split(",", $_GET["ids"]);
 
-                       foreach ($ids as $id) {
+                       $cmode = sprintf("%d", $_GET["cmode"]);
 
-                               db_query($link, "UPDATE ttrss_user_entries SET unread=false,last_read = NOW()
-                                       WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
+                       foreach ($ids as $id) {
 
+                               if ($cmode == 0) {
+                                       db_query($link, "UPDATE ttrss_user_entries SET 
+                                       unread = false,last_read = NOW()
+                                       WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
+                               } else if ($cmode == 1) {
+                                       db_query($link, "UPDATE ttrss_user_entries SET 
+                                       unread = true
+                                       WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
+                               } else {
+                                       db_query($link, "UPDATE ttrss_user_entries SET 
+                                       unread = NOT unread,last_read = NOW()
+                                       WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
+                               }
                        }
+                       print "<rpc-reply>";
+                       getAllCounters($link);
+                       print "</rpc-reply>";
+               }
+
+               if ($subop == "markSelected") {
+
+                       $ids = split(",", $_GET["ids"]);
+
+                       $cmode = sprintf("%d", $_GET["cmode"]);
+
+                       foreach ($ids as $id) {
 
-                       print "Marked active page as read.";
+                               if ($cmode == 0) {
+                                       db_query($link, "UPDATE ttrss_user_entries SET 
+                                       marked = false
+                                       WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
+                               } else if ($cmode == 1) {
+                                       db_query($link, "UPDATE ttrss_user_entries SET 
+                                       marked = true
+                                       WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
+                               } else {
+                                       db_query($link, "UPDATE ttrss_user_entries SET 
+                                       marked = NOT marked
+                                       WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
+                               }
+                       }
+                       print "<rpc-reply>";
+                       getAllCounters($link);
+                       print "</rpc-reply>";
                }
 
                if ($subop == "sanityCheck") {
 
                }
 
-               print "<table class=\"headlinesList\" id=\"headlinesList\" width=\"100%\">";
-
                $search = $_GET["search"];
 
                $search_mode = $_GET["smode"];
                        $query_strategy_part = "id > 0"; // dumb
                }
 
-
                $order_by = "updated DESC";
 
 //             if ($feed < -10) {
 //                     $order_by = "feed_id,updated DESC";
 //             }
 
+               $feed_title = "";
+
+               if ($search && $search_mode == "All feeds") {
+                       $feed_title = "Search results";
+               } else if (sprintf("%d", $feed) == 0) {
+                       $feed_title = $feed;
+               } else if ($feed > 0) {
+                       $result = db_query($link, "SELECT title,site_url FROM ttrss_feeds 
+                               WHERE id = '$feed'");
+
+                       $feed_title = db_fetch_result($result, 0, "title");
+                       $feed_site_url = db_fetch_result($result, 0, "site_url");
+
+               } else if ($feed == -1) {
+                       $feed_title = "Starred articles";
+               } else if ($feed < -10) {
+                       $label_id = -$feed - 11;
+                       $result = db_query($link, "SELECT description FROM ttrss_labels
+                               WHERE id = '$label_id'");
+                       $feed_title = db_fetch_result($result, 0, "description");
+               } else {
+                       $feed_title = "?";
+               }
+
+               print "<table class=\"headlinesSubToolbar\" 
+                       width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><tr>";
+               
+               print "<td class=\"headlineActions\">
+                       Select: 
+                                       <a href=\"javascript:selectTableRowsByIdPrefix('headlinesList', 
+                                               'RROW-', 'RCHK-', true)\">All</a>,
+                                       <a href=\"javascript:selectTableRowsByIdPrefix('headlinesList', 
+                                               'RROW-', 'RCHK-', true, 'Unread')\">Unread</a>,
+                                       <a href=\"javascript:selectTableRowsByIdPrefix('headlinesList', 
+                                               'RROW-', 'RCHK-', false)\">None</a>
+                       &nbsp;&nbsp;
+                       Toggle: <a href=\"javascript:toggleUnread()\">Unread</a>,
+                                       <a href=\"javascript:toggleStarred()\">Starred</a>";
+
+/*             print "&nbsp;&nbsp;
+                       View:
+                               <a href=\"javascript:limitView('All')\">All</a>,
+                               <a href=\"javascript:limitView('Unread')\">Unread</a>,
+                               <a href=\"javascript:limitView('Starred')\">Starred</a>
+                       &nbsp;&nbsp;
+                       Feed:
+                               <a href=\"javascript:updateCurrentFeed()\">Update</a>,
+                               <a href=\"javascript:catchupCurrentFeed()\">Mark as read</a>"; */
+
+               print "</td>";
+
+               print "<td class=\"headlineTitle\">";
+
+               if ($feed_site_url) {
+                       print "<a href=\"$feed_site_url\">$feed_title</a>";
+               } else {
+                       print $feed_title;
+               }
+               
+               print "</td>";
+               print "</tr></table>";
+               
+               print "<table class=\"headlinesList\" id=\"headlinesList\" width=\"100%\">";
+
+
                if ($feed < -10) error_reporting (0);
 
                if (sprintf("%d", $feed) != 0) {
                        }
 
                        $result = db_query($link, "SELECT 
-                                       id,title,updated,unread,feed_id,marked,link,last_read,
+                                       id,title,
+                                       SUBSTRING(updated,1,16) as updated,
+                                       unread,feed_id,marked,link,last_read,
                                        SUBSTRING(last_read,1,19) as last_read_noms,
                                        $vfeed_query_part
                                        SUBSTRING(updated,1,19) as updated_noms
                        $feed_kind = "Tags";
 
                        $result = db_query($link, "SELECT
-                               ttrss_entries.id as id,title,updated,unread,feed_id,
+                               ttrss_entries.id as id,title,
+                               SUBSTRING(updated,1,16) as updated,
+                               unread,feed_id,
                                marked,link,last_read,
                                SUBSTRING(last_read,1,19) as last_read_noms,
                                $vfeed_query_part
                        // onclick=\"javascript:view($id,$feed_id)\">
 
                        print "<td valign='center' align='center'>$update_pic</td>";
+
+                       print "<td valign='center' align='center'>
+                               <input type=\"checkbox\" onclick=\"toggleSelectRow(this)\"
+                                       class=\"feedCheckBox\" id=\"RCHK-$id\">
+                               </td>";
+
                        print "<td valign='center' align='center'>$marked_pic</td>";
 
-                       print "<td width='25%'>
+                       print "<td width='20%'>
                                <a href=\"javascript:view($id,$feed_id);\">".$line["updated"]."</a></td>";
 
                        if ($line["feed_title"]) {                      
-                               print "<td width='50%'>$content_link</td>";
+                               print "<td width='55%'>$content_link</td>";
                                print "<td width='20%'>
                                        <a href='javascript:viewfeed($feed_id)'>".$line["feed_title"]."</a></td>";
                        } else {
-                               print "<td width='70%'>$content_link</td>";
+                               print "<td width='75%'>$content_link</td>";
                        }
 
                        print "</tr>";
index 36aa8fd6a7c1abab32d65e32156281708f7eeddc..d3886437b932bc391657c56d50b5b52e09208e8b 100644 (file)
@@ -32,6 +32,13 @@ function rpc_notify_callback() {
        }
 }
 
+function rpc_pnotify_callback() {
+       var container = parent.document.getElementById('notify');
+       if (xmlhttp_rpc.readyState == 4) {
+               container.innerHTML=xmlhttp_rpc.responseText;
+       }
+}
+
 function param_escape(arg) {
        if (typeof encodeURIComponent != 'undefined')
                return encodeURIComponent(arg); 
@@ -469,7 +476,8 @@ function selectTableRow(r, do_select) {
        }
 }
 
-function selectTableRowsByIdPrefix(content_id, prefix, check_prefix, do_select) {
+function selectTableRowsByIdPrefix(content_id, prefix, check_prefix, do_select, 
+       classcheck) {
 
        var content = document.getElementById(content_id);
 
@@ -479,15 +487,18 @@ function selectTableRowsByIdPrefix(content_id, prefix, check_prefix, do_select)
        }
 
        for (i = 0; i < content.rows.length; i++) {
-               if (content.rows[i].id.match(prefix)) {
-                       selectTableRow(content.rows[i], do_select);
-               }
+               if (!classcheck || content.rows[i].className.match(classcheck)) {
+       
+                       if (content.rows[i].id.match(prefix)) {
+                               selectTableRow(content.rows[i], do_select);
+                       }
 
-               var row_id = content.rows[i].id.replace(prefix, "");
-               var check = document.getElementById(check_prefix + row_id);
+                       var row_id = content.rows[i].id.replace(prefix, "");
+                       var check = document.getElementById(check_prefix + row_id);
 
-               if (check) {
-                       check.checked = do_select;
+                       if (check) {
+                               check.checked = do_select;
+                       }
                }
        }
 }
@@ -504,7 +515,9 @@ function getSelectedTableRowIds(content_id, prefix) {
        var sel_rows = new Array();
 
        for (i = 0; i < content.rows.length; i++) {
-               if (content.rows[i].className.match("Selected")) {
+               if (content.rows[i].id.match(prefix) && 
+                               content.rows[i].className.match("Selected")) {
+                               
                        var row_id = content.rows[i].id.replace(prefix + "-", "");
                        sel_rows.push(row_id);  
                }
@@ -514,3 +527,18 @@ function getSelectedTableRowIds(content_id, prefix) {
 
 }
 
+function toggleSelectRow(sender) {
+       var parent_row = sender.parentNode.parentNode;
+
+       if (sender.checked) {
+               if (!parent_row.className.match("Selected")) {
+                       parent_row.className = parent_row.className + "Selected";
+               }
+       } else {
+               if (parent_row.className.match("Selected")) {
+                       parent_row.className = parent_row.className.replace("Selected", "");
+               }
+       }
+}
+
+
index 5c699f2370c909dc88ce9b59943945bd1bca146e..59af58fd1315c17d1f369a7f34d9ad509015fee3 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -195,20 +195,6 @@ function updateUsersList() {
 
 }
 
-function toggleSelectRow(sender) {
-       var parent_row = sender.parentNode.parentNode;
-
-       if (sender.checked) {
-               if (!parent_row.className.match("Selected")) {
-                       parent_row.className = parent_row.className + "Selected";
-               }
-       } else {
-               if (parent_row.className.match("Selected")) {
-                       parent_row.className = parent_row.className.replace("Selected", "");
-               }
-       }
-}
-
 function addLabel() {
 
        if (!xmlhttp_ready(xmlhttp)) {
index d7c905734749f8ef7021f72d2f9e145a75741493..9da226bc8fe2f65e92bfd5d158da18454d359fdf 100644 (file)
@@ -686,3 +686,17 @@ td.selectPrompt {
        font-size : x-small;
        color : gray;
 }
+
+table.headlinesSubToolbar td.headlineActions {
+       font-size : x-small;
+       color : gray;
+       padding : 5px 0px 5px 5px;
+}
+
+table.headlinesSubToolbar td.headlineTitle {
+       font-size : x-small;
+       color : gray;
+       padding : 5px 5px 5px 0px;
+       text-align : right;
+}
+
index 48a491fa6faeb70cfe66ccd7a198f7be95a14cf4..cb2021fded6fc55c5d8bd6d4e1313a11cccf8526 100644 (file)
                <input type="submit" 
                        class="button" onclick="javascript:search()" value="Search">
 
-               &nbsp; 
-               
-               View: 
+               &nbsp;View: 
                
                <select id="viewbox" onchange="javascript:viewCurrentFeed(0, '')">
                        <option>All Articles</option>
                
                </select>
 
+<!--           &nbsp;Selection:
+
+               <select id="headopbox">
+                       <option id="hopToggleRead">Toggle (un)read</option>
+               </select>
+
+               <input class="button" type="submit" onclick="headopGo()" value="Go"> -->
+
                &nbsp;Feed: <input class="button" type="submit"
                        onclick="javascript:viewCurrentFeed(0, 'ForceUpdate')" value="Update">
 
                <input class="button" type="submit" id="btnMarkFeedAsRead"
-                       onclick="javascript:viewCurrentFeed(0, 'MarkAllRead')" value="Mark as read">
+                       onclick="javascript:viewCurrentFeed(0, 'MarkAllRead')" value="Mark as read"> 
 
                </td>
                <td align="right">
index 9d42b9102c4272c186e92ac1fdc8aa5e600a1466..7f33824021cb531bb4eafcee76fc6965ed4fe175 100644 (file)
@@ -77,6 +77,11 @@ function view(id, feed_id) {
 
 }
 
+function rowToggleMark(row) {
+
+
+
+}
 
 function toggleMark(id, toggle) {
 
@@ -133,7 +138,7 @@ function toggleMark(id, toggle) {
        }
 
        xmlhttp_rpc.open("GET", query, true);
-       xmlhttp_rpc.onreadystatechange=rpc_notify_callback;
+       xmlhttp_rpc.onreadystatechange=rpc_pnotify_callback;
        xmlhttp_rpc.send(null);
 
 }
@@ -208,6 +213,92 @@ function localHotkeyHandler(keycode) {
 
 }
 
+function toggleUnread() {
+       try {
+               if (!xmlhttp_ready(xmlhttp_rpc)) {
+                       printLockingError();
+                       return;
+               }
+       
+               var rows = getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
+
+               for (i = 0; i < rows.length; i++) {
+                       var row = document.getElementById("RROW-" + rows[i]);
+                       if (row) {
+                               var nc = row.className;
+                               nc = nc.replace("Unread", "");
+                               nc = nc.replace("Selected", "");
+
+                               if (row.className.match("Unread")) {
+                                       row.className = nc + "Selected";
+                               } else {
+                                       row.className = nc + "UnreadSelected";
+                               }
+                       }
+               }
+
+               if (rows.length > 0) {
+
+                       var query = "backend.php?op=rpc&subop=catchupSelected&ids=" +
+                               param_escape(rows.toString()) + "&cmode=2";
+
+                       xmlhttp_rpc.open("GET", query, true);
+                       xmlhttp_rpc.onreadystatechange=all_counters_callback;
+                       xmlhttp_rpc.send(null);
+
+               }
+
+       } catch (e) {
+               exception_error(e);
+       }
+}
+
+function toggleStarred() {
+       try {
+               if (!xmlhttp_ready(xmlhttp_rpc)) {
+                       printLockingError();
+                       return;
+               }
+       
+               var rows = getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
+
+               for (i = 0; i < rows.length; i++) {
+                       var row = document.getElementById("RROW-" + rows[i]);
+                       var mark_img = document.getElementById("FMARKPIC-" + rows[i]);
+
+                       if (row && mark_img) {
+
+                               if (mark_img.alt == "Set mark") {
+                                       mark_img.src = "images/mark_set.png";
+                                       mark_img.alt = "Reset mark";
+                                       mark_img.setAttribute('onclick', 
+                                               'javascript:toggleMark('+rows[i]+', false)');
+
+                               } else {
+                                       mark_img.src = "images/mark_unset.png";
+                                       mark_img.alt = "Set mark";
+                                       mark_img.setAttribute('onclick', 
+                                               'javascript:toggleMark('+rows[i]+', true)');
+                               }
+                       }
+               }
+
+               if (rows.length > 0) {
+
+                       var query = "backend.php?op=rpc&subop=markSelected&ids=" +
+                               param_escape(rows.toString()) + "&cmode=2";
+
+                       xmlhttp_rpc.open("GET", query, true);
+                       xmlhttp_rpc.onreadystatechange=all_counters_callback;
+                       xmlhttp_rpc.send(null);
+
+               }
+
+       } catch (e) {
+               exception_error(e);
+       }
+}
+
 function init() {
        document.onkeydown = hotkey_handler;
 }