From 8d4b241156139b219172d21372d87f0c80b24950 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Sun, 17 Oct 2010 07:19:01 +0200 Subject: [PATCH] Save bytes --- adminer/static/functions.js | 43 ++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/adminer/static/functions.js b/adminer/static/functions.js index acdd3b72..c1d25c5e 100644 --- a/adminer/static/functions.js +++ b/adminer/static/functions.js @@ -139,31 +139,26 @@ var ajaxTimeout; * @return XMLHttpRequest or false in case of an error */ function ajax(url) { - var xmlhttp; - if (window.XMLHttpRequest) { - xmlhttp = new XMLHttpRequest(); - } else if (window.ActiveXObject) { - xmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); - } else { - return false; - } - var currentState = ++ajaxState; - clearTimeout(ajaxTimeout); - ajaxTimeout = setTimeout(function () { - setHtml('main', ''); - }, 1000); // defer displaying loader - xmlhttp.open('GET', url); - xmlhttp.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); - xmlhttp.onreadystatechange = function () { - if (xmlhttp.readyState == 4 && currentState == ajaxState) { - clearTimeout(ajaxTimeout); - setHtml('main', xmlhttp.responseText); - if (window.jush) { - jush.highlight_tag('code'); + var xmlhttp = (window.XMLHttpRequest ? new XMLHttpRequest() : (window.ActiveXObject ? new ActiveXObject('Microsoft.XMLHTTP') : false)); + if (xmlhttp) { + var currentState = ++ajaxState; + clearTimeout(ajaxTimeout); + ajaxTimeout = setTimeout(function () { + setHtml('main', ''); + }, 1000); // defer displaying loader + xmlhttp.open('GET', url); + xmlhttp.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); + xmlhttp.onreadystatechange = function () { + if (xmlhttp.readyState == 4 && currentState == ajaxState) { + clearTimeout(ajaxTimeout); + setHtml('main', xmlhttp.responseText); + if (window.jush) { + jush.highlight_tag('code'); + } } - } - }; - xmlhttp.send(''); + }; + xmlhttp.send(''); + } return xmlhttp; }