최현영

Highway congest function fixed..

...@@ -187,12 +187,6 @@ function inputroadnumber(typetext){ ...@@ -187,12 +187,6 @@ function inputroadnumber(typetext){
187 } 187 }
188 188
189 function pushmsg(eventObj, roadnumberstring, roadnumberstringLength){ 189 function pushmsg(eventObj, roadnumberstring, roadnumberstringLength){
190 - for(var i = 0; i < 5; i++){
191 - if(roadnumberstringLength == count + i){
192 - raodnumberstringlength[count + i] = "";
193 - }
194 - }
195 -
196 request.post( 190 request.post(
197 { 191 {
198 url: TARGET_URL, 192 url: TARGET_URL,
...@@ -245,7 +239,7 @@ app.post('/hook', function (req, res) { ...@@ -245,7 +239,7 @@ app.post('/hook', function (req, res) {
245 var eventObj = req.body.events[0]; 239 var eventObj = req.body.events[0];
246 var source = eventObj.source; 240 var source = eventObj.source;
247 var message = eventObj.message; 241 var message = eventObj.message;
248 - var isnext = false; 242 + var isnext;
249 // request log 243 // request log
250 console.log('======================', new Date() ,'======================'); 244 console.log('======================', new Date() ,'======================');
251 console.log('[request]', req.body); 245 console.log('[request]', req.body);
...@@ -322,8 +316,10 @@ app.post('/hook', function (req, res) { ...@@ -322,8 +316,10 @@ app.post('/hook', function (req, res) {
322 } 316 }
323 317
324 isnext = nexttext(message.text); 318 isnext = nexttext(message.text);
325 - if(isnext = true){ 319 + if(isnext == true){
326 pushmsg(eventObj, roadnumberstring, roadnumberstringLength); 320 pushmsg(eventObj, roadnumberstring, roadnumberstringLength);
321 + console.log(roadnumberstring);
322 + console.log(roadnumberstringLength);
327 } 323 }
328 324
329 res.sendStatus(200); 325 res.sendStatus(200);
...@@ -753,6 +749,11 @@ function roadcongest(eventObj, msg){ ...@@ -753,6 +749,11 @@ function roadcongest(eventObj, msg){
753 var iscount = 0; 749 var iscount = 0;
754 console.log(number); 750 console.log(number);
755 count = 0; 751 count = 0;
752 + console.log(count);
753 + roadnumberstringLength = 0;
754 + roadnumberstring = new Array();
755 + console.log(roadnumberstring);
756 +
756 if(number.length == 1){ //노선번호가 한자수일 경우, 노선을 찾을 때 두자리 혹은 세자리 번호와 겹칠 수 있으므로. 757 if(number.length == 1){ //노선번호가 한자수일 경우, 노선을 찾을 때 두자리 혹은 세자리 번호와 겹칠 수 있으므로.
757 number = "00" + number; 758 number = "00" + number;
758 } 759 }
...@@ -764,12 +765,19 @@ function roadcongest(eventObj, msg){ ...@@ -764,12 +765,19 @@ function roadcongest(eventObj, msg){
764 if(jsonForcongest.list[i].routeNo.indexOf(number) >= 0){ 765 if(jsonForcongest.list[i].routeNo.indexOf(number) >= 0){
765 766
766 roadnumberstring[iscount] = ("# 노선이름: " + jsonForcongest.list[i].routeName + ", 정체구간: " + jsonForcongest.list[i].conzoneName + ', 기점종점방향: ' + jsonForcongest.list[i].updownTypeCode + ', 교통량: ' + jsonForcongest.list[i].trafficAmout + ', 평균속도: ' + jsonForcongest.list[i].speed); 767 roadnumberstring[iscount] = ("# 노선이름: " + jsonForcongest.list[i].routeName + ", 정체구간: " + jsonForcongest.list[i].conzoneName + ', 기점종점방향: ' + jsonForcongest.list[i].updownTypeCode + ', 교통량: ' + jsonForcongest.list[i].trafficAmout + ', 평균속도: ' + jsonForcongest.list[i].speed);
768 + iscount += 1;
767 } 769 }
768 - iscount += 1; 770 +
769 } 771 }
770 roadnumberstringLength = roadnumberstring.length; 772 roadnumberstringLength = roadnumberstring.length;
771 - 773 + if(roadnumberstringLength != 0){
772 - if(iscount == 0){ 774 + iscount = (roadnumberstringLength % 5);
775 + for(var i = 0; i < (5-iscount); i++ ){
776 + roadnumberstring[roadnumberstringLength + i] = "Out of range";
777 + }
778 + }
779 +
780 + if(roadnumberstringLength == 0){
773 var Notfoundroadnumberstring = "검색하신 노선에서 발견된 정체구간은 없습니다."; 781 var Notfoundroadnumberstring = "검색하신 노선에서 발견된 정체구간은 없습니다.";
774 request.post( 782 request.post(
775 { 783 {
......