]> git.wh0rd.org Git - tt-rss.git/commitdiff
show tag cloud instead of flat tag list
authorAndrew Dolgov <fox@bah.spb.su>
Thu, 17 May 2007 11:58:38 +0000 (12:58 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Thu, 17 May 2007 11:58:38 +0000 (12:58 +0100)
feedlist.js
functions.php
modules/popup-dialog.php
tt-rss.css
tt-rss.js
tt-rss.php

index 740020e633f121ef51c40e94c66193b7f6561ed7..9bfd9a235765f472f721347a052cca9542f9609c 100644 (file)
@@ -46,6 +46,8 @@ function viewfeed(feed, subop, is_cat, subop_param, skip_history, offset) {
 
                enableHotkeys();
 
+               closeInfoBox();
+
 /*             if (!skip_history) {
                        history_push('FEED:' + feed + ':' + subop + ':' + is_cat +
                                ':' + subop_param);
index 17712ebceb5a5221fb5ae875aac14f97a026c1de..0bcbc5e47944ef5e6d0a91f32b28907f7130c525 100644 (file)
 
                return $topmost_article_ids;
        }
+
+// from here: http://www.roscripts.com/Create_tag_cloud-71.html
+
+       function printTagCloud($link) {
+       
+               $query = "SELECT tag_name, COUNT(post_int_id) AS count 
+                       FROM ttrss_tags WHERE owner_uid = ".$_SESSION["uid"]." 
+                       GROUP BY tag_name ORDER BY count DESC LIMIT 50";
+
+               $result = db_query($link, $query);
+
+               $tags = array();
+
+               while ($line = db_fetch_assoc($result)) {
+                       $tags[$line["tag_name"]] = $line["count"];
+               }
+
+               ksort($tags);
+
+               $max_size = 32; // max font size in pixels
+               $min_size = 9; // min font size in pixels
+                  
+               // largest and smallest array values
+               $max_qty = max(array_values($tags));
+               $min_qty = min(array_values($tags));
+                  
+               // find the range of values
+               $spread = $max_qty - $min_qty;
+               if ($spread == 0) { // we don't want to divide by zero
+                               $spread = 1;
+               }
+                  
+               // set the font-size increment
+               $step = ($max_size - $min_size) / ($spread);
+                  
+               // loop through the tag array
+               foreach ($tags as $key => $value) {
+                       // calculate font-size
+                       // find the $value in excess of $min_qty
+                       // multiply by the font-size increment ($size)
+                       // and add the $min_size set above
+                       $size = round($min_size + (($value - $min_qty) * $step));
+                  
+                       echo "<a href=\"javascript:viewfeed('$key') \" style=\"font-size: " . 
+                               $size . "px\" title=\"$value articles tagged with " . 
+                               $key . '">' . $key . '</a> ';
+               }
+       }
 ?>
index 0403b6231b7b853fe59ff487ad3a023b7a27458b..3011f8c1be1138976ecd57a5794930cdb45dc50f 100644 (file)
                        return;
                }
 
+               if ($id == "printTagCloud") {
+                       print "<div id=\"infoBoxTitle\">".__('Tag Cloud')."</div>";
+                       print "<div class=\"infoBoxContents\">";
+
+                       print "Showing top 50 most popular tags (<a 
+                               href='javascript:toggleTags(true)'>show all</a>):<br/>";
+
+                       print "<div class=\"tagCloudContainer\">";
+
+                       printTagCloud($link);
+
+                       print "</div>";
+
+                       print "<div align='center'>";
+                       print "<input class=\"button\"
+                               type=\"submit\" onclick=\"return closeInfoBox()\" 
+                               value=\"".__('Close')."\">";
+                       print "</div>";
+
+                       print "</div>";
+
+                       return;
+               }
+
                print "<div id='infoBoxTitle'>Internal Error</div>
                        <div id='infoBoxContents'>
                        <p>Unknown dialog <b>$id</b></p>
index 69f191cda7b65b9c831af9a25c6c2f482f77b299..47152d2b609489f843f63608484739b1b6bf2901 100644 (file)
@@ -921,6 +921,16 @@ span.groupPrompt {
        color : #4684ff;
 }
 
+div.tagCloudContainer {
+/*     height : 300px;
+       overflow : auto; */
+       border : 1px solid #99d67a;
+       background-color : white;
+       margin : 5px 0px 5px 0px;
+       padding : 10px;
+       text-align : center;
+}
+
 ul.feedErrorsList {
        height : 300px;
        overflow : auto;
index 861c9abb8acaf096ed1574af08496237f920d4e5..56351332e00c33057c4369178877073e3db87e1e 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -27,20 +27,26 @@ function tagsAreDisplayed() {
        return display_tags;
 }
 
-function toggleTags() {
-       display_tags = !display_tags;
+function toggleTags(show_all) {
 
        var p = document.getElementById("dispSwitchPrompt");
 
-       if (display_tags) {
+       if (!show_all && !display_tags) {
+               displayDlg("printTagCloud");
+       } else if (show_all) {
+               closeInfoBox();
+               display_tags = true;
                p.innerHTML = __("display feeds");
-       } else {
-               p.innerHTML = __("display tags");
+               notify_progress("Loading, please wait...");
+               updateFeedList();
+       } else if (display_tags) {
+               display_tags = false;
+               p.innerHTML = __("tag cloud");
+               notify_progress("Loading, please wait...");
+               updateFeedList();
        }
-       
-       notify_progress("Loading, please wait...");
 
-       updateFeedList();
+       return false;
 }
 
 function dlg_frefresh_callback() {
@@ -514,6 +520,7 @@ function quickMenuGo(opid) {
                if (opid == "qmcAddFilter") {
                        displayDlg("quickAddFilter", getActiveFeedId());
                }
+
        } catch (e) {
                exception_error("quickMenuGo", e);
        }
index 6ab331611b7d238f59419419ab9c85c92ab34975..968f9cfeb8484b32ef0f05cd7cdbd620e160302e 100644 (file)
@@ -122,7 +122,7 @@ window.onload = init;
 <div id="feeds-holder">
        <div id="dispSwitch"> 
                <a id="dispSwitchPrompt" 
-                       href="javascript:toggleTags()"><?php echo __("display tags") ?></a>
+                       href="javascript:toggleTags()"><?php echo __("tag cloud") ?></a>
        </div>
        <div id="feeds-frame">&nbsp;</div>
 </div>