MySQL popup query window utils

By mungushume Last update Nov 20, 2008 — Installed 43 times. Daily Installs: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0

There are 1 previous version of this script.

// ==UserScript==
// @author         mungushume
// @version        1.0
// @name           MySQL popup query window utils
// @description    Makes the textarea of the MySQL popup window full window height and allows you to execute the query with alt + x or ctrl + e
// @namespace      http://www.monkeyr.com
// @include        */mysqladmin/querywindow.php*
// @scriptsource   http://userscripts.org/scripts/show/37210
// ==/UserScript==

function txtResizer() {
  var o = document.getElementById('sqlquery'); // textarea
  if(o){
    scrollTo(0,0);
    var adjust = 56;
    var ih = window.innerHeight ? window.innerHeight : document.body.clientHeight;
    var h = ih - getTop(o) - adjust;
    o.style.height=Math.max(1,h)+'px';
  }
  function getTop(o) {
    top = 0;
    if (o.offsetParent) {
      top = o.offsetTop;
      while (o = o.offsetParent) {
        top += o.offsetTop;
      }
    }
    return top;
  }  
}

function exec(e){
  if(e){
    if((e.altKey && e.which==120) || (e.ctrlKey && e.which==101)) {
      e.preventDefault();
      e.stopPropagation();
      var frm = document.getElementById('sqlqueryform');
      if(frm) frm.submit();
    }
  }
}

txtResizer();
window.addEventListener("resize", txtResizer, false);
window.addEventListener("keypress", exec, false);