# HG changeset patch # User Oleksandr Gavenko # Date 1411575785 -10800 # Node ID 28694f058ea4616b77ebb562fb1ab4ab18aead63 # Parent e0958e5217163be73a29a3ad631523c04a225a7e Make a way to stop statistic gathering. diff -r e0958e521716 -r 28694f058ea4 2048.html --- a/2048.html Wed Sep 24 19:17:52 2014 +0300 +++ b/2048.html Wed Sep 24 19:23:05 2014 +0300 @@ -283,6 +283,7 @@
up to times
up to sec
+
score
turn
@@ -889,6 +890,7 @@ reportsDom.insertBefore(reportDom, reportsDom.firstChild); } ui.report.start = function() { + ui.report.executed = true; var histo = {}; var gameCntLimit = parseInt(document.getElementById('stat-count-limit').value); if (isNaN(gameCntLimit) || !isFinite(gameCntLimit) || gameCntLimit < 1) @@ -926,7 +928,7 @@ var tsFrom = new Date().getTime(), tsFrame = tsFrom; function batch() { /* console.profile(); */ - while (gameCnt++ < gameCntLimit) { + while (gameCnt++ < gameCntLimit && ui.report.executed) { play(); var tsTo = new Date().getTime(); if (tsTo - tsFrame > 7000) { @@ -937,7 +939,7 @@ break; } /* console.profileEnd(); */ - if (tsTo - tsFrom >= tsLimit || gameCnt >= gameCntLimit) { + if (tsTo - tsFrom >= tsLimit || gameCnt >= gameCntLimit || ! ui.report.executed) { ui.report.fix(histo); ui.report.show(histo, gameCnt); } else { @@ -949,6 +951,12 @@ var statisticStartBtn = document.getElementById("statistic-start"); statisticStartBtn.addEventListener("click", ui.report.start, false); + ui.report.stop = function() { + ui.report.executed = false; + } + var statisticStopBtn = document.getElementById("statistic-stop"); + statisticStopBtn.addEventListener("click", ui.report.stop, false); + ui.report.clean = function() { while (reportsDom.hasChildNodes()) { reportsDom.removeChild(reportsDom.lastChild);