2048.html
changeset 98 eb4f89e2a001
parent 97 b3cadad6ef14
child 99 df4736e659f2
equal deleted inserted replaced
97:b3cadad6ef14 98:eb4f89e2a001
    64     button.ai {
    64     button.ai {
    65       position: absolute;
    65       position: absolute;
    66       left: 1em;
    66       left: 1em;
    67       top: -1em;
    67       top: -1em;
    68     }
    68     }
    69     button#statistic {
    69     button#statistic, button#statistic-clean {
    70       display: inline-block;
    70       display: inline-block;
    71       float: left;
    71       float: left;
    72       margin: 3px 4px;
    72       margin: 3px 4px;
    73     }
    73     }
    74     div.ai > div.option, div.setting, div.report {
    74     div.ai > div.option, div.setting, div.report {
   274     <h1>Reports</h1>
   274     <h1>Reports</h1>
   275     <div class="settings">
   275     <div class="settings">
   276       <div class="setting"><input type="text" id="stat-count-limit" value="100"> times</div>
   276       <div class="setting"><input type="text" id="stat-count-limit" value="100"> times</div>
   277       <div class="setting">limit to <input type="text" id="stat-time-limit" value="10"> sec</div>
   277       <div class="setting">limit to <input type="text" id="stat-time-limit" value="10"> sec</div>
   278       <button id="statistic">Start</button>
   278       <button id="statistic">Start</button>
       
   279       <button id="statistic-clean">Clean</button>
   279       <div class="setting"><input type="checkbox" id="report-score"/> score</div>
   280       <div class="setting"><input type="checkbox" id="report-score"/> score</div>
   280       <div class="setting"><input type="checkbox" id="report-turn"/> turn</div>
   281       <div class="setting"><input type="checkbox" id="report-turn"/> turn</div>
   281       <div class="setting"><input type="checkbox" id="report-speed"/> speed</div>
   282       <div class="setting"><input type="checkbox" id="report-speed"/> speed</div>
   282       <div class="clearfix"></div>
   283       <div class="clearfix"></div>
   283     </div>
   284     </div>
   293 
   294 
   294     ////////////////////////////////////////////////////////////////
   295     ////////////////////////////////////////////////////////////////
   295     // UI widgets.
   296     // UI widgets.
   296 
   297 
   297     ui.dom = {};
   298     ui.dom = {};
       
   299     ui.dom.clearfix = function() {
       
   300       var divDom = document.createElement('div');
       
   301       divDom.classList.add("clearfix");
       
   302       return divDom;
       
   303     }
   298     ui.dom.table = function(tbl, cols, cfg) {
   304     ui.dom.table = function(tbl, cols, cfg) {
   299       var tableDom = document.createElement('table');
   305       var tableDom = document.createElement('table');
   300       if (typeof cfg.tableClass === 'string')
   306       if (typeof cfg.tableClass === 'string')
   301         tableDom.classList.add(cfg.tableClass);
   307         tableDom.classList.add(cfg.tableClass);
   302       var trDom = document.createElement('tr');
   308       var trDom = document.createElement('tr');
   886       }
   892       }
   887       var tableDom = ui.dom.table(tbl, tblCols, { tableClass: 'report-by-maxval' });
   893       var tableDom = ui.dom.table(tbl, tblCols, { tableClass: 'report-by-maxval' });
   888       reportDom.appendChild(tableDom);
   894       reportDom.appendChild(tableDom);
   889       reportsDom.insertBefore(reportDom, reportsDom.firstChild);
   895       reportsDom.insertBefore(reportDom, reportsDom.firstChild);
   890     }
   896     }
   891 
       
   892     var statisticBtn = document.getElementById('statistic');
   897     var statisticBtn = document.getElementById('statistic');
   893     statisticBtn.addEventListener("click", ui.report.stat, false);
   898     statisticBtn.addEventListener("click", ui.report.stat, false);
   894 
   899 
       
   900     ui.report.statClean = function() {
       
   901       while (reportsDom.hasChildNodes()) {
       
   902         reportsDom.removeChild(reportsDom.lastChild);
       
   903       }
       
   904       reportsDom.appendChild(ui.dom.clearfix());
       
   905     }
       
   906     var statisticCleanBtn = document.getElementById('statistic-clean');
       
   907     statisticCleanBtn.addEventListener("click", ui.report.statClean, false);
   895 
   908 
   896     ////////////////////////////////////////////////////////////////
   909     ////////////////////////////////////////////////////////////////
   897     // Initialise game.
   910     // Initialise game.
   898 
   911 
   899     ui.brdEngine = BoardArr2d; // TODO make user selectable
   912     ui.brdEngine = BoardArr2d; // TODO make user selectable