blob: ab0669d5836145cea85bac2c90fe989c8d08bcc2 [file] [log] [blame]
/*
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// showStats: Show the ML stats on the front page
function showStats(json) {
var obj = document.getElementById('list_stats')
obj.innerHTML = "<h3 style='margin-top: -10px;'>Overall 14 day activity:</h3>"
obj.innerHTML += '<span class="glyphicon glyphicon-user"> </span> ' + json.participants.toLocaleString() + " People &nbsp; "
obj.innerHTML += '<span class="glyphicon glyphicon-envelope"> </span> ' + json.hits.toLocaleString() + ' messages &nbsp';
obj.innerHTML += '<span class="glyphicon glyphicon-list-alt"> </span> ' + json.no_threads.toLocaleString() + " topics &nbsp; "
obj.innerHTML += '<span class="glyphicon glyphicon-inbox"> </span> ' + json.no_active_lists.toLocaleString() + " active lists."
var ts = "<table border='0' style='float: right; margin-top: -30px;'><tr>"
// find the max no. of emails in a single day, for calculating max height of the 14 day chart
var max = 1
for (var i in json.activity) {
max = Math.max(max, json.activity[i][1])
}
// for each day, make a bar, taking into account the max value
for (var i in json.activity) {
var day = new Date(json.activity[i][0]).toDateString()
ts += "<td style='padding-left: 2px; vertical-align: bottom'><div title='" + day + ": " + json.activity[i][1] + " emails' style='background: #369; width: 6px; height: " + parseInt((json.activity[i][1] / max) * 48) + "px;'> </div></td>"
}
ts += "</tr></table>"
obj.innerHTML += ts
}