events: {
'config-changed': function () {this.modified = true;},
- 'send': function (msg) {if (this.status == 'connected') this.sock.send(msg)}
+
+
+ send: function (msg) {
+ if (this.status == 'connected') this.sock.send(msg)
+ },
+
+
+ connected: function () {this.update()}
},
ready: function () {
+ $(window).on('hashchange', this.parse_hash);
this.connect();
+ },
- $.get('/config-template.json').success(function (data, status, xhr) {
- this.template = data;
- api.get('load').done(function (data) {
- this.config = data;
+ methods: {
+ update: function () {
+ $.get('/config-template.json').success(function (data, status, xhr) {
+ this.template = data;
- this.parse_hash();
- $(window).on('hashchange', this.parse_hash);
- }.bind(this))
- }.bind(this))
- },
+ api.get('load').done(function (data) {
+ this.config = data;
+
+ this.parse_hash();
+ }.bind(this))
+ }.bind(this))
+ },
- methods: {
connect: function () {
this.sock = new Sock('//' + window.location.host + '/ws');
this.sock.onopen = function (e) {
this.status = 'connected';
+ this.$emit(this.status);
this.$broadcast(this.status);
}.bind(this);