X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;ds=sidebyside;f=testing%2FMCTXWeb%2Fpublic_html%2Fstatic%2Fmctx.gui.js;h=3df2bac10e52374bdd6baae629a8a5922a057898;hb=1538b01df7b16dc1223c1459620dac4b22c916a4;hp=48737b5932395324837ddd2413c9a377cce4e815;hpb=e0132025a1df98f88b2415e9e5f75ce7304efb33;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..3df2bac 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 = { @@ -54,6 +58,9 @@ mctx.actuators = { 3 : {name : "Pressure regulator"} }; +mctx.actuator = {}; +mctx.actuator.pressure_regulator = 0; + mctx.strain_gauges = {}; mctx.strain_gauges.ids = [0, 1, 2, 3]; mctx.strain_gauges.time_limit = 20; @@ -71,7 +78,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 +279,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 +303,14 @@ $.fn.setErrorLog = function () { return this; }; +$.fn.checkStatus = function(data) { + if (data.status !== mctx.status.OK) { + $(this).text(data.description).removeClass("pass").addClass("fail"); + return false; + } + return true; +}; + $(document).ready(function () { //Show the content! $("#content").css("display", "block");