X-Git-Url: https://git.rvb.name/squid-reports.git/blobdiff_plain/ec03340acbf414ccaee2f2ac9bed6fb68fe75674..HEAD:/web/squid.js?ds=sidebyside diff --git a/web/squid.js b/web/squid.js index 58a9542..8c85cca 100644 --- a/web/squid.js +++ b/web/squid.js @@ -1,8 +1,5 @@ urlbase="./api.php" -refresh = 1000 -online_history = 60 - graph_colors = [ "salmon", "lightcoral", "crimson", "red", "darkred", "orangered", "gold", "orange", "yellow", "darkkhaki", "lime", "green", "greenyellow", @@ -36,17 +33,29 @@ online_connections = null online_hosts = [] timer = null +start_date = null assigned_colors = [] current_time = null time_labels = [] -var d = new Date(); -var curr_day = d.getDate(); -var curr_month = d.getMonth() + 1; -var curr_year = d.getFullYear(); -today = curr_year + "-" + curr_month + "-" + curr_day; +function toDate(d) { + var curr_day = d.getDate(); + if (curr_day<10) { curr_day = '0' + curr_day; } + var curr_month = d.getMonth() + 1; + if (curr_month<10) { curr_month = '0' + curr_month; } + var curr_year = d.getFullYear(); + return curr_year + "-" + curr_month + "-" + curr_day +} + +function Today() { + var dToday = new Date(); + dToday.setHours(0,0,0,0) + return dToday +} + +today = toDate(Today()); date_from = today date_to = today @@ -133,6 +142,12 @@ function UpdatePageProps(props) { var logo = document.getElementById("brand"); logo.innerText = props["site-header"]; + refresh = props["online_refresh"] + online_history = props["online_history"] + + start_date = new Date(props["start_date"]) + start_date.setHours(0,0,0,0) + cats = props["cats"] for (var i in res["columns"]) { @@ -635,6 +650,43 @@ function UpdateDates() { } +function DateLeft() { + UpdateDates() + var dFrom = new Date(date_from) + var dTo = new Date(date_to) + var delta = Math.round(((dTo.getTime() - dFrom.getTime()))/(86400*1000)) + dTo.setDate(dTo.getDate() - (1 + delta)) + dFrom.setDate(dFrom.getDate() - (1 + delta)) + if (dToToday()) { + dTo = Today() + } + if (dFrom>Today()) { + dFrom = Today() + } + date_from = toDate(dFrom) + date_to = toDate(dTo) + SetDates() +} + function SetFilter(name,select) { current_filter[name] = select.value; }