# HG changeset patch # User Oleksandr Gavenko # Date 1411195448 -10800 # Node ID eb4f89e2a00137f97ae36478a6e1b8cc1a346118 # Parent b3cadad6ef14f6b46a5b70c88fd16c7a3e2d1763 Clean statistics button. diff -r b3cadad6ef14 -r eb4f89e2a001 2048.html --- a/2048.html Sat Sep 20 01:16:14 2014 +0300 +++ b/2048.html Sat Sep 20 09:44:08 2014 +0300 @@ -66,7 +66,7 @@ left: 1em; top: -1em; } - button#statistic { + button#statistic, button#statistic-clean { display: inline-block; float: left; margin: 3px 4px; @@ -276,6 +276,7 @@
times
limit to sec
+
score
turn
speed
@@ -295,6 +296,11 @@ // UI widgets. ui.dom = {}; + ui.dom.clearfix = function() { + var divDom = document.createElement('div'); + divDom.classList.add("clearfix"); + return divDom; + } ui.dom.table = function(tbl, cols, cfg) { var tableDom = document.createElement('table'); if (typeof cfg.tableClass === 'string') @@ -888,10 +894,17 @@ reportDom.appendChild(tableDom); reportsDom.insertBefore(reportDom, reportsDom.firstChild); } - var statisticBtn = document.getElementById('statistic'); statisticBtn.addEventListener("click", ui.report.stat, false); + ui.report.statClean = function() { + while (reportsDom.hasChildNodes()) { + reportsDom.removeChild(reportsDom.lastChild); + } + reportsDom.appendChild(ui.dom.clearfix()); + } + var statisticCleanBtn = document.getElementById('statistic-clean'); + statisticCleanBtn.addEventListener("click", ui.report.statClean, false); //////////////////////////////////////////////////////////////// // Initialise game.