changeset 138:23cd36180bf9

Add ability to enable browser profile.
author Oleksandr Gavenko <gavenkoa@gmail.com>
date Thu, 25 Sep 2014 01:10:01 +0300
parents be8ee2240a17
children 4dde63ac0bb4
files 2048.html
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/2048.html	Thu Sep 25 00:54:13 2014 +0300
+++ b/2048.html	Thu Sep 25 01:10:01 2014 +0300
@@ -163,6 +163,7 @@
       <button id="step">Step</button>
       <button id="visual-finish">Visual</button>
       <button id="finish">Finish</button>
+      <div class="option"><input type="checkbox" id="profile"> profile</div>
     </div>
     <br>
     <div class="control">
@@ -636,6 +637,9 @@
     document.getElementById("visual-finish").addEventListener("click", ui.action.visualFinish, false);
 
     ui.action.finish = function() {
+      var isProfile = document.getElementById("profile").checked;
+      if (isProfile)
+        console.profile();
       if ( ! ui.ai.current) {
         ui.game.setMessage('Select AI!');
         return;
@@ -668,6 +672,8 @@
       ui.score.speed(parseFloat((step*1000.0/(tsTo-tsFrom)).toPrecision(3)));
       ui.game.setMessage("Game over!");
       ui.ai.current.cleanup();
+      if (isProfile)
+        console.profileEnd();
     }
     document.getElementById("finish").addEventListener("click", ui.action.finish, false);