Skip to content

Commit

Permalink
Fixed mrdoob stats.js
Browse files Browse the repository at this point in the history
Fixed z-index from stats.js.
Changed stats.js to local file.
  • Loading branch information
pmav committed Dec 6, 2016
1 parent acbf88c commit 514461a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 33 deletions.
56 changes: 28 additions & 28 deletions assets/js/game-of-life-v3.1.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
stats.domElement.style.position = 'absolute';
stats.domElement.style.right = '0px';
stats.domElement.style.bottom = '0px';
stats.domElement.style.zIndex = '999999';
stats.domElement.style.zIndex = '-999999';

document.addEventListener("DOMContentLoaded", function() {
document.body.appendChild( stats.domElement );
Expand All @@ -25,7 +25,7 @@

columns : 0,
rows : 0,

waitTime: 0,
generation : 0,

Expand Down Expand Up @@ -158,7 +158,7 @@
this.keepDOMElements(); // Keep DOM References (getElementsById)
this.canvas.init(); // Init canvas GUI
this.registerEvents(); // Register event handlers

this.prepare();
} catch (e) {
alert("Error: "+e);
Expand Down Expand Up @@ -216,7 +216,7 @@
}

state = jsonParse(decodeURI(s));

for (i = 0; i < state.length; i++) {
for (y in state[i]) {
for (j = 0 ; j < state[i][y].length ; j++) {
Expand All @@ -233,7 +233,7 @@
*/
randomState : function() {
var i, liveCells = (this.rows * this.columns) * 0.12;

for (i = 0; i < liveCells; i++) {
this.listLife.addCell(this.helpers.random(0, this.columns - 1), this.helpers.random(0, this.rows - 1), this.listLife.actualState);
}
Expand Down Expand Up @@ -314,7 +314,7 @@
var i, x, y, r, liveCellNumber, algorithmTime, guiTime;

// Algorithm run

algorithmTime = (new Date());

liveCellNumber = GOL.listLife.nextGeneration();
Expand Down Expand Up @@ -443,7 +443,7 @@
if (!event) {
event = window.event;
}

if (event.keyCode === 67) { // Key: C
GOL.handlers.buttons.clear();
} else if (event.keyCode === 82 ) { // Key: R
Expand All @@ -455,7 +455,7 @@


buttons : {

/**
* Button Handler - Run
*/
Expand Down Expand Up @@ -572,7 +572,7 @@
}

}

},


Expand Down Expand Up @@ -685,7 +685,7 @@
* drawCell
*/
drawCell : function (i, j, alive) {

if (alive) {

if (this.age[i][j] > -1)
Expand All @@ -700,7 +700,7 @@
}

this.context.fillRect(this.cellSpace + (this.cellSpace * i) + (this.cellSize * i), this.cellSpace + (this.cellSpace * j) + (this.cellSize * j), this.cellSize, this.cellSize);

},


Expand Down Expand Up @@ -773,9 +773,9 @@
/**
*
NOTE: The following code is slower than the used one.
(...)
if (allDeadNeighbours[key] === undefined) {
allDeadNeighbours[key] = {
x: deadNeighbours[m][0],
Expand All @@ -785,14 +785,14 @@
} else {
allDeadNeighbours[key].i++;
}
(...)
// Process dead neighbours
for (key in allDeadNeighbours) {
if (allDeadNeighbours[key].i === 3) { // Add new Cell
this.addCell(allDeadNeighbours[key].x, allDeadNeighbours[key].y, newState);
alive++;
this.redrawList.push([allDeadNeighbours[key].x, allDeadNeighbours[key].y, 1]);
Expand All @@ -806,7 +806,7 @@
for (i = 0; i < this.actualState.length; i++) {
this.topPointer = 1;
this.bottomPointer = 1;

for (j = 1; j < this.actualState[i].length; j++) {
x = this.actualState[i][j];
y = this.actualState[i][0];
Expand All @@ -821,7 +821,7 @@
for (m = 0; m < 8; m++) {
if (deadNeighbours[m] !== undefined) {
key = deadNeighbours[m][0] + ',' + deadNeighbours[m][1]; // Create hashtable key

if (allDeadNeighbours[key] === undefined) {
allDeadNeighbours[key] = 1;
} else {
Expand All @@ -846,7 +846,7 @@
key = key.split(',');
t1 = parseInt(key[0], 10);
t2 = parseInt(key[1], 10);

this.addCell(t1, t2, newState);
alive++;
this.redrawList.push([t1, t2, 1]);
Expand Down Expand Up @@ -896,7 +896,7 @@
} else {
this.topPointer = k - 1;
}

neighbours++;
}

Expand All @@ -907,7 +907,7 @@
}
}
}

// Middle
for (k = 1; k < this.actualState[i].length; k++) {
if (this.actualState[i][k] >= (x - 1)) {
Expand Down Expand Up @@ -948,7 +948,7 @@

if (this.actualState[i+1][k] === (x + 1)) {
possibleNeighboursList[7] = undefined;

if (k == 1) {
this.bottomPointer = 1;
} else {
Expand All @@ -965,7 +965,7 @@
}
}
}

return neighbours;
},

Expand All @@ -975,7 +975,7 @@
*/
isAlive : function(x, y) {
var i, j;

for (i = 0; i < this.actualState.length; i++) {
if (this.actualState[i][0] === y) {
for (j = 1; j < this.actualState[i].length; j++) {
Expand All @@ -994,7 +994,7 @@
*/
removeCell : function(x, y, state) {
var i, j;

for (i = 0; i < state.length; i++) {
if (state[i][0] === y) {

Expand Down Expand Up @@ -1107,7 +1107,7 @@
getUrlParameter : function(name) {
if (this.urlParameters === null) { // Cache miss
var hash, hashes, i;

this.urlParameters = [];
hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');

Expand Down Expand Up @@ -1146,7 +1146,7 @@
if (!event) {
event = window.event;
}

if (event.pageX || event.pageY) {
posx = event.pageX;
posy = event.pageY;
Expand Down
8 changes: 4 additions & 4 deletions assets/js/stats.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<script src="assets/js/json-sans-eval.js"></script>
<script src="assets/js/css-browser-selector.js"></script>
<script src="http://rawgit.com/mrdoob/stats.js/master/build/stats.min.js"></script>
<script src="assets/js/stats.min.js"></script>
<script src="assets/js/game-of-life-v3.1.1.js"></script>

<link rel="stylesheet" type="text/css" href="assets/css/style.css" />
Expand Down

0 comments on commit 514461a

Please sign in to comment.