3d-interface/js/l3d/src/utils/Logger.js

138 lines
3.3 KiB
JavaScript
Raw Normal View History

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");
// 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 16:31:43 +02:00
L3D.BD.Private.enabled = true;
2015-07-01 16:31:43 +02:00
L3D.BD.enable = function() {
L3D.BD.Private.enabled = true;
};
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-05-19 11:03:53 +02:00
2015-07-01 16:31:43 +02:00
L3D.BD.Private.compactCamera = function(camera) {
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-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() {
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-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() {
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-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() {
var url = "/posts/keyboard-event";
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 16:31:43 +02:00
L3D.BD.Private.sendData(url, data);
};
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() {
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 16:31:43 +02:00
L3D.BD.Event.PreviousNextClicked = function() {};
L3D.BD.Event.PreviousNextClicked.prototype.send = function() {
var url = "/posts/previous-next-clicked";
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-07-01 16:31:43 +02:00
L3D.BD.Private.sendData(url, data);
};
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() {
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-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
var url = "/posts/fps";
2015-06-22 09:41:59 +02:00
var data = {
fps: this.fps
};
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-09 15:38:56 +02:00
L3D.BD.Event.PointerLocked = function() {};
L3D.BD.Event.PointerLocked.prototype.send = function() {
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() {
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
};