Created
June 11, 2010 10:05
-
-
Save weisslj/434308 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/js/Bookmarklet.js b/src/js/Bookmarklet.js | |
index daa633e..f335fc7 100644 | |
--- a/src/js/Bookmarklet.js | |
+++ b/src/js/Bookmarklet.js | |
@@ -178,11 +178,60 @@ formParameters = function(aLoginForm) { | |
//----------------------------------------------------------------------------- | |
+getImageData = function (url) { | |
+ try { | |
+ var canvas = document.createElement("canvas"); | |
+ | |
+ var img = document.createElement("img"); // works better than new Image()? | |
+ img.src = url; | |
+ | |
+ canvas.width = img.width; | |
+ canvas.height = img.height; | |
+ | |
+ var ctx = canvas.getContext("2d"); | |
+ ctx.drawImage(img, 0, 0); | |
+ return canvas.toDataURL("image/png"); | |
+ } catch (e) { | |
+ return null; | |
+ } | |
+} | |
+ | |
+getFaviconData = function() { | |
+ // default location | |
+ var favicon_href = location.protocol + "//" + location.hostname + "/favicon.ico"; | |
+ | |
+ var data = getImageData(favicon_href); | |
+ if (data != null) | |
+ return data; | |
+ | |
+ var linktags = document.getElementsByTagName("link"); | |
+ | |
+ // browsers seem to take last favicon specified | |
+ for (var i = linktags.length-1; i >= 0; i--) | |
+ { | |
+ if (linktags.item(i).rel == "icon" || linktags.item(i).rel == "shortcut icon") { | |
+ if (linktags.item(i).href) { | |
+ favicon_href = linktags.item(i).href; | |
+ data = getImageData(favicon_href); | |
+ if (data != null) | |
+ return data; | |
+ } | |
+ } | |
+ } | |
+ | |
+ return null; | |
+} | |
+ | |
pageParameters = function() { | |
var result; | |
result = {}; | |
result['title'] = document.title; | |
+ var favicon = getFaviconData(); | |
+ if (favicon != null) { | |
+ result['favicon'] = favicon; | |
+ } | |
+ | |
//<link rel="icon" href="http://example.com/favicon.ico" type="image/x-icon"> | |
return result; | |
diff --git a/src/js/Clipperz/PM/BookmarkletProcessor.js b/src/js/Clipperz/PM/BookmarkletProcessor.js | |
index 14b585f..262e787 100644 | |
--- a/src/js/Clipperz/PM/BookmarkletProcessor.js | |
+++ b/src/js/Clipperz/PM/BookmarkletProcessor.js | |
@@ -125,7 +125,11 @@ Clipperz.PM.BookmarkletProcessor.prototype = MochiKit.Base.update(null, { | |
'favicon': function() { | |
if (this._favicon == null) { | |
- this._favicon = "http://" + this.hostname() + "/favicon.ico"; | |
+ if (this.configuration().page.favicon) { | |
+ this._favicon = this.configuration().page.favicon; | |
+ } else { | |
+ this._favicon = "http://" + this.hostname() + "/favicon.ico"; | |
+ } | |
//MochiKit.Logging.logDebug("+++ favicon: " + this._favicon); | |
} | |
diff --git a/src/js/Clipperz/PM/Components/RecordDetail/DirectLoginsComponent.js b/src/js/Clipperz/PM/Components/RecordDetail/DirectLoginsComponent.js | |
index 3a469a4..807877d 100644 | |
--- a/src/js/Clipperz/PM/Components/RecordDetail/DirectLoginsComponent.js | |
+++ b/src/js/Clipperz/PM/Components/RecordDetail/DirectLoginsComponent.js | |
@@ -135,6 +135,7 @@ YAHOO.extendX(Clipperz.PM.Components.RecordDetail.DirectLoginsComponent, Clipper | |
newDirectLogin = new Clipperz.PM.DataModel.DirectLogin({record:this.record(), | |
label:configuration['page']['title'], | |
bookmarkletVersion:'0.2', | |
+ favicon:configuration['page']['favicon'], | |
// bookmarkletVersion:configuration['version'], | |
formData:configuration['form']}); | |
this.record().addDirectLogin(newDirectLogin); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment