This commit is contained in:
Squidly271 2021-12-29 12:42:11 -05:00
parent 1865ba4ed4
commit 39030c90bc
5 changed files with 258 additions and 35 deletions

View File

@ -134,9 +134,6 @@ function tr($string,$ret=false) {
</script>
<?endif;?>
<script>
String.prototype.basename = function() {return this.split('/').reverse()[0];}
String.prototype.escapeHTML = function() {return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');}
var searchBoxInput;
var searchBoxAwesomplete;
var pluginInstallIntervalTimer;
@ -229,7 +226,9 @@ $(function(){
$(".sidebarClose").on("click",function(e) {
closeSidebar();
});
$(".mainArea").on("click",".actionsButtonContext,.actionsButton,.supportButton,.supportButtonCardContext",function() {
data.actions = true;
});
$("#searchBox").keydown(function(e) {
if (e.which === 13) {
searchBoxAwesomplete.close();
@ -349,25 +348,29 @@ $(function(){
}
});
$("body").on("click",".repoPopup,.ca_repoinfo,.ca_reporeadmore,.ca_repoFromPopUp,.cardDescriptionRepo", function() {
var repository = $(this).data("repository");
showRepoPopup(repository);
});
$('body').on("click",".ca_appPopup",function() {
if ( $(this).hasClass("dockerCardBackground") || $(this).hasClass("noClick") )
return;
if ( $(".dropdown-menu").is(":visible") ) {
$(".dropdown-menu").hide();
$('body').on("click",".ca_holder",function(event) {
if (data.actions) {
data.actions = false;
return;
}
data.actions = false;
event.stopPropagation();
if ( $(this).hasClass("ca_repoPopup") ) {
var repository = $(this).data("repository");
showRepoPopup(repository);
} else {
if ( $(this).hasClass("dockerCardBackground") || $(this).hasClass("noClick") )
return;
if ( $(".dropdown-menu").is(":visible") ) {
$(".dropdown-menu").hide();
return;
}
var apppath = $(this).data("apppath");
var appname = $(this).data("appname");
appname = stripTags(appname);
showSidebarApp(apppath,appname);
var apppath = $(this).data("apppath");
var appname = $(this).data("appname");
appname = stripTags(appname);
showSidebarApp(apppath,appname);
}
});
$('body').on("click",".dockerPopup", function() {
@ -984,7 +987,8 @@ function installPlugin(pluginURL,update=false,comment="") {
});
} else {
openBox('/plugins/community.applications/scripts/pluginInstall.php&arg1='+type+'&arg2='+pluginURL,title,600,900,true,"OpenSidebarAndRefreshDisplay");
}
}
}
function OpenSidebarAndRefreshDisplay() {
@ -1109,6 +1113,10 @@ function postUninstallPlugin() {
enableSearch();
}
String.prototype.basename = function() {
return this.split('/').reverse()[0];
}
function uninstallDocker(application,humanName) {
closeSidebar();
disableSearch();
@ -1208,6 +1216,7 @@ function pinnedApps() {
}
function displayTags(leadTemplate,rename=false) {
event.stopPropagation();
closeSidebar();
post({action:'displayTags',leadTemplate:leadTemplate,noSpinner:true,rename:rename},function(result) {
disableSearch();
@ -1231,7 +1240,6 @@ function displayTags(leadTemplate,rename=false) {
function makePlural(string,count) {
return ( (count > 1) || (count == 0) ) ? string + "s" : string;
}
function selectAllPrevious() {
$(".ca_multiselect").each(function() {
$(this).prop("checked",true);
@ -1504,7 +1512,7 @@ function saveState() {
$.cookie("ca_selectedMenu",selectedMenu);
$.cookie("ca_filter",$("#searchBox").val());
$.cookie("ca_categoryName",$(".categoryMenuName").html());
}
}
function restoreState() {
swalBackground("transparent");
@ -1530,6 +1538,7 @@ function restoreState() {
$("#searchButton").removeClass("fa-search").addClass("fa-remove");
var ca_sortIcon = $.cookie("ca_sortIcon");
// enableIcon("#sortIcon",ca_sortIcon);
post({action:"getSortOrder"},function(sortOrder) {
$(".sortIcons").removeClass("enabledIcon");
$(".sortIcons").each(function() {
@ -1601,6 +1610,10 @@ function addDockerWarning(enableDisable) {
}
}
String.prototype.escapeHTML = function() {
return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
}
function post(options,callback) {
var URL = "/plugins/<?=$plugin?>/include/exec.php";
@ -1794,11 +1807,13 @@ function CAswitchLanguage(language) {
}
function installLanguage(languageURL,language) {
disableSearch();
openBox('/plugins/community.applications/scripts/languageInstall.sh&arg1=install&arg2='+languageURL,"<?tr('Install Language Pack')?>",600,900,true,"postLanguageRefresh");
}
function updateLanguage(language) {
disableSearch();
$.cookie("updateLanguage",language);
openBox('/plugins/community.applications/scripts/languageInstall.sh&arg1=update&arg2='+language,"<?tr('Update Language Pack')?>",600,900,true,"postUpdateLanguage");
@ -1817,10 +1832,10 @@ function postUpdateLanguage() {
refreshDisplay();
}
}
function removeLanguage(language) {
closeSidebar();
openBox('/plugins/community.applications/scripts/languageInstall.sh&arg1=remove&arg2='+language,"<?tr('Remove Language Pack')?>",600,900,true,"postLanguageRemove");
}
function postLanguageRefresh() {
@ -1890,6 +1905,7 @@ function setFavourite(button) {
}
function popupInstallXML(xml,type,comment="") {
event.stopPropagation();
saveState();
if ( $.trim(comment) ) {
swal({

View File

@ -0,0 +1,205 @@
Menu='Buttons'
Link='nav-user'
---
<?
###############################################################
# #
# Community Applications copyright 2015-2021, Andrew Zawadzki #
# Licenced under GPLv2 #
# #
###############################################################
### Note: This file is only needed on OS versions less than 6.8.3
?>
<? if ( ! file_exists("/usr/local/emhttp/plugins/dynamix.plugin.manager/PluginHelpers.page") ) : ?>
<style>
.ca_plugin_notice{position:fixed;top:1px;left:0;}
.ca_element_notice{padding-right:20px;width:100%;height:40px;line-height:40px;color:#e68a00;background:#feefb3;border-bottom:#e68a00 1px solid;text-align:center;font-size:1.4rem;z-index:900;display:none;}
.ca_PluginUpdateDismiss{float:right;margin-right:20px;cursor:pointer;}
.ca_pluginUpdateInfo{cursor:pointer;}
.ca_PluginUpdateInstall{cursor:pointer;}
a.bannerInfo {cursor:pointer;text-decoration:none;}
.bannerInfo::before {content:"\f05a";font-family:fontAwesome;color:#e68a00;}
</style>
<script>
var ca_PluginUpdatePLG;
var ca_PluginUpdateElement;
var ca_WarningItems = [];
var currentWarning = 0;
warningInterval = false;
$(function() {
$(".upgrade_notice").after("<div class='ca_plugin_notice ca_element_notice'></div>");
});
if ( typeof caPluginUpdateCheck !== "function" ) {
function ca_PluginUpdate_openBox(cmd,title,height,width,load,func) {
// open shadowbox window (run in foreground)
var run = cmd.split('?')[0].substr(-4)=='.php' ? cmd : '/logging.htm?cmd='+cmd+'&csrf_token=<?=$var['csrf_token']?>';
var options = load ? {modal:true,onClose:function(){ eval(func); }} : {modal:true};
Shadowbox.open({content:run, player:'iframe', title:title, height:height, width:width, options:options});
}
function ca_hidePluginUpdate(version) {
$.cookie(ca_PluginUpdatePLG,version);
$(ca_PluginUpdateElement).hide();
}
function ca_pluginUpdateInstall(plugin) {
ca_PluginUpdate_openBox("/plugins/community.applications/scripts/installPluginUpdate.sh&arg1="+plugin,"Installing Update",600,900,true,"window.location.reload()");
}
function ca_pluginUpdateShowInfo(cmd,title,height,width,load,func,id) {
// open shadowbox window (run in foreground)
var run = cmd.split('?')[0].substr(-4)=='.php' ? cmd : '/logging.htm?cmd='+cmd+'&csrf_token=<?=$var['csrf_token']?>';
var options = load ? (func ? {modal:true,onClose:function(){setTimeout(func+'('+'"'+(id||'')+'")',0);}} : {modal:false,onClose:function(){location=location;}}) : {modal:false};
Shadowbox.open({content:run, player:'iframe', title:title, height:Math.min(height,screen.availHeight), width:Math.min(width,screen.availWidth), options:options});
}
function ca_pluginUpdate_evaluateBoolean(str) {
regex=/^\s*(true|1|on)\s*$/i
return regex.test(str);
}
function caPluginUpdateCheck(plugin,options=[],callback) {
ca_PluginUpdatePLG = plugin;
pluginFilename = plugin.substr(0, plugin.lastIndexOf("."));
console.time("checkPlugin "+plugin);
console.log("checkPlugin "+plugin);
$.post("/plugins/community.applications/scripts/PluginAPI.php",{action:'checkPlugin',options:{plugin:plugin}},function(caAPIresult) {
console.groupCollapsed("Result checkPlugin "+plugin);
console.log(caAPIresult);
console.timeEnd("checkPlugin "+plugin);
console.groupEnd();
var result = JSON.parse(caAPIresult);
if ( options.debug == true ) result.updateAvailable = true;
var name = options.name ? options.name : "this plugin ("+plugin+")";
if ( ! options.element ) {
if ( result.updateAvailable ) {
var HTML = "An upgrade to "+name+" is available. Click <a class='ca_PluginUpdateInstall' onclick='ca_pluginUpdateInstall(&quot;"+plugin+"&quot;);'>here</a> to install version "+result.version+" <a class='bannerInfo fa fa-info-circle' onclick=ca_pluginUpdateShowInfo('/plugins/dynamix.plugin.manager/include/ShowChanges.php?file=%2Ftmp%2Fplugins%2F"+pluginFilename+".txt','Release&nbsp;Notes',600,900); return false;'></a>";
addBannerWarning(HTML,false,ca_pluginUpdate_evaluateBoolean(options.noDismiss));
}
} else {
if ( $.cookie(plugin) != result.version ) {
if ( result.updateAvailable ) {
var HTML = "An upgrade to "+name+" is available. Click <a class='ca_PluginUpdateInstall' onclick='ca_pluginUpdateInstall(&quot;"+plugin+"&quot;);'>here</a> to install version "+result.version+" <i class='ca_pluginUpdateInfo fa fa-info-circle' onclick=ca_pluginUpdateShowInfo('/plugins/dynamix.plugin.manager/include/ShowChanges.php?file=%2Ftmp%2Fplugins%2F"+pluginFilename+".txt','Release&nbsp;Notes',600,900); return false;'></i>";
if ( ! ca_pluginUpdate_evaluateBoolean(options.noDismiss) ) {
HTML = HTML.concat("<span class='ca_PluginUpdateDismiss'><i class='fa fa-close' onclick='ca_hidePluginUpdate(&quot;"+result.version+"&quot;);'></i>");
}
result.HTML = HTML;
ca_PluginUpdateElement = options.element ? options.element : ".ca_plugin_notice";
if ( ! ca_pluginUpdate_evaluateBoolean(options.dontShow) ) {
if ( ! options.element ) {
$(".ca_element_notice").html(HTML);
if (options.priority) {
var z_index = $(".upgrade_notice").css("z-index");
$(".ca_element_notice").css("z-index",z_index+1);
}
} else {
$(ca_PluginUpdateElement).html(HTML);
}
$(ca_PluginUpdateElement).addClass("ca_element_notice").show();
}
}
}
}
if ( typeof options === "function" ) {
callback = options;
}
if ( typeof callback === "function" ) {
callback(JSON.stringify(result));
}
});
}
}
if ( typeof addBannerWarning !== "function" ) {
function addBannerWarning(text,warning=true,noDismiss=false) {
var cookieText = text.replace(/[^a-z0-9]/gi,'');
if ( $.cookie(cookieText) == "true" ) { return false; }
var z_index = $(".upgrade_notice").css("z-index");
$(".ca_element_notice").css("z-index",z_index+1); // Warnings take precendence over unRaid's OS warnings
if ( warning ) {
text = "<i class='fa fa-warning'></i> "+text;
}
var arrayEntry = ca_WarningItems.push("placeholder") - 1;
if ( ! noDismiss ) {
text = text + "<span class='ca_PluginUpdateDismiss'><i class='fa fa-close' onclick='dismissBannerWarning("+arrayEntry+",&quot;"+cookieText+"&quot;)'></i>";
}
ca_WarningItems[arrayEntry] = text;
if ( ! warningInterval ) {
showWarnings();
warningInterval = setInterval(function() {
showWarnings()
},10000);
}
return arrayEntry;
}
function dismissBannerWarning(entry,cookieText) {
$.cookie(cookieText,"true");
removeBannerWarning(entry);
}
function removeBannerWarning(entry) {
ca_WarningItems[entry] = false;
showWarnings();
}
function filterArray(array) {
var newArray = [];
array.filter(function(value,index,arr) {
if ( value ) {
newArray.push(value);
}
});
return newArray;
}
function showWarnings() {
var allWarnings = filterArray(Object.values(ca_WarningItems));
if ( allWarnings.length == 0 ) {
$(".ca_plugin_notice,.ca_element_notice").hide();
clearInterval(warningInterval);
warningInterval = false;
return;
}
if ( currentWarning >= allWarnings.length ) {
currentWarning = 0;
}
$(".upgrade_notice").hide();
$(".ca_plugin_notice,.ca_element_notice").show();
$(".ca_plugin_notice").html(allWarnings[currentWarning]);
currentWarning++;
}
}
</script>
<? endif; ?>
<script>
if ( typeof addRebootNotice !== "function" ) {
// add any pre-existing reboot notices
$(function() {
<?
$rebootNotice = @file("/tmp/reboot_notifications") ?: array();
foreach ($rebootNotice as $notice):
?>
var rebootMessage = "<?=trim($notice)?>";
if ( rebootMessage ) {
addBannerWarning(rebootMessage,true,true);
}
<?
endforeach;
?>
});
function addRebootNotice(message="You must reboot for changes to take effect") {
addBannerWarning(message,true,true);
$.post("/plugins/community.applications/scripts/PluginAPI.php",{action:'addRebootNotice',message:message});
}
}
</script>

View File

@ -1,4 +1,4 @@
acb35706b3a778589ac1e6046a93201d ./Apps.page
8ec96e4413a11691820a9ccc725857ae ./Apps.page
83b3f89cd42e8601c7c217d5b4889c81 ./CA_notices.page
18ded5848ac35ffae0e8e0fc8ed3c512 ./ca_settings.page
ed2883d6c44c19304c431079596a1731 ./default.cfg
@ -6,6 +6,7 @@ ed2883d6c44c19304c431079596a1731 ./default.cfg
b6920c2d8b2ea81a4dabbd935b93895e ./include/helpers.php
95709ae0ed53e2889a93849a69b37892 ./include/paths.php
410c0166bae560754e231486050621f6 ./javascript/libraries.js
8c24d585c7dd3ff9ef961bb2c2705711 ./PluginAPI.page
b398273cf7daa62ab00d2de2336ca25f ./README.md
717f49d6faabd7e1d7cf0940beb5cd5e ./scripts/checkForUpdates.php
1e2b902321d4bb7efe0d0b78c8130a73 ./scripts/installMulti.php
@ -21,4 +22,4 @@ e3dc9ed23036a09d69d5cd5c3111751e ./scripts/showStatistics.php
2bd671daecaf01549f8cc0202cb184b3 ./scripts/updatePluginSupport.php
e847d17faa1276c97ce3702f57ac56ea ./skins/Narrow/css.php
cfa1511913f794c8c5980460dfcdf049 ./skins/Narrow/skin.html
44912f026b88f862384922c49b0b0f0c ./skins/Narrow/skin.php
1612dbb7b05d8d48e61b43c24e506659 ./skins/Narrow/skin.php

View File

@ -935,6 +935,7 @@ function displayCard($template) {
$supportContext[] = array("icon"=>"ca_fa-support","link"=>$Support,"text"=> $SupportLanguage ?: tr("Support Forum"));
} else {
$holderClass='repositoryCard';
$cardClass = "ca_repoinfo";
$ID = str_replace(" ","",$RepoName);
$supportContext = array();
@ -962,15 +963,15 @@ function displayCard($template) {
if ( $DockerHub ) {
$backgroundClickable = "dockerCardBackground";
$card .= "
<div class='ca_holder $class'>
<div class='dockerHubHolder $class $popupType'>
<div class='ca_bottomLine $bottomClass'>
<div class='infoButton_docker dockerPopup' data-dockerHub='$DockerHub'>".tr("Docker Hub")."</div>";
} else {
$backgroundClickable = "ca_backgroundClickable";
$card .= "
<div class='ca_holder $class'>
<div class='ca_holder $class $popupType $holderClass' data-apppath='$Path' data-appname='$Name' data-repository='".htmlentities($RepoName,ENT_QUOTES)."'>
<div class='ca_bottomLine $bottomClass'>
<div class='infoButton $cardClass' data-apppath='$Path' data-appname='$Name' data-repository='".htmlentities($RepoName,ENT_QUOTES)."'>".tr("Info")."</div>
<div class='infoButton $cardClass'>".tr("Info")."</div>
";
}
if ( count($supportContext) == 1)
@ -990,9 +991,9 @@ function displayCard($template) {
$card .= "<span class='$appType' title='".htmlentities($typeTitle)."'></span>";
if ( $ca_fav ) {
$favText = $RepositoryTemplate ? tr("This is your favourite repository") : tr("This application is from your favourite repository");
$card .= "<span class='favCardBackground' title='".htmlentities($favText)."' data-repository='".htmlentities($RepoName,ENT_QUOTES)."'></span>";
$card .= "<span class='favCardBackground' title='".htmlentities($favText)."'></span>";
} else
$card .= "<span class='favCardBackground' title='".htmlentities($favText)."' style='display:none;' data-repository='".htmlentities($RepoName,ENT_QUOTES)."'></span>";
$card .= "<span class='favCardBackground' title='".htmlentities($favText)."' style='display:none;'></span>";
if ( ! $Pinned )
$pinStyle = "display:none;";
@ -1005,7 +1006,7 @@ function displayCard($template) {
$card .= "<input class='ca_multiselect ca_tooltip' title='".tr("Check off to select multiple reinstalls")."' type='checkbox' data-name='$previousAppName' data-humanName='$Name' data-type='$type' data-deletepath='$InstallPath' $checked>";
}
$card .= "</div>";
$card .= "<div class='$cardClass $backgroundClickable' data-apppath='$Path' data-appname='$Name' data-repository='".htmlentities($RepoName,ENT_QUOTES)."'>";
$card .= "<div class='$cardClass $backgroundClickable'>";
$card .= "<div class='ca_iconArea'>";
if ( $DockerHub )
$imageNoClick = "noClick";
@ -1017,7 +1018,7 @@ function displayCard($template) {
else {
$displayIcon = $template['IconFA'] ?: $template['Icon'];
$displayIconClass = startsWith($displayIcon,"icon-") ? $displayIcon : "fa fa-$displayIcon";
$card .= "<i class='ca_appPopup $displayIconClass displayIcon $imageNoClick' data-apppath='$Path' data-appname='$Name'></i>";
$card .= "<i class='ca_appPopup $displayIconClass displayIcon $imageNoClick'></i>";
}
$card .= "</div>";
@ -1067,10 +1068,10 @@ function displayCard($template) {
$ovr = str_replace("\n","<br>",$ovr);
$Overview = str_replace("<br>"," ",$ovr);
$descClass= $RepositoryTemplate ? "cardDescriptionRepo" : "cardDescription";
$card .= "<div class='$descClass $backgroundClickable' data-apppath='$Path' data-appname='$Name' data-repository='".htmlentities($RepoName,ENT_QUOTES)."'><div class='cardDesc'>$Overview</div></div>";
$card .= "<div class='$descClass $backgroundClickable'><div class='cardDesc'>$Overview</div></div>";
if ( $RecommendedDate ) {
$card .= "
<div class='homespotlightIconArea ca_center' data-apppath='$Path' data-appname='$Name' data-repository='".htmlentities($RepoName,ENT_QUOTES)."'>
<div class='homespotlightIconArea ca_center''>
<div><img class='spotlightIcon' src='{$caPaths['SpotlightIcon']}'></img></div>
<div class='spotlightDate'>".tr(date("M Y",$RecommendedDate),0)."</div>
</div>