nps/web/static/js/main.js

49 lines
1.4 KiB
Go
Raw Normal View History

2018-12-11 08:37:12 +00:00
(function () {
"use strict";
2018-12-11 08:37:12 +00:00
var treeviewMenu = $('.app-menu');
2018-12-11 08:37:12 +00:00
// Toggle Sidebar
$('[data-toggle="sidebar"]').click(function (event) {
event.preventDefault();
$('.app').toggleClass('sidenav-toggled');
});
2018-12-11 08:37:12 +00:00
// Activate sidebar treeview toggle
$("[data-toggle='treeview']").click(function (event) {
event.preventDefault();
if (!$(this).parent().hasClass('is-expanded')) {
treeviewMenu.find("[data-toggle='treeview']").parent().removeClass('is-expanded');
}
$(this).parent().toggleClass('is-expanded');
});
2018-12-11 08:37:12 +00:00
// Set initial active toggle
$("[data-toggle='treeview.'].is-expanded").parent().toggleClass('is-expanded');
2018-12-11 08:37:12 +00:00
//Activate bootstrip tooltips
// $("[data-toggle='tooltip']").tooltip();
2018-12-11 08:37:12 +00:00
})();
function change(limit) {
var size = "";
if (limit < 0.1 * 1024) {
size = limit.toFixed(2) + "B"
} else if (limit < 0.1 * 1024 * 1024) {
size = (limit / 1024).toFixed(2) + "KB"
} else if (limit < 0.1 * 1024 * 1024 * 1024) {
size = (limit / (1024 * 1024)).toFixed(2) + "MB"
} else {
size = (limit / (1024 * 1024 * 1024)).toFixed(2) + "GB"
}
var sizeStr = size + "";
var index = sizeStr.indexOf(".");
var dou = sizeStr.substr(index + 1, 2)
if (dou == "00") {
return sizeStr.substring(0, index) + sizeStr.substr(index + 3, 2)
}
return size;
}