PageSourceSearch

https://www.carlsberggroup.com/assets/scripts/components/favicon.js

js carlsberggroup.com collected 2026-09-24 08:47:00 UTC 1,818 bytes, 72 lines download raw bytes

1$(document).ready(function() {
2
3	// Creates png favicons dynamically from CMS-uploaded SVG.
4	// Note: Not great browser support - missing .ico format, manifest.json and browserconfig.xml mainly.
5
6	var carlsbergGroupFavicon = (function() {
7 
8		// 'Private'
9		var svgUrl = $('body').data('favicon');
10		var head = document.getElementsByTagName('head')[0];
11
12		function init(){
13
14			if(!svgUrl || typeof(Path2D) == 'undefined'){ 
15				return;
16			};
17
18			svgToImageURL(svgUrl);
19		}
20
21		function generateLinks(imageUrl){
22			// Construct various link objects (allows us to extend in future)
23			var link1 = { rel: 'apple-touch-icon', type: null, href: imageUrl, sizes: '180x180'};
24			var link2 = { rel: 'icon', type: 'image/png', href: imageUrl, sizes: '32x32'};
25			var link3 = { rel: 'icon', type: 'image/png', href: imageUrl, sizes: '16x16'};
26			
27			generateLink(link1);
28			generateLink(link2);
29			generateLink(link3);
30		}
31
32		function generateLink(linkData){
33			var link = document.createElement('link');
34			if(linkData.type){
35				link.type = linkData.type;
36			}
37			if(linkData.rel){
38				link.rel = linkData.rel;
39			}
40			if(linkData.href){
41				link.href = linkData.href;
42			}
43			if(linkData.sizes){
44				link.sizes = linkData.sizes;
45			}
46			head.appendChild(link);
47		}
48
49		function svgToImageURL(svgPath){
50			var img = new Image();
51			img.src = svgPath;
52
53			img.onload = function() {
54				var canvas = document.createElement('canvas');              
55				var ctx = canvas.getContext('2d');
56				canvas.width = this.width;
57				canvas.height = this.height;
58				ctx.drawImage(this, 0, 0);
59				var dataURL = canvas.toDataURL('image/png');
60				generateLinks(dataURL);
61			};
62		};
63
64		// 'Public'
65		return {
66			init: init
67		};
68
69	})();
70 
71	carlsbergGroupFavicon.init();
72});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.