-
-
Save tallykatt/89d96a6129e406179ef6365d0ccdce51 to your computer and use it in GitHub Desktop.
phpMyAdmin - Bookmarklet for quickly selecting database(s) on a search string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Will not select system databases (greyed out) | |
* Works with regular expressions: | |
* '^te' -> matches 'test' database | |
* '^est' -> will NOT match 'test' database | |
* | |
* I created this to easily drop numerous databases | |
* that are part of a large system, such as 'phabricator.' | |
*/ | |
// code to save as a bookmark | |
javascript:(function(){var checkOn=0,checkOff=0,search=prompt("Database(s) to toggle checkbox?").trim();""==search&&(search=".*"),search=eval("/"+search+"/i"),$(".name").each(function(c){if($(this).find("a").text().match(search)){var e=$(this).parent().find(".checkall");if(!e.is(":disabled")){var a=!e.prop("checked");e.prop("checked",a),checkOn+=1==a,checkOff+=0==a}}});var msg="";checkOn&&(msg+="Selected: "+checkOn),checkOff&&(msg+=(msg?"\n":"")+"Unselected: "+checkOff),alert(msg);})(); | |
// un-minified code | |
var checkOn = 0 | |
,checkOff = 0 | |
,search = (prompt("Database(s) to toggle checkbox?")).trim(); | |
if (search == "") {search = ".*";} | |
search = eval('/'+search+'/i'); | |
$(".name").each(function(index) { | |
if ($(this).find("a").text().match(search)) { | |
var checkbox = $(this).parent().find(".checkall"); | |
if (!checkbox.is(":disabled")) { | |
var state = !checkbox.prop("checked"); | |
checkbox.prop("checked", state); | |
checkOn += (true == state); | |
checkOff += (false == state); | |
} | |
} | |
}); | |
var msg = ""; | |
if (checkOn) {msg += "Selected: "+ checkOn;} | |
if (checkOff) {msg += (msg?"\n":"")+"Unselected: "+ checkOff;} | |
alert(msg); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment