-
Notifications
You must be signed in to change notification settings - Fork 0
/
jiaba.html
132 lines (120 loc) · 3.57 KB
/
jiaba.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<html>
<head>
<title>加班时间计算器</title>
<META http-equiv="content-type" content="text/html;charset=UTF-8" />
<META http-equiv="Cache-Control" content="max-age=0;" />
<link type="text/css" href="jquery-ui-1.8.18.custom/css/redmond/jquery-ui-1.8.18.custom.css" rel="stylesheet" />
<style type="text/css">
.f {
float:left;
margin:10px auto;
zoom:1;
}
.ex {
color:red;
}
.inc {
color:green;
}
</style>
</head>
<body>
<div>
<div style="margin:20 auto;">点击日期选择不要的日子,进行计算,<span class="inc">包含</span>的日期覆盖<span class="ex">不包含</span>日期</div>
<div id="modebar">
<input name="mode" type="radio" value="1" /> <span class="inc">包含</span>
<input name="mode" type="radio" checked=checked value="2" /><span class="ex">不包含</span>
</div>
<div style="overflow:hidden;">
<div id="bar" class="f"></div>
<div id="ex" class="f ex"></div>
<div id="inc" class="f inc"></div>
</div>
<div><input id="cal" type="button" value="计算" ></div>
<div id="retd" style="display:none;margin:20px auto;">
<div>详情:<input type="text" value="" id="ret"/></div>
<div>总天数:<input type="text" value="" id="tolDays"/></div>
</div>
</div>
</body>
<script type="text/javascript" src="jquery-ui-1.8.18.custom/js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="jquery-ui-1.8.18.custom/js/jquery-ui-1.8.18.custom.min.js"></script>
<script type="text/javascript" src="lib/jiaban.js"></script>
<script type="text/javascript">
var init = function() {
var now = new Date();
var excludes = {};
var includes = {};
now.setDate(16);
var start = jb.addMonth(now,-1);
now.setDate(15);
var isExMode = function() {
var val = $('#modebar > input[name=mode]:checked').val();
return 2 == val;
};
var renderList = function(id,obj) {
var html = ['<ol>'];
for(var i in obj ) {
if(!obj[i]) {
continue;
}
html[html.length] = '<li>' + i + '</li>';
}
html[html.length] = '</ol>';
$('#'+id).html(html.join(''));
};
// Datepicker
$('#bar').datepicker({
numberOfMonths: 2,
showButtonPanel: false,
dayNames:['日','一','二','三','四','五','六'],
dayNamesMin:['日','一','二','三','四','五','六'],
dayNamesShort:['日','一','二','三','四','五','六'],
monthNames:['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'],
monthNamesShort:['一','二','三','四','五','六','七','八','九','十','十一','十二'],
dateFormat:'yy-mm-dd',
maxDate:now,
minDate:start,
onSelect:function(date,ele){
if(isExMode()) {
excludes[date] = !excludes[date];
} else {
includes[date] = !includes[date];
}
renderList('ex',excludes);
renderList('inc',includes);
}
});
var objToArr = function(obj) {
if(!obj) {
return;
}
var ret = [];
for(var i in obj) {
if(obj[i]){
ret[ret.length]= i;
}
}
return ret;
}
$('#cal').click(function(){
var ex = objToArr(excludes);
var inc = objToArr(includes);
var end = new Date(now);
end.setDate(16);
var ret = jb.getText(start,end,ex,inc);
excludes={};
includes={};
if(!ret) {
$('#ret').html('没有结果');
return;
}
$('#ret').val(ret.r).attr('size',ret.r.length+10);
$('#tolDays').val(ret.d);
$('#retd').css('display','');
});
$('#cal').click();
};
$(document.body).ready(init);
</script>
</html>