Skip to content

Commit

Permalink
Allow for alternate language control for URL titles.
Browse files Browse the repository at this point in the history
  • Loading branch information
craigsapp committed Sep 8, 2024
1 parent 3a40542 commit c30abaa
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion _includes/vhv-scripts/menu/makePdfIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,38 @@

function makePdfIcon(url, title) {
title = title.replace(/"/g, "'");
var output = "<div title=\"" + title + "\" ";

let lindex = {};
// let lindexArray = [];
const regex = /@([A-Z]{2})\{(.*?)\}/g;
let match;

while ((match = regex.exec(title)) !== null) {
let lang = match[1];
let title = match[2];
console.warn("LANG", lang, "TITLE", title);
lindex[lang] = title;
// let obj = {};
// obj.lang = lang;
// obj.title = title;
// lindexArray.push(obj);
}

let newtitle = "";
if (lindex[LANGUAGE]) {
newtitle = lindex[LANGUAGE];
} else if (lindex.EN) {
newtitle = lindex[EN];
} else {
newtitle = title;
}

let output = "<div title=\"" + newtitle + "\" ";
output += "style='margin-left:10px !important; margin-right:0px !important; font-size:100%' ";
output += "onclick='openPdfAtBottomThirdOfScreen(\"" + url + "\")' ";
output += "class='nav-icon fas fa-file-pdf'></div>";
return output;

}


0 comments on commit c30abaa

Please sign in to comment.