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)})}functiondownloadFile(t,e){"use strict";$(document.createElement("a")).attr({download:t,href:"data:text/plain,"+e})[0].click()}functionapplyMouseControls(t,e,i){"use strict";functionr(){e.position.x=Math.cos(s)*Math.sin(o)*n,e.position.y=Math.sin(s)*n,e.position.z=Math.cos(s)*Math.cos(o)*n,e.lookAt(newTHREE.Vector3(0,0,0))}varn=20,o=0,s=0,a=!1;$(t.domElement).on("mousedown",function(t){a=!0}).on("wheel",function(t){vare=t.originalEvent;e.preventDefault(),n=THREE.Math.clamp(n-e.wheelDelta,1,i),r()}),$(window).on("mouseup",function(t){a=!1}).on("mousemove",function(t){vare=t.originalEvent;a===!0&&(o=(o-e.webkitMovementX/100)%(2*Math.PI),s=THREE.Math.clamp(s+e.webkitMovementY/100,-Math.PI/2,Math.PI/2),r())}),r()}varD3D={version:"0.1",website:"http://www.doodle3d.com/",contact:"develop@doodle3d.com"};THREE.Vector2.prototype.normal=function(){"use strict";vart=this.y,e=-this.x;returnthis.set(t,e)},Array.prototype.clone=function(){"use strict";for(vart=[],e=0;e<this.length;e++)t[e]=this[e];returnt};varrequestAnimFrame=function(){"use strict";returnrequestAnimationFrame||webkitRequestAnimationFrame||mozRequestAnimationFrame||function(t){setTimeout(t,1e3/60)}}();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.printBatches=[],this.currentBatch=0,this.loaded=!1,this.onload,getAPI(e.api+"config/all",function(t){for(variint)0===i.indexOf("doodle3d")&&(e.config[i]=t[i]);e.printer=newD3D.Printer(t),e.update(),e.loaded=!0,void0!==e.onload&&e.onload()})},D3D.Box.prototype.update=function(){"use strict";this.printBatches.length>0?this.printBatch():this.updateState()},D3D.Box.prototype.updateState=function(){"use strict";vart=this;getAPI(this.api+"info/status",function(e){t.printer.status=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();sendAPI(this.api+"printer/print",{start:0===this.currentBatch?"true":"false",first:0===this.currentBatch?"true":"false",gcode:e.join("\n")},function(e){console.log("batch sent: "+t.currentBatch,e),t.printBatches.length>0&&t.currentBatch++,t.updateState()})},D3D.Box.prototype.stop=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)"];returnsendAPI(this.api+"printer/stop",{gcode:t.join("\n")},function(t){console.log("Printer stop command sent")}),this},D3D.Box.prototype.setConfig=function(t){"use strict";returnsendAPI(this.api+"config",t),this},D3D.Box.prototype.getInfoLog=function(t){"use strict";returngetAPI(self.api+"info/logfiles",function(e){void0!==t&&t(e)}),this},D3D.Box.prototype.getInfoAcces=function(t){"use strict";returngetAPI(self.api+"info/acces",function(e){void0!==t&&t(e)}),this},D3D.Box.prototype.getNetwerkScan=function(t){"use strict";returngetAPI(self.api+"network/scan",function(e){void0!==t&&t(e)}),this},D3D.Box.prototype.getNetworkKnown=function(t){"use strict";r