홍용민

module.exports와 오류 수정

Showing 1 changed file with 16 additions and 13 deletions
......@@ -12,6 +12,7 @@ require('dotenv').config();
var routeID = ['200000112', '200000115', '234000016', '200000103'];
var Bus = [];
var busNum = [];
// request(BusArrivalUrl, (err, res, body) => {
// var $ = cheerio.load(body, {decodeEntities: false});
......@@ -53,6 +54,7 @@ function getBusNum(){
console.log(newBus);
Bus.push(newBus);
busNum.push(num);
})
})
}
......@@ -74,13 +76,14 @@ function predict(){
let route = $(this).find('routeId').text();
var index = Bus.findIndex(function(e, idx){ return e.routeId == route;});
console.log(index);
if(index > -1){
//var num = $(this).find('plateNo1').text(); // 버스 차량번호 ex) 70사 1290
var time = $(this).find('predictTime1').text(); // 버스 예상 도착시간
var predictHour1 = date.getHours();
var predictMinute1 = date.getMinutes() + Bus[index].mintime - (3 - (time*1)); // 사색의 광장 -> 경희대학교 3분정도 소요
var predictMinute1 = date.getMinutes() + parseInt(Bus[index].MinTime) - (3 - parseInt(time)); // 사색의 광장 -> 경희대학교 3분정도 소요
var predictHour2 = date.getHours();
var predictMinute2 = date.getMinutes() + Bus[index].maxtime - (3 - (time*1)); // time*1 : string to integer 형변환
var predictMinute2 = date.getMinutes() + parseInt(Bus[index].MaxTime)- (3 - parseInt(time)); // time*1 : string to integer 형변환
if(predictMinute1 >= 60){
predictHour1 += 1;
......@@ -102,18 +105,16 @@ function predict(){
var gapHour = Math.floor(gapSec / 60 / 60);
var gapMin = Math.floor((gapSec - gapHour * 3600) / 60);
// var ans = gapHour + "시간" + gapMin + "분 이상";
module.exports.data = {};
// var ETD_min_H = predictTime[0];
// var ETD_min_M = predictTime[1];
// var ETD_max_H = predictTime[2];
// var ETD_max_M = predictTime[3];
module.exports.data.remainTime = gapHour + "시간" + gapMin + "분 이상";
module.exports.data.ETD_min_H = predictTime[0];
module.exports.data.ETD_min_M = predictTime[1];
module.exports.data.ETD_max_H = predictTime[2];
module.exports.data.ETD_max_M = predictTime[3];
module.exports.data.busNum = Bus[index]["BusNum"];
module.exports.remainTime = gapHour + "시간" + gapMin + "분 이상";
module.exports.ETD_min_H = predictTime[0];
module.exports.ETD_min_M = predictTime[1];
module.exports.ETD_max_H = predictTime[2];
module.exports.ETD_max_M = predictTime[3];
console.log(predictTime);
}
})
})
......@@ -121,6 +122,8 @@ function predict(){
function start(){
setInterval(predict, 60000);
console.log(Bus);
console.log(busNum);
}
setTimeout(start, 20000);
\ No newline at end of file
setTimeout(start, 10000);
\ No newline at end of file
......