functionsendAPI(t,e,i){"use strict";$.ajax({url:t,type:"POST",data:e,dataType:"json",timeout:1e4,success:function(t){"success"===t.status?void0!==i&&i(t.data):console.warn(t.msg)}}).fail(function(){console.warn("Failed connecting to "+t),sendAPI(t,e,i)})}functiongetAPI(t,e){"use strict";$.ajax({url:t,dataType:"json",timeout:5e3,success:function(t){"success"===t.status?void0!==e&&e(t.data):console.warn(t.msg)}}).fail(function(){console.warn("Failed connecting to "+t),getAPI(t,e)})}functionloadSettings(t,e){"use strict";$.ajax({url:t,dataType:"json",success:function(t){void0!==e&&e(t)}})}functiondownloadFile(t,e){"use strict";vari=newBlob([e],{type:"text/plain"}),r=document.createElement("a");r.download=t,r.href=window.URL.createObjectURL(i),r.click()}varD3D={version:"0.1",website:"http://www.doodle3d.com/",contact:"develop@doodle3d.com"};Array.prototype.clone=function(){"use strict";for(vart=[],e=0;e<this.length;e++)t[e]=this[e];returnt},D3D.Box=function(t){"use strict";vare=this;this.batchSize=512,this.maxBufferedLines=4096,this.localIp=t,this.api="http://"+t+"/d3dapi/",this.config={},this.status={},this.printBatches=[],this.currentBatch=0,this.loaded=!1,this.getConfigAll(function(t){e.updateConfig(t),e.update(),e.loaded=!0,void0!==e.onload&&e.onload()})},D3D.Box.prototype.updateConfig=function(t){"use strict";for(vareint)this.config[e]=t[e];returnthis},D3D.Box.prototype.update=function(){"use strict";this.printBatches.length>0&&this.status.buffered_lines+this.batchSize<=this.maxBufferedLines?this.printBatch():this.updateState()},D3D.Box.prototype.updateState=function(){"use strict";vart=this;this.getInfoStatus(function(e){t.status=e,void0!==t.onupdate&&t.onupdate(e),t.update()})},D3D.Box.prototype.print=function(t){"use strict";for(this.currentBatch=0,t=t.clone();t.length>0;){vare=t.splice(0,Math.min(this.batchSize,t.length));this.printBatches.push(e)}returnthis},D3D.Box.prototype.printBatch=function(){"use strict";vart=this,e=this.printBatches.shift();this.setPrinterPrint({start:0===this.currentBatch?!0:!1,first:0===this.currentBatch?!0:!1,gcode:e.join("\n")},function(e){console.log("batch sent: "+t.currentBatch,e),t.printBatches.length>0&&t.currentBatch++,t.updateState()})},D3D.Box.prototype.stopPrint=function(){"use strict";this.printBatches=[],this.currentBatch=0;vart=["M107 ;fan off","G91 ;relative positioning","G1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure","G1 Z+0.5 E-5 X-20 Y-20 F9000 ;move Z up a bit and retract filament even more","G28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way","M84 ;disable axes / steppers","G90 ;absolute positioning","M104 S180",";M140 S70","M117 Done ;display message (20 characters to clear whole screen)"];returnthis.setPrinterStop({gcode:t.join("\n")},function(t){console.log("Printer stop command sent")}),this},D3D.Box.prototype.getConfig=function(t,e){"use strict";returngetAPI(this.api+"config/?"+t.join("=&")+"=",e),this},D3D.Box.prototype.getConfigAll=function(t){"use strict";returngetAPI(this.api+"config/all",t),this},D3D.Box.prototype.setConfig=function(t,e){"use strict";vari=this;returnsendAPI(this.api+"config",t,function(r){for(varninr.validation)"ok"===r.validation[n]&&(i[n]=t[n]);void0!==e&&e(r)}),this},D3D.Box.prototype.getInfo=function(t){"use strict";returngetAPI(this.api+"info",t),this},D3D.Box.prototype.getInfoStatus=function(t){"use strict";returngetAPI(this.api+"info/status",t),this},D3D.Box.prototype.downloadInfoLogFiles=function(){"use strict";window.location=this.api+"info/logfiles"},D3D.Box.prototype.getInfoAcces=function(t){"use strict";returngetAPI(this.api+"info/access",t),this},D3D.Box.prototype.getNetworkScan=function(t){"use strict";returngetAPI(this.api+"network/scan",t),this},D3D.Box.prototype.getNetworkKnown=function(t){"use strict";returngetAPI(this.api+"network/known",t),this},D3D.Box.prototype.getNetworkStatus=function(t){"use strict";returngetAPI(this.api+"network/status",t),this},D3D.Box.prototype.setNetworkAssosiate=function(t,e