diff --git a/.gitignore b/.gitignore index a0cc0c0..cc8cda8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ .project .idea/* +www/js/*.js +www/css/*.css __index.html _index.html div_bgs.html diff --git a/www/css/.gitkeep b/www/css/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/www/css/debug.css b/www/css/debug.css deleted file mode 100644 index 0f0de5e..0000000 --- a/www/css/debug.css +++ /dev/null @@ -1,45 +0,0 @@ -.debugContainer { - position: absolute; - top: 0; - left: 0; - z-index: 500; - background-color: #f0f; - display: none; -} - -#debug_textArea { - position:absolute; - bottom: 0; - /*width: 800px; */ - z-index: 500; - display: none; -} - -.debugBtn { - width: 25px; - height: 25px; - background-color: #03b; - float:left; -} - -.agentInfo { - background: #fff; - border: 1px #333 solid; - display: none; - float:left; - opacity: .7; -} - -.agentInfoToggle { - display: block; -} - -#debug_display { - position: absolute; - top: 0; - left: 0; - display: none; - background-color: #fff; - opacity: .7; - color: #000; -} \ No newline at end of file diff --git a/www/css/debug.min.css b/www/css/debug.min.css deleted file mode 100644 index 3047837..0000000 --- a/www/css/debug.min.css +++ /dev/null @@ -1 +0,0 @@ -.debugContainer{position:absolute;top:0;left:0;z-index:500;background-color:#f0f;display:none}#debug_textArea{position:absolute;bottom:0;z-index:500;display:none}.debugBtn{width:25px;height:25px;background-color:#03b;float:left}.agentInfo{background:#fff;border:1px #333 solid;display:none;float:left;opacity:.7}.agentInfoToggle{display:block}#debug_display{position:absolute;top:0;left:0;display:none;background-color:#fff;opacity:.7;color:#000} \ No newline at end of file diff --git a/www/css/settings.css b/www/css/settings.css deleted file mode 100644 index 8feddcc..0000000 --- a/www/css/settings.css +++ /dev/null @@ -1,109 +0,0 @@ -form { - margin: 10px; - max-width: 600px; -} -form input { - margin: 1px; -} - -body,th,td { - font-family: Helvetica, Arial, "Nimbus Sans L", sans-serif; - font-size: 13px; -} -.settingsContainer { - position:relative; - /*min-width: 370px;*/ - width: 100%; - height: 100%; -} -/*form#settingsForm {*/ - /*width: 100% auto;*/ -/*}*/ -form fieldset { - max-width: 600px; - border: 1px solid rgb(187, 187, 187); - border-radius: 5px; - -webkit-border-radius: 5px; - -moz-border-radius: 5px; - margin-bottom: 20px; - padding: 8px; - /*padding-right: 8px;*/ -} -form fieldset fieldset{ - max-width: 580px; - margin: 15px 0 5px 0; - clear: left; - float: left; -} -form fieldset legend { - margin-left: 10px; - font-weight: bold; -} -form label { - min-width: 150px; - display: block; - float: left; - margin: 1px 0 0 0; - clear: left; -} -form div { - float: left; -} -form input[type="text"], form input[type="number"], form input[type="password"] { - border: 1px solid rgb(144, 192, 255); - margin-right: 5px; - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; -} -form input[type="text"].small, form input[type="number"].small, form input[type="password"].small { - width: 50px; -} -form input[type="text"].large, form input[type="number"].large, form input[type="password"].large { - width: 250px; -} -form input[type="radio"] { - margin: 4px 4px 0 0; -} - -form textarea { - border: 1px solid rgb(144, 192, 255); - -webkit-border-radius: 5px; - -moz-border-radius: 5px; - border-radius: 5px; -} -form .startgcode_left { - float:left; - margin-right: 20px; -} -form textarea.gcode { - width: 252px; - /*max-width: 262px;*/ - /*min-width: 200px;*/ - height: 150px; -} -form small { - margin: 3px 0 0 0; - display: block; - clear: left; -} -form .button { - display: inline-block; -} - -form #passwordLabel, form #password { - display: none; -} - -form input.error, form textarea.error, form select.error { - border: #f00 solid 2px; -} -form .errorMsg { - color: #f00; - margin: 0 0 0 1em; -} -form dl dt { - float: left; - font-style: italic; - width: 10em; -} \ No newline at end of file diff --git a/www/css/settings.min.css b/www/css/settings.min.css deleted file mode 100644 index 11ea3a1..0000000 --- a/www/css/settings.min.css +++ /dev/null @@ -1 +0,0 @@ -form{margin:10px;max-width:600px}form input{margin:1px}body,th,td{font-family:Helvetica,Arial,"Nimbus Sans L",sans-serif;font-size:13px}.settingsContainer{position:relative;width:100%;height:100%}form fieldset{max-width:600px;border:1px solid #bbb;border-radius:5px;-webkit-border-radius:5px;-moz-border-radius:5px;margin-bottom:20px;padding:8px}form fieldset fieldset{max-width:580px;margin:15px 0 5px;clear:left;float:left}form fieldset legend{margin-left:10px;font-weight:700}form label{min-width:150px;display:block;float:left;margin:1px 0 0;clear:left}form div{float:left}form input[type=text],form input[type=number],form input[type=password]{border:1px solid #90c0ff;margin-right:5px;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}form input[type=text].small,form input[type=number].small,form input[type=password].small{width:50px}form input[type=text].large,form input[type=number].large,form input[type=password].large{width:250px}form input[type=radio]{margin:4px 4px 0 0}form textarea{border:1px solid #90c0ff;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}form .startgcode_left{float:left;margin-right:20px}form textarea.gcode{width:252px;height:150px}form small{margin:3px 0 0;display:block;clear:left}form .button{display:inline-block}form #passwordLabel,form #password{display:none}form input.error,form textarea.error,form select.error{border:red solid 2px}form .errorMsg{color:red;margin:0 0 0 1em}form dl dt{float:left;font-style:italic;width:10em} \ No newline at end of file diff --git a/www/css/styles.css b/www/css/styles.css deleted file mode 100644 index a9948b9..0000000 --- a/www/css/styles.css +++ /dev/null @@ -1,1058 +0,0 @@ -/* - - GLOBAL CONTAINER - -*/ - -body { - background-color: #fcfcfc; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; - /* disable cut copy paste */ - overflow: hidden; - /* This chops off any overhanging divs */ -} - -img { - z-index: 5; - /*pointer-events:none;*/ - /*-webkit-touch-callout: none; */ - /*disable callout, image save panel */ - /*-webkit-tap-highlight-color: transparent; */ - /* "turn off" link highlight */ -} - -/* http://stackoverflow.com/questions/5348092/prevent-default-press-but-not-default-drag-in-ios-mobilesafari */ - -.btn { - background-repeat: no-repeat; - /* -webkit-user-select: none;*/ - cursor: pointer; -} - -#landscape { - position: absolute; - background-color: #fff; - width: 100%; - max-width: 1024px; - max-height: 768px; - top: 0px; - bottom: 0px; - left: 0px; - right: 0px; - z-index: 5; - overflow: hidden; - margin: 0px auto; - outline: 2px solid #5e8c71; - -webkit-box-shadow: 0 0 8px rgba(8, 8, 8, 0.25); - box-shadow: 0 0 8px rgba(8, 8, 8, 0.25); -} - -#portrait { - display: none; -} - -.bgContainer { - position: absolute; - width: 100%; - height: 100%; - overflow: hidden; -} - -.bgTop, -.bgMiddle, -.bgBottom { - opacity: 1.0; - -webkit-transition: opacity .35s linear; - transition: opacity .35s linear; - position: absolute; - left: 0px; - z-index: -5; -} - -.bgTop { - top: 0px; -} - -.bgMiddle { - top: 30%; -} - -.bgBottom { - bottom: 0px; -} - -/* - - CENTER PANEL - -*/ - -.centerpanel { - position: absolute; - left: 50%; - margin-left: -33%; - width: 66%; - height: 100%; - z-index: 5; -} - -.logopanel { - height: 25%; -} - -.d3dlogo { - position: relative; - top: 15%; - width: 100%; - height: 100%; - margin: 0px auto; - max-width: 399px; - height: 139px; - background: url('../img/logo/logo_full.png') no-repeat center center; - cursor: pointer; -} - -#verticalShapes { - position: absolute; - right: 0; - bottom: 15px; - margin-right: -8.5%; - width: 8%; -} - -#verticalShapes > div { - border: 2px solid #333; - border-radius: 0px 5px 5px 0px; - margin-top: 4px; - background-color: #fff; - cursor: pointer; -} - -#verticalShapes > div img.verticalshape { - width: 100%; - max-width: 50px; - height: auto; - vertical-align: bottom; -} - -.drawareacontainer { - position: relative; - width: 100%; - height: 65%; - background-color: #fff; - border: 4px solid #000; - border-radius: 15px; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; - z-index: 15; -} - -#canvasContainers { - position: absolute; - top: 0; - bottom: 0; - left: 0; - right: 0; - width: 100%; - height: 100%; - padding: 0; - margin: 0; -} - -#mycanvasContainer { - position: absolute; - top: 0; - left: 0; - width: 78%; - height: 100%; -} - -#mycanvas { - width: 100%; - height: 100%; - margin: 0; - padding: 0; - border-right: 2px solid #333; -} - -#previewContainer { - position: absolute; - top: 0; - right: 0; - width: 22%; - height: 100%; -} - -#preview { - min-width: 50px; - width: 100%; - height: 100%; - margin: 0; - padding: 0; -} - -/* DEBUG THING */ - -#preview_tmp { - position: absolute; - top: 0px; - left: 0px; - z-index: 500; - border: 1px solid #f80; - display: none; -} - -.bottompanel { - position: relative; - bottom: 0px; - width: 100%; - height: 10%; -} - -/* - DOODLE UP/DOWN/LEFT/RIGHT buttons -*/ - -.manipulationBtns { - margin: 2px 5px; - position: absolute; - right: 0; - top: 0; - max-width: 340px; - max-height: 70px; - width: 45%; -} - -.manipulationBtn { - width: 45%; - height: auto; - cursor: pointer; -} - -#btnsUpDown { - float: left; - width: 45%; -} - -#btnsUpDown > div { - float: left; - padding-right: 8px; - background-repeat: no-repeat; -} - -#btnsTurnLeftRight { - float: right; - width: 45%; -} - -#btnsTurnLeftRight > div { - float: left; - padding-right: 8px; - background-repeat: no-repeat; -} - -#btnMoveUp { - max-width: 65px; -} - -#btnMoveDown { - max-width: 64px; -} - -#btnTwistLeft { - max-width: 59px; -} - -#btnTwistRight { - max-width: 64px; -} - -/* - HEIGHT-related RESPONSIVE STUFF -*/ - -@media screen and (max-height: 700px) { - .logopanel { - height: 22%; - } - - .doodlecontainer { - height: 68%; - } - - .d3dlogo { - top: 25%; - max-width: 399px; - height: 74px; - background-image: url('../img/logo/logo_small.png'); - } -} - -@media screen and (max-height: 655px) { - .bgMiddle { - opacity: 0; - } -} - -@media screen and (max-height: 525px) { - .d3dlogo { - top: 20%; - height: 57px; - max-width: 307px; - background-image: url('../img/logo/logo_smaller.png'); - } -} - -@media screen and (max-height: 375px) { - .d3dlogo { - height: 40px; - max-width: 216px; - background-image: url('../img/logo/logo_smallest.png'); - } -} - -/* - - LEFT PANEL - -*/ - -.leftpanel { - position: absolute; - width: 17%; - /* background-color: rgba(67, 204, 67, 0.4);*/ - top: 0px; - left: 0px; - bottom: 0px; -} - -.btnNew { - margin: 5% 0% 1% 5%; - width: 100%; - max-width: 180px; - height: auto; -} - -.btnsPrevNext { - margin: 1% 7%; - max-width: 160px; -} - -.btnPrevious { - width: 40%; - max-width: 56px; - height: auto; -} - -.btnNext { - width: 40%; - max-width: 56px; - height: auto; - float: right; -} - -.btnSave { - margin: 5% 5% 1% 5%; - width: 90%; - max-width: 144px; - height: auto; -} - -.btnOops { - margin: 5% 5% 1% 5%; - width: 90%; - max-width: 144px; - height: auto; -} - -/* - - RIGHT PANEL - -*/ - -.rightpanel { - position: absolute; - width: 17%; - /* background-color: rgba(255, 0, 254, 0.4);*/ - top: 0; - right: 0; - bottom: 0; -} - -.btnPrint { - margin: 1% 5% 5% 0%; - width: 100%; - max-width: 163px; - height: auto; - float: right; -} - -.btnStop { - margin: 5% 10% 1% 5%; - float: right; - width: 90%; - max-width: 98px; - height: auto; -} - -.btnsSettingsInfo { - position: absolute; - bottom: 25px; - right: 5px; - width: 80%; - margin: 1% 5%; - max-width: 160px; -} - -.btnInfo { - width: 40%; - max-width: 53px; - height: auto; -} - -.btnSettings { - width: 40%; - max-width: 53px; - height: auto; - float: right; -} - -/* - - PROGRESSGUAGE AND THERMOMETER SHARED STYLES - -*/ - -.progressbarAppear { - /*margin-right: 1.5% !important;*/ - right: -0.5% !important; -} - -.thermometerAppear { - /*margin-right: 1.5% !important;*/ - right: -6.5% !important; -} - -/* - - PROGRESS GUAGE - -*/ - -.progressbarCanvasContainerParent { - position: relative; - width: 100%; -} - -#progressbarCanvasContainer { - position: relative; - width: 50%; - float: right; - border: solid #000; - border-width: 2px 0 2px 2px; - border-radius: 15px 0 0 15px; - /*padding: 5px 0px 5px 5px;*/ - padding: 5px; - background-color: #fff; - -webkit-box-shadow: 0 2px 5px rgba(37, 37, 37, 0.35); - box-shadow: 0 2px 5px rgba(37, 37, 37, 0.35); - -webkit-transition: right 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55); - transition: right 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55); - right: -60%; - margin: 5% 0%; -} - -#progressbarCanvas { - top: 0; - right: 0; - bottom: 0; - left: 0; - width: 100%; - height: auto; - background-color: #fff; -} - -/* - - THERMOMETER - -*/ - -.thermometerContainerParent { - position: relative; - width: 100%; - padding-top: 10px; -} - -#thermometerContainer { - position: relative; - width: 45%; - float: right; - background-color: #fff; - border: solid #000; - border-width: 2px 0 2px 2px; - border-radius: 15px 0 0 15px; - padding: 5px; - -webkit-box-shadow: 0 2px 5px rgba(37, 37, 37, 0.35); - box-shadow: 0 2px 5px rgba(37, 37, 37, 0.35); - -webkit-transition: right 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55); - transition: right 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55); - right: -55%; -} - -#thermometerCanvas { - top: 0; - right: 0; - bottom: 0; - left: 0; - width: 100%; - height: auto; - background-color: #fff; -} - -/* - under all the above styles w.r.t. the cascading effect -*/ - -.disabled { - opacity: 0.3; - cursor: default; -} - -#btnStop.disabled { - display: none; -} - -/* - - REST - -*/ - -/* CLEARFIX */ - -/* http://nicolasgallagher.com/micro-clearfix-hack/ */ - -.clearfix:before, -.clearfix:after { - content: " "; - /* 1 */ - display: table; - /* 2 */ -} - -.clearfix:after { - clear: both; -} - -/* For IE 6/7 only*/ - -.clearfix { - *zoom: 1; -} - -/* - - SETTINGS POPUP - -*/ - -#contentOverlay { - background-color: rgba(255, 255, 255, 0.65); - z-index: 20; - position: absolute; - top: 0; - left: 0; - right: 0; - bottom: 0; - width: 100%; - height: 100%; - display: none; - -webkit-user-select: text; - -moz-user-select: text; - -ms-user-select: text; - user-select: text; -} - -#contentOverlay #settings { - background-color: #fff; - position: absolute; - top: 0; - left: 0; - right: 0; - bottom: 0; - z-index: 15; - max-width: 775px; - max-height: 540px; - width: 80%; - height: 75%; - margin: 7% 8%; - -webkit-box-shadow: 0px 2px 6px 0px rgba(16, 16, 16, 0.65); - box-shadow: 0px 2px 6px 0px rgba(16, 16, 16, 0.65); - border: 2px solid #222; - border-radius: 15px; - padding: 2%; -} - -#contentOverlay #settings .toppanel { - height: 10%; -} - -#contentOverlay #settings .toppanel .settingsLabelContainer { - width: 100%; - height: auto; - margin-bottom: 1%; -} - -#contentOverlay #settings .toppanel .settingsLabelContainer .settingsLabelImg { - width: 45%; - max-width: 373px; - height: auto; -} - -#contentOverlay #settings .bottompanel { - width: 100%; - height: 90%; -} - -#contentOverlay #settings .bottompanel > .settingsContainer { - float: left; - width: 83%; - height: 98%; - margin: .5%; - overflow-y: scroll; - overflow-x: hidden; - border: 1px solid #bbbbbb; - border-radius: 5px; -} - -#contentOverlay #settings .bottompanel > .btnContainer { - width: 15%; - height: 100%; - float: right; - position: relative; - right: 0; -} - -#contentOverlay #settings .bottompanel > .btnContainer > .btnOK { - position: absolute; - bottom: 3%; - right: 7%; - max-width: 85px; - min-width: 42px; - width: 88%; - height: auto; - margin: 0 2% 2% 0; - cursor: pointer; -} - -#message { - position: absolute; - top: 0; - right: 0; - padding: 0.4em 0.5em; - border-radius: 0 0 0 10px; - border: 2px solid #333; - border-width: 0 0 2px 2px; - font-weight: bold; - -webkit-box-shadow: 0px 2px 6px 0px rgba(16, 16, 16, 0.65); - box-shadow: 0px 2px 6px 0px rgba(16, 16, 16, 0.65); - color: #333; - white-space: nowrap; - display: none; -} - -#message.error { - background: #EB313C; - color: #fff; -} - -#message.warning { - background: #E9A86E; -} - -#message.notice { - background: #93CAF4; -} - -#message.info { - background: #97DD8A; -} - -@media only screen and (max-width: 480px), only screen and (max-width: 720px) and (min-device-pixel-ratio: 1.5), only screen and (max-width: 720px) and (-webkit-min-device-pixel-ratio: 1.5) { - /* - TOP LOGO - */ - - .centerpanel { - left: 0; - margin-left: 0; - width: 100%; - /* background-color: rgba(0, 135, 255, 0.4);*/ - } - - .logopanel { - height: 40px; - } - - .d3dlogo { - top: 0; - height: 40px; - max-width: 216px; - background-image: url('../img/logo/logo_smallest.png'); - } - - .drawareacontainer { - /* position: absolute;*/ - height: 70%; - } - - .bottompanel { - height: 10%; - } - - .bottompanel .manipulationBtns { - margin: 2px -27; - right: 22%; - width: 38%; - } - - /* - LEFT - */ - - .leftpanel { - width: 100px; - background-color: #fff; - z-index: 50; - -webkit-transition: left 0.3s ease-out; - transition: left 0.3s ease-out; - } - - .hideleft { - left: -101px; - } - - .shadowright { - -webkit-box-shadow: 2px 0 4px rgba(42, 42, 41, 0.6); - box-shadow: 2px 0 4px rgba(42, 42, 41, 0.6); - } - - .btnNew { - margin: 5% 5% 1% 5%; - width: 90%; - } - - .btnSave { - margin-left: 9%; - width: 75%; - } - - .btnOops { - margin-left: 6%; - width: 71%; - } - - /* - RIGHT - */ - - .rightpanel { - width: 100px; - background-color: #fff; - z-index: 50; - -webkit-transition: right 0.3s ease-out; - transition: right 0.3s ease-out; - } - - .hideright { - right: -101px; - } - - .shadowleft { - -webkit-box-shadow: -2px 0 4px rgba(42, 42, 41, 0.6); - box-shadow: -2px 0 4px rgba(42, 42, 41, 0.6); - } - - .btnPrint { - margin: 1% 5% 5% 5%; - width: 90%; - } - - .btnStop { - margin: 5% 6% 1% 5%; - width: 70%; - } - - /* - REST - */ - - .sidebutton { - display: block; - position: absolute; - /* top: 50%;*/ - /* margin-top: -20px;*/ - top: 40px; - /*float:right;*/ - width: 25px; - height: 38px; - border: 1px solid #808; - background: url('../img/arrows.png') no-repeat; - background-color: #eee; - cursor: pointer; - } - - .sidebutton:active { - background-color: #aaa; - } - - .leftpanel .sidebutton { - right: -27px; - background-position: 0px 0px; - } - - .rightpanel .sidebutton { - left: -27px; - background-position: -25px 0px; - } - - .sidebuttonin:active { - background-color: #888; - } - - .leftpanel .sidebuttonin { - background-color: #ccc; - background-position: -25px 0px; - } - - .rightpanel .sidebuttonin { - background-color: #ccc; - background-position: 0px 0px; - } - - /* - - SETTINGS POPUP - MOBILE - - */ - - #contentOverlay { - z-index: 200; - } - - #contentOverlay #settings { - width: 87%; - height: 82%; - margin: 6% 4%; - } - - #contentOverlay #settings > .right { - width: 14%; - } -} - -@media only screen and (min-width: 1000px) and (max-device-pixel-ratio: 1.5), only screen and (min-width: 1000px) and (-webkit-max-device-pixel-ratio: 1.5) { - -} - -@media only screen and (orientation: portrait) { - #landscape { - display: none; - } - - #portrait { - display: block; - } - - .vertImage { - margin: 0px; - padding: 0px; - /*border: 2px solid #f0f;*/ - max-width: 100%; - height: auto; - width: auto; - /* for ie9 */ - } -} - -/* Tourbus leg definitions element */ - -.tourbus-legs { - display: none; -} - -/* Container for tourbus leg */ - -.tourbus-leg { - position: absolute; - visibility: hidden; - top: 0; - border: 1px solid #E5E5E5; - -webkit-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.45); - box-shadow: 0 2px 5px rgba(0, 0, 0, 0.45); - border-radius: 4px; - background: white; -} - -/* Interior of leg, clearfixed */ - -.tourbus-leg-inner { - padding: 20px; - position: relative; - zoom: 1; -} - -.tourbus-leg-inner:before, -.tourbus-leg-inner:after { - content: "\0020"; - display: block; - height: 0; - overflow: hidden; -} - -.tourbus-leg-inner:after { - clear: both; -} - -.prevnextBtn { - border: 1px solid #8e8e8e; - color: #252525; - border-radius: 4px; - padding: 4px 8px; - background-color: #eaeaea; - -webkit-box-shadow: 0 0 3px rgba(0, 0, 0, 0.7); - box-shadow: 0 0 3px rgba(0, 0, 0, 0.7); - margin-right: 8px; -} - -/* - remove top padding/margin on headings - because the interior of the leg has padding -*/ - -.tourbus-leg h1, -.tourbus-leg h2, -.tourbus-leg h3, -.tourbus-leg h4, -.tourbus-leg h5, -.tourbus-leg h6 { - margin-top: 0; - padding-top: 0; -} - -/* Tourbus leg arrow */ - -.tourbus-arrow:before, -.tourbus-arrow:after { - border: solid rgba(0, 0, 0, 0); - content: " "; - height: 0; - width: 0; - position: absolute; - pointer-events: none; - border-color: transparent; -} - -/* set the :after to be the _interior_ size of the arrow */ - -/* set the :before to be the _interior + desired border width_ */ - -.tourbus-arrow:after { - border-width: 14px; -} - -.tourbus-arrow:before { - border-width: 16px; -} - -/* Arrow background and border colors */ - -/* - change margin-top/left values here to - match the border width for :after above - - border colors here are for the _interior_ of the arrow -*/ - -.tourbus-arrow-right:after { - border-right-color: #ffffff; - margin-top: -14px; - top: 50%; -} - -.tourbus-arrow-left:after { - border-left-color: #ffffff; - margin-top: -14px; - top: 50%; -} - -.tourbus-arrow-bottom:after { - border-bottom-color: #ffffff; - margin-left: -14px; - left: 50%; -} - -.tourbus-arrow-top:after { - border-top-color: #ffffff; - margin-left: -14px; - left: 50%; -} - -/* - change margin-top/left values here to - match the border width for :before above - - border colors here are for the _border_ of the arrow -*/ - -.tourbus-arrow-right:before { - border-right-color: #e5e5e5; - margin-top: -16px; - top: 50%; -} - -.tourbus-arrow-left:before { - border-left-color: #e5e5e5; - margin-top: -16px; - top: 50%; -} - -.tourbus-arrow-bottom:before { - border-bottom-color: #e5e5e5; - margin-left: -16px; - left: 50%; -} - -.tourbus-arrow-top:before { - border-top-color: #e5e5e5; - margin-left: -16px; - left: 50%; -} - -/* you shouldn't need to change these */ - -.tourbus-arrow-right:after, -.tourbus-arrow-right:before { - right: 100%; -} - -.tourbus-arrow-left:after, -.tourbus-arrow-left:before { - left: 100%; -} - -.tourbus-arrow-bottom:after, -.tourbus-arrow-bottom:before { - bottom: 100%; -} - -.tourbus-arrow-top:after, -.tourbus-arrow-top:before { - top: 100%; -} \ No newline at end of file diff --git a/www/css/styles.min.css b/www/css/styles.min.css deleted file mode 100644 index 5a472a6..0000000 --- a/www/css/styles.min.css +++ /dev/null @@ -1 +0,0 @@ -body{background-color:#fcfcfc;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;overflow:hidden}img{z-index:5}.btn{background-repeat:no-repeat;cursor:pointer}#landscape{position:absolute;background-color:#fff;width:100%;max-width:1024px;max-height:768px;top:0;bottom:0;left:0;right:0;z-index:5;overflow:hidden;margin:0 auto;outline:2px solid #5e8c71;-webkit-box-shadow:0 0 8px rgba(8,8,8,.25);box-shadow:0 0 8px rgba(8,8,8,.25)}#portrait{display:none}.bgContainer{position:absolute;width:100%;height:100%;overflow:hidden}.bgTop,.bgMiddle,.bgBottom{opacity:1;-webkit-transition:opacity .35s linear;transition:opacity .35s linear;position:absolute;left:0;z-index:-5}.bgTop{top:0}.bgMiddle{top:30%}.bgBottom{bottom:0}.centerpanel{position:absolute;left:50%;margin-left:-33%;width:66%;height:100%;z-index:5}.logopanel{height:25%}.d3dlogo{position:relative;top:15%;width:100%;height:100%;margin:0 auto;max-width:399px;height:139px;background:url(../img/logo/logo_full.png) no-repeat center center;cursor:pointer}#verticalShapes{position:absolute;right:0;bottom:15px;margin-right:-8.5%;width:8%}#verticalShapes>div{border:2px solid #333;border-radius:0 5px 5px 0;margin-top:4px;background-color:#fff;cursor:pointer}#verticalShapes>div img.verticalshape{width:100%;max-width:50px;height:auto;vertical-align:bottom}.drawareacontainer{position:relative;width:100%;height:65%;background-color:#fff;border:4px solid #000;border-radius:15px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;z-index:15}#canvasContainers{position:absolute;top:0;bottom:0;left:0;right:0;width:100%;height:100%;padding:0;margin:0}#mycanvasContainer{position:absolute;top:0;left:0;width:78%;height:100%}#mycanvas{width:100%;height:100%;margin:0;padding:0;border-right:2px solid #333}#previewContainer{position:absolute;top:0;right:0;width:22%;height:100%}#preview{min-width:50px;width:100%;height:100%;margin:0;padding:0}#preview_tmp{position:absolute;top:0;left:0;z-index:500;border:1px solid #f80;display:none}.bottompanel{position:relative;bottom:0;width:100%;height:10%}.manipulationBtns{margin:2px 5px;position:absolute;right:0;top:0;max-width:340px;max-height:70px;width:45%}.manipulationBtn{width:45%;height:auto;cursor:pointer}#btnsUpDown{float:left;width:45%}#btnsUpDown>div{float:left;padding-right:8px;background-repeat:no-repeat}#btnsTurnLeftRight{float:right;width:45%}#btnsTurnLeftRight>div{float:left;padding-right:8px;background-repeat:no-repeat}#btnMoveUp{max-width:65px}#btnMoveDown{max-width:64px}#btnTwistLeft{max-width:59px}#btnTwistRight{max-width:64px}@media screen and (max-height:700px){.logopanel{height:22%}.doodlecontainer{height:68%}.d3dlogo{top:25%;max-width:399px;height:74px;background-image:url(../img/logo/logo_small.png)}}@media screen and (max-height:655px){.bgMiddle{opacity:0}}@media screen and (max-height:525px){.d3dlogo{top:20%;height:57px;max-width:307px;background-image:url(../img/logo/logo_smaller.png)}}@media screen and (max-height:375px){.d3dlogo{height:40px;max-width:216px;background-image:url(../img/logo/logo_smallest.png)}}.leftpanel{position:absolute;width:17%;top:0;left:0;bottom:0}.btnNew{margin:5% 0 1% 5%;width:100%;max-width:180px;height:auto}.btnsPrevNext{margin:1% 7%;max-width:160px}.btnPrevious{width:40%;max-width:56px;height:auto}.btnNext{width:40%;max-width:56px;height:auto;float:right}.btnSave{margin:5% 5% 1%;width:90%;max-width:144px;height:auto}.btnOops{margin:5% 5% 1%;width:90%;max-width:144px;height:auto}.rightpanel{position:absolute;width:17%;top:0;right:0;bottom:0}.btnPrint{margin:1% 5% 5% 0;width:100%;max-width:163px;height:auto;float:right}.btnStop{margin:5% 10% 1% 5%;float:right;width:90%;max-width:98px;height:auto}.btnsSettingsInfo{position:absolute;bottom:25px;right:5px;width:80%;margin:1% 5%;max-width:160px}.btnInfo{width:40%;max-width:53px;height:auto}.btnSettings{width:40%;max-width:53px;height:auto;float:right}.progressbarAppear{right:-.5%!important}.thermometerAppear{right:-6.5%!important}.progressbarCanvasContainerParent{position:relative;width:100%}#progressbarCanvasContainer{position:relative;width:50%;float:right;border:solid #000;border-width:2px 0 2px 2px;border-radius:15px 0 0 15px;padding:5px;background-color:#fff;-webkit-box-shadow:0 2px 5px rgba(37,37,37,.35);box-shadow:0 2px 5px rgba(37,37,37,.35);-webkit-transition:right .4s cubic-bezier(0.68,-.55,.265,1.55);transition:right .4s cubic-bezier(0.68,-.55,.265,1.55);right:-60%;margin:5% 0}#progressbarCanvas{top:0;right:0;bottom:0;left:0;width:100%;height:auto;background-color:#fff}.thermometerContainerParent{position:relative;width:100%;padding-top:10px}#thermometerContainer{position:relative;width:45%;float:right;background-color:#fff;border:solid #000;border-width:2px 0 2px 2px;border-radius:15px 0 0 15px;padding:5px;-webkit-box-shadow:0 2px 5px rgba(37,37,37,.35);box-shadow:0 2px 5px rgba(37,37,37,.35);-webkit-transition:right .5s cubic-bezier(0.68,-.55,.265,1.55);transition:right .5s cubic-bezier(0.68,-.55,.265,1.55);right:-55%}#thermometerCanvas{top:0;right:0;bottom:0;left:0;width:100%;height:auto;background-color:#fff}.disabled{opacity:.3;cursor:default}#btnStop.disabled{display:none}.clearfix:before,.clearfix:after{content:" ";display:table}.clearfix:after{clear:both}.clearfix{*zoom:1}#contentOverlay{background-color:rgba(255,255,255,.65);z-index:20;position:absolute;top:0;left:0;right:0;bottom:0;width:100%;height:100%;display:none;-webkit-user-select:text;-moz-user-select:text;-ms-user-select:text;user-select:text}#contentOverlay #settings{background-color:#fff;position:absolute;top:0;left:0;right:0;bottom:0;z-index:15;max-width:775px;max-height:540px;width:80%;height:75%;margin:7% 8%;-webkit-box-shadow:0 2px 6px 0 rgba(16,16,16,.65);box-shadow:0 2px 6px 0 rgba(16,16,16,.65);border:2px solid #222;border-radius:15px;padding:2%}#contentOverlay #settings .toppanel{height:10%}#contentOverlay #settings .toppanel .settingsLabelContainer{width:100%;height:auto;margin-bottom:1%}#contentOverlay #settings .toppanel .settingsLabelContainer .settingsLabelImg{width:45%;max-width:373px;height:auto}#contentOverlay #settings .bottompanel{width:100%;height:90%}#contentOverlay #settings .bottompanel>.settingsContainer{float:left;width:83%;height:98%;margin:.5%;overflow-y:scroll;overflow-x:hidden;border:1px solid #bbb;border-radius:5px}#contentOverlay #settings .bottompanel>.btnContainer{width:15%;height:100%;float:right;position:relative;right:0}#contentOverlay #settings .bottompanel>.btnContainer>.btnOK{position:absolute;bottom:3%;right:7%;max-width:85px;min-width:42px;width:88%;height:auto;margin:0 2% 2% 0;cursor:pointer}#message{position:absolute;top:0;right:0;padding:.4em .5em;border-radius:0 0 0 10px;border:2px solid #333;border-width:0 0 2px 2px;font-weight:700;-webkit-box-shadow:0 2px 6px 0 rgba(16,16,16,.65);box-shadow:0 2px 6px 0 rgba(16,16,16,.65);color:#333;white-space:nowrap;display:none}#message.error{background:#EB313C;color:#fff}#message.warning{background:#E9A86E}#message.notice{background:#93CAF4}#message.info{background:#97DD8A}@media only screen and (max-width:480px),only screen and (max-width:720px) and (min-device-pixel-ratio:1.5),only screen and (max-width:720px) and (-webkit-min-device-pixel-ratio:1.5){.centerpanel{left:0;margin-left:0;width:100%}.logopanel{height:40px}.d3dlogo{top:0;height:40px;max-width:216px;background-image:url(../img/logo/logo_smallest.png)}.drawareacontainer{height:70%}.bottompanel{height:10%}.bottompanel .manipulationBtns{margin:2px -27;right:22%;width:38%}.leftpanel{width:100px;background-color:#fff;z-index:50;-webkit-transition:left .3s ease-out;transition:left .3s ease-out}.hideleft{left:-101px}.shadowright{-webkit-box-shadow:2px 0 4px rgba(42,42,41,.6);box-shadow:2px 0 4px rgba(42,42,41,.6)}.btnNew{margin:5% 5% 1%;width:90%}.btnSave{margin-left:9%;width:75%}.btnOops{margin-left:6%;width:71%}.rightpanel{width:100px;background-color:#fff;z-index:50;-webkit-transition:right .3s ease-out;transition:right .3s ease-out}.hideright{right:-101px}.shadowleft{-webkit-box-shadow:-2px 0 4px rgba(42,42,41,.6);box-shadow:-2px 0 4px rgba(42,42,41,.6)}.btnPrint{margin:1% 5% 5%;width:90%}.btnStop{margin:5% 6% 1% 5%;width:70%}.sidebutton{display:block;position:absolute;top:40px;width:25px;height:38px;border:1px solid #808;background:url(../img/arrows.png) no-repeat;background-color:#eee;cursor:pointer}.sidebutton:active{background-color:#aaa}.leftpanel .sidebutton{right:-27px;background-position:0 0}.rightpanel .sidebutton{left:-27px;background-position:-25px 0}.sidebuttonin:active{background-color:#888}.leftpanel .sidebuttonin{background-color:#ccc;background-position:-25px 0}.rightpanel .sidebuttonin{background-color:#ccc;background-position:0 0}#contentOverlay{z-index:200}#contentOverlay #settings{width:87%;height:82%;margin:6% 4%}#contentOverlay #settings>.right{width:14%}}@media only screen and (min-width:1000px) and (max-device-pixel-ratio:1.5),only screen and (min-width:1000px) and (-webkit-max-device-pixel-ratio:1.5){}@media only screen and (orientation:portrait){#landscape{display:none}#portrait{display:block}.vertImage{margin:0;padding:0;max-width:100%;height:auto;width:auto}}.tourbus-legs{display:none}.tourbus-leg{position:absolute;visibility:hidden;top:0;border:1px solid #E5E5E5;-webkit-box-shadow:0 2px 5px rgba(0,0,0,.45);box-shadow:0 2px 5px rgba(0,0,0,.45);border-radius:4px;background:#fff}.tourbus-leg-inner{padding:20px;position:relative;zoom:1}.tourbus-leg-inner:before,.tourbus-leg-inner:after{content:"\0020";display:block;height:0;overflow:hidden}.tourbus-leg-inner:after{clear:both}.prevnextBtn{border:1px solid #8e8e8e;color:#252525;border-radius:4px;padding:4px 8px;background-color:#eaeaea;-webkit-box-shadow:0 0 3px rgba(0,0,0,.7);box-shadow:0 0 3px rgba(0,0,0,.7);margin-right:8px}.tourbus-leg h1,.tourbus-leg h2,.tourbus-leg h3,.tourbus-leg h4,.tourbus-leg h5,.tourbus-leg h6{margin-top:0;padding-top:0}.tourbus-arrow:before,.tourbus-arrow:after{border:solid rgba(0,0,0,0);content:" ";height:0;width:0;position:absolute;pointer-events:none;border-color:transparent}.tourbus-arrow:after{border-width:14px}.tourbus-arrow:before{border-width:16px}.tourbus-arrow-right:after{border-right-color:#fff;margin-top:-14px;top:50%}.tourbus-arrow-left:after{border-left-color:#fff;margin-top:-14px;top:50%}.tourbus-arrow-bottom:after{border-bottom-color:#fff;margin-left:-14px;left:50%}.tourbus-arrow-top:after{border-top-color:#fff;margin-left:-14px;left:50%}.tourbus-arrow-right:before{border-right-color:#e5e5e5;margin-top:-16px;top:50%}.tourbus-arrow-left:before{border-left-color:#e5e5e5;margin-top:-16px;top:50%}.tourbus-arrow-bottom:before{border-bottom-color:#e5e5e5;margin-left:-16px;left:50%}.tourbus-arrow-top:before{border-top-color:#e5e5e5;margin-left:-16px;left:50%}.tourbus-arrow-right:after,.tourbus-arrow-right:before{right:100%}.tourbus-arrow-left:after,.tourbus-arrow-left:before{left:100%}.tourbus-arrow-bottom:after,.tourbus-arrow-bottom:before{bottom:100%}.tourbus-arrow-top:after,.tourbus-arrow-top:before{top:100%} \ No newline at end of file diff --git a/www/js/.gitkeep b/www/js/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/www/js/doodle3d-client.js b/www/js/doodle3d-client.js deleted file mode 100644 index 3ba19c6..0000000 --- a/www/js/doodle3d-client.js +++ /dev/null @@ -1,3402 +0,0 @@ -//these settings are defined in the firmware (conf_defaults.lua) and will be initialized in loadSettings() -var settings = { -"network.ap.ssid": "d3d-ap-%%MAC_ADDR_TAIL%%", -"network.ap.address": "192.168.10.1", -"network.ap.netmask": "255.255.255.0", -"printer.temperature": 220, -"printer.maxObjectHeight": 150, -"printer.layerHeight": 0.2, -"printer.wallThickness": 0.7, -"printer.screenToMillimeterScale": 0.3, -"printer.speed": 50, -"printer.travelSpeed": 200, -"printer.filamentThickness": 2.85, -"printer.enableTraveling": true, -"printer.useSubLayers": true, -"printer.firstLayerSlow": true, -"printer.autoWarmUp": true, -"printer.simplify.iterations": 10, -"printer.simplify.minNumPoints": 15, -"printer.simplify.minDistance": 3, -"printer.retraction.enabled": true, -"printer.retraction.speed": 50, -"printer.retraction.minDistance": 1, -"printer.retraction.amount": 5, -"printer.autoWarmUpCommand": "M104 S220 (hardcoded temperature)" -} - - -function SettingsWindow() { - this.wifiboxURL; - this.wifiboxCGIBinURL - this.window; - this.form; - this.timeoutTime = 3000; - this.retryDelay = 2000; // retry setTimout delay - this.retryRetrieveNetworkStatusDelayTime = 1000;// retry setTimout delay - - this.retryLoadSettingsDelay; // retry setTimout instance - this.retrySaveSettingsDelay; // retry setTimout instance - this.retryRetrieveNetworkStatusDelay;// retry setTimout instance - - - this.apFieldSet; - this.clientFieldSet; - this.networks; - this.currentNetwork; // the ssid of the network the box is on - this.selectedNetwork; // the ssid of the selected network in the client mode settings - this.currentLocalIP = ""; - this.clientModeState = SettingsWindow.NOT_CONNECTED; - this.currentAP; - this.apModeState = SettingsWindow.NO_AP; - - // after switching wifi network or creating a access point we delay the status retrieval - // because the webserver needs time to switch - this.retrieveNetworkStatusDelay; // setTimout delay - this.retrieveNetworkStatusDelayTime = 1000; - - // Events - SettingsWindow.SETTINGS_LOADED = "settingsLoaded"; - - // network client mode states - SettingsWindow.NOT_CONNECTED = "not connected"; // also used as first item in networks list - SettingsWindow.CONNECTED = "connected"; - SettingsWindow.CONNECTING = "connecting"; - SettingsWindow.CONNECTING_FAILED = "connecting failed" - - // network access point mode states - SettingsWindow.NO_AP = "no ap"; - SettingsWindow.AP = "ap"; - SettingsWindow.CREATING_AP = "creating ap"; - - SettingsWindow.API_CONNECTING_FAILED = -1 - SettingsWindow.API_NOT_CONNECTED = 0 - SettingsWindow.API_CONNECTING = 1 - SettingsWindow.API_CONNECTED = 2 - SettingsWindow.API_CREATING = 3 - SettingsWindow.API_CREATED = 4 - - // network mode - SettingsWindow.NETWORK_MODE_NEITHER = "neither"; - SettingsWindow.NETWORK_MODE_CLIENT = "clientMode"; - SettingsWindow.NETWORK_MODE_ACCESS_POINT = "accessPointMode"; - - this.networkMode = SettingsWindow.NETWORK_MODE_NEITHER; - - this.updatePanel = new UpdatePanel(); - - var self = this; - - this.init = function(wifiboxURL,wifiboxCGIBinURL) { - this.wifiboxURL = wifiboxURL; - this.wifiboxCGIBinURL = wifiboxCGIBinURL; - - this.window = $("#settings"); - this.window.find(".btnOK").click(this.submitwindow); - this.window.find(".settingsContainer").load("settings.html", function() { - console.log("Settings:finished loading settings.html, now loading settings..."); - - self.form = self.window.find("form"); - self.form.submit(function (e) { self.submitwindow(e) }); - - self.loadSettings(); - - var btnAP = self.form.find("label[for='ap']"); - var btnClient = self.form.find("label[for='client']"); - var btnRefresh = self.form.find("#refreshNetworks"); - var btnConnect = self.form.find("#connectToNetwork"); - var btnCreate = self.form.find("#createAP"); - var networkSelector = self.form.find("#network"); - self.apFieldSet = self.form.find("#apSettings"); - self.clientFieldSet = self.form.find("#clientSettings"); - - btnAP.on('touchstart mousedown',self.showAPSettings); - btnClient.on('touchstart mousedown',self.showClientSettings); - btnRefresh.on('touchstart mousedown',self.refreshNetworks); - btnConnect.on('touchstart mousedown',self.connectToNetwork); - btnCreate.on('touchstart mousedown',self.createAP); - networkSelector.change(self.networkSelectorChanged); - - // update panel - var $updatePanelElement = self.form.find("#updatePanel"); - self.updatePanel.init(wifiboxURL,$updatePanelElement); - }); - } - this.submitwindow = function(e) { - e.preventDefault(); - e.stopPropagation(); - self.saveSettings(self.readForm(),function(){ - self.hideSettings(); - }); - - clearTimeout(self.retryRetrieveNetworkStatusDelay); - } - - this.showSettings = function() { - console.log("f:showSettings()"); - - this.loadSettings(); // reload settings -// this.window.css("display","table"); - $("#contentOverlay").fadeIn(375, function() { - document.body.removeEventListener('touchmove',prevent,false); - }); - } - this.hideSettings = function() { - $("#contentOverlay").fadeOut(375, function() { - document.body.addEventListener('touchmove',prevent,false); -// self.window.css("display","none"); - }); - } - - this.loadSettings = function() { - if (!communicateWithWifibox) { - console.log(" communicateWithWifibox is false: settings aren't being loaded from wifibox...") - return; - } - console.log("Settings:loadSettings() >> getting new data..."); - - $.ajax({ - url: this.wifiboxURL + "/config/all", - dataType: 'json', - timeout: this.timeoutTime, - success: function(response){ - console.log("Settings:loadSettings response: ",response); - settings = response.data; - console.log(" settings: ",settings); - self.fillForm(); - $(document).trigger(SettingsWindow.SETTINGS_LOADED); - } - }).fail(function() { - console.log("Settings:loadSettings: failed"); - clearTimeout(self.retryLoadSettingsDelay); - self.retryLoadSettingsDelay = setTimeout(function() { self.loadSettings() },self.retryDelay); // retry after delay - }); - - this.refreshNetworks(); - this.retrieveNetworkStatus(false); - } - this.fillForm = function() { - console.log("SettingsWindow:fillForm"); - - //fill form with loaded settings - var selects = this.form.find("select"); - selects.each( function(index,element) { - var element = $(element); - element.val(settings[element.attr('name')]); - }); - var inputs = this.form.find("input"); - inputs.each( function(index,element) { - var element = $(element); - //console.log("printer setting input: ",index,element.attr("type"),element.attr('name')); //,element); - switch(element.attr("type")) { - case "text": - case "number": - element.val(settings[element.attr('name')]); - break; - case "checkbox": - element.prop('checked', settings[element.attr('name')]); - break; - } - }); - var textareas = this.form.find("textarea"); - textareas.each( function(index,element) { - var element = $(element); - var value = settings[element.attr('name')]; - element.val(value); - }); - } - - this.saveSettings = function(newSettings,complete) { - settings = newSettings; // store new settings in global settings - if (communicateWithWifibox) { - $.ajax({ - url: this.wifiboxURL + "/config", - type: "POST", - data: newSettings, - dataType: 'json', - timeout: this.timeoutTime, - success: function(response){ - console.log("Settings:saveSettings response: ",response); - if(response.status == "error") { - clearTimeout(self.retrySaveSettingsDelay); - self.retrySaveSettingsDelay = setTimeout(function() { self.saveSettings(settings) },self.retryDelay); // retry after delay - } else { - var data = response.data; - var validation = data.validation; - self.clearValidationErrors(); - var validated = true; - $.each(validation, function(key, val) { - if (val != "ok") { - console.log("ERROR: setting '" + key + "' not successfully set. Message: " + val); - self.displayValidationError(key,val); - validated = false; - } - }); - settings.substituted_ssid = data.substituted_ssid; - if(complete && validated) complete(); - } - } - }).fail(function() { - console.log("Settings:saveSettings: failed"); - clearTimeout(self.retrySaveSettingsDelay); - self.retrySaveSettingsDelay = setTimeout(function() { self.saveSettings(settings) },self.retryDelay); // retry after delay - }); - } - } - this.displayValidationError = function(key,msg) { - var formElement = self.form.find("[name|='"+key+"']"); - console.log("formElement: ",formElement); - formElement.addClass("error"); - var errorMsg = "
"+msg+"
" - formElement.after(errorMsg); - } - this.clearValidationErrors = function() { - var formElements = self.form.find(".error"); - formElements.each( function(index,element) { - $(element).removeClass("error"); - }); - } - - this.readForm = function() { - //console.log("SettingsWindow:readForm"); - var settings = {}; - var selects = self.form.find("select"); - selects.each( function(index,element) { - var element = $(element); - if(element.attr('name') != "network.client.network") { - settings[element.attr('name')] = element.val(); - } - }); - - var inputs = self.form.find("input"); - inputs.each( function(index,element) { - var element = $(element); - switch(element.attr("type")) { - case "text": - case "number": - settings[element.attr('name')] = element.val(); - break; - case "checkbox": - settings[element.attr('name')] = element.prop('checked') - break; - } - }); - - var textareas = self.form.find("textarea"); - textareas.each( function(index,element) { - var element = $(element); - settings[element.attr('name')] = element.val(); - }); - //console.log(settings); - return settings; - } - - /* - * Networks ui - */ - this.showAPSettings = function() { - self.apFieldSet.show(); - self.clientFieldSet.hide(); - } - this.showClientSettings = function() { - self.clientFieldSet.show(); - self.apFieldSet.hide(); - } - this.refreshNetworks = function() { - console.log("Settings:refreshNetworks"); - - if (communicateWithWifibox) { - $.ajax({ - url: self.wifiboxURL + "/network/scan", - type: "GET", - dataType: 'json', - timeout: self.timeoutTime, - success: function(response){ - console.log("Settings:refreshNetworks response: ",response); - if(response.status == "error") { - //clearTimeout(self.retrySaveSettingsDelay); - //self.retrySaveSettingsDelay = setTimeout(function() { self.saveSettings() },self.retryDelay); // retry after delay - } else { - var networks = response.data.networks - self.networks = {}; - var foundCurrentNetwork = false; - var networkSelector = self.form.find("#network"); - networkSelector.empty(); - networkSelector.append( - $("").val(SettingsWindow.NOT_CONNECTED).html("not connected") - ); - $.each(networks, function(index,element) { - if(element.ssid == self.currentNetwork) { - foundCurrentNetwork = true; - } - networkSelector.append( - $("").val(element.ssid).html(element.ssid) - ); - self.networks[element.ssid] = element; - }); - if(foundCurrentNetwork) { - networkSelector.val(self.currentNetwork); - self.selectNetwork(self.currentNetwork); - } - } - } - }).fail(function() { - - }); - } - } - - this.retrieveNetworkStatus = function(connecting) { - //console.log("Settings:retrieveNetworkStatus"); - if (communicateWithWifibox) { - $.ajax({ - url: self.wifiboxURL + "/network/status", - type: "GET", - dataType: 'json', - timeout: self.timeoutTime, - success: function(response){ - console.log("Settings:retrieveNetworkStatus response: ",response); - if(response.status == "error") { - - } else { - var data = response.data; - - if(typeof data.status === 'string') { - data.status = parseInt(data.status); - } - //console.log(" data.status: ",data.status,data.statusMessage); - - // Determine which network settings to show - switch(data.status) { - case SettingsWindow.API_NOT_CONNECTED: - //console.log(" not connected & not a access point"); - self.apFieldSet.show(); - self.clientFieldSet.show(); - - self.networkMode = SettingsWindow.NETWORK_MODE_NEITHER; - break; - case SettingsWindow.API_CONNECTING_FAILED: - case SettingsWindow.API_CONNECTING: - case SettingsWindow.API_CONNECTED: - //console.log(" client mode"); - self.form.find("#client").prop('checked',true); - - self.apFieldSet.hide(); - self.clientFieldSet.show(); - - if(data.status == SettingsWindow.API_CONNECTED) { - var networkSelector = self.form.find("#network"); - networkSelector.val(data.ssid); - - self.currentNetwork = data.ssid; - self.currentLocalIP = data.localip; - self.selectNetwork(data.ssid); - } else { - self.currentLocalIP = "" - } - self.networkMode = SettingsWindow.NETWORK_MODE_CLIENT; - break; - case SettingsWindow.API_CREATING: - case SettingsWindow.API_CREATED: - //console.log(" access point mode"); - self.form.find("#ap").prop('checked',true); - - self.apFieldSet.show(); - self.clientFieldSet.hide(); - - self.currentNetwork = undefined; - self.selectNetwork(SettingsWindow.NOT_CONNECTED); - var networkSelector = self.form.find("#network"); - networkSelector.val(SettingsWindow.NOT_CONNECTED); - - if(data.ssid && data.status == SettingsWindow.API_CREATED) { - self.currentAP = data.ssid; - } - self.networkMode = SettingsWindow.NETWORK_MODE_ACCESS_POINT; - break; - } - self.updatePanel.setNetworkMode(self.networkMode); - - // update status message - switch(data.status) { - case SettingsWindow.API_CONNECTING_FAILED: - self.setClientModeState(SettingsWindow.CONNECTING_FAILED,data.statusMessage); - self.setAPModeState(SettingsWindow.NO_AP,""); - break; - case SettingsWindow.API_NOT_CONNECTED: - self.setClientModeState(SettingsWindow.NOT_CONNECTED,""); - self.setAPModeState(SettingsWindow.NO_AP,""); - break; - case SettingsWindow.API_CONNECTING: - self.setClientModeState(SettingsWindow.CONNECTING,""); - self.setAPModeState(SettingsWindow.NO_AP,""); - break; - case SettingsWindow.API_CONNECTED: - self.setClientModeState(SettingsWindow.CONNECTED,""); - self.setAPModeState(SettingsWindow.NO_AP,""); - break; - case SettingsWindow.API_CREATING: - self.setClientModeState(SettingsWindow.NOT_CONNECTED,""); - self.setAPModeState(SettingsWindow.CREATING_AP,""); - break; - case SettingsWindow.API_CREATED: - self.setClientModeState(SettingsWindow.NOT_CONNECTED,""); - self.setAPModeState(SettingsWindow.AP,""); - break; - } - - // Keep checking for updates? - if(connecting) { - switch(data.status) { - case SettingsWindow.API_CONNECTING: - case SettingsWindow.API_CREATING: - clearTimeout(self.retryRetrieveNetworkStatusDelay); - self.retryRetrieveNetworkStatusDelay = setTimeout(function() { self.retrieveNetworkStatus(connecting) },self.retryRetrieveNetworkStatusDelayTime); // retry after delay - break; - } - } - } - } - }).fail(function() { - console.log("Settings:retrieveNetworkStatus: failed"); - clearTimeout(self.retryRetrieveNetworkStatusDelay); - self.retryRetrieveNetworkStatusDelay = setTimeout(function() { self.retrieveNetworkStatus(connecting) },self.retryDelay); // retry after delay - }); - } - } - - this.networkSelectorChanged = function(e) { - var selectedOption = $(this).find("option:selected"); - self.selectNetwork(selectedOption.val()); - } - - this.selectNetwork = function(ssid) { - console.log("select network: ",ssid); - if(ssid == "") return; - console.log(" checked"); - this.selectedNetwork = ssid; - if(this.networks == undefined || ssid == SettingsWindow.NOT_CONNECTED) { - this.hideWiFiPassword(); - } else { - var network = this.networks[ssid]; - if(network.encryption == "none") { - this.hideWiFiPassword(); - } else { - this.showWiFiPassword(); - } - this.form.find("#password").val(""); - } - } - this.showWiFiPassword = function() { - this.form.find("#passwordLabel").show(); - this.form.find("#password").show(); - } - this.hideWiFiPassword = function() { - this.form.find("#passwordLabel").hide(); - this.form.find("#password").hide(); - } - - this.setClientModeState = function(state,msg) { - var field = this.form.find("#clientModeState"); - var btnConnect = self.form.find("#connectToNetwork"); - switch(state) { - case SettingsWindow.NOT_CONNECTED: - btnConnect.removeAttr("disabled"); - field.html("Not connected"); - break; - case SettingsWindow.CONNECTED: - btnConnect.removeAttr("disabled"); - - var fieldText = "Connected to: "+this.currentNetwork+"."; - if(this.currentLocalIP != undefined && this.currentLocalIP != "") { - var a = ""+this.currentLocalIP+""; - fieldText += " (IP: "+a+")"; - } - field.html(fieldText); - break; - case SettingsWindow.CONNECTING: - btnConnect.attr("disabled", true); - field.html("Connecting... Reconnect by connecting your device to "+this.selectedNetwork+" and going to connect.doodle3d.com"); - break; - case SettingsWindow.CONNECTING_FAILED: - btnConnect.removeAttr("disabled"); - field.html(msg); - break; - } - this.clientModeState = state; - } - this.setAPModeState = function(state,msg) { - var field = this.form.find("#apModeState"); - var btnCreate = this.form.find("#createAP"); - switch(state) { - case SettingsWindow.NO_AP: - btnCreate.removeAttr("disabled"); - field.html("Not currently a access point"); - break; - case SettingsWindow.AP: - btnCreate.removeAttr("disabled"); - field.html("Is access point: "+this.currentAP+""); - break; - case SettingsWindow.CREATING_AP: - btnCreate.attr("disabled", true); - field.html("Creating access point... Reconnect by connecting your device to "+settings.substituted_ssid+" and going to draw.doodle3d.com"); - break; - } - this.apModeState = state; - } - - this.connectToNetwork = function() { - console.log("connectToNetwork"); - if(self.selectedNetwork == undefined) return; - var postData = { - ssid:self.selectedNetwork, - phrase:self.form.find("#password").val(), - recreate:true - } - console.log(" postData: ",postData); - if (communicateWithWifibox) { - - // save network related settings and on complete, connect to network - self.saveSettings(self.readForm(),function() { - - $.ajax({ - url: self.wifiboxCGIBinURL + "/network/associate", - type: "POST", - data: postData, - dataType: 'json', - timeout: self.timeoutTime, - success: function(response){ - console.log("Settings:connectToNetwork response: ",response); - } - }).fail(function() { - console.log("Settings:connectToNetwork: timeout (normal behavior)"); - //clearTimeout(self.retrySaveSettingsDelay); - //self.retrySaveSettingsDelay = setTimeout(function() { self.saveSettings() },self.retryDelay); // retry after delay - }); - }); - } - self.setClientModeState(SettingsWindow.CONNECTING,""); - - // after switching wifi network or creating a access point we delay the status retrieval - // because the webserver needs time to switch - clearTimeout(self.retrieveNetworkStatusDelay); - self.retrieveNetworkStatusDelay = setTimeout(function() { self.retrieveNetworkStatus(true) },self.retrieveNetworkStatusDelayTime); - } - - this.createAP = function() { - console.log("createAP"); - if (communicateWithWifibox) { - - // save network related settings and on complete, create access point - self.saveSettings(self.readForm(),function() { - self.setAPModeState(SettingsWindow.CREATING_AP); // get latest substituted ssid - $.ajax({ - url: self.wifiboxCGIBinURL + "/network/openap", - type: "POST", - dataType: 'json', - timeout: self.timeoutTime, - success: function(response){ - console.log("Settings:createAP response: ",response); - } - }).fail(function() { - console.log("Settings:createAP: timeout (normal behavior)"); - //clearTimeout(self.retrySaveSettingsDelay); - //self.retrySaveSettingsDelay = setTimeout(function() { self.saveSettings() },self.retryDelay); // retry after delay - }); - - self.setAPModeState(SettingsWindow.CREATING_AP,""); - - // after switching wifi network or creating a access point we delay the status retrieval - // because the webserver needs time to switch - clearTimeout(self.retrieveNetworkStatusDelay); - self.retrieveNetworkStatusDelay = setTimeout(function() { self.retrieveNetworkStatus(true) },self.retrieveNetworkStatusDelayTime); - }); - } - } -} - -/************************* - * - * - * FROM DOODLE3D.INI - * - */ -//TODO: find all references to these variables, replace them and finally remove these. -var objectHeight = 20; -var layerHeight = .2; -//var wallThickness = .5; -//var hop = 0; -//var speed = 70; -//var travelSpeed = 200; -var enableTraveling = true; -//var filamentThickness = 2.89; -var minScale = .3; -var maxScale = 1; -var shape = "%"; -var twists = 0; -//var useSubLayers = true; -//var debug = false; // debug moved to main.js -var loglevel = 2; -//var zOffset = 0; -var serverport = 8888; -var autoLoadImage = "hand.txt"; -var loadOffset = [0, 0]; // x en y ? -var showWarmUp = true; -var loopAlways = false; -var firstLayerSlow = true; -var useSubpathColors = false; -var autoWarmUp = true; -//var maxObjectHeight = 150; -var maxScaleDifference = .1; -var frameRate = 60; -var quitOnEscape = true; -var screenToMillimeterScale = .3; // 0.3 -//var targetTemperature = 220; -//var simplifyiterations = 10; -//var simplifyminNumPoints = 15; -//var simplifyminDistance = 3; -//var retractionspeed = 50; -//var retractionminDistance = 5; -//var retractionamount = 3; -var sideis3D = true; -var sidevisible = true; -var sidebounds = [900, 210, 131, 390]; -var sideborder = [880, 169, 2, 471]; -var windowbounds = [0, 0, 800, 500]; -var windowcenter = true; -var windowfullscreen = false; -var autoWarmUpCommand = "M104 S230"; -//var checkTemperatureInterval = 3; -var autoWarmUpDelay = 3; - -function UpdatePanel() { - this.wifiboxURL; - this.element; - - this.statusCheckInterval = 1000; - this.statusCheckDelayer; // setTimout instance - this.installedDelay = 60*1000; // Since we can't retrieve status during installation we show the installed text after a fixed delay - this.installedDelayer; // setTimout instance - this.retryDelay = 1000; - this.retryDelayer; // setTimout instance - //this.timeoutTime = 3000; - - this.canUpdate = false; - this.currentVersion = ""; - this.newestVersion; - this.progress; - this.imageSize; - - // states from api, see Doodle3D firmware src/script/d3d-updater.lua - UpdatePanel.NONE = 1; // default state - UpdatePanel.DOWNLOADING = 2; - UpdatePanel.DOWNLOAD_FAILED = 3; - UpdatePanel.IMAGE_READY = 4; // download successfull and checked - UpdatePanel.INSTALLING = 5; - UpdatePanel.INSTALLED = 6; - UpdatePanel.INSTALL_FAILED = 7; - - this.state; // update state from api - this.stateText = ""; // update state text from api - - this.networkMode; // network modes from SettingsWindow - - var self = this; - - this.init = function(wifiboxURL,updatePanelElement) { - - this.wifiboxURL = wifiboxURL; - - this.element = updatePanelElement; - this.btnUpdate = this.element.find("#update"); - this.statusDisplay = this.element.find("#updateState"); - this.infoDisplay = this.element.find("#updateInfo"); - - this.btnUpdate.click(this.update); - - this.checkStatus(false); - } - - this.update = function() { - console.log("UpdatePanel:update"); - self.downloadUpdate(); - } - this.downloadUpdate = function() { - console.log("UpdatePanel:downloadUpdate"); - $.ajax({ - url: self.wifiboxURL + "/update/download", - type: "POST", - dataType: 'json', - success: function(response){ - console.log("UpdatePanel:downloadUpdate response: ",response); - } - }).fail(function() { - console.log("UpdatePanel:downloadUpdate: failed"); - }); - self.setState(UpdatePanel.DOWNLOADING); - self.startCheckingStatus(); - } - this.installUpdate = function() { - console.log("UpdatePanel:installUpdate"); - self.stopCheckingStatus(); - $.ajax({ - url: self.wifiboxURL + "/update/install", - type: "POST", - dataType: 'json', - success: function(response){ - console.log("UpdatePanel:installUpdate response: ",response); - } - }).fail(function() { - console.log("UpdatePanel:installUpdate: no respons (there shouldn't be)"); - }); - self.setState(UpdatePanel.INSTALLING); - - clearTimeout(self.installedDelayer); - self.installedDelayer = setTimeout(function() { self.setState(UpdatePanel.INSTALLED) },self.installedDelay); - } - - this.startCheckingStatus = function() { - clearTimeout(self.statusCheckDelayer); - clearTimeout(self.retryDelayer); - self.statusCheckDelayer = setTimeout(function() { self.checkStatus(true) },self.statusCheckInterval); - } - this.stopCheckingStatus = function() { - clearTimeout(self.statusCheckDelayer); - clearTimeout(self.retryDelayer); - } - this.checkStatus = function(keepChecking) { - if (!communicateWithWifibox) return; - $.ajax({ - url: self.wifiboxURL + "/update/status", - type: "GET", - dataType: 'json', - //timeout: self.timeoutTime, - success: function(response){ - console.log("UpdatePanel:checkStatus response: ",response); - - // Keep checking ? - if(keepChecking) { - switch(self.state){ - case UpdatePanel.DOWNLOADING: - case UpdatePanel.INSTALLING: - clearTimeout(self.statusCheckDelayer); - self.statusCheckDelayer = setTimeout(function() { self.checkStatus(keepChecking) },self.statusCheckInterval); - break; - } - } - - if(response.status != "error") { - var data = response.data; - self.handleStatusData(data); - } - } - }).fail(function() { - //console.log("UpdatePanel:checkStatus: failed"); - if(keepChecking) { - clearTimeout(self.retryDelayer); - self.retryDelayer = setTimeout(function() { self.checkStatus(keepChecking) },self.retryDelay); // retry after delay - } - }); - } - - this.handleStatusData = function(data) { - //console.log("UpdatePanel:handleStatusData"); - self.canUpdate = data.can_update; - - if(self.currentVersion != data.current_version || self.newestVersion != data.newest_version) { - self.currentVersion = data.current_version; - self.newestVersion = data.newest_version; - self.updateInfoDisplay(); - } - - self.stateText = data.state_text; - self.progress = data.progress; // not always available - self.imageSize = data.image_size; // not always available - - self.setState(data.state_code); - - switch(this.state){ - case UpdatePanel.IMAGE_READY: - self.installUpdate(); - break; - } - } - this.setState = function(newState) { - if(this.state == newState) return; - console.log("UpdatePanel:setState: ",this.state," > ",newState,"(",this.stateText,") (networkMode: ",self.networkMode,") (newestVersion: ",self.newestVersion,")"); - this.state = newState; - - // download button - // if there isn't newestVersion data something went wrong, - // probably accessing the internet - if(self.newestVersion != undefined) { - switch(this.state){ - case UpdatePanel.NONE: - case UpdatePanel.DOWNLOAD_FAILED: - case UpdatePanel.INSTALL_FAILED: - if(self.canUpdate) { - self.btnUpdate.removeAttr("disabled"); - } else { - self.btnUpdate.attr("disabled", true); - } - break; - default: - self.btnUpdate.attr("disabled", true); - break; - } - } else { - self.btnUpdate.attr("disabled", true); - } - this.updateStatusDisplay(); - } - this.updateStatusDisplay = function() { - var text = ""; - if(self.newestVersion != undefined) { - switch(this.state){ - case UpdatePanel.NONE: - if(self.canUpdate) { - text = "Update(s) available."; - } else { - text = "You're up to date."; - } - break; - case UpdatePanel.DOWNLOADING: - text = "Downloading update..."; - break; - case UpdatePanel.DOWNLOAD_FAILED: - text = "Downloading update failed."; - break; - case UpdatePanel.IMAGE_READY: - text = "Update downloaded."; - break; - case UpdatePanel.INSTALLING: - text = "Installing update... (will take a minute)"; - break; - case UpdatePanel.INSTALLED: - text = "Update complete, please refresh Page."; - break; - case UpdatePanel.INSTALL_FAILED: - text = "Installing update failed."; - break; - } - } else { - if(self.networkMode == SettingsWindow.NETWORK_MODE_ACCESS_POINT) { - text = "Can't access internet in access point mode."; - } else { - text = "Can't access internet."; - } - } - this.statusDisplay.html(text); - } - this.updateInfoDisplay = function() { - var text = "Current version: "+self.currentVersion+". "; - if(self.canUpdate) { - text += "Latest version: "+self.newestVersion+"."; - } - self.infoDisplay.text(text); - } - this.setNetworkMode = function(networkMode) { - self.networkMode = networkMode; - } -} -function setTemperature(callback) { - - if (callback != undefined) callback(); - -} -function setTemperature(callback) { - - if (callback != undefined) callback(); - -} -var VERTICALSHAPE; -var verticalShapes = { - "NONE": 'none', - "DIVERGING": 'diverging', - "CONVERGING": 'converging', - "SINUS": 'sinus' -}; - -function initVerticalShapes() { - // TODO give these vertical shapes a better spot - VERTICALSHAPE = verticalShapes.NONE; - $(".verticalShapes, .straight").on('mouseup touchend', function(e) { - e.preventDefault(); - console.log("diverging"); - VERTICALSHAPE = verticalShapes.NONE; - redrawRenderedPreview(); - }) - $(".verticalShapes, .diverging").on('mouseup touchend', function(e) { - e.preventDefault(); - console.log("diverging"); - VERTICALSHAPE = verticalShapes.DIVERGING; - redrawRenderedPreview(); - }) - $(".verticalShapes, .converging").on('mouseup touchend', function(e) { - e.preventDefault(); - console.log("converging"); - VERTICALSHAPE = verticalShapes.CONVERGING; - redrawRenderedPreview(); - }) - $(".verticalShapes, .sinus").on('mouseup touchend', function(e) { - e.preventDefault(); - console.log("sinus"); - VERTICALSHAPE = verticalShapes.SINUS; - redrawRenderedPreview(); - }) - -} - -function resetVerticalShapes() { - VERTICALSHAPE = verticalShapes.NONE; -} -var btnMoveUpInterval; -var btnMoveDownInterval; - -var btnTwistLeftInterval; -var btnTwistRightInterval; -var twistIncrement = Math.PI/1800; - -var btnOopsInterval; - -var btnNew, btnPrevious, btnNext; -var btnOops, btnStop, btnClear; -var btnMoveUp, btnMoveDown, btnTwistLeft, btnTwistRight; -var btnInfo, btnSettings; -//var btnDebug; // debug - -var state; -var prevState; -var hasControl; - -var gcodeGenerateDelayer; -var gcodeGenerateDelay = 50; - -function initButtonBehavior() { - console.log("f:initButtonBehavior"); - -// btnClear= $(".btnClear"); - btnOops = $(".btnOops"); - btnMoveUp = $("#btnMoveUp"); - btnMoveDown = $("#btnMoveDown"); - btnTwistLeft = $("#btnTwistLeft"); - btnTwistRight = $("#btnTwistRight"); - btnInfo = $(".btnInfo"); - btnSettings = $(".btnSettings"); - btnNew = $(".btnNew"); - btnPrint= $(".btnPrint"); - btnStop = $(".btnStop"); - - btnPrevious = $(".btnPrevious"); - btnNext = $(".btnNext"); - - //debug - //btnDebug = $(".debugBtn"); - - btnNew.on('touchstart mousedown', clearDoodle); - btnPrint.on('touchstart mousedown', print); - - // not using these at the moment - $("#btnPrevious").css("opacity", "0.3"); - btnNext.css("opacity", "0.3"); - $("#btnSave").css("opacity", "0.3"); - btnInfo.css("opacity", "0.3"); - -// btnClear.click(function(e) { -// e.preventDefault(); -// // console.log("clear"); -// -// clearDoodle(); -// }); - - function startOops(e) { - // console.log("btnOops mouse down"); - e.preventDefault(); - btnOopsInterval = setInterval( function() { - oopsUndo(); - }, 1000/50); - } - function stopOops(e) { - // console.log("btnOops mouse up"); - e.preventDefault(); - clearInterval(btnOopsInterval); - } - btnOops.on('touchstart', function(e) { startOops(e); }); - btnOops.on('touchend', function(e) { stopOops(e); }); - btnOops.mousedown(function(e) { startOops(e); }); - btnOops.mouseup(function(e) { stopOops(e); }); - - function startMoveUp(e) { - e.preventDefault(); - // console.log("btnMoveUp mouse down"); - previewUp(true); - clearInterval(btnMoveUpInterval); - btnMoveUpInterval = setInterval( function() { - previewUp(true); - }, 1000/30); - } - function stopMoveUp(e) { - e.preventDefault(); - console.log("btnMoveUp mouse up"); - clearInterval(btnMoveUpInterval); - previewUp(); - } - btnMoveUp.mousedown(function(e) { startMoveUp(e) }); - btnMoveUp.mouseup(function(e) { stopMoveUp(e) }); - btnMoveUp.on('touchstart', function(e) { startMoveUp(e) }); - btnMoveUp.on('touchend', function(e) { stopMoveUp(e) }); - - function startMoveDown(e) { - e.preventDefault(); - // console.log("btnMoveDown mouse down"); - previewDown(true); - clearInterval(btnMoveDownInterval); - btnMoveDownInterval = setInterval( function() { - previewDown(true); - }, 1000/30); - } - function stopMoveDown(e) { - e.preventDefault(); - console.log("btnMoveDown mouse up"); - clearInterval(btnMoveDownInterval); - previewDown(); - } - btnMoveDown.mousedown(function(e) { startMoveDown(e) }); - btnMoveDown.mouseup(function(e) { stopMoveDown(e) }); - btnMoveDown.on('touchstart', function(e) { startMoveDown(e) }); - btnMoveDown.on('touchend', function(e) { stopMoveDown(e) }); - - function startTwistLeft(e) { - e.preventDefault(); - // console.log("btnTwistLeft mouse down"); - previewTwistLeft(true); - clearInterval(btnTwistLeftInterval); - btnTwistLeftInterval = setInterval( function() { - previewTwistLeft(true); - }, 1000/30); - } - function stopTwistLeft(e) { - e.preventDefault(); - // console.log("btnTwistLeft mouse up"); - clearInterval(btnTwistLeftInterval); - previewTwistLeft(); - } - btnTwistLeft.mousedown(function(e) { startTwistLeft(e) }); - btnTwistLeft.mouseup(function(e) { stopTwistLeft(e) }); - btnTwistLeft.on('touchstart', function(e) { startTwistLeft(e) }); - btnTwistLeft.on('touchend', function(e) { stopTwistLeft(e) }); - - function startTwistRight(e) { - e.preventDefault(); - // console.log("btnTwistRight mouse down"); - previewTwistRight(true); - clearInterval(btnTwistRightInterval); - btnTwistRightInterval = setInterval( function() { - previewTwistRight(true); - }, 1000/30); - } - function stopTwistRight(e) { - e.preventDefault(); - // console.log("btnTwistRight mouse up"); - clearInterval(btnTwistRightInterval); - previewTwistRight(); - } - btnTwistRight.mousedown(function(e) { startTwistRight(e) }); - btnTwistRight.mouseup(function(e) { stopTwistRight(e) }); - btnTwistRight.on('touchstart', function(e) { startTwistRight(e) }); - btnTwistRight.on('touchend', function(e) { stopTwistRight(e) }); - - /*function openSettings() { - console.log("f:openSettings()"); - $("#contentOverlay").fadeIn(1000, function() { - loadSettings(); - }); - }*/ - btnSettings.bind('touchstart mousedown',function () { - //e.preventDefault(); - //console.log("btnSettings clicked"); - settingsWindow.showSettings(); - }); -// btnSettings.on('touchend', function(e) { -// e.preventDefault(); -// console.log("btnSettings touchend"); -// }); - - btnInfo.mouseup(function(e) { - e.preventDefault(); - console.log("btnInfo mouse up"); - }); - - // DEBUG - /* - // $(".agentInfo").css("display", "none"); - btnDebug.click(function(e) { - console.log("debugClick"); - $(".agentInfo").toggleClass("agentInfoToggle"); - e.preventDefault(); - }) - //*/ - - //btnStop.on('touchstart mousedown',stopPrint); -} -function stopPrint() { - console.log("f:stopPrint() >> sendPrintCommands = " + sendPrintCommands); - //if (!confirm("Weet je zeker dat je huidige print wilt stoppen?")) return; - if (sendPrintCommands) printer.stop(); - //setState(Printer.STOPPING_STATE,printer.hasControl); - printer.overruleState(Printer.STOPPING_STATE); -} - - -function prevDoodle(e) { - console.log("f:prevDoodle()"); - console.log("f:prevDoodle()"); -} -function nextDoodle(e) { - console.log("f:nextDoodle()"); -} - -function print(e) { - console.log("f:print() >> sendPrintCommands = " + sendPrintCommands); - - //$(".btnPrint").css("display","none"); - - if (_points.length > 2) { - - //setState(Printer.BUFFERING_STATE,printer.hasControl); - printer.overruleState(Printer.BUFFERING_STATE); - - btnStop.css("display","none"); // hack - - // we put the gcode generation in a little delay - // so that for example the print button is disabled right away - clearTimeout(gcodeGenerateDelayer); - gcodeGenerateDelayer = setTimeout(function() { - - var gcode = generate_gcode(); - if (sendPrintCommands) { - if(gcode.length > 0) { - printer.print(gcode); - } else { - printer.overruleState(Printer.IDLE_STATE); - printer.startStatusCheckInterval(); - } - } else { - console.log("sendPrintCommands is false: not sending print command to 3dprinter"); - } - - if (debugMode) { - $("#textdump").text(""); - $("#textdump").text(gcode.join("\n")); - } - - }, gcodeGenerateDelay); - } else { - console.log("f:print >> not enough points!"); - } - - //alert("Je tekening zal nu geprint worden"); - //$(".btnPrint").css("display","block"); - - - // $.post("/doodle3d.of", { data:output }, function(data) { - // btnPrint.disabled = false; - // }); -} - - -function clearMainView() { - // console.log("f:clearMainView()"); - ctx.save(); - ctx.clearRect(0,0,canvas.width, canvas.height); - ctx.restore(); -} -function resetPreview() { - // console.log("f:resetPreview()"); - - // clear preview canvas - previewCtx.save(); - previewCtx.clearRect(0,0,canvas.width, canvas.height); - previewCtx.restore(); - - // reset height and rotation to default values - numLayers = previewDefaults.numLayers; // current number of preview layers - rStep = previewDefaults.rotation; // Math.PI/180; //Math.PI/40; // -} - -function oopsUndo() { - // console.log("f:oopsUndo()"); - _points.pop(); - redrawDoodle(); - redrawPreview(); -} -function previewUp(redrawLess) { - // console.log("f:previewUp()"); - if (numLayers < maxNumLayers) { - numLayers++; - } -// redrawPreview(redrawLess); - redrawRenderedPreview(redrawLess); -} -function previewDown(redrawLess) { - // console.log("f:previewDown()"); - if (numLayers > minNumLayers) { - numLayers--; - } -// redrawPreview(redrawLess); - redrawRenderedPreview(redrawLess); -} -function previewTwistLeft(redrawLess) { - if (redrawLess == undefined) redrawLess = false; - // console.log("f:previewTwistLeft()"); - if (rStep > -previewRotationLimit) rStep -= twistIncrement; - // redrawPreview(redrawLess); - redrawRenderedPreview(redrawLess); -} -function previewTwistRight(redrawLess) { - // console.log("f:previewTwistRight()"); - if (rStep < previewRotationLimit) rStep += twistIncrement; - // redrawPreview(redrawLess); - redrawRenderedPreview(redrawLess); -} - - - -function update() { - setState(printer.state,printer.hasControl); - - thermometer.update(printer.temperature, printer.targetTemperature); - progressbar.update(printer.currentLine, printer.totalLines); -} - -function setState(newState,newHasControl) { - if(newState == state && newHasControl == hasControl) return; - - prevState = state; - - console.log("setState: ",prevState," > ",newState," ( ",newHasControl,")"); - setDebugText("State: "+newState); - - // print button - var printEnabled = (newState == Printer.IDLE_STATE && newHasControl); - if(printEnabled) { - btnPrint.removeClass("disabled"); // enable print button - btnPrint.unbind('touchstart mousedown'); - btnPrint.bind('touchstart mousedown',print); - } else { - btnPrint.addClass("disabled"); // disable print button - btnPrint.unbind('touchstart mousedown'); - } - - // stop button - var stopEnabled = ((newState == Printer.PRINTING_STATE || newState == Printer.BUFFERING_STATE) && newHasControl); - if(stopEnabled) { - btnStop.removeClass("disabled"); - btnStop.unbind('touchstart mousedown'); - btnStop.bind('touchstart mousedown',stopPrint); - } else { - btnStop.addClass("disabled"); - btnStop.unbind('touchstart mousedown'); - } - - // thermometer - switch(newState) { - case Printer.IDLE_STATE: - case Printer.BUFFERING_STATE: - case Printer.PRINTING_STATE: - case Printer.STOPPING_STATE: - thermometer.show(); - break; - default: - thermometer.hide(); - break; - } - - // progress indicator - switch(newState) { - case Printer.PRINTING_STATE: - progressbar.show(); - break; - default: - progressbar.hide(); - break; - } - - if(newState == Printer.WIFIBOX_DISCONNECTED_STATE) { - message.set("Lost connection to WiFi box",Message.ERROR); - } else if(prevState == Printer.WIFIBOX_DISCONNECTED_STATE) { - message.set("Connected to WiFi box",Message.INFO,true); - } else if(newState == Printer.DISCONNECTED_STATE) { - message.set("Printer disconnected",Message.WARNING,true); - } else if(prevState == Printer.DISCONNECTED_STATE && newState == Printer.IDLE_STATE || - prevState == Printer.UNKNOWN_STATE && newState == Printer.IDLE_STATE) { - message.set("Printer connected",Message.INFO,true); - } - - state = newState; - hasControl = newHasControl; -} - -/* * * * * * * * * * - * - * VARS - * - * * * * * * * * * */ -var preview; -var previewCtx; - -var svgPathRegExp = /[LM]\d* \d*/ig; -var svgPathParamsRegExp = /([LM])(\d*) (\d*)/; - -var dragging = false; - -var $canvas, canvas, ctx; -var canvasWidth, canvasHeight; - -var drawCanvas; -var drawCanvasTopLeftCoords = [0, 0]; - -var doodleBounds = [-1, -1, -1, -1]; // left, top, right, bottom -// var doodleScaleVals = [[0, 0], [1.0, 1.0]]; // [ [x, y], [scaleX, scaleY] ] -var doodleTransform = [0, 0, 1.0, 1.0]; // [ x, y, scaleX, scaleY ] - -var _points = []; - -var prevCountingTime = 0; -var movementCounter = 0; - -var drawVariableLineWeight = false; // set to true to have the momentum of the mouse/touch movement result in larger/smaller strokes -var lineweight = 2; - -/* * * * * * * * * * - * - * INIT - * - * * * * * * * * * */ -function initDoodleDrawing() { - console.log("f:initDoodleDrawing()"); - - $canvas = $("#mycanvas"); - canvas = $canvas[0]; - ctx = canvas.getContext('2d'); - - canvasWidth = canvas.width; - canvasHeight = canvas.height; - - - //* - //TODO make these jquery eventhandlers (works for all) - if (!canvas.addEventListener) { - canvas.attachEvent('onmousedown',onCanvasMouseDown); - canvas.attachEvent('onmousemove',onCanvasMouseMove); - canvas.attachEvent('onmouseup',onCanvasMouseUp); - canvas.attachEvent('ontouchstart',onCanvasTouchDown); - canvas.attachEvent('ontouchmove',onCanvasTouchMove); - canvas.attachEvent('ontouchend',onCanvasTouchEnd); - document.body.attachEvent('ontouchmove',prevent); - } else { - canvas.addEventListener('mousedown',onCanvasMouseDown,false); - canvas.addEventListener('mousemove',onCanvasMouseMove,false); - canvas.addEventListener('mouseup',onCanvasMouseUp,false); - canvas.addEventListener('touchstart',onCanvasTouchDown,false); - canvas.addEventListener('touchmove',onCanvasTouchMove,false); - canvas.addEventListener('touchend',onCanvasTouchEnd,false); - if (!debugMode) document.body.addEventListener('touchmove',prevent,false); - } - //*/ - -// drawCanvas = $(".drawareacontainer"); - drawCanvas = $("#mycanvasContainer"); // $("#drawAreaContainer") - - console.log("drawCanvasTopLeftCoords: " + drawCanvasTopLeftCoords); -// drawCanvasTopLeftCoords[0] = drawCanvas.css("left").match(/[0-9]/g).join(""); -// drawCanvasTopLeftCoords[1] = drawCanvas.css("top").match(/[0-9]/g).join(""); - drawCanvasTopLeftCoords[0] = drawCanvas.offset().left; - drawCanvasTopLeftCoords[1] = drawCanvas.offset().top; -// drawCanvasTopLeftCoords[0] = drawCanvas[0].offsetParent.offsetLeft; -// drawCanvasTopLeftCoords[1] = drawCanvas[0].offsetParent.offsetTop; - - console.log("f:initDoodleDrawing() >> canvasWidth: " + canvasWidth); - console.log("f:initDoodleDrawing() >> canvasHeight: " + canvasHeight); - -} - -/* * * * * * * * * * - * - * CANVAS DRAWING FUNCTION - * - * * * * * * * * * */ -function draw(_x, _y, _width) { - // console.log("f:draw() >> _width: " + _width); - - if (prevX == 0 && prevY ==0) { - prevX = _x; - prevY = _y; - } - - ctx.beginPath(); - ctx.moveTo(prevX, prevY); - ctx.lineTo(_x, _y); - - if (_width != undefined) { - ctx.lineWidth = _width; - } else { - if (drawVariableLineWeight) { - var dist = Math.sqrt(Math.pow((prevX - _x), 2) + Math.pow((prevY - _y), 2)); - if (dist < 10) { - lineweight += .25; - } else if (dist < 20) { - lineweight += .5; - } else if (dist < 30) { - lineweight += .75; - } else if (dist < 50) { - lineweight += 1; - } else if (dist < 80) { - lineweight += 1.5; - } else if (dist < 120) { - lineweight += 2.25; - } else if (dist < 170) { - lineweight += 3.5; - } else { - lineweight += 2; - } - lineweight = Math.min(lineweight, 30); - lineweight *= 0.90; - lineweight = Math.max(lineweight, 1.0); - } else { - lineweight = 2; - } - - ctx.lineWidth = lineweight; - } - ctx.lineCap = 'round'; - ctx.stroke(); - - prevX = _x; - prevY = _y; -} - - -/* * * * * * * * * * - * - * SUPPORTING FUNCTIONS - * - * * * * * * * * * */ -function clearDoodle() { - console.log("f:clearDoodle"); - - _points = []; - - prevX = 0; - prevY = 0; - - updatePrevX = -1; - updatePrevY = -1; - - doodleBounds = [-1, -1, -1, -1]; // left, top, right, bottom - doodleTransform = [0, 0, 1.0, 1.0]; // [ x, y, scaleX, scaleY ] - - dragging = false; - - clearMainView(); - resetPreview(); - resetVerticalShapes(); -} - -function redrawDoodle() { - console.log("f:redrawDoodle()"); - - clearMainView(); - - prevX = 0; - prevY = 0; - - for (var i = 0; i < _points.length; i++) { - // console.log(" drawing points " + _points[i]); - if (_points[i][2] == true) { - draw(_points[i][0], _points[i][1], 0.5); - } else { - draw(_points[i][0], _points[i][1]); - } - } -} - - function adjustBounds(x, y) { - var newPointsOutsideOfCurrentBounds = false; - console.log("f:adjustBounds("+x+","+y+")"); - - if (doodleBounds[0] == -1) { - // if doodleBounds[0] is -1 then it isn't initted yet, so x and y are both the min and max vals - - doodleBounds[0] = x; - doodleBounds[1] = y; - doodleBounds[2] = x; - doodleBounds[3] = y; - return; - } - - if (x < doodleBounds[0]) { - doodleBounds[0] = x; - newPointsOutsideOfCurrentBounds = true; - } - if (x > doodleBounds[2]) { - doodleBounds[2] = x; - newPointsOutsideOfCurrentBounds = true; - } - if (y < doodleBounds[1]) { - doodleBounds[1] = y; - newPointsOutsideOfCurrentBounds = true; - } - if (y > doodleBounds[3]) { - doodleBounds[3] = y; - newPointsOutsideOfCurrentBounds = true; - } -// doodleBounds[0] = Math.min(doodleBounds[0], x); // left -// doodleBounds[2] = Math.max(doodleBounds[2], x); // right -// -// doodleBounds[1] = Math.min(doodleBounds[1], y); // top -// doodleBounds[3] = Math.max(doodleBounds[3], y); // bottom - - // draw the bounding rect (DEBUG) - /* - ctx.beginPath(); - ctx.rect(doodleBounds[0],doodleBounds[1], doodleBounds[2] - doodleBounds[0], doodleBounds[3] - doodleBounds[1]); - ctx.lineWidth = .2; - ctx.strokeStyle = "#333" - ctx.stroke(); - ctx.closePath(); - //*/ - - // console.log(" new bounds: " + doodleBounds); - - return newPointsOutsideOfCurrentBounds; -} - -// does what exactly? -function adjustPreviewTransformation() { - // console.log("f:adjustPreviewTransformation()"); - -// doodleTransform[0] = doodleBounds[0] - (doodleBounds[2] - doodleBounds[0]) / 2; -// doodleTransform[1] = doodleBounds[1] - (doodleBounds[3] - doodleBounds[1]) / 2; -// doodleTransform[0] = doodleBounds[0] - ((doodleBounds[2] - doodleBounds[0]) / 2); -// doodleTransform[1] = doodleBounds[1] - ((doodleBounds[3] - doodleBounds[1]) / 2); - doodleTransform[0] = doodleBounds[0]; - doodleTransform[1] = doodleBounds[1]; - - var sclX, sclY, finalScl; - if (_points.length < 2) { -// console.log(_points); - sclX = 1.0; - sclY = 1.0; - finalScl = Math.min(sclX, sclY); - } else { - sclX = canvasWidth / (doodleBounds[2] - doodleBounds[0]); - sclY = canvasHeight / (doodleBounds[3] - doodleBounds[1]); - - // TODO this shouldn't be a matter if choosing the smallest but should probably involve maintaining aspect ratio?? - finalScl = Math.min(sclX, sclY); - } - - doodleTransform[2] = finalScl; - doodleTransform[3] = finalScl; -} - - -/* * * * * * * * * * - * - * MOUSE/TOUCH EVENTHANDLERS - * - * * * * * * * * * */ -function onCanvasMouseDown(e) { - // console.log("onmousedown >> e.offsetX,e.offsetY = " + e.offsetX+","+e.offsetY); - // console.log("onmousedown >> e.layerX,e.layerY= " + e.layerX+","+e.layerY); - // console.log("onmousedown >> e: " + e); - // console.log(e); -// console.log("f:onCanvasMouseDown()"); - dragging = true; - - prevCountingTime = new Date().getTime(); - movementCounter = 0 - -// _points.push([e.clientX - canvas.offsetLeft, e.clientY - canvas.offsetTop, true]); -// adjustBounds(e.clientX - canvas.offsetLeft, e.clientY - canvas.offsetTop); -// adjustPreviewTransformation(); -// draw(e.clientX - canvas.offsetLeft, e.clientY - canvas.offsetTop, 0.5); - - var x, y; - if (e.offsetX != undefined) { - x = e.offsetX; - y = e.offsetY; - } else { - x = e.layerX; - y = e.layerY; - } -// console.log(" x: " + x + ", y: " + y); - - _points.push([x, y, true]); - adjustBounds(x, y); - adjustPreviewTransformation(); - draw(x, y, 0.5); -} - -var prevPoint = {x:-1, y:-1}; -function onCanvasMouseMove(e) { -// console.log("f:onCanvasMouseMove()"); - if (!dragging) return; - // console.log("onmousemove"); - - var x, y; - if (e.offsetX != undefined) { - x = e.offsetX; - y = e.offsetY; - } else { - x = e.layerX; - y = e.layerY; - } - - if (prevPoint.x != -1 || prevPoint.y != -1) { - var dist = Math.sqrt(Math.pow((prevPoint.x - x), 2) + Math.pow((prevPoint.y - y), 2)); - if (dist > 5) { // replace by setting: doodle3d.simplify.minDistance - _points.push([x, y, false]); - adjustBounds(x, y) - adjustPreviewTransformation(); - draw(x, y); - prevPoint.x = x; - prevPoint.y = y; - } - } else { - _points.push([x, y, false]); - adjustBounds(x, y) - adjustPreviewTransformation(); - draw(x, y); - prevPoint.x = x; - prevPoint.y = y; - } - - // DEBUG -// $("#textdump").text(""); -// $("#textdump").append("doodlebounds:" + doodleBounds + "\n"); -// $("#textdump").append("doodletransform:" + doodleTransform + "\n"); - - if (new Date().getTime() - prevRedrawTime > redrawInterval) { - // redrawing the whole preview the first X points ensures that the doodleBounds is set well - prevRedrawTime = new Date().getTime(); - if (_points.length < 50) { - redrawPreview(); - } else { - updatePreview(x, y, true); - /* - if (_points.length - prevUpdateFullPreview > prevUpdateFullPreviewInterval) { - console.log("f:onTouchMove >> passed prevUpdateFullPreviewInterval, updating full preview"); - redrawPreview(); - prevUpdateFullPreview = _points.length; - } else { - updatePreview(x, y, true); - } - //*/ -// redrawPreview(); - } - } -} -prevUpdateFullPreview = 0; // 0 is not a timeframe but refers to the _points array -prevUpdateFullPreviewInterval = 25; // refers to number of points, not a timeframe - -function onCanvasMouseUp(e) { -// console.log("f:onCanvasMouseUp()"); - // console.log("onmouseup"); - dragging = false; - console.log("doodleBounds: " + doodleBounds); - console.log("doodleTransform: " + doodleTransform); - // ctx.stroke(); - - console.log("_points.length :" + _points.length); -// console.log(_points); - - // DEBUG -// $("#textdump").text(""); -// $("#textdump").append("doodlebounds:" + doodleBounds + "\n"); -// $("#textdump").append("doodletransform:" + doodleTransform + "\n"); - -// redrawPreview(); - renderToImageDataPreview(); -} - -function onCanvasTouchDown(e) { - e.preventDefault(); - console.log("f:onCanvasTouchDown >> e: " , e); -// var x = e.touches[0].pageX - e.touches[0].target.offsetLeft; -// var y = e.touches[0].pageY - e.touches[0].target.offsetTop; - var x = e.touches[0].pageX - drawCanvasTopLeftCoords[0]; - var y = e.touches[0].pageY - drawCanvasTopLeftCoords[1]; -// var x = e.touches[0].pageX; -// var y = e.touches[0].pageY; -// var x = e.touches[0].layerX; -// var y = e.touches[0].layerY; - - _points.push([x, y, true]); - adjustBounds(x, y); - adjustPreviewTransformation(); - draw(x, y, .5); - - movementCounter = 0; - - prevRedrawTime = new Date().getTime(); -} - -function onCanvasTouchMove(e) { - e.preventDefault(); -// var x = e.touches[0].pageX - e.touches[0].target.offsetLeft; -// var y = e.touches[0].pageY - e.touches[0].target.offsetTop; - var x = e.touches[0].pageX - drawCanvasTopLeftCoords[0]; - var y = e.touches[0].pageY - drawCanvasTopLeftCoords[1]; -// var x = e.touches[0].layerX; -// var y = e.touches[0].layerY; -// var x = e.touches[0].layerX; -// var y = e.touches[0].layerY; - - console.log("f:onCanvasTouchMove >> x,y = "+x+","+y+" , e: " , e); - - if (prevPoint.x != -1 || prevPoint.y != -1) { - var dist = Math.sqrt(Math.pow((prevPoint.x - x), 2) + Math.pow((prevPoint.y - y), 2)); - if (dist > 5) { - _points.push([x, y, false]); - adjustBounds(x, y) - adjustPreviewTransformation(); - draw(x, y); - prevPoint.x = x; - prevPoint.y = y; - } - } else { - _points.push([x, y, false]); - adjustBounds(x, y) - adjustPreviewTransformation(); - draw(x, y); - prevPoint.x = x; - prevPoint.y = y; - } - - // update counter -> this was for getting a handle on how often the Canvas fires a move-event - /* - movementCounter++; - if (new Date().getTime() - prevCountingTime > 1000) { - // console.log("number of moves in 1sec: " + movementCounter) - prevCountingTime= new Date().getTime(); - $("#numtimes").text(movementCounter + " times"); - movementCounter = 0; - } - //*/ - - if (new Date().getTime() - prevRedrawTime > redrawInterval) { - // redrawing the whole preview the first X points ensures that the doodleBounds is set well - if (_points.length < 50) { - redrawPreview(); - } else { - updatePreview(x, y, true); - /* - if (_points.length - prevUpdateFullPreview > prevUpdateFullPreviewInterval) { - console.log("f:onTouchMove >> passed prevUpdateFullPreviewInterval, updating full preview"); - redrawPreview(); - prevUpdateFullPreview = _points.length; - } else { - updatePreview(x, y, true); - } - //*/ - } - prevRedrawTime = new Date().getTime(); - } -} - -function onCanvasTouchEnd(e) { - console.log("f:onCanvasTouchEnd()"); - console.log("doodleBounds: " + doodleBounds); - console.log("doodleTransform: " + doodleTransform); - // ctx.stroke(); - - console.log("_points.length :" + _points.length); - - // redrawPreview(); - renderToImageDataPreview(); -} - -function prevent(e) { - e.preventDefault(); -} -//* -var $preview; -var preview; -var previewCtx; - -var preview_tmp; -var previewCtx_tmp; - -var previewDefaults = { - rotation: Math.PI/90, - numLayers: 10 -} - -var svgPathRegExp = /[LM]\d* \d*/ig; -var svgPathParamsRegExp = /([LM])(\d*) (\d*)/; - -var prevRedrawTime = new Date().getTime(); -var redrawInterval = 1000 / 30; // ms - -function initPreviewRendering() { - console.log("f:initPreviewRendering()"); - - $preview = $("#preview"); - preview = $preview[0]; - previewCtx = preview.getContext('2d'); - - // DEBUG --> mbt preview_tmp (voor de toImageData truc) - var _ratio = preview.width / canvas.width; - preview_tmp = document.getElementById('preview_tmp'); - preview_tmp.width = preview.width; - preview_tmp.height = canvas.height * _ratio; - $("#preview_tmp").css("top", -preview_tmp.height); - - previewCtx_tmp = preview_tmp.getContext('2d'); - - calcPreviewCanvasProperties(); - redrawPreview(); -} - -function calcPreviewCanvasProperties() { - console.log("f:calcPreviewCanvasProperties()"); - - globalScale = preview.width / canvasWidth; - layerCX = (canvasWidth / 2) * globalScale; // defined in canvasDrawing_v01.js - layerCY = (canvasHeight / 2) * globalScale; // defined in canvasDrawing_v01.js -// layerOffsetY = preview.height - 1.75 * layerCY; - layerOffsetY = preview.height * (1 - previewVerticalPadding.bottom); - yStep = (preview.height - (preview.height * (previewVerticalPadding.top + previewVerticalPadding.bottom))) / maxNumLayers; -} - -// TODO (perhaps) : make the twist limit dynamic, depending on what's printable (w.r.t. overlapping) -var previewRotationLimit = Math.PI / 30; // rough estimate - -var numLayers = previewDefaults.numLayers; // current number of preview layers -var maxNumLayers= 100; // maximum number of preview layers -var minNumLayers= 2; // minimum number of preview layers -var globalScale = 0.3; // global scale of preview (width preview / width canvas) -var globalAlpha = 0.20; // global alpha of preview -var scaleY = 0.4; // additional vertical scale per path for 3d effect -var viewerScale = 0.65; // additional scale to fit into preview nicely (otherwise is fills out totally) -var previewVerticalPadding = { "top" : .15, "bottom" : 0.12 }; // % -var strokeWidth = 2; //4; -//var rStep = Math.PI/40; //Math.PI/40; // -var rStep = previewDefaults.rotation; // Math.PI/180; //Math.PI/40; // -var yStep;// = preview.height / 150; // 3; //6; -//var svgWidth = 500; // 650 //parseInt($(svg).css("width")); -//var svgHeight = 450; //450; //parseInt($(svg).css("height")); -var layerCX, layerCY; -//var layerCX = (canvasWidth / 2) * globalScale; // defined in canvasDrawing_v01.js -//var layerCY = (canvasHeight / 2) * globalScale; // defined in canvasDrawing_v01.js -var layerOffsetY; //= preview.height - 1.75 * layerCY; // 330; // previewHeight - 120 -var prevX = 0; -var prevY = 0; -var highlight = true; //highlight bottom, middle and top layers - -var linesRaw = ""; -var debug_redrawSimplification = 6; -function redrawPreview(redrawLess) { - if (redrawLess == undefined) redrawLess = false; - - if (_points.length < 2) return; - - if (!redrawLess) { - //debug_redrawSimplification = Math.round(_points.length / 65); - //* - if (_points.length < 100) { - debug_redrawSimplification = 6; - } else if (_points.length < 250) { - debug_redrawSimplification = 7; - } else if (_points.length < 400) { - debug_redrawSimplification = 8; - } else if (_points.length < 550) { - debug_redrawSimplification = 9; - } else if (_points.length < 700) { - debug_redrawSimplification = 10; - } else { - debug_redrawSimplification = 11; - } - //*/ -// console.log("debug_redrawSimplification: " + debug_redrawSimplification); - } - - var y = 0; - var r = 0; - - //preview.width = preview.width; - previewCtx.clearRect(0, 0, preview.width, preview.height); - previewCtx.lineWidth = strokeWidth; - previewCtx.strokeStyle = '#f00'; //"rgba(255,255,0,0)"; - - for(var i = 0; i < numLayers; i++) { - - var verticalScaleFactor = scaleFunction(i / maxNumLayers); - - if(i == 0 || i == Math.floor(numLayers/2) || i == numLayers-1) { - previewCtx.globalAlpha = 1; - } else { - previewCtx.globalAlpha = globalAlpha; - } - - if (redrawLess && i%debug_redrawSimplification != 0 && !(i == 0 || i == Math.floor(numLayers/2) || i == numLayers-1) ) { - y -= yStep; - r += rStep; - continue; - } - - previewCtx.save(); - -// previewCtx.translate(layerCX, layerOffsetY + layerCY + y); - previewCtx.translate(layerCX, layerOffsetY + y); -// previewCtx.setTransform(1, 0, 0, scaleY, layerCX, layerOffsetY+layerCY+y); - previewCtx.scale(viewerScale * verticalScaleFactor, scaleY * viewerScale * verticalScaleFactor); - previewCtx.rotate(r); - previewCtx.translate((-doodleTransform[0]) * (globalScale * doodleTransform[2]), (-doodleTransform[1]) * (globalScale * doodleTransform[3])); - - var adjustedDoodlePoint = centeredAndScaledDoodlePoint(_points[0]); - - previewCtx.beginPath(); - previewCtx.moveTo(adjustedDoodlePoint.x, adjustedDoodlePoint.y); - for(var j = 1; j < _points.length; j++) { - adjustedDoodlePoint = centeredAndScaledDoodlePoint(_points[j]) - if (redrawLess && j%debug_redrawSimplification != 0 ) continue; - previewCtx.lineTo(adjustedDoodlePoint.x, adjustedDoodlePoint.y); - } - previewCtx.stroke(); - - y -= yStep; - r += rStep; - previewCtx.restore(); - } - previewCtx.globalAlpha = globalAlpha; -} - -function renderToImageDataPreview() { - console.log("f:renderToImageDataPreview()"); - - if (_points.length < 2) return; - - //* - // the first step - previewCtx_tmp.clearRect(0, 0, preview.width, preview.height); - previewCtx_tmp.lineWidth = strokeWidth; - previewCtx_tmp.strokeStyle = '#f00'; //"rgba(255,255,0,0)"; - - previewCtx_tmp.save(); - previewCtx_tmp.translate(layerCX, layerCY); - previewCtx_tmp.scale(viewerScale, viewerScale); - previewCtx_tmp.translate((-doodleTransform[0]) * (globalScale * doodleTransform[2]), (-doodleTransform[1]) * (globalScale * doodleTransform[3])); - - var adjustedDoodlePt = centeredAndScaledDoodlePoint(_points[0]); - - previewCtx_tmp.beginPath(); - previewCtx_tmp.moveTo(adjustedDoodlePt.x, adjustedDoodlePt.y); - for(var j = 1; j < _points.length; j++) { - adjustedDoodlePt = centeredAndScaledDoodlePoint(_points[j]) - previewCtx_tmp.lineTo(adjustedDoodlePt.x, adjustedDoodlePt.y); - } - previewCtx_tmp.stroke(); - previewCtx_tmp.closePath(); - previewCtx_tmp.restore(); - //*/ - - // var saved_rect = previewCtx_tmp.getImageData(0, 0, layerCX*2, layerCY*2); - var saved_rect_todataurl = preview_tmp.toDataURL(); - doodleImageCapture = new Image(); - doodleImageCapture.onload = function() { - - previewCtx.clearRect(0, 0, preview.width, preview.height); - previewCtx.lineWidth = strokeWidth; - previewCtx.strokeStyle = '#f00'; //"rgba(255,255,0,0)"; - - var y = 0; - var r = 0; - - for(var i=0;i"+c+"
";d.after(e)},this.clearValidationErrors=function(){var b=a.form.find(".error");b.each(function(a,b){$(b).removeClass("error")})},this.readForm=function(){var b={},c=a.form.find("select");c.each(function(a,c){var c=$(c);"network.client.network"!=c.attr("name")&&(b[c.attr("name")]=c.val())});var d=a.form.find("input");d.each(function(a,c){var c=$(c);switch(c.attr("type")){case"text":case"number":b[c.attr("name")]=c.val();break;case"checkbox":b[c.attr("name")]=c.prop("checked")}});var e=a.form.find("textarea");return e.each(function(a,c){var c=$(c);b[c.attr("name")]=c.val()}),b},this.showAPSettings=function(){a.apFieldSet.show(),a.clientFieldSet.hide()},this.showClientSettings=function(){a.clientFieldSet.show(),a.apFieldSet.hide()},this.refreshNetworks=function(){console.log("Settings:refreshNetworks"),communicateWithWifibox&&$.ajax({url:a.wifiboxURL+"/network/scan",type:"GET",dataType:"json",timeout:a.timeoutTime,success:function(b){if(console.log("Settings:refreshNetworks response: ",b),"error"==b.status);else{var c=b.data.networks;a.networks={};var d=!1,e=a.form.find("#network");e.empty(),e.append($("").val(SettingsWindow.NOT_CONNECTED).html("not connected")),$.each(c,function(b,c){c.ssid==a.currentNetwork&&(d=!0),e.append($("").val(c.ssid).html(c.ssid)),a.networks[c.ssid]=c}),d&&(e.val(a.currentNetwork),a.selectNetwork(a.currentNetwork))}}}).fail(function(){})},this.retrieveNetworkStatus=function(b){communicateWithWifibox&&$.ajax({url:a.wifiboxURL+"/network/status",type:"GET",dataType:"json",timeout:a.timeoutTime,success:function(c){if(console.log("Settings:retrieveNetworkStatus response: ",c),"error"==c.status);else{var d=c.data;switch("string"==typeof d.status&&(d.status=parseInt(d.status)),d.status){case SettingsWindow.API_NOT_CONNECTED:a.apFieldSet.show(),a.clientFieldSet.show(),a.networkMode=SettingsWindow.NETWORK_MODE_NEITHER;break;case SettingsWindow.API_CONNECTING_FAILED:case SettingsWindow.API_CONNECTING:case SettingsWindow.API_CONNECTED:if(a.form.find("#client").prop("checked",!0),a.apFieldSet.hide(),a.clientFieldSet.show(),d.status==SettingsWindow.API_CONNECTED){var e=a.form.find("#network");e.val(d.ssid),a.currentNetwork=d.ssid,a.currentLocalIP=d.localip,a.selectNetwork(d.ssid)}else a.currentLocalIP="";a.networkMode=SettingsWindow.NETWORK_MODE_CLIENT;break;case SettingsWindow.API_CREATING:case SettingsWindow.API_CREATED:a.form.find("#ap").prop("checked",!0),a.apFieldSet.show(),a.clientFieldSet.hide(),a.currentNetwork=void 0,a.selectNetwork(SettingsWindow.NOT_CONNECTED);var e=a.form.find("#network");e.val(SettingsWindow.NOT_CONNECTED),d.ssid&&d.status==SettingsWindow.API_CREATED&&(a.currentAP=d.ssid),a.networkMode=SettingsWindow.NETWORK_MODE_ACCESS_POINT}switch(a.updatePanel.setNetworkMode(a.networkMode),d.status){case SettingsWindow.API_CONNECTING_FAILED:a.setClientModeState(SettingsWindow.CONNECTING_FAILED,d.statusMessage),a.setAPModeState(SettingsWindow.NO_AP,"");break;case SettingsWindow.API_NOT_CONNECTED:a.setClientModeState(SettingsWindow.NOT_CONNECTED,""),a.setAPModeState(SettingsWindow.NO_AP,"");break;case SettingsWindow.API_CONNECTING:a.setClientModeState(SettingsWindow.CONNECTING,""),a.setAPModeState(SettingsWindow.NO_AP,"");break;case SettingsWindow.API_CONNECTED:a.setClientModeState(SettingsWindow.CONNECTED,""),a.setAPModeState(SettingsWindow.NO_AP,"");break;case SettingsWindow.API_CREATING:a.setClientModeState(SettingsWindow.NOT_CONNECTED,""),a.setAPModeState(SettingsWindow.CREATING_AP,"");break;case SettingsWindow.API_CREATED:a.setClientModeState(SettingsWindow.NOT_CONNECTED,""),a.setAPModeState(SettingsWindow.AP,"")}if(b)switch(d.status){case SettingsWindow.API_CONNECTING:case SettingsWindow.API_CREATING:clearTimeout(a.retryRetrieveNetworkStatusDelay),a.retryRetrieveNetworkStatusDelay=setTimeout(function(){a.retrieveNetworkStatus(b)},a.retryRetrieveNetworkStatusDelayTime)}}}}).fail(function(){console.log("Settings:retrieveNetworkStatus: failed"),clearTimeout(a.retryRetrieveNetworkStatusDelay),a.retryRetrieveNetworkStatusDelay=setTimeout(function(){a.retrieveNetworkStatus(b)},a.retryDelay)})},this.networkSelectorChanged=function(){var b=$(this).find("option:selected");a.selectNetwork(b.val())},this.selectNetwork=function(a){if(console.log("select network: ",a),""!=a)if(console.log(" checked"),this.selectedNetwork=a,void 0==this.networks||a==SettingsWindow.NOT_CONNECTED)this.hideWiFiPassword();else{var b=this.networks[a];"none"==b.encryption?this.hideWiFiPassword():this.showWiFiPassword(),this.form.find("#password").val("")}},this.showWiFiPassword=function(){this.form.find("#passwordLabel").show(),this.form.find("#password").show()},this.hideWiFiPassword=function(){this.form.find("#passwordLabel").hide(),this.form.find("#password").hide()},this.setClientModeState=function(b,c){var d=this.form.find("#clientModeState"),e=a.form.find("#connectToNetwork");switch(b){case SettingsWindow.NOT_CONNECTED:e.removeAttr("disabled"),d.html("Not connected");break;case SettingsWindow.CONNECTED:e.removeAttr("disabled");var f="Connected to: "+this.currentNetwork+".";if(void 0!=this.currentLocalIP&&""!=this.currentLocalIP){var g=""+this.currentLocalIP+"";f+=" (IP: "+g+")"}d.html(f);break;case SettingsWindow.CONNECTING:e.attr("disabled",!0),d.html("Connecting... Reconnect by connecting your device to "+this.selectedNetwork+" and going to connect.doodle3d.com");break;case SettingsWindow.CONNECTING_FAILED:e.removeAttr("disabled"),d.html(c)}this.clientModeState=b},this.setAPModeState=function(a){var b=this.form.find("#apModeState"),c=this.form.find("#createAP");switch(a){case SettingsWindow.NO_AP:c.removeAttr("disabled"),b.html("Not currently a access point");break;case SettingsWindow.AP:c.removeAttr("disabled"),b.html("Is access point: "+this.currentAP+"");break;case SettingsWindow.CREATING_AP:c.attr("disabled",!0),b.html("Creating access point... Reconnect by connecting your device to "+settings.substituted_ssid+" and going to draw.doodle3d.com")}this.apModeState=a},this.connectToNetwork=function(){if(console.log("connectToNetwork"),void 0!=a.selectedNetwork){var b={ssid:a.selectedNetwork,phrase:a.form.find("#password").val(),recreate:!0};console.log(" postData: ",b),communicateWithWifibox&&a.saveSettings(a.readForm(),function(){$.ajax({url:a.wifiboxCGIBinURL+"/network/associate",type:"POST",data:b,dataType:"json",timeout:a.timeoutTime,success:function(a){console.log("Settings:connectToNetwork response: ",a)}}).fail(function(){console.log("Settings:connectToNetwork: timeout (normal behavior)")})}),a.setClientModeState(SettingsWindow.CONNECTING,""),clearTimeout(a.retrieveNetworkStatusDelay),a.retrieveNetworkStatusDelay=setTimeout(function(){a.retrieveNetworkStatus(!0)},a.retrieveNetworkStatusDelayTime)}},this.createAP=function(){console.log("createAP"),communicateWithWifibox&&a.saveSettings(a.readForm(),function(){a.setAPModeState(SettingsWindow.CREATING_AP),$.ajax({url:a.wifiboxCGIBinURL+"/network/openap",type:"POST",dataType:"json",timeout:a.timeoutTime,success:function(a){console.log("Settings:createAP response: ",a)}}).fail(function(){console.log("Settings:createAP: timeout (normal behavior)")}),a.setAPModeState(SettingsWindow.CREATING_AP,""),clearTimeout(a.retrieveNetworkStatusDelay),a.retrieveNetworkStatusDelay=setTimeout(function(){a.retrieveNetworkStatus(!0)},a.retrieveNetworkStatusDelayTime)})}}function UpdatePanel(){this.wifiboxURL,this.element,this.statusCheckInterval=1e3,this.statusCheckDelayer,this.installedDelay=6e4,this.installedDelayer,this.retryDelay=1e3,this.retryDelayer,this.canUpdate=!1,this.currentVersion="",this.newestVersion,this.progress,this.imageSize,UpdatePanel.NONE=1,UpdatePanel.DOWNLOADING=2,UpdatePanel.DOWNLOAD_FAILED=3,UpdatePanel.IMAGE_READY=4,UpdatePanel.INSTALLING=5,UpdatePanel.INSTALLED=6,UpdatePanel.INSTALL_FAILED=7,this.state,this.stateText="",this.networkMode;var a=this;this.init=function(a,b){this.wifiboxURL=a,this.element=b,this.btnUpdate=this.element.find("#update"),this.statusDisplay=this.element.find("#updateState"),this.infoDisplay=this.element.find("#updateInfo"),this.btnUpdate.click(this.update),this.checkStatus(!1)},this.update=function(){console.log("UpdatePanel:update"),a.downloadUpdate()},this.downloadUpdate=function(){console.log("UpdatePanel:downloadUpdate"),$.ajax({url:a.wifiboxURL+"/update/download",type:"POST",dataType:"json",success:function(a){console.log("UpdatePanel:downloadUpdate response: ",a)}}).fail(function(){console.log("UpdatePanel:downloadUpdate: failed")}),a.setState(UpdatePanel.DOWNLOADING),a.startCheckingStatus()},this.installUpdate=function(){console.log("UpdatePanel:installUpdate"),a.stopCheckingStatus(),$.ajax({url:a.wifiboxURL+"/update/install",type:"POST",dataType:"json",success:function(a){console.log("UpdatePanel:installUpdate response: ",a)}}).fail(function(){console.log("UpdatePanel:installUpdate: no respons (there shouldn't be)")}),a.setState(UpdatePanel.INSTALLING),clearTimeout(a.installedDelayer),a.installedDelayer=setTimeout(function(){a.setState(UpdatePanel.INSTALLED)},a.installedDelay)},this.startCheckingStatus=function(){clearTimeout(a.statusCheckDelayer),clearTimeout(a.retryDelayer),a.statusCheckDelayer=setTimeout(function(){a.checkStatus(!0)},a.statusCheckInterval)},this.stopCheckingStatus=function(){clearTimeout(a.statusCheckDelayer),clearTimeout(a.retryDelayer)},this.checkStatus=function(b){communicateWithWifibox&&$.ajax({url:a.wifiboxURL+"/update/status",type:"GET",dataType:"json",success:function(c){if(console.log("UpdatePanel:checkStatus response: ",c),b)switch(a.state){case UpdatePanel.DOWNLOADING:case UpdatePanel.INSTALLING:clearTimeout(a.statusCheckDelayer),a.statusCheckDelayer=setTimeout(function(){a.checkStatus(b)},a.statusCheckInterval)}if("error"!=c.status){var d=c.data;a.handleStatusData(d)}}}).fail(function(){b&&(clearTimeout(a.retryDelayer),a.retryDelayer=setTimeout(function(){a.checkStatus(b)},a.retryDelay))})},this.handleStatusData=function(b){switch(a.canUpdate=b.can_update,(a.currentVersion!=b.current_version||a.newestVersion!=b.newest_version)&&(a.currentVersion=b.current_version,a.newestVersion=b.newest_version,a.updateInfoDisplay()),a.stateText=b.state_text,a.progress=b.progress,a.imageSize=b.image_size,a.setState(b.state_code),this.state){case UpdatePanel.IMAGE_READY:a.installUpdate()}},this.setState=function(b){if(this.state!=b){if(console.log("UpdatePanel:setState: ",this.state," > ",b,"(",this.stateText,") (networkMode: ",a.networkMode,") (newestVersion: ",a.newestVersion,")"),this.state=b,void 0!=a.newestVersion)switch(this.state){case UpdatePanel.NONE:case UpdatePanel.DOWNLOAD_FAILED:case UpdatePanel.INSTALL_FAILED:a.canUpdate?a.btnUpdate.removeAttr("disabled"):a.btnUpdate.attr("disabled",!0);break;default:a.btnUpdate.attr("disabled",!0)}else a.btnUpdate.attr("disabled",!0);this.updateStatusDisplay()}},this.updateStatusDisplay=function(){var b="";if(void 0!=a.newestVersion)switch(this.state){case UpdatePanel.NONE:b=a.canUpdate?"Update(s) available.":"You're up to date.";break;case UpdatePanel.DOWNLOADING:b="Downloading update...";break;case UpdatePanel.DOWNLOAD_FAILED:b="Downloading update failed.";break;case UpdatePanel.IMAGE_READY:b="Update downloaded.";break;case UpdatePanel.INSTALLING:b="Installing update... (will take a minute)";break;case UpdatePanel.INSTALLED:b="Update complete, please refresh Page.";break;case UpdatePanel.INSTALL_FAILED:b="Installing update failed."}else b=a.networkMode==SettingsWindow.NETWORK_MODE_ACCESS_POINT?"Can't access internet in access point mode.":"Can't access internet.";this.statusDisplay.html(b)},this.updateInfoDisplay=function(){var b="Current version: "+a.currentVersion+". ";a.canUpdate&&(b+="Latest version: "+a.newestVersion+"."),a.infoDisplay.text(b)},this.setNetworkMode=function(b){a.networkMode=b}}function setTemperature(a){void 0!=a&&a()}function setTemperature(a){void 0!=a&&a()}function initVerticalShapes(){VERTICALSHAPE=verticalShapes.NONE,$(".verticalShapes, .straight").on("mouseup touchend",function(a){a.preventDefault(),console.log("diverging"),VERTICALSHAPE=verticalShapes.NONE,redrawRenderedPreview()}),$(".verticalShapes, .diverging").on("mouseup touchend",function(a){a.preventDefault(),console.log("diverging"),VERTICALSHAPE=verticalShapes.DIVERGING,redrawRenderedPreview()}),$(".verticalShapes, .converging").on("mouseup touchend",function(a){a.preventDefault(),console.log("converging"),VERTICALSHAPE=verticalShapes.CONVERGING,redrawRenderedPreview()}),$(".verticalShapes, .sinus").on("mouseup touchend",function(a){a.preventDefault(),console.log("sinus"),VERTICALSHAPE=verticalShapes.SINUS,redrawRenderedPreview()})}function resetVerticalShapes(){VERTICALSHAPE=verticalShapes.NONE}function initButtonBehavior(){function a(a){a.preventDefault(),btnOopsInterval=setInterval(function(){oopsUndo()},20)}function b(a){a.preventDefault(),clearInterval(btnOopsInterval)}function c(a){a.preventDefault(),previewUp(!0),clearInterval(btnMoveUpInterval),btnMoveUpInterval=setInterval(function(){previewUp(!0)},1e3/30)}function d(a){a.preventDefault(),console.log("btnMoveUp mouse up"),clearInterval(btnMoveUpInterval),previewUp()}function e(a){a.preventDefault(),previewDown(!0),clearInterval(btnMoveDownInterval),btnMoveDownInterval=setInterval(function(){previewDown(!0)},1e3/30)}function f(a){a.preventDefault(),console.log("btnMoveDown mouse up"),clearInterval(btnMoveDownInterval),previewDown()}function g(a){a.preventDefault(),previewTwistLeft(!0),clearInterval(btnTwistLeftInterval),btnTwistLeftInterval=setInterval(function(){previewTwistLeft(!0)},1e3/30)}function h(a){a.preventDefault(),clearInterval(btnTwistLeftInterval),previewTwistLeft()}function i(a){a.preventDefault(),previewTwistRight(!0),clearInterval(btnTwistRightInterval),btnTwistRightInterval=setInterval(function(){previewTwistRight(!0)},1e3/30)}function j(a){a.preventDefault(),clearInterval(btnTwistRightInterval),previewTwistRight()}console.log("f:initButtonBehavior"),btnOops=$(".btnOops"),btnMoveUp=$("#btnMoveUp"),btnMoveDown=$("#btnMoveDown"),btnTwistLeft=$("#btnTwistLeft"),btnTwistRight=$("#btnTwistRight"),btnInfo=$(".btnInfo"),btnSettings=$(".btnSettings"),btnNew=$(".btnNew"),btnPrint=$(".btnPrint"),btnStop=$(".btnStop"),btnPrevious=$(".btnPrevious"),btnNext=$(".btnNext"),btnNew.on("touchstart mousedown",clearDoodle),btnPrint.on("touchstart mousedown",print),$("#btnPrevious").css("opacity","0.3"),btnNext.css("opacity","0.3"),$("#btnSave").css("opacity","0.3"),btnInfo.css("opacity","0.3"),btnOops.on("touchstart",function(b){a(b)}),btnOops.on("touchend",function(a){b(a)}),btnOops.mousedown(function(b){a(b)}),btnOops.mouseup(function(a){b(a)}),btnMoveUp.mousedown(function(a){c(a)}),btnMoveUp.mouseup(function(a){d(a)}),btnMoveUp.on("touchstart",function(a){c(a)}),btnMoveUp.on("touchend",function(a){d(a)}),btnMoveDown.mousedown(function(a){e(a)}),btnMoveDown.mouseup(function(a){f(a)}),btnMoveDown.on("touchstart",function(a){e(a)}),btnMoveDown.on("touchend",function(a){f(a)}),btnTwistLeft.mousedown(function(a){g(a)}),btnTwistLeft.mouseup(function(a){h(a)}),btnTwistLeft.on("touchstart",function(a){g(a)}),btnTwistLeft.on("touchend",function(a){h(a)}),btnTwistRight.mousedown(function(a){i(a)}),btnTwistRight.mouseup(function(a){j(a)}),btnTwistRight.on("touchstart",function(a){i(a)}),btnTwistRight.on("touchend",function(a){j(a)}),btnSettings.bind("touchstart mousedown",function(){settingsWindow.showSettings()}),btnInfo.mouseup(function(a){a.preventDefault(),console.log("btnInfo mouse up")})}function stopPrint(){console.log("f:stopPrint() >> sendPrintCommands = "+sendPrintCommands),sendPrintCommands&&printer.stop(),printer.overruleState(Printer.STOPPING_STATE)}function prevDoodle(){console.log("f:prevDoodle()"),console.log("f:prevDoodle()")}function nextDoodle(){console.log("f:nextDoodle()")}function print(){console.log("f:print() >> sendPrintCommands = "+sendPrintCommands),_points.length>2?(printer.overruleState(Printer.BUFFERING_STATE),btnStop.css("display","none"),clearTimeout(gcodeGenerateDelayer),gcodeGenerateDelayer=setTimeout(function(){var a=generate_gcode();sendPrintCommands?a.length>0?printer.print(a):(printer.overruleState(Printer.IDLE_STATE),printer.startStatusCheckInterval()):console.log("sendPrintCommands is false: not sending print command to 3dprinter"),debugMode&&($("#textdump").text(""),$("#textdump").text(a.join("\n")))},gcodeGenerateDelay)):console.log("f:print >> not enough points!")}function clearMainView(){ctx.save(),ctx.clearRect(0,0,canvas.width,canvas.height),ctx.restore()}function resetPreview(){previewCtx.save(),previewCtx.clearRect(0,0,canvas.width,canvas.height),previewCtx.restore(),numLayers=previewDefaults.numLayers,rStep=previewDefaults.rotation}function oopsUndo(){_points.pop(),redrawDoodle(),redrawPreview()}function previewUp(a){maxNumLayers>numLayers&&numLayers++,redrawRenderedPreview(a)}function previewDown(a){numLayers>minNumLayers&&numLayers--,redrawRenderedPreview(a)}function previewTwistLeft(a){void 0==a&&(a=!1),rStep>-previewRotationLimit&&(rStep-=twistIncrement),redrawRenderedPreview(a)}function previewTwistRight(a){previewRotationLimit>rStep&&(rStep+=twistIncrement),redrawRenderedPreview(a)}function update(){setState(printer.state,printer.hasControl),thermometer.update(printer.temperature,printer.targetTemperature),progressbar.update(printer.currentLine,printer.totalLines)}function setState(a,b){if(a!=state||b!=hasControl){prevState=state,console.log("setState: ",prevState," > ",a," ( ",b,")"),setDebugText("State: "+a);var c=a==Printer.IDLE_STATE&&b;c?(btnPrint.removeClass("disabled"),btnPrint.unbind("touchstart mousedown"),btnPrint.bind("touchstart mousedown",print)):(btnPrint.addClass("disabled"),btnPrint.unbind("touchstart mousedown"));var d=(a==Printer.PRINTING_STATE||a==Printer.BUFFERING_STATE)&&b;switch(d?(btnStop.removeClass("disabled"),btnStop.unbind("touchstart mousedown"),btnStop.bind("touchstart mousedown",stopPrint)):(btnStop.addClass("disabled"),btnStop.unbind("touchstart mousedown")),a){case Printer.IDLE_STATE:case Printer.BUFFERING_STATE:case Printer.PRINTING_STATE:case Printer.STOPPING_STATE:thermometer.show();break;default:thermometer.hide()}switch(a){case Printer.PRINTING_STATE:progressbar.show();break;default:progressbar.hide()}a==Printer.WIFIBOX_DISCONNECTED_STATE?message.set("Lost connection to WiFi box",Message.ERROR):prevState==Printer.WIFIBOX_DISCONNECTED_STATE?message.set("Connected to WiFi box",Message.INFO,!0):a==Printer.DISCONNECTED_STATE?message.set("Printer disconnected",Message.WARNING,!0):(prevState==Printer.DISCONNECTED_STATE&&a==Printer.IDLE_STATE||prevState==Printer.UNKNOWN_STATE&&a==Printer.IDLE_STATE)&&message.set("Printer connected",Message.INFO,!0),state=a,hasControl=b}}function initDoodleDrawing(){console.log("f:initDoodleDrawing()"),$canvas=$("#mycanvas"),canvas=$canvas[0],ctx=canvas.getContext("2d"),canvasWidth=canvas.width,canvasHeight=canvas.height,canvas.addEventListener?(canvas.addEventListener("mousedown",onCanvasMouseDown,!1),canvas.addEventListener("mousemove",onCanvasMouseMove,!1),canvas.addEventListener("mouseup",onCanvasMouseUp,!1),canvas.addEventListener("touchstart",onCanvasTouchDown,!1),canvas.addEventListener("touchmove",onCanvasTouchMove,!1),canvas.addEventListener("touchend",onCanvasTouchEnd,!1),debugMode||document.body.addEventListener("touchmove",prevent,!1)):(canvas.attachEvent("onmousedown",onCanvasMouseDown),canvas.attachEvent("onmousemove",onCanvasMouseMove),canvas.attachEvent("onmouseup",onCanvasMouseUp),canvas.attachEvent("ontouchstart",onCanvasTouchDown),canvas.attachEvent("ontouchmove",onCanvasTouchMove),canvas.attachEvent("ontouchend",onCanvasTouchEnd),document.body.attachEvent("ontouchmove",prevent)),drawCanvas=$("#mycanvasContainer"),console.log("drawCanvasTopLeftCoords: "+drawCanvasTopLeftCoords),drawCanvasTopLeftCoords[0]=drawCanvas.offset().left,drawCanvasTopLeftCoords[1]=drawCanvas.offset().top,console.log("f:initDoodleDrawing() >> canvasWidth: "+canvasWidth),console.log("f:initDoodleDrawing() >> canvasHeight: "+canvasHeight)}function draw(a,b,c){if(0==prevX&&0==prevY&&(prevX=a,prevY=b),ctx.beginPath(),ctx.moveTo(prevX,prevY),ctx.lineTo(a,b),void 0!=c)ctx.lineWidth=c;else{if(drawVariableLineWeight){var d=Math.sqrt(Math.pow(prevX-a,2)+Math.pow(prevY-b,2));lineweight+=10>d?.25:20>d?.5:30>d?.75:50>d?1:80>d?1.5:120>d?2.25:170>d?3.5:2,lineweight=Math.min(lineweight,30),lineweight*=.9,lineweight=Math.max(lineweight,1)}else lineweight=2;ctx.lineWidth=lineweight}ctx.lineCap="round",ctx.stroke(),prevX=a,prevY=b}function clearDoodle(){console.log("f:clearDoodle"),_points=[],prevX=0,prevY=0,updatePrevX=-1,updatePrevY=-1,doodleBounds=[-1,-1,-1,-1],doodleTransform=[0,0,1,1],dragging=!1,clearMainView(),resetPreview(),resetVerticalShapes()}function redrawDoodle(){console.log("f:redrawDoodle()"),clearMainView(),prevX=0,prevY=0;for(var a=0;a<_points.length;a++)1==_points[a][2]?draw(_points[a][0],_points[a][1],.5):draw(_points[a][0],_points[a][1])}function adjustBounds(a,b){var c=!1;return console.log("f:adjustBounds("+a+","+b+")"),-1==doodleBounds[0]?(doodleBounds[0]=a,doodleBounds[1]=b,doodleBounds[2]=a,doodleBounds[3]=b,void 0):(a