2018-12-18 01:45:23 +00:00
|
|
|
//
|
2019-02-26 10:10:57 +00:00
|
|
|
// LJ.js v0.7.1
|
2018-12-18 01:45:23 +00:00
|
|
|
//
|
|
|
|
|
2019-03-24 16:24:52 +00:00
|
|
|
// LJ websocket address. Change here if LJ is not bind to 127.0.0.1
|
|
|
|
|
|
|
|
var LJ = 'ws://127.0.0.1:9001/'
|
|
|
|
|
2019-02-26 10:10:57 +00:00
|
|
|
//
|
|
|
|
// Central horizontal menu
|
|
|
|
//
|
2018-12-18 01:45:23 +00:00
|
|
|
|
2018-12-18 02:03:00 +00:00
|
|
|
function noMenu() {
|
2019-02-26 10:10:57 +00:00
|
|
|
// Set all central menu buttons with normal button style
|
2019-03-10 22:06:04 +00:00
|
|
|
var x = document.getElementById("align");
|
2019-02-26 10:10:57 +00:00
|
|
|
x.value = 0 ;
|
|
|
|
var x = document.getElementById("run");
|
|
|
|
x.value = 0 ;
|
|
|
|
var x = document.getElementById("simu");
|
|
|
|
x.value = 0 ;
|
|
|
|
var x = document.getElementById("live");
|
|
|
|
x.value = 0 ;
|
2018-12-18 02:03:00 +00:00
|
|
|
|
|
|
|
// Hide all possible main central grids.
|
|
|
|
var x = document.getElementById("mgalign");
|
|
|
|
x.style.display = "none";
|
2019-02-10 15:53:51 +00:00
|
|
|
var x = document.getElementById("mgsimu");
|
2018-12-18 02:03:00 +00:00
|
|
|
x.style.display = "none";
|
2019-02-10 15:53:51 +00:00
|
|
|
var x = document.getElementById("mgrun");
|
|
|
|
x.style.display = "none";
|
|
|
|
var x = document.getElementById("mglive");
|
|
|
|
x.style.display = "none";
|
2019-03-10 22:06:04 +00:00
|
|
|
|
2018-12-18 01:45:23 +00:00
|
|
|
}
|
|
|
|
|
2018-12-18 02:03:00 +00:00
|
|
|
function showAlign() {
|
2019-02-26 10:10:57 +00:00
|
|
|
noMenu();
|
2018-12-18 02:03:00 +00:00
|
|
|
var x = document.getElementById("mgalign");
|
2019-02-10 23:31:24 +00:00
|
|
|
x.style.display = "grid";
|
2019-02-26 10:10:57 +00:00
|
|
|
var x = document.getElementById("align");
|
|
|
|
x.value = 1 ;
|
2018-12-18 02:03:00 +00:00
|
|
|
}
|
2018-12-18 01:45:23 +00:00
|
|
|
|
2019-02-26 10:10:57 +00:00
|
|
|
function showRun() {
|
|
|
|
noMenu();
|
|
|
|
var x = document.getElementById("mgrun");
|
|
|
|
x.style.display = "grid";
|
|
|
|
var x = document.getElementById("run");
|
|
|
|
x.value = 1 ;
|
|
|
|
}
|
2018-12-18 02:03:00 +00:00
|
|
|
|
2019-02-26 10:10:57 +00:00
|
|
|
function showCanvas() {
|
|
|
|
noMenu();
|
|
|
|
var x = document.getElementById("mgsimu");
|
|
|
|
x.style.display = "grid";
|
2019-03-10 22:06:04 +00:00
|
|
|
var x = document.getElementById("cnvbuttons");
|
2019-02-26 10:10:57 +00:00
|
|
|
x.style.display = "grid";
|
|
|
|
var x = document.getElementById("simu");
|
|
|
|
x.value = 1 ;
|
|
|
|
}
|
|
|
|
|
|
|
|
function showLive() {
|
|
|
|
noMenu();
|
|
|
|
var x = document.getElementById("mglive");
|
|
|
|
x.style.display = "grid";
|
|
|
|
var x = document.getElementById("live");
|
|
|
|
x.value = 1 ;
|
|
|
|
}
|
2019-02-10 23:31:24 +00:00
|
|
|
|
2019-02-26 10:10:57 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// SimuUIs
|
|
|
|
//
|
|
|
|
|
|
|
|
function nosimuUI() {
|
|
|
|
// Hide all possible main central grids.
|
|
|
|
var x = document.getElementById("planetUI");
|
|
|
|
x.style.display = "none";
|
|
|
|
var x = document.getElementById("nozoidUI");
|
|
|
|
x.style.display = "none";
|
|
|
|
var x = document.getElementById("aiUI");
|
|
|
|
x.style.display = "none";
|
|
|
|
var x = document.getElementById("lissaUI");
|
|
|
|
x.style.display = "none";
|
|
|
|
var x = document.getElementById("vjUI");
|
|
|
|
x.style.display = "none";
|
2019-03-19 13:24:11 +00:00
|
|
|
var x = document.getElementById("poseUI");
|
|
|
|
x.style.display = "none";
|
2019-03-10 22:06:04 +00:00
|
|
|
var x = document.getElementById("wordsUI");
|
|
|
|
x.style.display = "none";
|
2019-03-17 03:19:57 +00:00
|
|
|
var x = document.getElementById("pluginsUI");
|
|
|
|
x.style.display = "none";
|
2018-12-18 01:45:23 +00:00
|
|
|
}
|
|
|
|
|
2019-02-26 10:10:57 +00:00
|
|
|
function showplanetUI() {
|
|
|
|
nosimuUI();
|
|
|
|
var x = document.getElementById("planetUI");
|
|
|
|
x.style.display = "grid";
|
2019-03-10 22:06:04 +00:00
|
|
|
_WS.send("/planet/ping");
|
2019-02-26 10:10:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function shownozoidUI() {
|
|
|
|
nosimuUI();
|
|
|
|
var x = document.getElementById("nozoidUI");
|
|
|
|
x.style.display = "grid";
|
2019-03-10 22:06:04 +00:00
|
|
|
_WS.send("/nozoid/ping");
|
2019-02-26 10:10:57 +00:00
|
|
|
}
|
2018-12-18 01:45:23 +00:00
|
|
|
|
2019-02-26 10:10:57 +00:00
|
|
|
function showaiUI() {
|
|
|
|
nosimuUI();
|
|
|
|
var x = document.getElementById("aiUI");
|
|
|
|
x.style.display = "grid";
|
|
|
|
}
|
|
|
|
|
|
|
|
function showlissaUI() {
|
|
|
|
nosimuUI();
|
|
|
|
var x = document.getElementById("lissaUI");
|
|
|
|
x.style.display = "grid";
|
|
|
|
}
|
|
|
|
|
|
|
|
function showvjUI() {
|
|
|
|
nosimuUI();
|
|
|
|
var x = document.getElementById("vjUI");
|
|
|
|
x.style.display = "grid";
|
2019-03-10 22:06:04 +00:00
|
|
|
_WS.send("/bank0/ping");
|
|
|
|
}
|
|
|
|
|
2019-03-19 13:24:11 +00:00
|
|
|
|
|
|
|
function showposeUI() {
|
|
|
|
nosimuUI();
|
|
|
|
var x = document.getElementById("poseUI");
|
|
|
|
x.style.display = "grid";
|
|
|
|
_WS.send("/pose/ping");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-10 22:06:04 +00:00
|
|
|
function showwordsUI() {
|
|
|
|
nosimuUI();
|
|
|
|
var x = document.getElementById("wordsUI");
|
|
|
|
x.style.display = "grid";
|
|
|
|
_WS.send("/words/ping");
|
|
|
|
}
|
|
|
|
|
2019-03-17 03:19:57 +00:00
|
|
|
function showpluginsUI() {
|
|
|
|
nosimuUI();
|
|
|
|
var x = document.getElementById("pluginsUI");
|
|
|
|
x.style.display = "grid";
|
|
|
|
//_WS.send("/words/ping");
|
|
|
|
}
|
|
|
|
|
2019-03-10 22:06:04 +00:00
|
|
|
//
|
|
|
|
// Button clicked
|
|
|
|
//
|
|
|
|
|
|
|
|
function buttonClicked(clicked_id) {
|
|
|
|
|
|
|
|
_WS.send("/" + clicked_id);
|
|
|
|
|
|
|
|
// update Canvas right part of maingrid
|
|
|
|
if (clicked_id === "planet/planetUI") {
|
|
|
|
showplanetUI();
|
|
|
|
}
|
|
|
|
if (clicked_id === "nozoid/nozoidUI") {
|
|
|
|
shownozoidUI();
|
|
|
|
}
|
|
|
|
if (clicked_id === "ai/aiUI") {
|
|
|
|
showaiUI();
|
|
|
|
}
|
|
|
|
if (clicked_id === "lissa/lissaUI") {
|
|
|
|
showlissaUI();
|
|
|
|
}
|
2019-03-19 13:24:11 +00:00
|
|
|
if (clicked_id === "bank0/vjUI") {
|
2019-03-10 22:06:04 +00:00
|
|
|
showvjUI();
|
|
|
|
}
|
2019-03-19 13:24:11 +00:00
|
|
|
if (clicked_id === "pose/poseUI") {
|
|
|
|
showposeUI();
|
|
|
|
}
|
2019-03-10 22:06:04 +00:00
|
|
|
if (clicked_id === "words/wordsUI") {
|
|
|
|
showwordsUI();
|
|
|
|
}
|
2019-03-17 03:19:57 +00:00
|
|
|
if (clicked_id === "lj/pluginsUI") {
|
|
|
|
showpluginsUI();
|
|
|
|
}
|
2019-03-10 22:06:04 +00:00
|
|
|
if (clicked_id === "nozoid/down 50") {
|
|
|
|
var x = document.getElementById("nozoid/down 50");
|
|
|
|
x.value = 0 ;
|
|
|
|
}
|
2019-02-26 10:10:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Forms submits
|
|
|
|
//
|
|
|
|
|
|
|
|
function onSubmit(clicked_id) {
|
|
|
|
var input = document.getElementById(clicked_id);
|
|
|
|
console.log("/" + clicked_id + " " + input.value);
|
|
|
|
_WS.send("/" + clicked_id + " " + input.value);
|
|
|
|
_WS.showout("/" + clicked_id + " " + input.value);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Websocket handler
|
|
|
|
//
|
2018-12-18 01:45:23 +00:00
|
|
|
|
2018-12-18 02:03:00 +00:00
|
|
|
var pl = "";
|
|
|
|
var pl2 = new Array();
|
2019-02-26 10:10:57 +00:00
|
|
|
var _WS = {
|
2019-03-24 16:24:52 +00:00
|
|
|
uri: LJ,
|
2019-02-26 10:10:57 +00:00
|
|
|
ws: null,
|
|
|
|
|
|
|
|
init : function (e) {
|
|
|
|
_WS.s = new WebSocket(_WS.uri);
|
|
|
|
_WS.s.onopen = function (e) { _WS.onOpen(e); };
|
|
|
|
_WS.s.onclose = function (e) { _WS.onClose(e); };
|
|
|
|
_WS.s.onmessage = function (e) { _WS.onMessage(e); };
|
|
|
|
_WS.s.onerror = function (e) { _WS.onError(e); };
|
|
|
|
},
|
|
|
|
|
|
|
|
onOpen: function () {
|
|
|
|
_WS.showout(_WS.uri);
|
|
|
|
_WS.showout('CONNECTED');
|
|
|
|
document.getElementById("on").value = 1;
|
|
|
|
},
|
|
|
|
|
|
|
|
onClose: function () {
|
|
|
|
_WS.showout('DISCONNECTED');
|
|
|
|
document.getElementById("on").value = 0;
|
|
|
|
document.getElementById("lstt/0").value = 0;
|
|
|
|
document.getElementById("lstt/1").value = 0;
|
|
|
|
document.getElementById("lstt/2").value = 0;
|
|
|
|
document.getElementById("lstt/3").value = 0;
|
|
|
|
document.getElementById("lack/0").value = 0;
|
|
|
|
document.getElementById("lack/1").value = 0;
|
|
|
|
document.getElementById("lack/2").value = 0;
|
|
|
|
document.getElementById("lack/3").value = 0;
|
|
|
|
},
|
|
|
|
|
|
|
|
onMessage: function (e) {
|
|
|
|
var res = e.data.split(" ");
|
|
|
|
//console.log(e.data)
|
|
|
|
//console.log(res[0].substring(0,6))
|
2019-03-24 16:24:52 +00:00
|
|
|
//console.log(res)
|
|
|
|
//console.log(res[0].slice(1))
|
2019-02-26 10:10:57 +00:00
|
|
|
|
2018-12-18 02:03:00 +00:00
|
|
|
switch (res[0].substring(0,6)) {
|
2019-03-17 03:19:57 +00:00
|
|
|
|
|
|
|
case "/statu":
|
|
|
|
_WS.showstatus(e.data.slice(8));
|
2018-12-18 02:03:00 +00:00
|
|
|
break;
|
2018-12-19 11:39:54 +00:00
|
|
|
case "/simul":
|
|
|
|
pl = e.data.slice(7);
|
2018-12-18 02:03:00 +00:00
|
|
|
pl2 = eval(pl.replace(/[()]/g, ''));
|
|
|
|
break;
|
2018-12-19 11:39:54 +00:00
|
|
|
case "/plpoi":
|
2018-12-18 02:03:00 +00:00
|
|
|
//console.log("plpoint");
|
|
|
|
break;
|
2018-12-19 11:39:54 +00:00
|
|
|
default:
|
2019-03-19 13:24:11 +00:00
|
|
|
//console.log(e);
|
2018-12-18 02:03:00 +00:00
|
|
|
document.getElementById(res[0].slice(1)).value = res[1];
|
2018-12-19 11:39:54 +00:00
|
|
|
_WS.showin(e.data);
|
2018-12-18 02:03:00 +00:00
|
|
|
}
|
2019-02-26 10:10:57 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onError: function (e) {
|
|
|
|
_WS.showin('<span style="color: red;">ERROR:</span> ' + e.data);
|
|
|
|
},
|
|
|
|
|
|
|
|
showin: function (message) {
|
|
|
|
var divtext = document.getElementById('showin');
|
|
|
|
divtext.innerHTML="";
|
|
|
|
divtext.innerHTML= message.toString();
|
|
|
|
},
|
|
|
|
|
|
|
|
showout: function (message) {
|
|
|
|
var divtext = document.getElementById('showout');
|
|
|
|
divtext.innerHTML="";
|
|
|
|
divtext.innerHTML= message.toString();
|
|
|
|
},
|
|
|
|
|
|
|
|
showstatus: function (message) {
|
|
|
|
var divtext = document.getElementById('showstatus');
|
|
|
|
divtext.innerHTML="";
|
|
|
|
divtext.innerHTML= message.toString();
|
|
|
|
},
|
|
|
|
|
|
|
|
send: function (message) {
|
|
|
|
if (!message.length) {
|
|
|
|
alert('Empty message not allowed !');
|
|
|
|
} else {
|
|
|
|
_WS.showout(message);
|
|
|
|
_WS.s.send(message);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
close: function () {
|
|
|
|
_WS.showout('GOODBYE !');
|
|
|
|
_WS.s.close();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
window.addEventListener('load', _WS.init, false);
|
2018-12-18 01:45:23 +00:00
|
|
|
|