2015-07-01 16:31:43 +02:00
|
|
|
L3D.BD = {};
|
2015-05-18 15:36:24 +02:00
|
|
|
|
2015-07-01 16:31:43 +02:00
|
|
|
L3D.BD.Private = {};
|
2015-05-26 11:49:24 +02:00
|
|
|
|
2015-07-17 14:53:45 +02:00
|
|
|
L3D.BD.Private.sendData = function(url, data, force) {
|
|
|
|
if (L3D.BD.Private.enabled || force) {
|
2015-05-26 11:49:24 +02:00
|
|
|
// Append time to data
|
|
|
|
data.time = Date.now() / 1000;
|
|
|
|
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
xhr.open("POST", url, true);
|
|
|
|
xhr.setRequestHeader("Content-type", "application/json;charset=UTF-8");
|
|
|
|
|
2015-06-22 14:39:41 +02:00
|
|
|
// xhr.onreadystatechange = function() {
|
|
|
|
// if(xhr.readyState == 4 && xhr.status == 200) {
|
|
|
|
// console.log("Done : " + xhr.responseText);
|
|
|
|
// }
|
|
|
|
// }
|
2015-05-26 11:49:24 +02:00
|
|
|
|
|
|
|
xhr.send(JSON.stringify(data));
|
|
|
|
}
|
2015-07-01 10:14:15 +02:00
|
|
|
};
|
2015-05-20 10:23:19 +02:00
|
|
|
|
2015-07-01 16:31:43 +02:00
|
|
|
L3D.BD.Private.enabled = true;
|
2015-05-20 16:28:53 +02:00
|
|
|
|
2015-07-01 16:31:43 +02:00
|
|
|
L3D.BD.enable = function() {
|
|
|
|
L3D.BD.Private.enabled = true;
|
2015-07-01 10:14:15 +02:00
|
|
|
};
|
2015-05-21 16:59:17 +02:00
|
|
|
|
2015-07-01 16:31:43 +02:00
|
|
|
L3D.BD.disable = function() {
|
|
|
|
L3D.BD.Private.enabled = false;
|
2015-07-01 10:14:15 +02:00
|
|
|
};
|
2015-05-19 11:03:53 +02:00
|
|
|
|
2015-07-01 16:31:43 +02:00
|
|
|
L3D.BD.Private.compactCamera = function(camera) {
|
2015-05-20 16:28:53 +02:00
|
|
|
return {
|
2015-06-22 09:41:59 +02:00
|
|
|
position: {
|
|
|
|
x: camera.position.x,
|
|
|
|
y: camera.position.y,
|
|
|
|
z: camera.position.z
|
|
|
|
},
|
|
|
|
target: {
|
|
|
|
x: camera.target.x,
|
|
|
|
y: camera.target.y,
|
|
|
|
z: camera.target.z
|
|
|
|
}
|
2015-05-20 16:28:53 +02:00
|
|
|
};
|
2015-07-01 10:14:15 +02:00
|
|
|
};
|
2015-05-20 16:28:53 +02:00
|
|
|
|
2015-07-01 16:31:43 +02:00
|
|
|
L3D.BD.Event = {};
|
2015-05-19 11:03:53 +02:00
|
|
|
|
2015-07-01 16:31:43 +02:00
|
|
|
L3D.BD.Event.ArrowClicked = function() {};
|
|
|
|
L3D.BD.Event.ArrowClicked.prototype.send = function() {
|
2015-07-09 16:15:10 +02:00
|
|
|
var url = "/posts/arrow-clicked";
|
2015-05-19 11:03:53 +02:00
|
|
|
var data = {arrow_id: this.arrow_id};
|
2015-07-01 16:31:43 +02:00
|
|
|
L3D.BD.Private.sendData(url, data);
|
2015-07-01 10:14:15 +02:00
|
|
|
};
|
2015-05-18 15:36:24 +02:00
|
|
|
|
2015-07-01 16:31:43 +02:00
|
|
|
L3D.BD.Event.CoinClicked = function() {};
|
|
|
|
L3D.BD.Event.CoinClicked.prototype.send = function() {
|
2015-07-09 16:15:10 +02:00
|
|
|
var url = "/posts/coin-clicked";
|
2015-05-19 11:03:53 +02:00
|
|
|
var data = {coin_id: this.coin_id};
|
2015-07-01 16:31:43 +02:00
|
|
|
L3D.BD.Private.sendData(url, data);
|
2015-07-01 10:14:15 +02:00
|
|
|
};
|
2015-05-18 15:36:24 +02:00
|
|
|
|
2015-07-01 16:31:43 +02:00
|
|
|
L3D.BD.Event.KeyboardEvent = function() {};
|
|
|
|
L3D.BD.Event.KeyboardEvent.prototype.send = function() {
|
2015-07-09 16:15:10 +02:00
|
|
|
var url = "/posts/keyboard-event";
|
2015-05-20 16:28:53 +02:00
|
|
|
|
2015-05-19 11:50:12 +02:00
|
|
|
var data = {
|
2015-07-01 16:31:43 +02:00
|
|
|
camera: L3D.BD.Private.compactCamera(this.camera)
|
2015-07-01 10:14:15 +02:00
|
|
|
};
|
2015-05-20 16:28:53 +02:00
|
|
|
|
2015-07-01 16:31:43 +02:00
|
|
|
L3D.BD.Private.sendData(url, data);
|
2015-07-01 10:14:15 +02:00
|
|
|
};
|
2015-05-20 15:20:59 +02:00
|
|
|
|
2015-07-01 16:31:43 +02:00
|
|
|
L3D.BD.Event.ResetClicked = function() {};
|
|
|
|
L3D.BD.Event.ResetClicked.prototype.send = function() {
|
2015-07-09 16:15:10 +02:00
|
|
|
var url = "/posts/reset-clicked";
|
2015-05-20 15:20:59 +02:00
|
|
|
var data = {};
|
2015-07-01 16:31:43 +02:00
|
|
|
L3D.BD.Private.sendData(url, data);
|
2015-07-01 10:14:15 +02:00
|
|
|
};
|
2015-05-20 16:28:53 +02:00
|
|
|
|
2015-07-01 16:31:43 +02:00
|
|
|
L3D.BD.Event.PreviousNextClicked = function() {};
|
|
|
|
L3D.BD.Event.PreviousNextClicked.prototype.send = function() {
|
2015-07-09 16:15:10 +02:00
|
|
|
var url = "/posts/previous-next-clicked";
|
2015-05-20 16:28:53 +02:00
|
|
|
var data = {
|
|
|
|
// casts previous to boolean
|
|
|
|
previous: this.previous,
|
2015-07-01 16:31:43 +02:00
|
|
|
camera: L3D.BD.Private.compactCamera(this.camera)
|
2015-05-20 16:28:53 +02:00
|
|
|
};
|
|
|
|
|
2015-07-01 16:31:43 +02:00
|
|
|
L3D.BD.Private.sendData(url, data);
|
2015-07-01 10:14:15 +02:00
|
|
|
};
|
2015-05-21 15:35:40 +02:00
|
|
|
|
2015-07-01 16:31:43 +02:00
|
|
|
L3D.BD.Event.Hovered = function() {};
|
|
|
|
L3D.BD.Event.Hovered.prototype.send = function() {
|
2015-07-09 16:15:10 +02:00
|
|
|
var url = "/posts/hovered";
|
2015-05-21 15:35:40 +02:00
|
|
|
var data = {
|
|
|
|
start: this.start,
|
|
|
|
arrow_id: this.arrow_id
|
|
|
|
};
|
|
|
|
|
2015-07-01 16:31:43 +02:00
|
|
|
L3D.BD.Private.sendData(url, data);
|
2015-07-01 10:14:15 +02:00
|
|
|
};
|
2015-06-22 09:41:59 +02:00
|
|
|
|
2015-07-01 16:31:43 +02:00
|
|
|
L3D.BD.Event.Fps = function() {};
|
|
|
|
L3D.BD.Event.Fps.prototype.send = function() {
|
2015-06-22 09:41:59 +02:00
|
|
|
|
2015-07-09 16:15:10 +02:00
|
|
|
var url = "/posts/fps";
|
2015-06-22 09:41:59 +02:00
|
|
|
var data = {
|
|
|
|
fps: this.fps
|
2015-07-01 10:14:15 +02:00
|
|
|
};
|
2015-06-22 09:41:59 +02:00
|
|
|
|
2015-07-01 16:31:43 +02:00
|
|
|
L3D.BD.Private.sendData(url, data);
|
2015-06-22 09:41:59 +02:00
|
|
|
|
2015-07-01 10:14:15 +02:00
|
|
|
};
|
2015-07-09 15:38:56 +02:00
|
|
|
|
|
|
|
L3D.BD.Event.PointerLocked = function() {};
|
|
|
|
L3D.BD.Event.PointerLocked.prototype.send = function() {
|
2015-07-09 16:15:10 +02:00
|
|
|
var url = "/posts/pointer-locked";
|
2015-07-09 15:38:56 +02:00
|
|
|
var data = {
|
|
|
|
locked: this.locked
|
|
|
|
};
|
|
|
|
|
|
|
|
L3D.BD.Private.sendData(url, data);
|
|
|
|
};
|
|
|
|
|
|
|
|
L3D.BD.Event.SwitchedLockOption = function() {};
|
|
|
|
L3D.BD.Event.SwitchedLockOption.prototype.send = function() {
|
2015-07-09 16:15:10 +02:00
|
|
|
var url = "/posts/switched-lock-option";
|
2015-07-09 15:38:56 +02:00
|
|
|
|
|
|
|
var data = {
|
|
|
|
locked: this.locked
|
|
|
|
};
|
|
|
|
|
|
|
|
L3D.BD.Private.sendData(url, data);
|
2015-07-09 17:48:46 +02:00
|
|
|
};
|