BGM

FreeBPX

BGM
Dec 1st, 2014
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        FreePBX
  3. // @namespace   @bgm-freepbx
  4. // @description freepbx interface mods
  5. // @include     http://YOUR_SERVER_HERE/admin/*
  6. // @require  http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
  7. // @version     1
  8. // @grant      GM_addStyle
  9. // @run-at document-end
  10. // ==/UserScript==
  11. //v 1.0 November 29, 2014 - initial release\
  12.  
  13.  
  14. GM_addStyle("#footer {display:none; }");
  15.  
  16. GM_addStyle(".rnav { width:250px; }");
  17. GM_addStyle(".rnav ul { max-height:70em;}");        //set the height of the right-nav
  18.  
  19. //add the filterbox and a button to clear the filter
  20. $("div.rnav").prepend("<div id='FilterTable' style='display:block;'> <table> <tr> <td width='125px'><input type='text' id='filterInput'></td> <td><input id='ClearFilterInput' type='button' value='Clear' style='height:20px; line-height:8pt;' /></td></tr></table> </div>");
  21.  
  22.  
  23. //attach a function to the keyup event on the filter box so we can filter in live fashion
  24. $('#filterInput').keyup(function() {
  25.     DynamicFilter($('#filterInput').val() );
  26. });
  27.  
  28. //attach a function to the ClearFilter button; clear the filter and unfilter the list
  29. $('#ClearFilterInput').click(function() {
  30.     $('#filterInput').val("");
  31.     DynamicFilter($('#filterInput').val() );
  32. });
  33.  
  34.  
  35. function DynamicFilter(whattext){
  36.   whattext = whattext.toLowerCase();
  37.  
  38.    
  39.     var thisrow = $('.rnav li.ui-menu-item');  
  40.     thisrow.find('a').each(function(index, thiselement){
  41.             var source = $(this).text().toLowerCase();
  42.             //now check to see if the filter text exists in the remaining text
  43.             if (source.indexOf(whattext) < 0){
  44.                 $(this).parent().hide();  //hide the row if it doesn't contain the text
  45.             } else {
  46.                 $(this).parent().show();  //otherwise show it
  47.             };
  48.        
  49.     });
  50.    
  51. };
Add Comment
Please, Sign In to add comment