2018-09-17 19:43:24 +02:00
|
|
|
// Generated by CoffeeScript 1.9.3
|
2018-08-28 14:49:03 +02:00
|
|
|
(function() {
|
2018-09-17 19:43:24 +02:00
|
|
|
var APIManager, BaseObject, MarkOn, WVNC, require,
|
2018-08-28 14:49:03 +02:00
|
|
|
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
|
|
|
hasProp = {}.hasOwnProperty;
|
|
|
|
|
|
|
|
window.classes = {};
|
|
|
|
|
|
|
|
window.libraries = {};
|
|
|
|
|
|
|
|
window.myuri = "/";
|
|
|
|
|
|
|
|
window.mobilecheck = function() {
|
|
|
|
if (navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/BlackBerry/i) || navigator.userAgent.match(/Windows Phone/i)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
|
|
|
window.makeclass = function(n, o) {
|
|
|
|
return window.classes[n] = o;
|
|
|
|
};
|
|
|
|
|
2018-09-17 19:43:24 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
window.require = (lib) ->
|
|
|
|
return new Promise (r, e) ->
|
|
|
|
return r() if window.libraries[lib]
|
|
|
|
$.getScript window.myuri + lib
|
|
|
|
.done (d) ->
|
|
|
|
window.libraries[lib] = true
|
|
|
|
r()
|
|
|
|
.fail (m, s) ->
|
|
|
|
e(m, s)
|
|
|
|
*/
|
|
|
|
|
|
|
|
require = function(lib) {
|
2018-08-28 14:49:03 +02:00
|
|
|
return new Promise(function(r, e) {
|
|
|
|
if (window.libraries[lib]) {
|
|
|
|
return r();
|
|
|
|
}
|
|
|
|
return $.getScript(window.myuri + lib).done(function(d) {
|
|
|
|
window.libraries[lib] = true;
|
|
|
|
return r();
|
|
|
|
}).fail(function(m, s) {
|
|
|
|
return e(m, s);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
BaseObject = (function() {
|
|
|
|
function BaseObject(name) {
|
|
|
|
this.name = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
BaseObject.prototype.ready = function() {
|
|
|
|
var me;
|
|
|
|
me = this;
|
|
|
|
return new Promise(function(r, e) {
|
|
|
|
return me.resolveDep().then(function() {
|
|
|
|
return r();
|
|
|
|
})["catch"](function(m, s) {
|
|
|
|
return e(m, s);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
BaseObject.prototype.resolveDep = function() {
|
|
|
|
var me;
|
|
|
|
me = this;
|
|
|
|
return new Promise(function(r, e) {
|
|
|
|
var dep, fn;
|
|
|
|
dep = window.classes[me.name].dependencies;
|
|
|
|
if (!dep) {
|
|
|
|
r();
|
|
|
|
}
|
|
|
|
fn = function(l, i) {
|
|
|
|
if (i >= dep.length) {
|
|
|
|
return r();
|
|
|
|
}
|
|
|
|
return require(l[i]).then(function() {
|
|
|
|
return fn(l, i + 1);
|
|
|
|
})["catch"](function(m, s) {
|
|
|
|
return e(m, s);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
return fn(dep, 0);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
return BaseObject;
|
|
|
|
|
|
|
|
})();
|
|
|
|
|
|
|
|
makeclass("BaseObject", BaseObject);
|
|
|
|
|
|
|
|
APIManager = (function(superClass) {
|
|
|
|
extend(APIManager, superClass);
|
|
|
|
|
2018-09-17 19:43:24 +02:00
|
|
|
function APIManager(args) {
|
|
|
|
this.args = args;
|
2018-08-28 14:49:03 +02:00
|
|
|
APIManager.__super__.constructor.call(this, "APIManager");
|
|
|
|
}
|
|
|
|
|
2018-09-17 19:43:24 +02:00
|
|
|
APIManager.prototype.init = function() {
|
|
|
|
var cname, me;
|
|
|
|
me = this;
|
|
|
|
if (!(this.args && this.args.length > 0)) {
|
|
|
|
return console.error("No class found");
|
|
|
|
}
|
|
|
|
cname = (this.args.splice(0, 1))[0].trim();
|
2018-08-28 14:49:03 +02:00
|
|
|
return this.ready().then(function() {
|
|
|
|
if (mobilecheck()) {
|
|
|
|
mobileConsole.init();
|
|
|
|
}
|
|
|
|
if (!cname || cname === "") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!window.classes[cname]) {
|
|
|
|
return console.error("Cannot find class ", cname);
|
|
|
|
}
|
2018-09-17 19:43:24 +02:00
|
|
|
return (new window.classes[cname](me.args)).init();
|
2018-08-28 14:49:03 +02:00
|
|
|
})["catch"](function(m, s) {
|
|
|
|
return console.error(m, s);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
return APIManager;
|
|
|
|
|
|
|
|
})(window.classes.BaseObject);
|
|
|
|
|
|
|
|
APIManager.dependencies = ["/assets/scripts/mobile_console.js"];
|
|
|
|
|
|
|
|
makeclass("APIManager", APIManager);
|
|
|
|
|
|
|
|
MarkOn = (function(superClass) {
|
|
|
|
extend(MarkOn, superClass);
|
|
|
|
|
2018-08-28 15:07:46 +02:00
|
|
|
function MarkOn() {
|
2018-08-28 14:49:03 +02:00
|
|
|
MarkOn.__super__.constructor.call(this, "MarkOn");
|
|
|
|
}
|
|
|
|
|
|
|
|
MarkOn.prototype.init = function() {
|
|
|
|
var me;
|
|
|
|
me = this;
|
|
|
|
return this.ready().then(function() {
|
|
|
|
return me.editor = new SimpleMDE({
|
2018-08-28 15:07:46 +02:00
|
|
|
element: $("#editor")[0]
|
2018-08-28 14:49:03 +02:00
|
|
|
});
|
|
|
|
})["catch"](function(m, s) {
|
|
|
|
return console.error(m, s);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
return MarkOn;
|
|
|
|
|
|
|
|
})(window.classes.BaseObject);
|
|
|
|
|
|
|
|
MarkOn.dependencies = ["/rst/gscripts/mde/simplemde.min.js"];
|
|
|
|
|
|
|
|
makeclass("MarkOn", MarkOn);
|
|
|
|
|
2018-09-17 19:43:24 +02:00
|
|
|
WVNC = (function(superClass) {
|
|
|
|
extend(WVNC, superClass);
|
|
|
|
|
|
|
|
function WVNC(args) {
|
|
|
|
this.args = args;
|
|
|
|
WVNC.__super__.constructor.call(this, "WVNC");
|
|
|
|
this.socket = void 0;
|
|
|
|
this.uri = void 0;
|
|
|
|
if (this.args && this.args.length > 0) {
|
|
|
|
this.uri = this.args[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
WVNC.prototype.init = function() {
|
|
|
|
var me;
|
|
|
|
me = this;
|
|
|
|
return this.ready().then(function() {
|
|
|
|
return me.openSession();
|
|
|
|
})["catch"](function(m, s) {
|
|
|
|
return console.error(m, s);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
WVNC.prototype.openSession = function() {
|
|
|
|
var me;
|
|
|
|
me = this;
|
|
|
|
if (this.socket) {
|
|
|
|
this.socket.close();
|
|
|
|
}
|
|
|
|
if (!this.uri) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.socket = new WebSocket(this.uri);
|
|
|
|
this.socket.binaryType = "arraybuffer";
|
|
|
|
this.socket.onopen = function() {
|
|
|
|
console.log("socket opened");
|
|
|
|
return me.initConnection();
|
|
|
|
};
|
|
|
|
this.socket.onmessage = function(e) {
|
|
|
|
return me.consume(e);
|
|
|
|
};
|
|
|
|
return this.socket.onclose = function() {
|
|
|
|
me.socket = null;
|
|
|
|
return console.log("socket closed");
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
WVNC.prototype.initConnection = function() {
|
|
|
|
var vncserver;
|
|
|
|
vncserver = "localhost:5901";
|
|
|
|
return this.socket.send(this.buildCommand(0x01, vncserver));
|
|
|
|
};
|
|
|
|
|
|
|
|
WVNC.prototype.buildCommand = function(hex, o) {
|
|
|
|
var cmd, data;
|
|
|
|
data = void 0;
|
|
|
|
switch (typeof o) {
|
|
|
|
case 'string':
|
|
|
|
data = (new TextEncoder()).encode(o);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
data = o;
|
|
|
|
}
|
|
|
|
cmd = new Uint8Array(data.length + 3);
|
|
|
|
cmd[0] = hex;
|
|
|
|
cmd[2] = data.length >> 8;
|
|
|
|
cmd[1] = data.length & 0x0F;
|
|
|
|
cmd.set(data, 3);
|
|
|
|
console.log("the command is", cmd.buffer);
|
|
|
|
return cmd.buffer;
|
|
|
|
};
|
|
|
|
|
|
|
|
WVNC.prototype.consume = function(e) {
|
|
|
|
return console.log(e);
|
|
|
|
};
|
|
|
|
|
|
|
|
return WVNC;
|
|
|
|
|
|
|
|
})(window.classes.BaseObject);
|
|
|
|
|
|
|
|
WVNC.dependencies = [];
|
|
|
|
|
|
|
|
makeclass("WVNC", WVNC);
|
|
|
|
|
2018-08-28 14:49:03 +02:00
|
|
|
}).call(this);
|