View the DQSD CVS repository here:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/dqsd/

Update of /cvsroot/dqsd/dqsd
In directory usw-pr-cvs1:/tmp/cvs-serv27695

Modified Files:
        ChangeLog.txt helpbox.js helpmenu.js loader.js 
Log Message:
Added ability for subcategories in popup menu.

Index: ChangeLog.txt
===================================================================
RCS file: /cvsroot/dqsd/dqsd/ChangeLog.txt,v
retrieving revision 1.125
retrieving revision 1.126
diff -C2 -d -r1.125 -r1.126
*** ChangeLog.txt       28 Sep 2002 20:02:28 -0000      1.125
--- ChangeLog.txt       29 Sep 2002 05:45:44 -0000      1.126
***************
*** 39,42 ****
--- 39,43 ----
    This is helpful to see what the actual command is from the shortcuts menu without 
having to open up localaliases.txt.
  * Added add-ons and searches to modify the popup menu using calls to registerMenuHook
+ * Added ability for subcategories in the popup menu by nesting <category/>'s
  
  Bug Fixes

Index: helpbox.js
===================================================================
RCS file: /cvsroot/dqsd/dqsd/helpbox.js,v
retrieving revision 1.35
retrieving revision 1.36
diff -C2 -d -r1.35 -r1.36
*** helpbox.js  25 Sep 2002 20:22:14 -0000      1.35
--- helpbox.js  29 Sep 2002 05:45:44 -0000      1.36
***************
*** 59,63 ****
      var txt;
      var helptable = "";
!     helptable += "<tr><td align=center colspan=50><table><tr class='localSearch'><td 
class='helpboxCommands' style='width: 12px;'></td><td>&nbsp;- indicates a local search 
(loaded from 'localsearches' subdirectory)</td></tr></table></td></tr>\n";
  
      for (i = 0; i < 10; i++)
--- 59,63 ----
      var txt;
      var helptable = "";
!     helptable += "<tr><td align=center colspan=50><table><tr class='localSearch'><td 
class='helpboxCommands' style='width: 12px;'></td><td>&nbsp;- indicates a local search 
or alias</td></tr></table></td></tr>\n";
  
      for (i = 0; i < 10; i++)

Index: helpmenu.js
===================================================================
RCS file: /cvsroot/dqsd/dqsd/helpmenu.js,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** helpmenu.js 28 Sep 2002 20:02:28 -0000      1.31
--- helpmenu.js 29 Sep 2002 05:45:44 -0000      1.32
***************
*** 19,22 ****
--- 19,25 ----
    mb.AppendMenuItem( "Check for update...", "checkWebForUpdateNotifyAll", "Check for 
update to Dave's Quick Search Deskbar" );
    mb.AppendSeparator( 0 );
+   
+   menuHandles = new Object();
+ 
    for (i = 0; i < categoryarray.length; i++)
    {
***************
*** 33,37 ****
        continue;
  
!     var hsubmenu = mb.AppendSubMenu( categoryName );
      helparray.sort( searchCompare );
      for (var k = 0; k < helparray.length; k++)
--- 36,40 ----
        continue;
  
!     var hcatmenu = mb.AppendSubMenu( categoryName );
      helparray.sort( searchCompare );
      for (var k = 0; k < helparray.length; k++)
***************
*** 41,48 ****
--- 44,76 ----
  
        if ( search.enabled )
+       {
+       
+         // If there are subcategories, nest them
+         if ( search.subcats && search.subcats.length >= 1 )
+         {
+           subcatPath = categoryName;
+           hsubmenu = hcatmenu;
+           for ( var isubmenu = 0; isubmenu < search.subcats.length; isubmenu++ )
+           {
+             subcatPath += '~' + search.subcats[ isubmenu ];
+             if ( menuHandles[ subcatPath ] )
+               hsubmenu = menuHandles[ subcatPath ]
+             else
+             {
+               hsubmenu = mb.AppendSubMenu( search.subcats[ isubmenu ], hsubmenu );
+               menuHandles[ subcatPath ] = hsubmenu;
+             }
+           }
+         }
+         else // no subcategories, append menu items
+         {
+           hsubmenu = hcatmenu;
+         }
+       
          mb.AppendMenuItem( search.name + (search.local ? ' [local]' : '' )  + '\t' + 
(search.aliasmenudisplay ? alias.replace(/&/g, '&&') : ""),  // menu text along with 
alias
                             search.aliases[0],         // function invoked when user 
selects menu item
                             makeToolTipString(search), 
                             hsubmenu );
+       }
      }
    }

Index: loader.js
===================================================================
RCS file: /cvsroot/dqsd/dqsd/loader.js,v
retrieving revision 1.53
retrieving revision 1.54
diff -C2 -d -r1.53 -r1.54
*** loader.js   28 Sep 2002 20:02:28 -0000      1.53
--- loader.js   29 Sep 2002 05:45:44 -0000      1.54
***************
*** 1,5 ****
  // Load the contents of search.xml, aliases, and menu files
  
! function addsearch(fname, name, desc, link, cat, local)
  {
    try
--- 1,5 ----
  // Load the contents of search.xml, aliases, and menu files
  
! function addsearch(fname, name, desc, link, cat, local, subcats)
  {
    try
***************
*** 10,13 ****
--- 10,14 ----
                         link:link, 
                         cat:cat, 
+                        subcats:subcats,
                         fun:eval(fname), 
                         aliases:[], 
***************
*** 29,33 ****
  INTERNAL_FUNC_PREFIX = "_dqsd_internal_fn_";
  
! function addalias(alias, fname, name, desc, cat)
  {
    // If this alias is already defined, then remove it from the search it was 
previously defined for
--- 30,34 ----
  INTERNAL_FUNC_PREFIX = "_dqsd_internal_fn_";
  
! function addalias(alias, fname, name, desc, cat, subcats)
  {
    // If this alias is already defined, then remove it from the search it was 
previously defined for
***************
*** 86,90 ****
                            );
        eval( fname + " = f;" );
!       addsearch( fname, name ? name : url, desc ? desc : url, url.search(/%s/) < 0 ? 
url : "", cat);
      }
      else if ((res = fname.match(/^(\w+) +(.+)/)) && searches[res[1]]) // starts with 
a valid search function
--- 87,91 ----
                            );
        eval( fname + " = f;" );
!       addsearch( fname, name ? name : url, desc ? desc : url, url.search(/%s/) < 0 ? 
url : "", cat, true, subcats);
      }
      else if ((res = fname.match(/^(\w+) +(.+)/)) && searches[res[1]]) // starts with 
a valid search function
***************
*** 97,101 ****
                            );
        eval( fname + " = f;" );
!       addsearch( fname, name ? name : cmd, desc ? desc : cmd, "", cat);
      }
      else
--- 98,102 ----
                            );
        eval( fname + " = f;" );
!       addsearch( fname, name ? name : cmd, desc ? desc : cmd, "", cat, true, 
subcats);
      }
      else
***************
*** 223,230 ****
        var externalScriptName = externalScriptRef.text;
        if ( loadedScripts[ externalScriptName ] ) // External script is already loaded
-       {
-         //alert( externalScriptName + ' already loaded' );
          continue;
-       }
        
        xScriptVal = readFile( externalScriptName );
--- 224,228 ----
***************
*** 274,277 ****
--- 272,277 ----
        var linkNode = searchNode.selectSingleNode("link");
        var categoryNode = searchNode.selectSingleNode("category");
+       var searchCategories = new Array();
+       getCategories( categoryNode, searchCategories );
        var descriptonXml = null;
        if(descriptionNode)
***************
*** 286,295 ****
                  descriptionXml,
                  (linkNode ? linkNode.text : null),
!                 (categoryNode ? categoryNode.text : null),
!                 localsearch);
      }
    }
  }
  
  
  // 4. load and execute the alias file
--- 286,317 ----
                  descriptionXml,
                  (linkNode ? linkNode.text : null),
!                 searchCategories.length ? searchCategories[0] : null,
!                 localsearch,
!                 searchCategories.slice( 1 ) );
      }
    }
  }
  
+ function getCategories( categoryNode, categories )
+ {
+   var nodes = categoryNode.childNodes;
+   if ( !nodes )
+     alert( categoryNode.text );
+   for ( var i = 0; i < nodes.length; i++ )
+   {
+     if ( nodes[i].nodeType == 3 ) // NODE_TEXT
+     {
+       var text = nodes[i].nodeValue
+                   .replace( /(^\s*)|(\s*$)/g, '' )    // leading/trailing whitespace
+                   .replace( /\r\n\s*\r\n/g, '\r\n' );  // blank lines
+ 
+       categories.push( text );
+     }
+     else if ( nodes[i].nodeType == 1 ) // NODE_ELEMENT
+     {
+       getCategories( nodes[i], categories );
+     }
+   }
+ }
  
  // 4. load and execute the alias file
***************
*** 316,320 ****
                   (fields.length >= 3 && fields[2] != '') ? fields[2] : null,   // 
name
                   (fields.length >= 4 && fields[3] != '') ? fields[3] : null,   // 
description
!                  (fields.length >= 5 && fields[4] != "") ? fields[4] : 
((arguments.length >= 2) ? category : null) // category
                   );
        }
--- 338,343 ----
                   (fields.length >= 3 && fields[2] != '') ? fields[2] : null,   // 
name
                   (fields.length >= 4 && fields[3] != '') ? fields[3] : null,   // 
description
!                  (fields.length >= 5 && fields[4] != "") ? fields[4] : 
((arguments.length >= 2) ? category : null), // category
!                  (fields.length >= 6 && fields[5] != "") ? fields[5].split(',') : 
new Array() // subcategories
                   );
        }




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
DQSD-CVS mailing list
https://lists.sourceforge.net/lists/listinfo/dqsd-cvs
DQSD CVS repository:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/dqsd/

Reply via email to