sunshineAnalysis.html
9.89 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>淹没分析</title>
<script src="/static/js/jquery-3.4.1.min.js"></script>
<script src="/static/js/JavaScript.js"></script>
<script src="/static/js/popupJS.js"></script>
<script src="/static/js/layui/layui.js"></script>
<link rel="stylesheet" href="/static/js/layui/css/layui.css">
<link rel="stylesheet" href="/static/css/analysis.css">
<style>
.layui-form-item {
margin-top: 20px;
}
/* 输入框的样式 */
.layui-input {
height: 30px;
}
.layui-input-block {
margin-left: 110px;
margin-right: 20px;
padding-top: 4px;
}
.layui-laydate-main .laydate-main-list-0 {
width: 200px;
height: 250px;
}
</style>
</head>
<body marginwidth="0" marginheight="0">
<div id="mainDiv" class="dialog tiaojian">
<h1 class="title" onmousedown="MouseDown(event)" onmouseup="MouseUp(event)" onmouseout="MouseUp(event)">
日照分析<i class="guanbibtn" onclick="Close()">X</i>
</h1>
<form class="main">
<div class="filter">
<h1 class="filter-title">参数设置</h1>
<div class="box">
<div class="layui-form-item">
<label class="layui-form-label">日期</label>
<div class="layui-input-block">
<input type="text" class="layui-input" id="test1">
</div>
</div>
<!-- <div class="layui-form-item">
<label class="layui-form-label">时间</label>
<div class="layui-input-block">
<input type="text" class="layui-input" id="test2">
</div>
</div> -->
</div>
<div style="padding:20px;">
<button type="button" class="short-search-btn" onclick="appointedTime()">确定</button>
<button type="button" class="short-search-btn" onclick="shadow()">阴影(开/闭)</button>
</div>
<h1 class="filter-title">时间范围调节</h1>
<div class="box">
<div class="layui-form-item">
<label class="layui-form-label">时间</label>
<div class="layui-input-block">
<div id="slideDate"></div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">时间</label>
<div class="layui-input-block">
<div id="slideTime"></div>
</div>
</div>
</div>
<h1 class="filter-title">动态模拟</h1>
<!-- <div class="box">
<div class="layui-form-item">
<label class="layui-form-label">开始时间</label>
<div class="layui-input-block">
<input type="text" class="layui-input" id="test3">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">结束时间</label>
<div class="layui-input-block">
<input type="text" class="layui-input" id="test4">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">时间间隔</label>
<div class="layui-input-block">
<input type="text" name="timeinterval" id="interval" lay-verify="number" autocomplete="off"
value="1.0" class="layui-input">
</div>
</div>
</div>
<div style="padding:20px;">
<button type="button" class="search-btn" onclick="sunshineBtn()">确定</button>
</div> -->
</div>
</form>
</div>
</body>
<script>
layui.use(['laydate', 'slider'], function () {
var laydate = layui.laydate;
var slider = layui.slider;
//执行一个laydate实例
laydate.render({
elem: '#test1' //指定元素
, type: 'datetime'
, value: new Date()
, done: function (value, date, endDate) {
//console.log(value); //得到日期生成的值,如:2017-08-18
//console.log(date); //得到日期时间对象:{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0}
skyDate.currentDate = date;
//alert(value);
//console.log(endDate); //得结束的日期时间对象,开启范围选择(range: true)才会返回。对象成员同上。
}
});
slider.render({
elem: '#slideDate' //绑定元素
, min: 0
, max: 365
, setTips: function (value) { //自定义提示文本
var y = new Date().getFullYear();
var date = new Date(y, 0, 1);
date.setDate(date.getDate() + value);
var m = date.getMonth();
var d = date.getDate();
return y + "-" + (m + 1) + "-" + d;
}
, change: function (value) {
setSkylineDate(value);
console.log(value); //动态获取滑块数值
//do something
}
});
slider.render({
elem: '#slideTime' //绑定元素
, min: 0
, max: 1440
, setTips: function (value) {
var h = parseInt(value / 60);
var m = value % 60;
return h + ":" + m;
},
change: function (value) {
setSkylineTime(value);
}
});
laydate.render({
elem: '#test3' //指定元素
, type: 'time'
, value: new Date()
, done: function (value, date, endDate) {
//console.log(value); //得到日期生成的值,如:2017-08-18
console.log(date); //得到日期时间对象:{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0}
skyDate.startTime = date;
//alert(value);
//console.log(endDate); //得结束的日期时间对象,开启范围选择(range: true)才会返回。对象成员同上。
}
});
laydate.render({
elem: '#test4' //指定元素
, type: 'time'
, value: new Date()
, done: function (value, date, endDate) {
console.log(date); //得到日期时间对象:{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0}
skyDate.endTime = date;
//console.log(endDate); //得结束的日期时间对象,开启范围选择(range: true)才会返回。对象成员同上。
}
});
});
</script>
<script>
var skyDate = {};
function appointedTime() {
var sgWorld = CreateSGObj();
if (!sgWorld.Command.IsChecked(2118, 0)) {
sgWorld.Command.Execute(2118, 0);
}
sgWorld.DateTime.SetMode(1);
var date = new Date();
alert(skyDate.currentDate.month);
date.setFullYear(skyDate.currentDate.year);
date.setMonth(skyDate.currentDate.month - 1);///月份范围是0-11
date.setDate(skyDate.currentDate.date);
date.setHours(skyDate.currentDate.hours);
date.setMinutes(skyDate.currentDate.minutes);
date.setSeconds(skyDate.currentDate.seconds);
//alert(date);
sgWorld.DateTime.Current = date;//修改当前的时间
//时间滑块被设置为这个时间,太阳光线对应于当前日期这个时间所在的位置
sgWorld.DateTime.FixedLocalTime = date;
//alert("当前时间为:" + sgWorld.DateTime.Current);
}
function shadow() {
var sgWorld = CreateSGObj();
sgWorld.Command.Execute(2118, 0);
}
function setSkylineDate(value) {
var d = new Date();
var arr = value.split('-');
d.setFullYear(arr[0]);
d.setMonth(arr[1] - 1);
d.setDate(arr[2]);
var sgWorld = CreateSGObj();
sgWorld.DateTime.FixedLocalTime = d;
}
function setSkylineTime(value) {
var d = new Date();
var arr = value.split(':');
d.setHours(arr[0]);
d.setMinutes(arr[1]);
var sgWorld = CreateSGObj();
sgWorld.DateTime.FixedLocalTime = d;
}
function sunshineBtn() {
var sgWorld = CreateSGObj();
var s = skyDate.startTime,
e = skyDate.endTime;
var startT = new Date();
startT.setHours(s.hours);
startT.setMinutes(s.minutes);
startT.setSeconds(s.seconds);
var endT = new Date();
endT.setHours(e.hours);
endT.setMinutes(e.minutes);
endT.setSeconds(e.seconds);
var day = endT < startT ? 0 : (endT - startT) / 1000 / 60;
function play() {
day -= parseInt($("#interval").val());
var start = startT.getTime();
var currentTime = start.setTime(
start + this.sunshine.interval * (24 * 60 * 60 * 1000)
);
sgWorld.DateTime.FixedLocalTime = currentTime;
day &&
setTimeout(() => {
play.call(this);
}, 500);
}
day && play.call(this);
}
</script>
</html>