Get minimum password length from options
authorRobert Sesek <rsesek@google.com>
Mon, 11 Jun 2012 19:36:13 +0000 (15:36 -0400)
committerRobert Sesek <rsesek@google.com>
Mon, 11 Jun 2012 19:36:13 +0000 (15:36 -0400)
core.html
core.js
options.js

index d13ab5b501e1f9cbcd5d47115fac9a0f336812c3..7b8bf69684c02e1a8e02e5980d100d83b6fec392 100644 (file)
--- a/core.html
+++ b/core.html
@@ -4,6 +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" src="options.js"></script>
     <link rel="stylesheet" href="common.css" />
     <link rel="stylesheet" href="core.css" />
   </head>
diff --git a/core.js b/core.js
index 3492c3003b50676879c63bef4fd174336256615d..7830546a1f6569a2607002b8a49f0cc20ae9e654 100644 (file)
--- a/core.js
+++ b/core.js
@@ -42,6 +42,9 @@ var SkeletonKey = SkeletonKey || function(doc) {
   this._username = doc.getElementById('username');
   this._password = doc.getElementById('password');
   this._generateButton = doc.getElementById('generate');
+
+  this._options = new SkeletonKeyOptions();
+
   this._init();
 };
 
@@ -56,12 +59,6 @@ SkeletonKey.prototype.ITERATIONS = 1000;
  */
 SkeletonKey.prototype.KEYSIZE = 256/32;
 
-/**
- * The minimum length of a password.
- * @const {int}
- */
-SkeletonKey.prototype.MIN_LENGTH = 6;
-
 /**
  * Initializes event handlers for the page.
  * @private
@@ -109,8 +106,8 @@ SkeletonKey.prototype._capitalizeKey = function(key) {
   // it as the basis for capitalizing the key.
   var capsSource = null;
   var keyLength = key.length;
-  if (keyLength / 2 <= this.MIN_LENGTH) {
-    capsSouce = key.substr(0, keyLength - this.MIN_LENGTH);
+  if (keyLength / 2 <= this._options.getMinimumPasswordLength()) {
+    capsSouce = key.substr(0, keyLength - this._options.getMinimumPasswordLength());
   } else {
     capsSource = key.substr(keyLength / 2);
   }
index 506b2f8639eec9178bb65be853abec27f88b9a2f..5d3b447dffb3f3f1c083635cb1305bc5dab88ed2 100644 (file)
 
 (function main() {
   document.addEventListener('DOMContentLoaded', function() {
-    var controller = new SkeletonKeyOptions(window);
+    var win = null;
+    if (window.location.pathname.indexOf('options.html') != -1)
+      win = window;
+    var controller = new SkeletonKeyOptions(win);
   });
 })();