Reload on reconnect
authorJoseph Coffland <joseph@cauldrondevelopment.com>
Thu, 23 Jun 2016 20:30:02 +0000 (13:30 -0700)
committerJoseph Coffland <joseph@cauldrondevelopment.com>
Thu, 23 Jun 2016 20:30:02 +0000 (13:30 -0700)
src/js/app.js

index fd7ea04093696456bcab1e3f61539787b17b7150..0e998bddbf302db6baaf2b3b39542747be320d66 100644 (file)
@@ -34,27 +34,37 @@ module.exports = new Vue({
 
   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');
 
@@ -64,6 +74,7 @@ module.exports = new Vue({
 
       this.sock.onopen = function (e) {
         this.status = 'connected';
+        this.$emit(this.status);
         this.$broadcast(this.status);
       }.bind(this);