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.
This commit is contained in:
parent
9051af0f3d
commit
755e831891
1 changed files with 12 additions and 7 deletions
19
script.html
19
script.html
|
|
@ -1141,12 +1141,9 @@ function bindShare() {
|
||||||
// fine, but clients that sniff the extension from the URL string are not.
|
// fine, but clients that sniff the extension from the URL string are not.
|
||||||
// A filename query is accepted and ignored by the file service.
|
// A filename query is accepted and ignored by the file service.
|
||||||
function named(url) {
|
function named(url) {
|
||||||
if (!url) return "";
|
// Through our own domain so an open can be counted; a link straight to the
|
||||||
var pet = ((DATA && DATA.project && DATA.project.pet_name) || "video");
|
// file is invisible to us. 33 characters against 74.
|
||||||
var t = ((DATA && DATA.script && DATA.script.title) || "");
|
return location.origin + "/v/" + String(pid || "").slice(0, 8);
|
||||||
var slug = (pet + " " + t).toLowerCase().replace(/[^a-z0-9]+/g, "-")
|
|
||||||
.replace(/^-|-$/g, "").slice(0, 40) || "video";
|
|
||||||
return url + (url.indexOf("?") < 0 ? "?" : "&") + "v=" + slug + ".mp4";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function paint(r) {
|
function paint(r) {
|
||||||
|
|
@ -1169,8 +1166,16 @@ function bindShare() {
|
||||||
+ '<button type="button" class="btn ghost" id="sharecopy" style="margin-left:8px;margin-top:8px">Copy the message</button>'
|
+ '<button type="button" class="btn ghost" id="sharecopy" style="margin-left:8px;margin-top:8px">Copy the message</button>'
|
||||||
+ '<a class="btn ghost" style="margin-left:8px;display:inline-block;text-decoration:none" '
|
+ '<a class="btn ghost" style="margin-left:8px;display:inline-block;text-decoration:none" '
|
||||||
+ 'href="' + esc(r.image) + '" download>Download the picture</a>'
|
+ 'href="' + esc(r.image) + '" download>Download the picture</a>'
|
||||||
+ '<p class="foot" style="margin:12px 0 0;word-break:break-all">' + esc(link) + '</p>'
|
+ '<p class="foot" style="margin:12px 0 0;word-break:break-all">' + esc(link)
|
||||||
|
+ '<span id="viewcount"></span></p>'
|
||||||
+ '</div></div>';
|
+ '</div></div>';
|
||||||
|
api("share_link", { email: email, project_id: pid }).then(function (s) {
|
||||||
|
var el = document.getElementById("viewcount");
|
||||||
|
if (el && s && s.ok) {
|
||||||
|
el.innerHTML = '<br>Opened ' + (s.views || 0) + ' time'
|
||||||
|
+ ((s.views === 1) ? '' : 's') + '.';
|
||||||
|
}
|
||||||
|
});
|
||||||
var sl = document.getElementById("sharelink");
|
var sl = document.getElementById("sharelink");
|
||||||
if (sl) sl.onclick = async function () {
|
if (sl) sl.onclick = async function () {
|
||||||
var title = (DATA && DATA.script && DATA.script.title) || "A video";
|
var title = (DATA && DATA.script && DATA.script.title) || "A video";
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue