X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=testing%2FMCTXWeb%2Fpublic_html%2Fstatic%2Fmctx.gui.js;h=3130a185be152e4ad42504da3d0fbdd5a7d2015e;hb=8c9214a60db100a206496d1c417c08a20ea2693e;hp=48737b5932395324837ddd2413c9a377cce4e815;hpb=93fb7f6632c677036f96d63baf36870628a0d34b;p=matches%2FMCTX3420.git diff --git a/testing/MCTXWeb/public_html/static/mctx.gui.js b/testing/MCTXWeb/public_html/static/mctx.gui.js index 48737b5..3130a18 100644 --- a/testing/MCTXWeb/public_html/static/mctx.gui.js +++ b/testing/MCTXWeb/public_html/static/mctx.gui.js @@ -25,8 +25,12 @@ mctx.menu = [ {'text' : 'Help', href : mctx.location + 'help.html'} ]; -mctx.statusCodes = { - STATUS_OK : 1 +mctx.status = { + OK : 1, + ERROR : -1, + UNAUTHORIZED : -2, + NOTRUNNING : -3, + ALREADYEXISTS : -4 }; mctx.statusCodesDescription = { @@ -71,7 +75,14 @@ function debugLog () { alert(arguments[i]); } } else { - console.log.apply(this, arguments); + try { + console.log.apply(this, arguments); + } catch (e) { + //Chromie + for (var i = 0; i < arguments.length; i++) { + console.log(arguments[i]); + } + } } } } @@ -265,11 +276,16 @@ $.fn.setErrorLog = function () { var url = mctx.api + "errorlog"; var outdiv = this; + if ($(this).length <= 0) { + //No error log, so do nothing. + return; + } + var updater = function () { $.ajax({url : url}).done(function (data) { outdiv.text(data); outdiv.scrollTop( - outdiv[0].scrollHeight - outdiv.height() + outdiv[0].scrollHeight - outdiv.height() ); setTimeout(updater, 3000); }).fail(function (jqXHR) { @@ -284,6 +300,14 @@ $.fn.setErrorLog = function () { return this; }; +$.fn.checkStatus = function(data) { + if (data.status !== mctx.status.OK) { + $(this).text(data.description).addClass("fail"); + return false; + } + return true; +}; + $(document).ready(function () { //Show the content! $("#content").css("display", "block");