Created
April 23, 2012 08:37
-
-
Save fedmich/2469602 to your computer and use it in GitHub Desktop.
CakePHP - Debug tools
This file contains hidden or 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
$(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; | |
} |
This file contains hidden or 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
// ==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