Skip to content

Commit

Permalink
Code refactoring batch vthibault#1
Browse files Browse the repository at this point in the history
Remove unused variables
Add missing semicolons
Other code convention
  • Loading branch information
Vincent Thibault committed May 7, 2015
1 parent 2bf6d3f commit 7061ba5
Show file tree
Hide file tree
Showing 19 changed files with 197 additions and 171 deletions.
6 changes: 3 additions & 3 deletions api.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,9 @@
frame.height = this.height;
frame.style.border = 'none';

frame.setAttribute('allowfullscreen', true);
frame.setAttribute('webkitallowfullscreen', true);
frame.setAttribute('mozallowfullscreen', true);
frame.setAttribute('allowfullscreen', 'true');
frame.setAttribute('webkitallowfullscreen', 'true');
frame.setAttribute('mozallowfullscreen', 'true');

if (this.target) {
while (this.target.firstChild) {
Expand Down
2 changes: 1 addition & 1 deletion src/Controls/ProcessCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ define(function( require )

// /str+
// TODO: do we have to spam the server with "1" unit or do we have to fix the servers code ?
var matches = text.match(/^(\w{3})\+ (\d+)$/);
matches = text.match(/^(\w{3})\+ (\d+)$/);
if (matches) {
var pos = ['str', 'agi', 'vit', 'int', 'dex', 'luk'].indexOf(matches[1]);
if (pos > -1 && matches[2] !== 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Context.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ define(function()
*/
Context.isFullScreen = function IsFullScreen()
{
return (
return !!(
document.fullscreenElement ||
document.mozFullScreenElement ||
document.webkitFullscreenElement ||
Expand Down
2 changes: 1 addition & 1 deletion src/Core/FileSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ define(function()
*/
function init( files, save, quota )
{
var requestFileSystemSync, requestFileSystem, temporaryStorage;
var requestFileSystemSync, requestFileSystem;
_files = normalizeFilesPath(files);

if (!_available) {
Expand Down
12 changes: 6 additions & 6 deletions src/Core/MemoryManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ define( ['Core/MemoryItem'], function( MemoryItem )
* Remove files from memory if not used until a period of time
* @var {number}
*/
var _remember_time = 2 * 60 * 1000; // 2 min
var _rememberTime = 2 * 60 * 1000; // 2 min


/**
Expand Down Expand Up @@ -54,7 +54,7 @@ define( ['Core/MemoryItem'], function( MemoryItem )
var item;

// Not in memory yet, create slot
if (!exist(filename)) {
if (!_memory[filename]) {
_memory[filename] = new MemoryItem();
}

Expand All @@ -80,7 +80,7 @@ define( ['Core/MemoryItem'], function( MemoryItem )
*/
function exist( filename )
{
return filename in _memory;
return !!_memory[filename];
}


Expand All @@ -94,7 +94,7 @@ define( ['Core/MemoryItem'], function( MemoryItem )
function set( filename, data, error )
{
// Not in memory yet, create slot
if (!exist(filename)) {
if (!_memory[filename]) {
_memory[filename] = new MemoryItem();
}

Expand Down Expand Up @@ -125,7 +125,7 @@ define( ['Core/MemoryItem'], function( MemoryItem )

keys = Object.keys(_memory);
count = keys.length;
tick = now - _remember_time;
tick = now - _rememberTime;

for (i = 0; i < count; ++i) {
item = _memory[ keys[i] ];
Expand All @@ -152,7 +152,7 @@ define( ['Core/MemoryItem'], function( MemoryItem )
function remove( gl, filename )
{
// Not found ?
if (!exist(filename)) {
if (!_memory[filename]) {
return;
}

Expand Down
44 changes: 22 additions & 22 deletions src/Network/NetworkManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ define(function( require )
* @param {callback} struct - callback to parse the packet
* @param {number} size - packet size
*/
function Packets( name, struct, size )
function Packets( name, Struct, size )
{
this.name = name;
this.struct = struct;
this.Struct = Struct;
this.size = size;
this.callback = null;
}
Expand Down Expand Up @@ -182,12 +182,12 @@ define(function( require )
* @param {number} id - packet UID
* @param {function} struct - packet structure callback
*/
function registerPacket( id, struct ) {
struct.id = id;
function registerPacket( id, Struct ) {
Struct.id = id;
Packets.list[id] = new Packets(
struct.name,
struct,
struct.size
Struct.name,
Struct,
Struct.size
);
}

Expand Down Expand Up @@ -313,10 +313,10 @@ define(function( require )

// Parse packet
if (!packet.instance) {
packet.instance = new packet.struct(fp, offset);
packet.instance = new packet.Struct(fp, offset);
}
else {
packet.struct.call(packet.instance, fp, offset);
packet.Struct.call(packet.instance, fp, offset);
}

console.log( '%c[Network] Recv:', 'color:#900090', packet.instance, packet.callback ? '' : '(no callback)' );
Expand Down Expand Up @@ -432,16 +432,7 @@ define(function( require )
/**
* Export
*/
return new function Network()
{
this.sendPacket = sendPacket;
this.send = send;
this.setPing = setPing;
this.connect = connect;
this.hookPacket = hookPacket;
this.close = close;
this.read = read;

return (function Network() {
var keys;
var i, count;

Expand All @@ -461,8 +452,17 @@ define(function( require )
registerPacket( keys[i], PacketRegister[ keys[i] ] );
}

this.utils = {
longToIP: utilsLongToIP
return {
sendPacket: sendPacket,
send: send,
setPing: setPing,
connect: connect,
hookPacket: hookPacket,
close: close,
read: read,
utils: {
longToIP: utilsLongToIP
}
};
}();
})();
});
Loading

0 comments on commit 7061ba5

Please sign in to comment.