Switch to a main() funciton
authorRobert Sesek <rsesek@google.com>
Sat, 9 Jun 2012 21:18:04 +0000 (17:18 -0400)
committerRobert Sesek <rsesek@google.com>
Sat, 9 Jun 2012 21:20:13 +0000 (17:20 -0400)
core.html
core.js

index 2bd95349c05dd3962f35c4bb6faf1953519a203f..8603e004231637e9779f46f597c9e1e496a7fcee 100644 (file)
--- a/core.html
+++ b/core.html
@@ -4,13 +4,7 @@
     <title>Skeleton Key</title>
     <script type="text/javascript" src="pbkdf2.js"></script>
     <script type="text/javascript" src="core.js"></script>
-    <script type="text/javascript">
-      if (typeof chrome.extension !== 'undefined') {
-        // TODO: load the extension JS
-      } else {
-        // TODO: load the hosted JS
-      }
-    </script>
+   </script>
     <link rel="stylesheet" href="core.css" />
   </head>
   <body>
@@ -46,8 +40,5 @@
 
     <div class="clear"></div>
 
-    <script type="text/javascript">
-      var controller = new SkeletonKey(document);
-    </script>
   </body>
 </html>
diff --git a/core.js b/core.js
index 836375638462f54239b1701d96e5540787b94ae6..54a8f8a9e3f3462d2bb19120884f1b2279b1a9ff 100644 (file)
--- a/core.js
+++ b/core.js
  * DEALINGS IN THE SOFTWARE.
  */
 
+(function main() {
+  if (typeof chrome !== 'undefined') {
+    // TODO: load the extension JS
+  } else {
+    // TODO: load the hosted JS
+  }
+
+  document.addEventListener('DOMContentLoaded', function() {
+    var controller = new SkeletonKey(document);
+  });
+})();
+
 /**
  * SkeletonKey is view controller for generating secure passwords.
  *
@@ -72,6 +84,8 @@ SkeletonKey.prototype._onGenerate = function(e) {
   var hexString = key.toString();
   hexString = this._capitalizeKey(hexString);
   this._password.value = hexString;
+  this._password.focus();
+  this._password.select();
 };
 
 /**