Add ability to enable browser profile.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Thu, 25 Sep 2014 01:10:01 +0300
changeset 138 23cd36180bf9
parent 137 be8ee2240a17
child 139 4dde63ac0bb4
Add ability to enable browser profile.
2048.html
--- 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);