Skip to content

Commit 0cf833c

Browse files
committed
add date change
1 parent 6cc1b7d commit 0cf833c

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

_posts/2019-02-02-car-location.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -324,13 +324,10 @@
324324
_this.carMarker = new CarMarker($deviceId.value, $startTime.value, $endTime.value);
325325
}
326326
$prevDateButton.onclick = function(){
327-
var dateCurrent = new Date($startTime.value);
328-
var dateNew = new Date(+dateCurrent - 3600 * 1000 * 24);
329-
_this.initTimeRound(dateNew);
330-
$searchButton.click();
327+
_this.dateChange(-1);
331328
}
332329
$nextDateButton.onclick = function(){
333-
_this.carMarker.renderPrevPage();
330+
_this.dateChange(1);
334331
}
335332
$prevPageButton.onclick = function(){
336333
_this.carMarker.renderPrevPage();
@@ -355,6 +352,12 @@
355352
$startTime.value = `${dateNow.getFullYear()}-${getDoubleDigit(dateNow.getMonth() + 1)}-${getDoubleDigit(dateNow.getDate())}T00:00:01`;
356353
$endTime.value = `${dateNow.getFullYear()}-${getDoubleDigit(dateNow.getMonth() + 1)}-${getDoubleDigit(dateNow.getDate())}T23:59:59`;
357354
},
355+
dateChange: function(offset){
356+
var dateCurrent = new Date($startTime.value);
357+
var dateNew = new Date(+dateCurrent + offset* 3600 * 1000 * 24);
358+
this.initTimeRound(dateNew);
359+
$searchButton.click();
360+
},
358361
baiduMap: {
359362
init: function(ctn){
360363
var map = new BMap.Map(ctn);

0 commit comments

Comments
 (0)