A web-based drawing app
git clone git://soophie.de/outline
200
});201
}202
this.event.action(this.modal.get('error').action.reconnect, 'click', function(event) {203
that.modal.close();203
that.modal.load();204
that.socket.reconnect();205
});206
},
40
},41
open: function(name) {42
if(this.app.state.modal[name]) {43
this.app.node.spinner.classList.add('hidden');44
for(let item of Object.values(this.app.state.modal)) {45
item.element.classList.add('hidden');46
}47
this.app.state.modal[name].element.classList.remove('hidden');48
this.app.node.wrapper.classList.remove('hidden');49
this.app.state.opened = true;
1
export default {2
socket: null,3
connected: false,4
timeout: false,5
interval: null,6
init: function(app) {7
this.app = app;8
},
14
});15
this.socket.on('connect', function() {16
that.connected = true;17
that.timeout = false;18
that.request();19
});20
this.socket.on('disconnect', function() {21
that.connected = false;22
that.timeout = true;23
that.app.modal.open('error');24
that.app.state.client = [];25
that.app.update();26
that._reconnectInterval();27
});28
this.socket.on('connect_error', function() {29
that.connected = false;30
that.timeout = true;31
that.app.modal.open('error');32
that.app.state.client = [];33
that.app.update();34
that._reconnectInterval();35
});36
this.socket.on('load', function(data) {37
let buffer = new Uint8Array(data);
73
that.app.update();74
});75
},76
_reconnectInterval: function() {77
let that = this;78
this.interval = setInterval(function() {79
if(!that.timeout) {80
clearInterval(this.interval);81
}82
else {83
that.reconnect();84
}85
}, 30 * 1000);86
},87
reconnect: function() {88
this.socket.open();89
},