Update DefaultPageLayout.php

This commit is contained in:
Squidly271
2024-11-02 12:07:34 -04:00
committed by GitHub
parent 092c6e0445
commit ca85424b7a

View File

@@ -1112,40 +1112,65 @@ $(function() {
$('form').append($('<input>').attr({type:'hidden', name:'csrf_token', value:csrf_token}));
});
var gui_pages_available = [];
<?
$gui_pages = glob("/usr/local/emhttp/plugins/*/*.page");
array_walk($gui_pages,function($value,$key){ ?>
gui_pages_available.push('<?=basename($value,".page")?>'); <?
});
?>
function isValidURL(url) {
try {
new URL(url);
return true;
} catch (err) {
return false;
}
}
$('body').on("click","a", function(e) {
href = $(this).attr("href").trim();
target = $(this).attr("target");
if ( href ) {
if ( href.indexOf("/") == 0 ) { // all internal links start with "/"
if ( href.match('https://[^\.]*.(my)?unraid.net/') || href.indexOf("https://unraid.net/") == 0 || href == "https://unraid.net" || href.indexOf("http://lime-technology.com") == 0) {
return;
}
if ( href.match('https://[^\.]*.(my)?unraid.net/') || href.indexOf("https://unraid.net/") == 0 || href == "https://unraid.net" || href.indexOf("http://lime-technology.com/") == 0) {
return;
} else {
if (href !== "#" && href.indexOf("javascript") !== 0) {
e.preventDefault();
swal({
title: "<?=_('External Link')?>",
text: "<?=_('Clicking OK will take you to a 3rd party website not associated with Limetech')?><br><br><b>"+href,
html: true,
type: 'warning',
showCancelButton: true,
showConfirmButton: true,
cancelButtonText: "<?=_('Cancel')?>",
confirmButtonText: "<?=_('OK')?>"
},function(isConfirm) {
if (isConfirm) {
var popupOpen = window.open(href,target);
if ( !popupOpen || popupOpen.closed || typeof popupOpen == "undefined" ) {
var popupWarning = addBannerWarning("<?=_('Popup Blocked.');?>");
setTimeout(function() {
removeBannerWarning(popupWarning);}
,10000);
}
}
});
}
if (href !== "#" && href.indexOf("javascript") !== 0) {
if ( ! isValidURL(href) ) {
if ( href.indexOf("/") == 0 ) { // all internal links start with "/"
return;
}
var baseURLpage = href.split("/");
if ( gui_pages_available.includes(baseURLpage[0]) ) {
return;
}
}
if ( $(this).hasClass("localURL") ) {
return;
}
e.preventDefault();
swal({
title: "<?=_('External Link')?>",
text: "<span title='"+href+"'><?=_('Clicking OK will take you to a 3rd party website not associated with Limetech')?><br><br><b>"+href+"</span>",
html: true,
type: 'warning',
showCancelButton: true,
showConfirmButton: true,
cancelButtonText: "<?=_('Cancel')?>",
confirmButtonText: "<?=_('OK')?>"
},function(isConfirm) {
if (isConfirm) {
var popupOpen = window.open(href,target);
if ( !popupOpen || popupOpen.closed || typeof popupOpen == "undefined" ) {
var popupWarning = addBannerWarning("<?=_('Popup Blocked.');?>");
setTimeout(function() {
removeBannerWarning(popupWarning);}
,10000);
}
}
});
}
}
});