From 324b19d281d144c9ae62f1c466525e2f6722e607 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Mon, 28 Mar 2011 12:41:02 +0200 Subject: [PATCH] Simplify JUSH replacement --- adminer/static/editing.js | 47 +++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/adminer/static/editing.js b/adminer/static/editing.js index 3280d1ef..3f17de1a 100644 --- a/adminer/static/editing.js +++ b/adminer/static/editing.js @@ -1,5 +1,7 @@ // Adminer specific functions +var jushRoot = '../externals/jush/'; // global variable to allow simple customization + /** Load syntax highlighting * @param string first three characters of database system version */ @@ -7,29 +9,30 @@ function bodyLoad(version) { if (history.state !== undefined) { // copied from editor/static/editing.js onpopstate(history); } - var jushRoot = '../externals/jush/'; - var script = document.createElement('script'); - script.src = jushRoot + 'jush.js'; - script.onload = function () { - if (window.jush) { // IE runs in case of an error too - jush.create_links = ' target="_blank" rel="noreferrer"'; - jush.urls.sql_sqlset = jush.urls.sql[0] = jush.urls.sqlset[0] = jush.urls.sqlstatus[0] = 'http://dev.mysql.com/doc/refman/' + version + '/en/$key'; - var pgsql = 'http://www.postgresql.org/docs/' + version + '/static/'; - jush.urls.pgsql_pgsqlset = jush.urls.pgsql[0] = pgsql + '$key'; - jush.urls.pgsqlset[0] = pgsql + 'runtime-config-$key.html#GUC-$1'; - jush.style(jushRoot + 'jush.css'); - if (window.jushLinks) { - jush.custom_links = jushLinks; + if (jushRoot) { + var script = document.createElement('script'); + script.src = jushRoot + 'jush.js'; + script.onload = function () { + if (window.jush) { // IE runs in case of an error too + jush.create_links = ' target="_blank" rel="noreferrer"'; + jush.urls.sql_sqlset = jush.urls.sql[0] = jush.urls.sqlset[0] = jush.urls.sqlstatus[0] = 'http://dev.mysql.com/doc/refman/' + version + '/en/$key'; + var pgsql = 'http://www.postgresql.org/docs/' + version + '/static/'; + jush.urls.pgsql_pgsqlset = jush.urls.pgsql[0] = pgsql + '$key'; + jush.urls.pgsqlset[0] = pgsql + 'runtime-config-$key.html#GUC-$1'; + jush.style(jushRoot + 'jush.css'); + if (window.jushLinks) { + jush.custom_links = jushLinks; + } + jush.highlight_tag('code', 0); } - jush.highlight_tag('code', 0); - } - }; - script.onreadystatechange = function () { - if (/^(loaded|complete)$/.test(script.readyState)) { - script.onload(); - } - }; - document.body.appendChild(script); + }; + script.onreadystatechange = function () { + if (/^(loaded|complete)$/.test(script.readyState)) { + script.onload(); + } + }; + document.body.appendChild(script); + } } /** Get value of dynamically created form field