From 8f8292cbb0b3f3e9ba60ea7def281cb71c3aaae2 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 11 Jun 2012 15:24:29 -0400 Subject: [PATCH] Intital work on options --- core.css | 2 +- hosted.html | 4 ++- options.html | 23 ++++++++++++++ options.js | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 options.html create mode 100644 options.js diff --git a/core.css b/core.css index 6b8f018..ab1b302 100644 --- a/core.css +++ b/core.css @@ -23,7 +23,7 @@ body { width: 36em; } -ol { +ol, ul { list-style-type: none; } diff --git a/hosted.html b/hosted.html index f5eea2e..e928b95 100644 --- a/hosted.html +++ b/hosted.html @@ -18,6 +18,8 @@ id est laborum.

- + + diff --git a/options.html b/options.html new file mode 100644 index 0000000..15f0725 --- /dev/null +++ b/options.html @@ -0,0 +1,23 @@ + + + + Skeleton Key - Options + + + + + +
+ +
+ + diff --git a/options.js b/options.js new file mode 100644 index 0000000..506b2f8 --- /dev/null +++ b/options.js @@ -0,0 +1,84 @@ +/* Copyright (c) 2012 Robert Sesek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +(function main() { + document.addEventListener('DOMContentLoaded', function() { + var controller = new SkeletonKeyOptions(window); + }); +})(); + +/** + * SkeletonKeyOptions is a controller for both retrieving settings and for + * displaying the view. + * + * @param {Window} win The window and document on wich to operate. + */ +var SkeletonKeyOptions = SkeletonKeyOptions || function(win) { + if (win) { + this._storage = win.localStorage; + this._maxLength = win.document.getElementById('maxlength'); + this._saveButton = win.document.getElementById('save'); + this._saveButton.onclick = this.onSave.bind(this); + } +}; + +/** + * Local storage key constants. + * @priate + */ +SkeletonKeyOptions.prototype._MIN_LENGTH_KEY = 'minlength'; +SkeletonKeyOptions.prototype._MAX_LENGTH_KEY = 'maxlength'; + +/** + * Gets the minimum password length. + * @returns {int} + */ +SkeletonKeyOptions.prototype.getMinimumPasswordLength = function() { + if (this._storage) { + var setting = this._storage.getItem(this._MIN_LENGTH_KEY); + if (setting) + return setting; + } + return 6; +}; + +/** + * Gets the maximum password length. + * @returns {int} + */ +SkeletonKeyOptions.prototype.getMaximumPasswordLength = function() { + if (this._storage) { + var setting = this._storage.getItem(this._MAX_LENGTH_KEY); + if (setting) + return setting; + } + return 18; +}; + +/** + * Saves the options. Requires a document. + */ +SkeletonKeyOptions.prototype.onSave = function() { + if (!this._storage) + return; + + this._storage.setItem(this._MAX_LENGTH_KEY, this._maxLength.value); +}; -- 2.22.5