shorten displayed text if needed

This commit is contained in:
frederik
2025-08-17 12:35:48 +02:00
committed by Nachtzuster
parent ec7131391d
commit 99ef84a6c7
2 changed files with 28 additions and 6 deletions
+14 -1
View File
@@ -300,9 +300,22 @@ if (get_included_files()[0] === __FILE__) {
}
function shorten(u) {
if (u.length < 48) {
return u;
}
uend = u.slice(u.length - 16);
ustart = u.substr(0, 32);
var shorter = ustart + '...' + uend;
return shorter;
}
function setModalText(iter, title, text, authorlink, photolink, licenseurl) {
let text_display = shorten(text);
let authorlink_display = shorten(authorlink);
let licenseurl_display = shorten(licenseurl);
document.getElementById('modalHeading').innerHTML = "Photo: \""+decodeURIComponent(title.replaceAll("+"," "))+"\" Attribution";
document.getElementById('modalText').innerHTML = "<div><img style='border-radius:5px;max-height: calc(100vh - 15rem);display: block;margin: 0 auto;' src='"+photolink+"'></div><br><div style='white-space:nowrap'>Image link: <a target='_blank' href="+text+">"+text+"</a><br>Author link: <a target='_blank' href="+authorlink+">"+authorlink+"</a><br>License URL: <a href="+licenseurl+" target='_blank'>"+licenseurl+"</a></div>";
document.getElementById('modalText').innerHTML = "<div><img style='border-radius:5px;max-height: calc(100vh - 15rem);display: block;margin: 0 auto;' src='"+photolink+"'></div><br><div style='white-space:nowrap'>Image link: <a target='_blank' href="+text+">"+text_display+"</a><br>Author link: <a target='_blank' href="+authorlink+">"+authorlink_display+"</a><br>License URL: <a href="+licenseurl+" target='_blank'>"+licenseurl_display+"</a></div>";
last_photo_link = text;
showDialog();
}