Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
KItinerary
Commits
330a56cf
Commit
330a56cf
authored
Oct 22, 2019
by
Volker Krause
Browse files
Simplify American Airlines extractor using the new Context API
parent
9b4cc069
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/extractors/americanairlines.js
View file @
330a56cf
...
...
@@ -18,30 +18,13 @@
*/
function
main
(
pdf
)
{
var
result
=
new
Array
();
for
(
var
i
=
0
;
i
<
pdf
.
pageCount
;
++
i
)
{
var
page
=
pdf
.
pages
[
i
];
var
images
=
page
.
imagesInRect
(
0.7
,
0
,
1
,
0.3
);
for
(
var
j
=
0
;
j
<
images
.
length
;
++
j
)
{
var
bcbp
=
Barcode
.
decodePdf417
(
images
[
j
]);
if
(
!
bcbp
)
continue
;
var
res
=
JsonLd
.
newFlightReservation
();
res
.
reservedTicket
.
ticketToken
=
"
aztecCode:
"
+
bcbp
;
var
time
=
page
.
text
.
match
(
/Departing at
\s
+
(\d{1,2}
:
\d{2}[
AP
]
M
)
/
);
if
(
time
)
res
.
reservationFor
.
departureTime
=
JsonLd
.
toDateTime
(
time
[
1
],
"
h:mmA
"
,
"
en
"
)
time
=
page
.
text
.
match
(
/Arriving at:
\s
+
(\d{1,2}
:
\d{2}[
AP
]
M
)
/
);
if
(
time
)
res
.
reservationFor
.
arrivalTime
=
JsonLd
.
toDateTime
(
time
[
1
],
"
h:mmA
"
,
"
en
"
)
result
.
push
(
res
);
break
;
}
}
return
result
;
var
res
=
Context
.
data
[
0
];
var
page
=
pdf
.
pages
[
Context
.
pdfPageNumber
];
var
time
=
page
.
text
.
match
(
/Departing at
\s
+
(\d{1,2}
:
\d{2}[
AP
]
M
)
/
);
if
(
time
)
res
.
reservationFor
.
departureTime
=
JsonLd
.
toDateTime
(
time
[
1
],
"
h:mmA
"
,
"
en
"
)
time
=
page
.
text
.
match
(
/Arriving at:
\s
+
(\d{1,2}
:
\d{2}[
AP
]
M
)
/
);
if
(
time
)
res
.
reservationFor
.
arrivalTime
=
JsonLd
.
toDateTime
(
time
[
1
],
"
h:mmA
"
,
"
en
"
)
return
res
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment