New Upstream Snapshot - libjs-favico.js

Ready changes

Summary

Merged new upstream version: 0.3.10+git20161218.1.6a3f430~dfsg1 (was: 0.3.10~dfsg1).

Resulting package

Built on 2023-01-18T23:30 (took 3m53s)

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-snapshots libjs-favico.js

Lintian Result

Diff

diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index e35b038..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-node_modules
-npm-debug.log
-.settings
-.gitignore
\ No newline at end of file
diff --git a/MIT-LICENSE.txt b/MIT-LICENSE.txt
index 13644dc..30c9247 100644
--- a/MIT-LICENSE.txt
+++ b/MIT-LICENSE.txt
@@ -1,4 +1,4 @@
-Copyright (c) 2011-2015 Miroslav Magda, http://ejci.net/
+Copyright (c) 2011-2016 Miroslav Magda, http://ejci.net/
 
 Permission is hereby granted, free of charge, to any person obtaining
 a copy of this software and associated documentation files (the
diff --git a/debian/changelog b/debian/changelog
index fc4b7f4..12af8ae 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+libjs-favico.js (0.3.10+git20161218.1.6a3f430~dfsg1-1) UNRELEASED; urgency=low
+
+  * New upstream snapshot.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Wed, 18 Jan 2023 23:28:26 -0000
+
 libjs-favico.js (0.3.10~dfsg1-6) unstable; urgency=medium
 
   * Team upload
diff --git a/favico.js b/favico.js
index 530c986..0df45b4 100644
--- a/favico.js
+++ b/favico.js
@@ -1,7 +1,8 @@
 /**
- * @license MIT
+ * @license MIT or GPL-2.0
  * @fileOverview Favico animations
  * @author Miroslav Magda, http://blog.ejci.net
+ * @source: https://github.com/ejci/favico.js
  * @version 0.3.10
  */
 
@@ -15,11 +16,13 @@
  *    textColor : '#fff',
  *    fontFamily : 'sans-serif',
  *    fontStyle : 'bold',
- *    position : 'down',
  *    type : 'circle',
+ *    position : 'down',
  *    animation : 'slide',
+ *    elementId: false,
+ *    element: null,
  *    dataUrl: function(url){},
- *    win: top
+ *    win: window
  * });
  */
 (function () {
@@ -36,6 +39,7 @@
 			position: 'down', // down, up, left, leftup (upleft)
 			animation: 'slide',
 			elementId: false,
+			element: null,
 			dataUrl: false,
 			win: window
 		};
@@ -69,38 +73,41 @@
 			var isUp = _opt.position.indexOf('up') > -1;
 			var isLeft = _opt.position.indexOf('left') > -1;
 
-			//transform animation
+			//transform the animations
 			if (isUp || isLeft) {
-				for (var i = 0; i < animation.types['' + _opt.animation].length; i++) {
-					var step = animation.types['' + _opt.animation][i];
+				for (var a in animation.types) {
+					for (var i = 0; i < animation.types[a].length; i++) {
+						var step = animation.types[a][i];
 
-					if (isUp) {
-						if (step.y < 0.6) {
-							step.y = step.y - 0.4;
-						} else {
-							step.y = step.y - 2 * step.y + (1 - step.w);
+						if (isUp) {
+							if (step.y < 0.6) {
+								step.y = step.y - 0.4;
+							} else {
+								step.y = step.y - 2 * step.y + (1 - step.w);
+							}
 						}
-					}
 
-					if (isLeft) {
-						if (step.x < 0.6) {
-							step.x = step.x - 0.4;
-						} else {
-							step.x = step.x - 2 * step.x + (1 - step.h);
+						if (isLeft) {
+							if (step.x < 0.6) {
+								step.x = step.x - 0.4;
+							} else {
+								step.x = step.x - 2 * step.x + (1 - step.h);
+							}
 						}
-					}
 
-					animation.types['' + _opt.animation][i] = step;
+						animation.types[a][i] = step;
+					}
 				}
 			}
 			_opt.type = (type['' + _opt.type]) ? _opt.type : _def.type;
 
-			_orig = link.getIcon();
+			_orig = link. getIcons();
 			//create temp canvas
 			_canvas = document.createElement('canvas');
 			//create temp image
 			_img = document.createElement('img');
-			if (_orig.hasAttribute('href')) {
+			var lastIcon = _orig[_orig.length - 1];
+			if (lastIcon.hasAttribute('href')) {
 				_img.setAttribute('crossOrigin', 'anonymous');
 				//get width/height
 				_img.onload = function () {
@@ -111,19 +118,16 @@
 					_context = _canvas.getContext('2d');
 					icon.ready();
 				};
-				_img.setAttribute('src', _orig.getAttribute('href'));
+				_img.setAttribute('src', lastIcon.getAttribute('href'));
 			} else {
-				_img.onload = function () {
-					_h = 32;
-					_w = 32;
-					_img.height = _h;
-					_img.width = _w;
-					_canvas.height = _h;
-					_canvas.width = _w;
-					_context = _canvas.getContext('2d');
-					icon.ready();
-				};
-				_img.setAttribute('src', '');
+				_h = 32;
+				_w = 32;
+				_img.height = _h;
+				_img.width = _w;
+				_canvas.height = _h;
+				_canvas.width = _w;
+				_context = _canvas.getContext('2d');
+				icon.ready();
 			}
 
 		};
@@ -369,6 +373,17 @@
 				_readyCb();
 			}
 		};
+		/**
+		 * Set the icon from a source url. Won't work with badges.
+		 */
+		var rawImageSrc = function (url) {
+			_readyCb = function() {
+				link.setIconSrc(url);
+			};
+			if (_ready) {
+				_readyCb();
+			}
+		};
 		/**
 		 * Set video as icon
 		 */
@@ -441,6 +456,26 @@
 
 		};
 
+		var setOpt = function (key, value) {
+			var opts = key;
+			if (!(value == null && Object.prototype.toString.call(key) == '[object Object]')) {
+				opts = {};
+				opts[key] = value;
+			}
+
+			var keys = Object.keys(opts);
+			for (var i = 0; i < keys.length; i++) {
+				if (keys[i] == 'bgColor' || keys[i] == 'textColor') {
+					_opt[keys[i]] = hexToRgb(opts[keys[i]]);
+				} else {
+					_opt[keys[i]] = opts[keys[i]];
+				}
+			}
+
+			_queue.push(_lastBadge);
+			icon.start();
+		};
+
 		/**
 		 * Draw video to context and repeat :)
 		 */
@@ -463,40 +498,46 @@
 
 		var link = {};
 		/**
-		 * Get icon from HEAD tag or create a new <link> element
+		 * Get icons from HEAD tag or create a new <link> element
 		 */
-		link.getIcon = function () {
-			var elm = false;
+		link.getIcons = function () {
+			var elms = [];
 			//get link element
-			var getLink = function () {
-				var link = _doc.getElementsByTagName('head')[0].getElementsByTagName('link');
-				for (var l = link.length, i = (l - 1); i >= 0; i--) {
-					if ((/(^|\s)icon(\s|$)/i).test(link[i].getAttribute('rel'))) {
-						return link[i];
+			var getLinks = function () {
+				var icons = [];
+				var links = _doc.getElementsByTagName('head')[0].getElementsByTagName('link');
+				for (var i = 0; i < links.length; i++) {
+					if ((/(^|\s)icon(\s|$)/i).test(links[i].getAttribute('rel'))) {
+						icons.push(links[i]);
 					}
 				}
-				return false;
+				return icons;
 			};
 			if (_opt.element) {
-				elm = _opt.element;
+				elms = [_opt.element];
 			} else if (_opt.elementId) {
 				//if img element identified by elementId
-				elm = _doc.getElementById(_opt.elementId);
-				elm.setAttribute('href', elm.getAttribute('src'));
+				elms = [_doc.getElementById(_opt.elementId)];
+				elms[0].setAttribute('href', elms[0].getAttribute('src'));
 			} else {
 				//if link element
-				elm = getLink();
-				if (elm === false) {
-					elm = _doc.createElement('link');
-					elm.setAttribute('rel', 'icon');
-					_doc.getElementsByTagName('head')[0].appendChild(elm);
+				elms = getLinks();
+				if (elms.length === 0) {
+					elms = [_doc.createElement('link')];
+					elms[0].setAttribute('rel', 'icon');
+					_doc.getElementsByTagName('head')[0].appendChild(elms[0]);
 				}
 			}
-			elm.setAttribute('type', 'image/png');
-			return elm;
+			elms.forEach(function(item) {
+				item.setAttribute('type', 'image/png');
+			});
+			return elms;
 		};
 		link.setIcon = function (canvas) {
 			var url = canvas.toDataURL('image/png');
+			link.setIconSrc(url);
+		};
+		link.setIconSrc = function (url) {
 			if (_opt.dataUrl) {
 				//if using custom exporter
 				_opt.dataUrl(url);
@@ -514,21 +555,24 @@
 				if (_browser.ff || _browser.opera) {
 					//for FF we need to "recreate" element, atach to dom and remove old <link>
 					//var originalType = _orig.getAttribute('rel');
-					var old = _orig;
-					_orig = _doc.createElement('link');
+					var old = _orig[_orig.length - 1];
+					var newIcon = _doc.createElement('link');
+					_orig = [newIcon];
 					//_orig.setAttribute('rel', originalType);
 					if (_browser.opera) {
-						_orig.setAttribute('rel', 'icon');
+						newIcon.setAttribute('rel', 'icon');
 					}
-					_orig.setAttribute('rel', 'icon');
-					_orig.setAttribute('type', 'image/png');
-					_doc.getElementsByTagName('head')[0].appendChild(_orig);
-					_orig.setAttribute('href', url);
+					newIcon.setAttribute('rel', 'icon');
+					newIcon.setAttribute('type', 'image/png');
+					_doc.getElementsByTagName('head')[0].appendChild(newIcon);
+					newIcon.setAttribute('href', url);
 					if (old.parentNode) {
 						old.parentNode.removeChild(old);
 					}
 				} else {
-					_orig.setAttribute('href', url);
+					_orig.forEach(function(icon) {
+						icon.setAttribute('href', url);
+					});
 				}
 			}
 		};
@@ -831,7 +875,9 @@
 			badge: badge,
 			video: video,
 			image: image,
+			rawImageSrc: rawImageSrc,
 			webcam: webcam,
+			setOpt: setOpt,
 			reset: icon.reset,
 			browser: {
 				supported: _browser.supported
diff --git a/package.json b/package.json
index 7929001..bf0b82f 100644
--- a/package.json
+++ b/package.json
@@ -15,7 +15,7 @@
     "badge"
   ],
   "author": "Miroslav Magda <magda.miroslav@gmail.com>",
-  "license": "MIT",
+  "license": "MIT or GPL-2.0",
   "bugs": {
     "url": "https://github.com/ejci/favico.js/issues"
   },
diff --git a/readme.md b/readme.md
index 342a900..4c35787 100644
--- a/readme.md
+++ b/readme.md
@@ -1,3 +1,4 @@
+[![volkswagen status](https://auchenberg.github.io/volkswagen/volkswargen_ci.svg?v=1)](https://github.com/auchenberg/volkswagen)
 # favico.js
 More info [here](http://lab.ejci.net/favico.js/).
 
@@ -72,3 +73,11 @@ All code is open source and dual licensed under GPL and MIT. Check the individua
 
 #### 0.1.0
 * proof of concept
+
+## Browser support
+* Chrome: Yes
+* Firefox: Yes
+* Opera: Yes
+* IE: No
+* Edge: No
+* Safari: No (Safari hides favicons)

Debdiff

File lists identical (after any substitutions)

No differences were encountered in the control files

More details

Full run details