From 65fbe62e6b6b33d3e185ed41f4f0930702ab1b69 Mon Sep 17 00:00:00 2001 From: Adriaan Wormgoor Date: Fri, 16 Aug 2013 22:28:58 +0200 Subject: [PATCH] Now looks for querystring variables which allow us to control Doodle3D's behavior, such as disabling the attempt to communicatie with the wifibox or disabling printcommands (i.e.: debug stuff and such). --- js/main.js | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/js/main.js b/js/main.js index 75015f5..3252870 100644 --- a/js/main.js +++ b/js/main.js @@ -1,11 +1,28 @@ -var debug = false; +var debugMode = false; // debug mode +var sendPrintCommands = true; // if Doodle3d should send print commands to the 3d printer +var communicateWithWifibox = true; // if Doodle3d should try interfacing with the wifibox (in case one is not connected) +var wifiboxIsRemote = true; // if Doodle3d should try interfacing with the wifibox (in case one is not connected) var printer = new Printer(); $(function() { console.log("ready"); - //var wifiboxURL = "http://" + window.location.host + "/cgi-bin/d3dapi"; - var wifiboxURL = "http://192.168.5.1/cgi-bin/d3dapi"; + + if (getURLParameter("d") != "null") debugMode = (getURLParameter("d") == "1"); + if (getURLParameter("p") != "null") sendPrintCommands = (getURLParameter("p") == "1"); + if (getURLParameter("c") != "null") communicateWithWifibox = (getURLParameter("c") == "1"); + if (getURLParameter("r") != "null") wifiboxIsRemote = (getURLParameter("r") == "1"); + + if (communicateWithWifibox) { + wifiboxURL = "http://" + window.location.host + "/cgi-bin/d3dapi"; + } else { + wifiboxURL = "http://192.168.5.1/cgi-bin/d3dapi"; + sendPrintCommands = false; // 'communicateWithWifibox = false' implies this + } + console.log("debugMode: " + debugMode); + console.log("sendPrintCommands: " + sendPrintCommands); + console.log("communicateWithWifibox: " + communicateWithWifibox); + console.log("wifiboxIsRemote: " + wifiboxIsRemote); console.log("wifibox URL: " + wifiboxURL); initLayouting(); @@ -18,18 +35,22 @@ $(function() { initSettingsPopup(wifiboxURL); $("#settings .settings").load("settings.html", function() { - console.log("finished loading settings.html, now loading settings..."); - loadSettings(); + if (communicateWithWifibox) { + console.log("finished loading settings.html, now loading settings..."); + loadSettings(); + } else { + console.log("finished loading settings.html >> communicateWithWifibox is false: not loading settings"); + } }); - if(debug) { - console.log("debug mode"); + if(debugMode) { + console.log("debug mode is true"); $("body").css("overflow", "auto"); $("#debug_textArea").css("display", "block"); } printer.init(); - printer.preheat(); + if (communicateWithWifibox) printer.preheat(); $(document).on(Printer.UPDATE,update);