Skip to content

Instantly share code, notes, and snippets.

@fedmich
Created April 23, 2012 08:37
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 fedmich/2469602 to your computer and use it in GitHub Desktop.
Save fedmich/2469602 to your computer and use it in GitHub Desktop.
CakePHP - Debug tools
$(function() {
$('table.cake-sql-log').css({border:'red 1px dashed'});
$('table.cake-sql-log tbody').hide();
$('table.cake-sql-log thead')
.prepend($('<tr><td colspan="4"><a href="#" onclick="return sql_toggle();" style="font-weight:bold; color:red;" >Hide/Show SQLDump</a></td></tr>'));
});
function sql_toggle (){
$('table.cake-sql-log tbody').toggle();
return false;
}
// ==UserScript==
// @name CakePHP Remove SQLdump
// @namespace CakePHP
// @author Fedmich
// @include http://localhost/cake_app/*
// @match http://localhost/cake_app/*
// @description Initially hide the SQL dump on a CakePHP web app
// ==/UserScript==
window.unsafeWindow || (
unsafeWindow = (function() {
var el = document.createElement('p');
el.setAttribute('onclick', 'return window;');
return el.onclick();
}())
);
function addJQuery(callback) {
if(typeof unsafeWindow.jQuery == 'function') {
$ = unsafeWindow.jQuery;
var script = document.createElement("script");
script.textContent = "(" + callback.toString() + ")();";
document.body.appendChild(script);
}
else{
var script = document.createElement("script");
script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js");
script.addEventListener('load', function() {
var script = document.createElement("script");
script.textContent = "(" + callback.toString() + ")();";
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
}
}
function main() {
//CakePHP_hide_sqldump()
$('table.cake-sql-log').css({border:'red 1px dashed'});
$('table.cake-sql-log tbody').hide();
$('table.cake-sql-log thead')
.prepend($('<tr><td colspan="4"><a href="#" onclick="$(\'table.cake-sql-log tbody\').toggle(); return false;" style="font-weight:bold; color:red;" >Hide/Show SQLDump</a></td></tr>'));
}
addJQuery(main);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment