cache = {}
function loadJS(src, callback) {
if (cache[src]) {
callback()
} else {
cache[src] = true;
var s = document.createElement('script');
s.src = src;
s.async = true;
s.onreadystatechange = s.onload = function() {
var state = s.readyState;
if (!callback.done && (!state || /loaded|complete/.test(state))) {
callback.done = true;
callback();
}
};
document.getElementsByTagName('head')[0].appendChild(s);
}
}
if ($('.chart-flot').exists()) {
loadJS('/js/plugins/flot/jquery.flot.min.js', function() {
loadJS('/js/plugins/flot/jquery.flot.pie.min.js', function(){
if($('#disk_space_chart').exists()) {
$.plot("#disk_space_chart", diskSpaceData, {
series: {
pie: {
show: true,
radius: 1,
innerRadius: 0.5,
label: {
show: true,
radius: 2 / 3,
formatter: function (label, series) {
return '<div style="font-size:13px; text-align:center; padding:2px; color: #fff; font-weight: 600;">'
+ label + "<br>" + Math.round(series.percent) + "%</div>";
},
threshold: 0.1
}
}
},
legend: {
show: false
}
});
}
})
});
}