From d3e5482f3ff74effa5b414c94aecaf4d22603dfc Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Mon, 19 Aug 2019 17:18:05 +0000 Subject: [PATCH] oops --- static/js/pageview_timer.js | 16 ++++++---------- templates/blogpost.html | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/static/js/pageview_timer.js b/static/js/pageview_timer.js index df7b3c5..2761396 100644 --- a/static/js/pageview_timer.js +++ b/static/js/pageview_timer.js @@ -12,7 +12,7 @@ (function() { let dnt = navigator.doNotTrack; - if (dnt == "1") { + if (dnt === "1") { return; } @@ -20,15 +20,11 @@ function logTime() { let stopTime = new Date(); - let message = JSON.stringify( - { - "path": window.location.pathname, - "start_time": startTime.toISOString(), - "end_time": stopTime.toISOString(), - } - ); - - window.navigator.sendBeacon("/api/pageview-timer", message); + window.navigator.sendBeacon("/api/pageview-timer", JSON.stringify({ + "path": window.location.pathname, + "start_time": startTime.toISOString(), + "end_time": stopTime.toISOString() + })); } window.addEventListener("pagehide", logTime, false); diff --git a/templates/blogpost.html b/templates/blogpost.html index 0ad0c63..7782f55 100644 --- a/templates/blogpost.html +++ b/templates/blogpost.html @@ -76,7 +76,7 @@ function share_on_mastodon() { var url = window.location.href; // get the page title from the og:title meta tag, if it exists. - var title = document.queryselectorall('meta[property="og:title"]')[0].getattribute("content"); + var title = document.querySelectorAll('meta[property="og:title"]')[0].getattribute("content"); // Otherwise, use the tag as the title if (!title) var title = document.getElementsByTagName("title")[0].innerHTML;