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";