https://src.bluestatic.org
/
skeletonkey.git
/ commitdiff
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0189a25
)
Break window and document up in Options
author
Robert Sesek <rsesek@google.com>
Mon, 11 Jun 2012 19:45:26 +0000
(15:45 -0400)
committer
Robert Sesek <rsesek@google.com>
Mon, 11 Jun 2012 19:45:26 +0000
(15:45 -0400)
core.js
patch
|
blob
|
history
options.js
patch
|
blob
|
history
diff --git
a/core.js
b/core.js
index fa34dd25b41e891ce44796ed7de37fdd818fbc2a..721cfe51bfbfd2ff9b6bea1bfc507062bd28b346 100644
(file)
--- a/
core.js
+++ b/
core.js
@@
-43,7
+43,12
@@
var SkeletonKey = SkeletonKey || function(doc) {
this._password = doc.getElementById('password');
this._generateButton = doc.getElementById('generate');
this._password = doc.getElementById('password');
this._generateButton = doc.getElementById('generate');
- this._options = new SkeletonKeyOptions();
+ // If this is an extension, use defaults until the Chrome settings are loaded.
+ var win = null;
+ if (!this._isChromeExtension())
+ win = window;
+ this._options = new SkeletonKeyOptions(null, win);
+
this._init();
};
this._init();
};
@@
-181,8
+186,6
@@
SkeletonKey.prototype._selectPassword = function() {
*/
SkeletonKey.prototype._initChromeExtension = function() {
return;
*/
SkeletonKey.prototype._initChromeExtension = function() {
return;
- if (typeof chrome == 'undefined' || typeof chrome.extension == 'undefined')
- return;
// getCurrent is undefined for backround pages. Need content script.
chrome.tabs.getCurrent(function (tab) {
// getCurrent is undefined for backround pages. Need content script.
chrome.tabs.getCurrent(function (tab) {
@@
-197,3
+200,12
@@
SkeletonKey.prototype._initChromeExtension = function() {
console.log(siteKey);
});
};
console.log(siteKey);
});
};
+
+/**
+ * Checks if SkeletonKey is running as a Chrome extension.
+ * @returns {bool}
+ * @private
+ */
+SkeletonKey.prototype._isChromeExtension = function() {
+ return typeof chrome != 'undefined' && typeof chrome.extension != 'undefined';
+};
diff --git
a/options.js
b/options.js
index 5d3b447dffb3f3f1c083635cb1305bc5dab88ed2..4d2e2452ea2ddfb39713f7241eeb275b30472498 100644
(file)
--- a/
options.js
+++ b/
options.js
@@
-21,10
+21,10
@@
(function main() {
document.addEventListener('DOMContentLoaded', function() {
(function main() {
document.addEventListener('DOMContentLoaded', function() {
- var
win
= null;
+ var
doc
= null;
if (window.location.pathname.indexOf('options.html') != -1)
if (window.location.pathname.indexOf('options.html') != -1)
-
win = window
;
- var controller = new SkeletonKeyOptions(
win
);
+
doc = document
;
+ var controller = new SkeletonKeyOptions(
doc, window
);
});
})();
});
})();
@@
-32,14
+32,17
@@
* SkeletonKeyOptions is a controller for both retrieving settings and for
* displaying the view.
*
* SkeletonKeyOptions is a controller for both retrieving settings and for
* displaying the view.
*
- * @param {Window} win The window and document on wich to operate.
+ * @param {HTMLDocument} doc The document on wich to operate.
+ * @param {Window} win The window to use for localStorage.
*/
*/
-var SkeletonKeyOptions = SkeletonKeyOptions || function(win) {
+var SkeletonKeyOptions = SkeletonKeyOptions || function(doc, win) {
+ if (doc) {
+ this._maxLength = doc.getElementById('maxlength');
+ this._saveButton = doc.getElementById('save');
+ this._saveButton.onclick = this.onSave.bind(this);
+ }
if (win) {
this._storage = win.localStorage;
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);
}
};
}
};