ybbond

My site. The main domain
Log | Files | Refs | README | LICENSE | CC-LICENSE

commit 05a8beaf9ccfd349809ad7ac5dcd7a1b223afd0e
parent 61d6178f7c8aea61ea70fb92a9dd9e55a9608965
Author: Yohanes Bandung Bondowoso <hi@ybbond.id>
Date:   Thu, 20 May 2021 01:54:47 +0700

refactor: update goatcounter binary

Diffstat:
Mlayouts/partials/components/goatcounter.html | 12++++++++----

1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/layouts/partials/components/goatcounter.html b/layouts/partials/components/goatcounter.html
@@ -22,6 +22,8 @@ window.goatcounter = {endpoint: 'https://stats.ybbond.id/count'}
 				window.goatcounter[k] = set[k]
 	}
 
+	var enc = encodeURIComponent
+
 	// Get all data we're going to send off to the counter endpoint.
 	var get_data = function(vars) {
 		var data = {
@@ -73,7 +75,7 @@ window.goatcounter = {endpoint: 'https://stats.ybbond.id/count'}
 		var p = []
 		for (var k in obj)
 			if (obj[k] !== '' && obj[k] !== null && obj[k] !== undefined && obj[k] !== false)
-				p.push(encodeURIComponent(k) + '=' + encodeURIComponent(obj[k]))
+				p.push(enc(k) + '=' + enc(obj[k]))
 		return '?' + p.join('&')
 	}
 
@@ -118,7 +120,7 @@ window.goatcounter = {endpoint: 'https://stats.ybbond.id/count'}
 			return 'visibilityState'
 		if (!goatcounter.allow_frame && location !== parent.location)
 			return 'frame'
-		if (!goatcounter.allow_local && location.hostname.match(/(localhost$|^127\.|^10\.|^172\.(1[6-9]|2[0-9]|3[0-1])\.|^192\.168\.)/))
+		if (!goatcounter.allow_local && location.hostname.match(/(localhost$|^127\.|^10\.|^172\.(1[6-9]|2[0-9]|3[0-1])\.|^192\.168\.|^0\.0\.0\.0$)/))
 			return 'localhost'
 		if (!goatcounter.allow_local && location.protocol === 'file:')
 			return 'localfile'
@@ -206,9 +208,11 @@ window.goatcounter = {endpoint: 'https://stats.ybbond.id/count'}
 			opt.path   = opt.path   || get_path()
 			opt.attr   = opt.attr   || {width: '200', height: (opt.no_branding ? '60' : '80')}
 
-			opt.attr['src'] = get_endpoint() + 'er/' + encodeURIComponent(opt.path) + '.' + opt.type + '?'
+			opt.attr['src'] = get_endpoint() + 'er/' + enc(opt.path) + '.' + enc(opt.type) + '?'
 			if (opt.no_branding) opt.attr['src'] += '&no_branding=1'
-			if (opt.style)       opt.attr['src'] += '&style=' + encodeURIComponent(opt.style)
+			if (opt.style)       opt.attr['src'] += '&style=' + enc(opt.style)
+			if (opt.start)       opt.attr['src'] += '&start=' + enc(opt.start)
+			if (opt.end)         opt.attr['src'] += '&end='   + enc(opt.end)
 
 			var tag = {png: 'img', svg: 'img', html: 'iframe'}[opt.type]
 			if (!tag)