mirror of
https://github.com/unraid/webgui.git
synced 2026-01-13 21:20:01 -06:00
85 lines
4.0 KiB
Plaintext
85 lines
4.0 KiB
Plaintext
Menu='Buttons'
|
|
Link='nav-user'
|
|
---
|
|
<?
|
|
/* Copyright 2020, Lime Technology
|
|
* Copyright 2020, Andrew Zawadzki.
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License version 2,
|
|
* as published by the Free Software Foundation.
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in
|
|
* all copies or substantial portions of the Software.
|
|
*/
|
|
?>
|
|
<style>
|
|
/* Additional CSS for when user supplies element */
|
|
.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>
|
|
|
|
function ca_hidePluginUpdate(plugin,version,element) {
|
|
$.cookie(plugin,version);
|
|
$(element).hide();
|
|
}
|
|
|
|
function ca_pluginUpdateInstall(plugin) {
|
|
openBox("/plugins/dynamix.plugin.manager/scripts/plugin&arg1=update&arg2="+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 caPluginUpdateCheck(plugin,options=[],callback) {
|
|
var pluginFilename = plugin.substr(0, plugin.lastIndexOf("."));
|
|
console.time("checkPlugin "+plugin);
|
|
console.log("checkPlugin "+plugin);
|
|
$.post("/plugins/dynamix.plugin.manager/scripts/PluginAPI.php",{action:'checkPlugin',options:{plugin:plugin,name:options.name}},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;
|
|
if ( ! options.element && ! options.dontShow ) {
|
|
if ( result.updateAvailable ) {
|
|
var HTML = result.updateMessage+" <a class='ca_PluginUpdateInstall' onclick='ca_pluginUpdateInstall(""+plugin+"");'>"+result.linkMessage+"</a> <a class='bannerInfo fa fa-info-circle' onclick=ca_pluginUpdateShowInfo('/plugins/dynamix.plugin.manager/include/ShowChanges.php?file=%2Ftmp%2Fplugins%2F"+pluginFilename+".txt','_(Release Notes)_',600,900); return false;'></a>";
|
|
addBannerWarning(HTML,false,options.noDismiss);
|
|
}
|
|
} else {
|
|
if ( $.cookie(plugin) != result.version ) {
|
|
if ( result.updateAvailable ) {
|
|
var HTML = result.updateMessage+" <a class='ca_PluginUpdateInstall' onclick='ca_pluginUpdateInstall(""+plugin+"");'>"+result.linkMessage+"</a> <a class='bannerInfo fa fa-info-circle' onclick=ca_pluginUpdateShowInfo('/plugins/dynamix.plugin.manager/include/ShowChanges.php?file=%2Ftmp%2Fplugins%2F"+pluginFilename+".txt','_(Release Notes)_',600,900); return false;'></a>";
|
|
if ( ! options.noDismiss ) {
|
|
HTML = HTML.concat("<span class='ca_PluginUpdateDismiss'><i class='fa fa-close' onclick='ca_hidePluginUpdate(""+plugin+"",""+result.version+"",""+options.element+"");'></i>");
|
|
}
|
|
result.HTML = HTML;
|
|
|
|
if ( ! options.dontShow ) {
|
|
$(options.element).html(HTML);
|
|
$(options.element).addClass("ca_element_notice").show();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if ( typeof options === "function" ) {
|
|
callback = options;
|
|
}
|
|
if ( typeof callback === "function" ) {
|
|
callback(JSON.stringify(result));
|
|
}
|
|
});
|
|
}
|
|
|
|
</script> |