-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbookdoctor.html
More file actions
156 lines (119 loc) · 3.21 KB
/
bookdoctor.html
File metadata and controls
156 lines (119 loc) · 3.21 KB
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<!DOCTYPE HTML>
<html>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<head>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript">
Date.prototype.format =function(format)
{
var o = {
"M+" : this.getMonth()+1, //month
"d+" : this.getDate(), //day
"h+" : this.getHours(), //hour
"m+" : this.getMinutes(), //minute
"s+" : this.getSeconds(), //second
"q+" : Math.floor((this.getMonth()+3)/3), //quarter
"S" : this.getMilliseconds() //millisecond
}
if(/(y+)/.test(format)) format=format.replace(RegExp.$1,
(this.getFullYear()+"").substr(4- RegExp.$1.length));
for(var k in o)if(new RegExp("("+ k +")").test(format))
format = format.replace(RegExp.$1,
RegExp.$1.length==1? o[k] :
("00"+ o[k]).substr((""+ o[k]).length));
return format;
}
//DateFilter = 2014-12-12 这种格式
var docID = 4336
var INTERVAL = 5000
var docPage = "http://sz.91160.com/doctors/index/docid-"+ docID +".html"
var timer = null
var docData = {docid: docID, date: "2014-10-28", days: 6}
function refreshData()
{
docPage = "http://sz.91160.com/doctors/index/docid-"+ docID +".html"
var date = new Date()
docData = {docid: docID, date: (date.format("yyyy-MM-dd")), days: 6}
}
var checkEmptyClass = function(data,dateFilter){
var schs = data["sch"]
var STR = JSON.stringify
for (var i = data['sch'].length - 1; i >= 0; i--) {
var sch = data['sch'][i]
for (var key in sch){
var value = sch[key]
var str = JSON.stringify(value)
for (var date in value){
var content = value[date]
var bookMax = parseInt(content['yuyue_max'])
var bookNum = parseInt(content['yuyue_num'])
if (bookMax > bookNum) {
console.log("stop Timer");
clearInterval(timer)
console.log("跳到医生主页:" + docPage);
location.href = docPage;
return
}
}
}
}
updateStatus(2)
}
function sendPost()
{
updateStatus(1)
refreshData()
console.log("doc Data = " + docData);
$.post("http://sz.91160.com/doctors/ajaxgetclass.html", docData,
function(data,status){
var objJSON = eval('(' + data + ')')
console.log("data = "+data)
checkEmptyClass(objJSON)
});
}
function startTimer(){
updateStatus(0)
timer = setInterval(sendPost, INTERVAL)
}
function updateStatus(st){
$("#status").text(function(i,origText){
if (st == 2){
return "预约已经满了,等待下一次刷新。"
}else if(st == 1){
return "刷新数据中..."
}else if(st == 0){
return "即将刷新。"
}else {
return ""
}
});
}
</script>
</head>
<body>
<p>医生ID: <input type="text" id="did" value="4336"/></p>
<p>刷新频率: <input type="text" id="interval" value=5000 /></p>
<input type="submit" value="确定" id='ok'/>
<input type="submit" value="停止" id='cancel'/>
<br>
<p状态: <label id='status'> </label></p>
<p id="status"></p>
<script type="text/javascript">
$("#ok").click(function(event) {
docID = $("#did").val()
INTERVAL = $("#interval").val()
refreshData()
sendPost()
startTimer()
$("#ok").hide();
$("#cancel").show();
});
$("#cancel").click(function(event) {
clearInterval(timer)
$("#cancel").hide();
$("#ok").show();
updateStatus(3)
});
</script>
</body>
</html>