Skip to content

Instantly share code, notes, and snippets.

@BGMcoder
Created March 11, 2015 03:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BGMcoder/051e265dccffb827a5b5 to your computer and use it in GitHub Desktop.
Save BGMcoder/051e265dccffb827a5b5 to your computer and use it in GitHub Desktop.
Greasemonkey userscript to provides some interface fixes for FreePBX Admin.
// ==UserScript==
// @name FreePBX
// @namespace @bgm-freepbx
// @description freepbx interface mods
// @include http://YOUR_SERVER_HERE/admin/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @version 1
// @grant GM_addStyle
// @run-at document-end
// ==/UserScript==
//v 1.0 November 29, 2014 - initial release\
GM_addStyle("#footer {display:none; }");
GM_addStyle(".rnav { width:250px; }");
GM_addStyle(".rnav ul { max-height:70em;}"); //set the height of the right-nav
//add the filterbox and a button to clear the filter
$("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>");
//attach a function to the keyup event on the filter box so we can filter in live fashion
$('#filterInput').keyup(function() {
DynamicFilter($('#filterInput').val() );
});
//attach a function to the ClearFilter button; clear the filter and unfilter the list
$('#ClearFilterInput').click(function() {
$('#filterInput').val("");
DynamicFilter($('#filterInput').val() );
});
function DynamicFilter(whattext){
whattext = whattext.toLowerCase();
var thisrow = $('.rnav li.ui-menu-item');
thisrow.find('a').each(function(index, thiselement){
var source = $(this).text().toLowerCase();
//now check to see if the filter text exists in the remaining text
if (source.indexOf(whattext) < 0){
$(this).parent().hide(); //hide the row if it doesn't contain the text
} else {
$(this).parent().show(); //otherwise show it
};
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment