115 lines
4.4 KiB
JavaScript
115 lines
4.4 KiB
JavaScript
plugin.loadLang();
|
|
plugin.loadMainCSS();
|
|
|
|
plugin.setValue = function( i, full, free )
|
|
{
|
|
var used = full-free;
|
|
var percent = iv(full ? used/full*100 : 0);
|
|
if(percent>100)
|
|
percent = 100;
|
|
var name = (plugin.diskNames && plugin.diskNames[i]) ? plugin.diskNames[i] + ': ' : '';
|
|
$("[id='meter-disk-value']").eq(i).width( percent+"%" ).css( { "background-color": (new RGBackground()).setGradient(this.prgStartColor,this.prgEndColor,percent).getColor(),
|
|
visibility: !percent ? "hidden" : "visible" } );
|
|
if(plugin.freeBytesInMeter) $("[id='meter-disk-text']").eq(i).text(name + theConverter.bytes(free));
|
|
else $("[id='meter-disk-text']").eq(i).text(name + percent+'%');
|
|
if(theUILang.diskUsage) {
|
|
$("[id='meter-disk-holder']").eq(i).prop("title",
|
|
theUILang.diskUsage
|
|
.replace(/%USED%/, theConverter.bytes(used))
|
|
.replace(/%TOTAL%/, theConverter.bytes(full))
|
|
.replace(/%FREE%/, theConverter.bytes(free) + ", " + iv(full ? free/full*100 : 0) + "%")
|
|
);
|
|
}
|
|
}
|
|
|
|
plugin.setValues = function( data )
|
|
{
|
|
var low = false;
|
|
$.each(data, function(i, d)
|
|
{
|
|
plugin.setValue(i, d.total, d.free);
|
|
if(d.free<plugin.notifySpaceLimit)
|
|
low = true;
|
|
});
|
|
|
|
if($.noty && plugin.allStuffLoaded)
|
|
{
|
|
if(low && !plugin.noty)
|
|
plugin.noty = $.noty(
|
|
{
|
|
text: theUILang.diskNotification,
|
|
layout : 'bottomLeft',
|
|
type: 'error',
|
|
timeout : false,
|
|
closeOnSelfClick: false
|
|
});
|
|
if(!low && plugin.noty)
|
|
{
|
|
$.noty.close(plugin.noty);
|
|
plugin.noty = null;
|
|
}
|
|
}
|
|
}
|
|
|
|
plugin.init = function()
|
|
{
|
|
if(getCSSRule("#meter-disk-holder"))
|
|
{
|
|
plugin.prgStartColor = new RGBackground("#99D699");
|
|
plugin.prgEndColor = new RGBackground("#E69999");
|
|
var holders = $("<div>");
|
|
for(var i = 0; i < plugin.diskCount; i++)
|
|
holders.append(
|
|
$("<div>").attr({id: "meter-disk-holder"}).append(
|
|
$("<div>").attr({id: "meter-disk-value"}).width(0),
|
|
$("<div>").attr({id: "meter-disk-text"}),
|
|
)
|
|
);
|
|
plugin.addPaneToStatusbar(
|
|
"meter-disk-pane",
|
|
$("<div>").append(
|
|
$("<div>").addClass("icon"),
|
|
holders.children(),
|
|
),
|
|
1, true,
|
|
);
|
|
|
|
plugin.check = function()
|
|
{
|
|
jQuery.ajax(
|
|
{
|
|
type: "GET",
|
|
timeout: theWebUI.settings["webui.reqtimeout"],
|
|
async : true,
|
|
cache: false,
|
|
url : "plugins/multidisk/action.php",
|
|
dataType : "json",
|
|
success : function(data)
|
|
{
|
|
plugin.setValues( data );
|
|
},
|
|
complete : function(jqXHR, textStatus)
|
|
{
|
|
plugin.diskTimeout = window.setTimeout(plugin.check,plugin.interval*1000);
|
|
}
|
|
});
|
|
};
|
|
plugin.check();
|
|
plugin.markLoaded();
|
|
}
|
|
else
|
|
window.setTimeout(arguments.callee,500);
|
|
};
|
|
|
|
plugin.onRemove = function()
|
|
{
|
|
plugin.removePaneFromStatusbar("meter-disk-pane");
|
|
if(plugin.diskTimeout)
|
|
{
|
|
window.clearTimeout(plugin.diskTimeout);
|
|
plugin.diskTimeout = null;
|
|
}
|
|
}
|
|
|
|
plugin.init();
|