mirror of
https://github.com/pi-hole/web.git
synced 2026-05-08 09:39:05 +01:00
Move padNumber() to utils.
Signed-off-by: XhmikosR <xhmikosr@gmail.com>
This commit is contained in:
@@ -50,10 +50,6 @@ $(function () {
|
||||
);
|
||||
});
|
||||
|
||||
function padNumber(num) {
|
||||
return ("00" + num).substr(-2, 2);
|
||||
}
|
||||
|
||||
var timeLineChart;
|
||||
|
||||
function compareNumbers(a, b) {
|
||||
@@ -197,28 +193,28 @@ $(document).ready(function () {
|
||||
var fromDate =
|
||||
time.getFullYear() +
|
||||
"-" +
|
||||
padNumber(time.getMonth() + 1) +
|
||||
utils.padNumber(time.getMonth() + 1) +
|
||||
"-" +
|
||||
padNumber(time.getDate());
|
||||
utils.padNumber(time.getDate());
|
||||
var fromTime =
|
||||
padNumber(time.getHours()) +
|
||||
utils.padNumber(time.getHours()) +
|
||||
":" +
|
||||
padNumber(time.getMinutes()) +
|
||||
utils.padNumber(time.getMinutes()) +
|
||||
":" +
|
||||
padNumber(time.getSeconds());
|
||||
utils.padNumber(time.getSeconds());
|
||||
time = new Date(time.valueOf() + 1000 * interval);
|
||||
var untilDate =
|
||||
time.getFullYear() +
|
||||
"-" +
|
||||
padNumber(time.getMonth() + 1) +
|
||||
utils.padNumber(time.getMonth() + 1) +
|
||||
"-" +
|
||||
padNumber(time.getDate());
|
||||
utils.padNumber(time.getDate());
|
||||
var untilTime =
|
||||
padNumber(time.getHours()) +
|
||||
utils.padNumber(time.getHours()) +
|
||||
":" +
|
||||
padNumber(time.getMinutes()) +
|
||||
utils.padNumber(time.getMinutes()) +
|
||||
":" +
|
||||
padNumber(time.getSeconds());
|
||||
utils.padNumber(time.getSeconds());
|
||||
|
||||
if (fromDate === untilDate) {
|
||||
// Abbreviated form for intervals on the same day
|
||||
|
||||
@@ -30,10 +30,6 @@ var colors = [
|
||||
"#d2d6de"
|
||||
];
|
||||
|
||||
function padNumber(num) {
|
||||
return ("00" + num).substr(-2, 2);
|
||||
}
|
||||
|
||||
var customTooltips = function (tooltip) {
|
||||
var tooltipEl = document.getElementById(this._chart.canvas.id + "-customTooltip");
|
||||
if (!tooltipEl) {
|
||||
@@ -844,8 +840,8 @@ $(document).ready(function () {
|
||||
var time = label.match(/(\d?\d):?(\d?\d?)/);
|
||||
var h = parseInt(time[1], 10);
|
||||
var m = parseInt(time[2], 10) || 0;
|
||||
var from = padNumber(h) + ":" + padNumber(m - 5) + ":00";
|
||||
var to = padNumber(h) + ":" + padNumber(m + 4) + ":59";
|
||||
var from = utils.padNumber(h) + ":" + utils.padNumber(m - 5) + ":00";
|
||||
var to = utils.padNumber(h) + ":" + utils.padNumber(m + 4) + ":59";
|
||||
return "Queries from " + from + " to " + to;
|
||||
},
|
||||
label: function (tooltipItems, data) {
|
||||
@@ -941,8 +937,8 @@ $(document).ready(function () {
|
||||
var time = label.match(/(\d?\d):?(\d?\d?)/);
|
||||
var h = parseInt(time[1], 10);
|
||||
var m = parseInt(time[2], 10) || 0;
|
||||
var from = padNumber(h) + ":" + padNumber(m - 5) + ":00";
|
||||
var to = padNumber(h) + ":" + padNumber(m + 4) + ":59";
|
||||
var from = utils.padNumber(h) + ":" + utils.padNumber(m - 5) + ":00";
|
||||
var to = utils.padNumber(h) + ":" + utils.padNumber(m + 4) + ":59";
|
||||
return "Client activity from " + from + " to " + to;
|
||||
},
|
||||
label: function (tooltipItems, data) {
|
||||
|
||||
@@ -40,6 +40,10 @@ function objectToArray(obj) {
|
||||
return [idx, arr];
|
||||
}
|
||||
|
||||
function padNumber(num) {
|
||||
return ("00" + num).substr(-2, 2);
|
||||
}
|
||||
|
||||
var info = null; // TODO clear this up; there shouldn't be a global var here
|
||||
function showAlert(type, icon, title, message) {
|
||||
var opts = {};
|
||||
@@ -207,6 +211,7 @@ window.utils = (function () {
|
||||
return {
|
||||
escapeHtml: escapeHtml,
|
||||
objectToArray: objectToArray,
|
||||
padNumber: padNumber,
|
||||
showAlert: showAlert,
|
||||
datetime: datetime,
|
||||
disableAll: disableAll,
|
||||
|
||||
Reference in New Issue
Block a user