From 755e8318915cd547f83a6d1142c8436087b19572 Mon Sep 17 00:00:00 2001 From: gator Date: Wed, 9 Sep 2026 01:14:55 +0000 Subject: [PATCH] Share the short link here too, and show the view count The message under the picture now carries the tracked link rather than the raw file, and the card reports how many times it has been opened. --- script.html | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/script.html b/script.html index 64546d5..4672046 100644 --- a/script.html +++ b/script.html @@ -1141,12 +1141,9 @@ function bindShare() { // fine, but clients that sniff the extension from the URL string are not. // A filename query is accepted and ignored by the file service. function named(url) { - if (!url) return ""; - var pet = ((DATA && DATA.project && DATA.project.pet_name) || "video"); - var t = ((DATA && DATA.script && DATA.script.title) || ""); - var slug = (pet + " " + t).toLowerCase().replace(/[^a-z0-9]+/g, "-") - .replace(/^-|-$/g, "").slice(0, 40) || "video"; - return url + (url.indexOf("?") < 0 ? "?" : "&") + "v=" + slug + ".mp4"; + // Through our own domain so an open can be counted; a link straight to the + // file is invisible to us. 33 characters against 74. + return location.origin + "/v/" + String(pid || "").slice(0, 8); } function paint(r) { @@ -1169,8 +1166,16 @@ function bindShare() { + '' + 'Download the picture' - + '

' + esc(link) + '

' + + '

' + esc(link) + + '

' + ''; + api("share_link", { email: email, project_id: pid }).then(function (s) { + var el = document.getElementById("viewcount"); + if (el && s && s.ok) { + el.innerHTML = '
Opened ' + (s.views || 0) + ' time' + + ((s.views === 1) ? '' : 's') + '.'; + } + }); var sl = document.getElementById("sharelink"); if (sl) sl.onclick = async function () { var title = (DATA && DATA.script && DATA.script.title) || "A video";