body(v-cloak)
+ #overlay(v-if="status != 'connected'")
+ span {{status}}
#layout
a#menuLink.menu-link(href="#menu"): span
script#control-view-template(type="text/x-template")
- .status(:class="status") {{status}}
-
#control
.jog
axis-control(axes="XY", :colors="['red', 'green']",
'use strict'
var api = require('./api');
+var Sock = require('./sock');
module.exports = new Vue({
data: function () {
return {
+ status: 'connecting',
currentView: 'loading',
index: -1,
modified: false,
events: {
- 'config-changed': function () {this.modified = true;}
+ 'config-changed': function () {this.modified = true;},
+ 'send': function (msg) {if (this.status == 'connected') this.sock.send(msg)}
},
ready: function () {
+ this.connect();
+
$.get('/config-template.json').success(function (data, status, xhr) {
this.template = data;
methods: {
+ connect: function () {
+ this.sock = new Sock('//' + window.location.host + '/ws');
+
+ this.sock.onmessage = function (e) {
+ this.$broadcast('message', e.data);
+ }.bind(this);
+
+ this.sock.onopen = function (e) {
+ this.status = 'connected';
+ this.$broadcast(this.status);
+ }.bind(this);
+
+ this.sock.onclose = function (e) {
+ this.status = 'disconnected';
+ this.$broadcast(this.status);
+ }.bind(this);
+ },
+
+
parse_hash: function () {
var hash = location.hash.substr(1);
'use strict'
var api = require('./api');
-var Sock = require('./sock');
function is_array(x) {
data: function () {
return {
- status: 'connecting',
mdi: '',
file: '',
last_file: '',
zero: function (axis) {
console.debug('zero(' + axis + ')');
this.send('$zero ' + axis);
+ },
+
+
+ message: function (data) {
+ if (typeof data == 'object')
+ for (var key in data)
+ this.$set('state.' + key, data[key]);
}
},
ready: function () {
- this.connect();
this.update();
},
methods: {
- connect: function () {
- this.sock = new Sock('//' + window.location.host + '/ws');
-
- this.sock.onmessage = function (e) {
- var data = e.data;
-
- if (typeof data == 'object')
- for (var key in data)
- this.$set('state.' + key, data[key]);
- }.bind(this);
-
- this.sock.onopen = function (e) {
- this.status = 'connected';
- }.bind(this);
-
- this.sock.onclose = function (e) {
- this.status = 'disconnected';
- }.bind(this);
- },
-
-
send: function (msg) {
- if (this.status == 'connected') this.sock.send(msg);
+ this.$dispatch('send', msg);
},
&.connected
color green
+#overlay
+ position fixed
+ top 0
+ left 0
+ width 100%
+ height 100%
+ background-color rgba(0, 0, 0, 0.7)
+ z-index 2000
+ color white
+ font-weight bold
+ font-size 24pt
+ text-align center
+ text-transform uppercase
+
+ span
+ position relative
+ top 50%
#menu
.save