From: Jeremy Tan Date: Sat, 5 Oct 2013 11:05:43 +0000 (+0800) Subject: Prevent multiple additions of the same pin type X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=271a0ddc89746532569570a0613257cd6862ecae;p=matches%2FMCTX3420.git Prevent multiple additions of the same pin type --- diff --git a/testing/MCTXWeb/public_html/pintest.html b/testing/MCTXWeb/public_html/pintest.html index 55f0e64..254bd09 100644 --- a/testing/MCTXWeb/public_html/pintest.html +++ b/testing/MCTXWeb/public_html/pintest.html @@ -49,12 +49,18 @@ $("#gpio-go").click(function () { if ($("#gpio-menu").val()) { - $("#gpio-container").exportGPIO($("#gpio-menu")); + $(this).attr("disabled", true); + $("#gpio-container").exportGPIO($("#gpio-menu")).always(function () { + $("#gpio-go").attr("disabled", false); + }); } }); $("#pwm-go").click(function () { if ($("#pwm-menu").val()) { - $("#pwm-container").exportPWM($("#pwm-menu")); + $(this).attr("disabled", true); + $("#pwm-container").exportPWM($("#pwm-menu")).always(function () { + $("#pwm-go").attr("disabled", false); + }); } }); $("#adc-controls").trigger("reset").setADCControl(); diff --git a/testing/MCTXWeb/public_html/static/mctx.pintest.js b/testing/MCTXWeb/public_html/static/mctx.pintest.js index d2ea59e..9e64e4e 100644 --- a/testing/MCTXWeb/public_html/static/mctx.pintest.js +++ b/testing/MCTXWeb/public_html/static/mctx.pintest.js @@ -27,7 +27,7 @@ $.fn.exportGPIO = function(menu) { var number = menu.val(); var container = this; - $.ajax({url : mctx.pintest.api, data : {type : "gpi", num : number, export : 1}}) + return $.ajax({url : mctx.pintest.api, data : {type : "gpi", num : number, export : 1}}) .done(function () { var form = $("
", {"class" : "controls", action : "#", id : "gpio-" + number}); var title = $("
", {"class" : "centre bold", text : "GPIO " + number}); @@ -60,14 +60,13 @@ $.fn.exportGPIO = function(menu) { alert("Failed to export GPIO " + number + ". Is the server running?\n" + "Error code: " + jqXHR.status); }); - return this; }; $.fn.exportPWM = function(menu) { var number = menu.val(); var container = this; - $.ajax({url : mctx.pintest.api, data : {type : "pwm", num : number, export : "1"}}) + return $.ajax({url : mctx.pintest.api, data : {type : "pwm", num : number, export : "1"}}) .done(function () { var form = $("", {"class" : "controls", action : "#", id : "pwm-" + number}); var title = $("
", {"class" : "centre bold", text : "PWM " + number}); @@ -106,7 +105,6 @@ $.fn.exportPWM = function(menu) { alert("Failed to export PWM " + number + ". Is the server running?\n" + "Error code: " + jqXHR.status); }); - return this; }; $.fn.setGPIOControl = function (number, menu) {