Use the rendered share address here too
The link in the message under the picture now comes from share_link, which returns the worker-rendered page rather than a guessed path on this site.
This commit is contained in:
parent
6b7ef08fcc
commit
f6f1335fff
1 changed files with 11 additions and 8 deletions
19
script.html
19
script.html
|
|
@ -1140,11 +1140,10 @@ function bindShare() {
|
|||
// correct (video/mp4, filename=final.mp4) so anything that reads them is
|
||||
// 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) {
|
||||
// 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);
|
||||
}
|
||||
// Filled in by share_link, which owns the address. A link straight to the
|
||||
// file would be invisible to us; this one is counted server side.
|
||||
var SHARE_LINK = "";
|
||||
function named(url) { return SHARE_LINK || ""; }
|
||||
|
||||
function paint(r) {
|
||||
var kb = Math.round((r.bytes || 0) / 1024);
|
||||
|
|
@ -1170,11 +1169,15 @@ function bindShare() {
|
|||
+ '<span id="viewcount"></span></p>'
|
||||
+ '</div></div>';
|
||||
api("share_link", { email: email, project_id: pid }).then(function (s) {
|
||||
if (!(s && s.ok)) return;
|
||||
SHARE_LINK = s.url || "";
|
||||
var el = document.getElementById("viewcount");
|
||||
if (el && s && s.ok) {
|
||||
el.innerHTML = '<br>Opened ' + (s.views || 0) + ' time'
|
||||
+ ((s.views === 1) ? '' : 's') + '.';
|
||||
if (el) {
|
||||
el.innerHTML = '<br>' + esc(SHARE_LINK) + '<br>Opened ' + (s.views || 0)
|
||||
+ ' time' + ((s.views === 1) ? '' : 's') + '.';
|
||||
}
|
||||
var t = document.getElementById("sharemsg");
|
||||
if (t && SHARE_LINK) t.value = t.value.replace(/https?:\/\/\S+/, SHARE_LINK);
|
||||
});
|
||||
var sl = document.getElementById("sharelink");
|
||||
if (sl) sl.onclick = async function () {
|
||||
|
|
|
|||
Loading…
Reference in a new issue