delivery-tracker
Advanced tools
Comparing version 1.4.3 to 1.4.4
@@ -0,1 +1,4 @@ | ||
# 1.4.4 | ||
* update USPS site changes. | ||
# 1.4.3 | ||
@@ -2,0 +5,0 @@ * update CJ Korea Express timezone. |
@@ -25,23 +25,45 @@ 'use strict' | ||
courier: courier, | ||
number: $('.tracking-number .value').text().trim(), | ||
number: $('input[name=label]').val(), | ||
status: tracker.STATUS.PENDING | ||
} | ||
var toText = function (txt) { | ||
if (!txt) { | ||
return '' | ||
} | ||
return $(txt.indexOf('<span>') !== -1 ? txt : '<span>' + txt + '</span>').text().trim() | ||
} | ||
var checkpoints = [] | ||
var $details = $('#tc-hits') | ||
$details.find('tbody').find('tr.detail-wrapper').each(function (idx) { | ||
var cols = $(this).find('td') | ||
if (cols.length === 1) { | ||
return false | ||
var $history = $('#trackingHistory_1').find('.panel-actions-content') | ||
$('.mobileOnly').remove() | ||
// html -> txt | ||
var rawTxt = $history.html() | ||
if (rawTxt) { | ||
rawTxt = rawTxt.replace(/\s+/g, ' ') | ||
} | ||
// txt -> history list | ||
var rawList = rawTxt.split('<hr>') | ||
for (var i = 0; i < rawList.length; i++) { | ||
var list = rawList[i].split('<br>') | ||
if (list.length < 3) { | ||
continue | ||
} | ||
var time = $(list[0]).text().trim() | ||
var statusMessage = toText(list[1]) | ||
var location = toText(list[2]) | ||
var message = [statusMessage] | ||
var message = [cols.eq(1).text().trim()] | ||
var time = moment(cols.eq(0).text().trim().replace(/\s{2,}/, ' '), 'MMM DD, YYYY, hh:mm a') | ||
if (list[3].trim().length > 0) { | ||
message.push(toText(list[3])) | ||
} | ||
var checkpoint = { | ||
courier: courier, | ||
location: cols.eq(2).text().trim(), | ||
location: location, | ||
message: message.join(' - '), | ||
status: tracker.STATUS.IN_TRANSIT, | ||
time: time.isValid() ? time.format('YYYY-MM-DDTHH:mm:ss') : '' | ||
// November 17, 2017, 3:08 pm | ||
time: moment(time, 'MMMM DD, YYYY, hh:mm a').format('YYYY-MM-DDTHH:mm') | ||
} | ||
@@ -53,3 +75,3 @@ | ||
checkpoints.push(checkpoint) | ||
}) | ||
} | ||
@@ -56,0 +78,0 @@ result.checkpoints = checkpoints |
{ | ||
"name": "delivery-tracker", | ||
"version": "1.4.3", | ||
"version": "1.4.4", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "name": "egg", |
50479
21
1329