2048.html
changeset 98 eb4f89e2a001
parent 97 b3cadad6ef14
child 99 df4736e659f2
--- 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 @@
       <div class="setting"><input type="text" id="stat-count-limit" value="100"> times</div>
       <div class="setting">limit to <input type="text" id="stat-time-limit" value="10"> sec</div>
       <button id="statistic">Start</button>
+      <button id="statistic-clean">Clean</button>
       <div class="setting"><input type="checkbox" id="report-score"/> score</div>
       <div class="setting"><input type="checkbox" id="report-turn"/> turn</div>
       <div class="setting"><input type="checkbox" id="report-speed"/> speed</div>
@@ -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.