summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/Clipperz/PM/DataModel/DirectLogin.js
Side-by-side diff
Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/DataModel/DirectLogin.js') (more/less context) (show whitespace changes)
-rw-r--r--frontend/gamma/js/Clipperz/PM/DataModel/DirectLogin.js15
1 files changed, 6 insertions, 9 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/DirectLogin.js b/frontend/gamma/js/Clipperz/PM/DataModel/DirectLogin.js
index 1d38509..8f8696d 100644
--- a/frontend/gamma/js/Clipperz/PM/DataModel/DirectLogin.js
+++ b/frontend/gamma/js/Clipperz/PM/DataModel/DirectLogin.js
@@ -1,216 +1,213 @@
/*
Copyright 2008-2011 Clipperz Srl
-This file is part of Clipperz's Javascript Crypto Library.
-Javascript Crypto Library provides web developers with an extensive
-and efficient set of cryptographic functions. The library aims to
-obtain maximum execution speed while preserving modularity and
-reusability.
+This file is part of Clipperz Community Edition.
+Clipperz Community Edition is an online password manager.
For further information about its features and functionalities please
-refer to http://www.clipperz.com
+refer to http://www.clipperz.com.
-* Javascript Crypto Library is free software: you can redistribute
+* Clipperz Community Edition is free software: you can redistribute
it and/or modify it under the terms of the GNU Affero General Public
License as published by the Free Software Foundation, either version
3 of the License, or (at your option) any later version.
-* Javascript Crypto Library is distributed in the hope that it will
+* Clipperz Community Edition is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public
- License along with Javascript Crypto Library. If not, see
+ License along with Clipperz Community Edition. If not, see
<http://www.gnu.org/licenses/>.
*/
Clipperz.Base.module('Clipperz.PM.DataModel');
Clipperz.PM.DataModel.DirectLogin = function(args) {
args = args || {};
Clipperz.PM.DataModel.DirectLogin.superclass.constructor.apply(this, arguments);
this._reference = args.reference
|| Clipperz.PM.Crypto.randomKey();
this._record = args.record
|| Clipperz.Base.exception.raise('MandatoryParameter');
this._retrieveIndexDataFunction = args.retrieveIndexDataFunction
|| this.record().retrieveDirectLoginIndexDataFunction()
|| Clipperz.Base.exception.raise('MandatoryParameter');
this._setIndexDataFunction = args.setIndexDataFunction
|| this.record().setDirectLoginIndexDataFunction()
|| Clipperz.Base.exception.raise('MandatoryParameter');
this._removeIndexDataFunction = args.removeIndexDataFunction
|| this.record().removeDirectLoginIndexDataFunction()
|| Clipperz.Base.exception.raise('MandatoryParameter');
this._inputs = null;
this._bindings = null;
this._formValues = null;
// this._inputsDeferredLock = new MochiKit.Async.DeferredLock();
// this._bindingsDeferredLock = new MochiKit.Async.DeferredLock();
// this._formValuesDeferredLock = new MochiKit.Async.DeferredLock();
this._transientState = null;
this._isBrandNew = MochiKit.Base.isUndefinedOrNull(args.reference);
this.record().addDirectLogin(this);
return this;
}
Clipperz.Base.extend(Clipperz.PM.DataModel.DirectLogin, Object, {
'toString': function() {
return "DirectLogin (" + this.reference() + ")";
},
//=========================================================================
'reference': function () {
return this._reference;
},
//-------------------------------------------------------------------------
'record': function () {
return this._record;
},
//=========================================================================
'isBrandNew': function () {
return this._isBrandNew;
},
//=========================================================================
'removeIndexDataFunction': function () {
return this._removeIndexDataFunction;
},
'remove': function () {
return Clipperz.Async.callbacks("DirectLogin.remove", [
MochiKit.Base.partial(this.removeIndexDataFunction(), this.reference()),
MochiKit.Base.method(this.record(), 'removeDirectLogin', this)
], {trace:false});
},
//=========================================================================
/*
'inputsDeferredLock': function () {
return this._inputsDeferredLock;
},
'bindingsDeferredLock': function () {
return this._bindingsDeferredLock;
},
'formValuesDeferredLock': function () {
return this._formValuesDeferredLock;
},
*/
//=========================================================================
'label': function () {
return this.getIndexDataForKey('label');
},
'setLabelKeepingBackwardCompatibilityWithBeta': function (aValue) {
return Clipperz.Async.callbacks("DirectLogin.setLabelKeepingBackwardCompatibilityWithBeta", [
MochiKit.Base.method(this, 'setIndexDataForKey', 'label', aValue),
MochiKit.Base.method(this, 'setValue', 'label', aValue)
], {trace:false});
},
'setLabel': function (aValue) {
return this.setLabelKeepingBackwardCompatibilityWithBeta(aValue);
// return this.setIndexDataForKey('label', aValue);
},
//=========================================================================
'favicon': function () {
return this.getIndexDataForKey('favicon');
},
'setFavicon': function (aValue) {
return this.setIndexDataForKey('favicon', aValue);
},
'faviconUrlWithBookmarkletConfiguration': function (aBookmarkletConfiguration) {
var result;
if (! MochiKit.Base.isUndefinedOrNull(aBookmarkletConfiguration['page']['favicon'])) {
result = aBookmarkletConfiguration['page']['favicon'];
} else if (! MochiKit.Base.isUndefinedOrNull(aBookmarkletConfiguration['form']['attributes']['action'])) {
var actionUrl;
var hostname;
actionUrl = aBookmarkletConfiguration['form']['attributes']['action'];
hostname = actionUrl.replace(/^https?:\/\/([^\/]*)\/.*/, '$1');
result = "http://" + hostname + "/favicon.ico";
} else {
result = null;
}
return result;
},
//-------------------------------------------------------------------------
/*
'faviconData': function () {
var regexp = new RegExp('^data\:\/\/.*', 'i');
return Clipperz.Async.callbacks("DirectLogin.favicon", [
MochiKit.Base.method(this, 'getIndexDataForKey', 'favicon'),
MochiKit.Base.method(regexp, 'test'),
Clipperz.Async.deferredIf("is data URL", [
MochiKit.Base.method(this, 'getIndexDataForKey', 'favicon')
], [
MochiKit.Base.method(this, 'transientState'),
MochiKit.Base.itemgetter('faviconData'),
Clipperz.Async.deferredIf('has a chaced value for the favicon data', [
MochiKit.Base.operator.identity
], [
MochiKit.Base.method(this, 'getIndexDataForKey', 'favicon'),
MochiKit.Base.method(this, 'loadFaviconDataFromURL')
])
])
], {trace:false});
},
//-------------------------------------------------------------------------
'loadFaviconDataFromURL': function (anURL) {
var deferredResult;
var image;
deferredResult = new Clipperz.Async.Deferred("DirectLogin.loadFaviconDataFromURL", {trace:false});
deferredResult.addCallback(function (anEvent) {
var image = anEvent.src();
var canvas = document.createElement("canvas");
var result;
canvas.width = image.width;
canvas.height = image.height;
var ctx = canvas.getContext("2d");
ctx.drawImage(image, 0, 0);
result = canvas.toDataURL(/*"image/png"* /);
return result;
});
deferredResult.addErrback(MochiKit.Async.succeed, Clipperz.PM.Strings.getValue('defaultFaviconUrl'));
deferredResult.addBoth(MochiKit.Base.bind(function (aDataUrl) {
this.transientState()['faviconData'] = aDataUrl;