SankeySheets/scripts/Client.js
2016-06-01 11:26:54 +01:00

55 lines
1 KiB
JavaScript

/**
* client stuff that's specific to the type server
*/
var Client = (function(client) {
client.start = function () {
// in case we're spinning
resetCursor();
// this'll call sync when there's any data change
Process.control.watching.watcher.watch(function (current , pack, watcher) {
Process.syncResult (current);
});
};
client.insertImage = function (png) {
spinCursor();
disableButtons (true);
Provoke.run ('Image', 'place', png)
.then (
function(result) {
resetCursor();
disableButtons(false);
},
function (error) {
resetCursor();
App.showNotification ("Failed to insert image", error);
disableButtons (false);
});
function disableButtons (state) {
Process.control.buttons.insert.disabled = state;
}
};
function resetCursor() {
DomUtils.hide ('spinner',true);
}
function spinCursor() {
DomUtils.hide ('spinner',false);
}
return client;
})(Client || {});