Created
July 18, 2013 08:16
-
-
Save songxiaofeng1981/6027625 to your computer and use it in GitHub Desktop.
js date format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends "base.html" %} | |
{% block content %} | |
<div id="nav" class="container nav"> | |
<div id="nav" class="container nav"> | |
<form class="form-inline " action="/billing/role_chart/{{ role }}/" method="POST" id="submitid"> | |
<label class="control-label" for="inputEmail">开始时间</label> | |
<input class="span3" type="text" onclick="WdatePicker({dateFmt:'yyyy-MM-dd H:m:s',readOnly:true})" | |
name="start_time" value="{{ start_time|default_if_none:'' }}" id="start_timeID" /> | |
<label class="control-label" for="inputEmail">结束时间</label> | |
<input class="span3" type="text" onclick="WdatePicker({dateFmt:'yyyy-MM-dd H:m:s',readOnly:true} )" | |
name="end_time" value="{{ end_time|default_if_none:'' }}" id="end_timeID"/> | |
<button type="submit" class="btn"> 提交</button> | |
<button class='btn btn-primary' type=submit id="threeHour" name="three" value="three"> 3小时</button> | |
<button class='btn btn-primary' type=submit id="today" name="today" value="today"> 当天</button> | |
<button class='btn btn-primary' type=submit id="towday" name="twoday" value="twoday">2天</button> | |
</form> | |
</div> | |
</div> | |
<div class="container"> | |
<script language="javascript" type="text/javascript" src="/js/FusionCharts.js"></script> | |
<div id="role_chart" align='center'></div> | |
<br> | |
<script type="text/javascript"> | |
FusionCharts._fallbackJSChartWhenNoFlash(); | |
var chart = new FusionCharts("/swf/MSLine.swf", "cns", "100%", "400", "0", "1"); | |
chart.setJSONUrl("/loging/role_chart_date/?start_time={{start_time|default_if_none:''}}&end_time={{end_time|default_if_none:''}}"); | |
chart.render("role_chart"); | |
</script> | |
</div> | |
<div class="container "> | |
<table class="table table-bordered table-hover" id="detail_node"> | |
<thead> | |
<tr> | |
<th>时间</th> | |
<th>DM上报数</th> | |
<th>实际接收数</th> | |
<th>接收百分比</th> | |
</tr> | |
</thead> | |
<tbody> | |
{% for total in logfiles %} | |
<tr class="{{ total.percent }}"> | |
<td><a href="/loging/find_nodecount_bydate?beginDate={{ total.day }}&role={{ role }}" | |
target="_blank">{{ total.day }}</a></td> | |
<td>{{ total.createcount }}</td> | |
<td>{{ total.receivecount }}</td> | |
<td>{{ total.percent }}%</td> | |
</tr> | |
{% endfor %} | |
<!-- <td>more <a id="go_detail">more info</a></td> --> | |
</tbody> | |
</table> | |
<script type="text/javascript"> | |
jQuery(document).ready(function () { | |
$("#submitid").attr("action", "/loging/role_chart/") | |
$("#end_timeID").val(new Date().pattern("yyyy-MM-dd HH:mm:ss")) | |
$("#start_timeID").val(get_zero_date()) | |
$("#threeHour").val(get_before_three_hours()) | |
$("#today").val(get_zero_date()) | |
$("#towday").val(get_before_two_days()) | |
}); | |
function get_before_three_hours() { | |
var today = new Date(); | |
var date = new Date(today.getTime() - (1000 * 60 * 60 * 3)); | |
return date.pattern("yyyy-MM-dd HH:mm:ss") | |
} | |
function get_zero_date() { | |
var today = new Date() | |
today.setHours(0) | |
today.setMinutes(0) | |
today.setMilliseconds(0) | |
today.setSeconds(0) | |
return today.pattern("yyyy-MM-dd HH:mm:ss") | |
} | |
function get_before_two_days() { | |
var today = new Date(); | |
var yesterday = new Date(today.getTime() - (1000 * 60 * 60 * 24)); | |
return yesterday.pattern("yyyy-MM-dd HH:mm:ss") | |
} | |
Date.prototype.pattern = function (fmt) { | |
var o = { | |
"M+": this.getMonth() + 1, //月份 | |
"d+": this.getDate(), //日 | |
"h+": this.getHours() % 12 == 0 ? 12 : this.getHours() % 12, //小时 | |
"H+": this.getHours(), //小时 | |
"m+": this.getMinutes(), //分 | |
"s+": this.getSeconds(), //秒 | |
"q+": Math.floor((this.getMonth() + 3) / 3), //季度 | |
"S": this.getMilliseconds() //毫秒 | |
}; | |
var week = { | |
"0": "\u65e5", | |
"1": "\u4e00", | |
"2": "\u4e8c", | |
"3": "\u4e09", | |
"4": "\u56db", | |
"5": "\u4e94", | |
"6": "\u516d" | |
}; | |
if (/(y+)/.test(fmt)) { | |
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); | |
} | |
if (/(E+)/.test(fmt)) { | |
fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? "\u661f\u671f" : "\u5468") : "") + week[this.getDay() + ""]); | |
} | |
for (var k in o) { | |
if (new RegExp("(" + k + ")").test(fmt)) { | |
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); | |
} | |
} | |
return fmt; | |
} | |
</script> | |
</div> | |
{% endblock %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment