Add "onlyLinkExtensions" variable in template to allow customizing what files to link

This commit is contained in:
rlv-dan 2020-04-28 19:12:52 +02:00
parent a622e419a1
commit 2ef355bb2d

View File

@ -773,6 +773,7 @@
var originalHash = location.hash.replace(/#/,""); var originalHash = location.hash.replace(/#/,"");
var SelectedFolderID = "-1"; var SelectedFolderID = "-1";
var currentView; var currentView;
var onlyLinkExtensions = []; // example: ["jpg","png"]
/* --- Init --- */ /* --- Init --- */
@ -1074,6 +1075,9 @@
if( linkFiles ) if( linkFiles )
{ {
var ext = file_tmp.split('.').pop();
if(onlyLinkExtensions.length === 0 || onlyLinkExtensions.indexOf(ext) !== -1) {
file_tmp = linkProtocol + linkRoot + dir_tmp.replace("\\","/") + SearchFilenames[index][3] + "\">"; file_tmp = linkProtocol + linkRoot + dir_tmp.replace("\\","/") + SearchFilenames[index][3] + "\">";
if( navigator.userAgent.toLowerCase().indexOf("msie") !== -1 && linkProtocol.indexOf("file:") !== -1 ) if( navigator.userAgent.toLowerCase().indexOf("msie") !== -1 && linkProtocol.indexOf("file:") !== -1 )
{ {
@ -1098,6 +1102,7 @@
file_tmp = "<a href=\"" + file_tmp + SearchFilenames[index][3] + "</a>"; file_tmp = "<a href=\"" + file_tmp + SearchFilenames[index][3] + "</a>";
} }
}
var located_in = SearchLocations[index]; var located_in = SearchLocations[index];
if( located_in === "" ) located_in = "[.]" if( located_in === "" ) located_in = "[.]"
@ -1231,6 +1236,9 @@
if( dir_tmp != "" ) dir_tmp += "/"; if( dir_tmp != "" ) dir_tmp += "/";
if( linkFiles ) if( linkFiles )
{ {
var ext = file_tmp.split('.').pop();
if(onlyLinkExtensions.length === 0 || onlyLinkExtensions.indexOf(ext) !== -1) {
file_tmp = linkProtocol + linkRoot + dir_tmp + sTmp[0] + "\">"; file_tmp = linkProtocol + linkRoot + dir_tmp + sTmp[0] + "\">";
if( navigator.userAgent.toLowerCase().indexOf("msie") !== -1 && linkProtocol.indexOf("file:") !== -1 ) if( navigator.userAgent.toLowerCase().indexOf("msie") !== -1 && linkProtocol.indexOf("file:") !== -1 )
{ {
@ -1255,6 +1263,7 @@
file_tmp = "<a href=\"" + file_tmp + sTmp[0] + "</a>"; file_tmp = "<a href=\"" + file_tmp + sTmp[0] + "</a>";
} }
}
var timestamp = timestampToDate(sTmp[2]); var timestamp = timestampToDate(sTmp[2]);
@ -1600,7 +1609,6 @@
}; };
}; };
// Save export to local file. Based on https://stackoverflow.com/a/29304414/1087811 // Save export to local file. Based on https://stackoverflow.com/a/29304414/1087811
function downloadToFile(content, fileName, mimeType) { function downloadToFile(content, fileName, mimeType) {
var a = document.createElement('a'); var a = document.createElement('a');