X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=testing%2FMCTXWeb%2Fpublic_html%2Fstatic%2Fmctx.gui.js;h=319805560906450b472252462fff3c9f41dd7fe0;hb=fc0dc3b827eeff91373db42a78a098200cbf8fa6;hp=478e9ad30c8789f6a936c4fffd4a94b1b2737221;hpb=023b5a18dcc7d501326abe2de06f24190d5b4320;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 478e9ad..3198055 100644 --- a/testing/MCTXWeb/public_html/static/mctx.gui.js +++ b/testing/MCTXWeb/public_html/static/mctx.gui.js @@ -1,88 +1,331 @@ /** - * MCTX3420 2013 GUI stuff. - */ +* MCTX3420 2013 GUI stuff. +* Coding style: +* - Always end statements with semicolons +* - Egyptian brackets are highly recommended (*cough*). +* - Don't use synchronous stuff - hook events into callbacks +* - $.fn functions should return either themselves or some useful object +* to allow for chaining of method calls +*/ mctx = {}; -//mctx.api = location.protocol + "/" + location.host + "/api/"; -mctx.api = "http://mctx.us.to:8080/api/"; +//Don't use this in the final version +mctx.location = window.location.pathname; +mctx.location = mctx.location.substring(0, mctx.location.lastIndexOf('/')) + "/"; +//mctx.location = location.protocol + "//" + location.host + "/"; +mctx.api = location.protocol + "//" + location.host + "/" + "api/"; mctx.expected_api_version = 0; +mctx.has_control = false; +mctx.debug = true; + +mctx.menu = [ + {'text' : 'Home', href : mctx.location + 'index.html'}, + {'text' : 'Experiment control', href : mctx.location + 'control.html'}, + {'text' : 'Pin debugging', href : mctx.location + 'pintest.html'}, + {'text' : 'Help', href : mctx.location + 'help.html'} +]; + +mctx.statusCodes = { + STATUS_OK : 1 +}; + +mctx.statusCodesDescription = { + "1" : "Ok", + "-1" : "General error", + "-2" : "Unauthorized", + "-3" : "Not running", + "-4" : "Already exists" +}; + mctx.sensors = { - 0 : {name : "Strain gauge 1"}, - 1 : {name : "Strain gauge 2"}, - 2 : {name : "Strain gauge 3"}, - 3 : {name : "Strain gauge 4"}, - 4 : {name : "Pressure sensor 1"}, - 5 : {name : "Pressure sensor 2"} + 0 : {name : "Strain gauge 1"}, + 1 : {name : "Strain gauge 2"}, + 2 : {name : "Strain gauge 3"}, + 3 : {name : "Strain gauge 4"}, + 4 : {name : "Pressure sensor 1"}, + 5 : {name : "Pressure sensor 2"}, + 6 : {name : "Pressure sensor 3"} }; mctx.actuators = { - 0 : {name : "Solenoid 1"}, - 1 : {name : "Solenoid 2"}, - 2 : {name : "Solenoid 3"}, - 3 : {name : "Pressure regulator"} + 0 : {name : "Solenoid 1"}, + 1 : {name : "Solenoid 2"}, + 2 : {name : "Solenoid 3"}, + 3 : {name : "Pressure regulator"} }; -function getDate(){ - document.write((new Date()).toDateString()); +mctx.strain_gauges = {}; +mctx.strain_gauges.ids = [0, 1, 2, 3]; +mctx.strain_gauges.time_limit = 20; + +/** +* Logs a message if mctx.debug is enabled. This function takes +* a variable number of arguments and passes them +* to alert or console.log (based on browser support). +* @returns {undefined} +*/ +function debugLog () { + if (mctx.debug) { + if (typeof console === "undefined" || typeof console.log === "undefined") { + for (var i = 0; i < arguments.length; i++) { + alert(arguments[i]); + } + } else { + try { + console.log.apply(this, arguments); + } catch (e) { + //Chromie + for (var i = 0; i < arguments.length; i++) { + console.log(arguments[i]); + } + } + } + } } -/** - * Populates the navigation bar - */ -$.fn.populateNavbar = function () { - var menu = $("