revised parser
This commit is contained in:
@@ -2,12 +2,12 @@ import * as I from "../types/types";
|
||||
var jQuery = require("jquery");
|
||||
|
||||
export function getVenueLocation(): string {
|
||||
let span: string[] = [];
|
||||
let spanArr: string[] = [];
|
||||
jQuery(".venue span").each(function (this: any) {
|
||||
span.push(jQuery(this).text());
|
||||
spanArr.push(jQuery(this).text());
|
||||
});
|
||||
|
||||
return span.join(", ");
|
||||
return spanArr.join(", ");
|
||||
}
|
||||
|
||||
export function getInputs(inContent: string): I.Inputs {
|
||||
@@ -17,6 +17,7 @@ export function getInputs(inContent: string): I.Inputs {
|
||||
jQuery(parsedHTML).find('input').each(function (this: any) {
|
||||
const name: string = this.name;
|
||||
const value: string = this.value;
|
||||
|
||||
if (value !== '')
|
||||
inputs[name] = value;
|
||||
});
|
||||
@@ -25,13 +26,13 @@ export function getInputs(inContent: string): I.Inputs {
|
||||
}
|
||||
|
||||
// todo: check with different venues
|
||||
export function getImportantNote(): { importantNote: string, importantNoteEncoded: string } | undefined {
|
||||
export function getImportantNote(): I.ImportantNote | undefined {
|
||||
if (jQuery(".important_note").length) {
|
||||
const importantNote: string | null = jQuery(".important_note")[0].textContent;
|
||||
|
||||
if (importantNote?.trim().length) {
|
||||
const importantNoteEncoded: string = encodeURIComponent(importantNote);
|
||||
return {
|
||||
return <I.ImportantNote> {
|
||||
"importantNote": importantNote,
|
||||
"importantNoteEncoded": importantNoteEncoded
|
||||
}
|
||||
@@ -41,7 +42,7 @@ export function getImportantNote(): { importantNote: string, importantNoteEncode
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function getAdditionalInputs(inContent: string): { [key: string]: string } {
|
||||
export function getAdditionalInputs(inContent: string): I.Inputs {
|
||||
const event = inContent.match(/event:"(.+?)"/)![1];
|
||||
const holdcode = inContent.match(/holdcode:"(.+?)"/)![1];
|
||||
const posturlRaw = inContent.match(/posturl:"(.+?)"/)![1];
|
||||
@@ -50,7 +51,7 @@ export function getAdditionalInputs(inContent: string): { [key: string]: string
|
||||
const venueLocation = getVenueLocation();
|
||||
const ticketPurchaseUrl = `${posturlRawDecoded.split("?")[0].split('/').slice(0,-1).join('/')}/TicketPurchase`;
|
||||
|
||||
return {
|
||||
return <I.Inputs> {
|
||||
"event": event,
|
||||
"holdcode": holdcode,
|
||||
"posturlRaw": posturlRaw,
|
||||
@@ -61,11 +62,11 @@ export function getAdditionalInputs(inContent: string): { [key: string]: string
|
||||
}
|
||||
}
|
||||
|
||||
export function getVenueImage(): { venueImageSrc: string, venueImageHeight: number, venueImageWidth: number } | undefined {
|
||||
export function getVenueImage(): I.VenueImage | undefined {
|
||||
const img: HTMLImageElement = jQuery("#static_venue_map img").get(0);
|
||||
|
||||
if (img) {
|
||||
return {
|
||||
return <I.VenueImage> {
|
||||
venueImageSrc: img.src,
|
||||
venueImageHeight: img.height,
|
||||
venueImageWidth: img.width
|
||||
@@ -76,15 +77,12 @@ export function getVenueImage(): { venueImageSrc: string, venueImageHeight: numb
|
||||
}
|
||||
|
||||
export function getSMAP(): string | undefined {
|
||||
if (jQuery("#seating_map_url").length === 0)
|
||||
if (!jQuery("#seating_map_url").length)
|
||||
return undefined;
|
||||
|
||||
const str: string = jQuery("#seating_map_url a").attr("onclick");
|
||||
const re = /openNewWindow\(\'(\d+)\'/;
|
||||
const found: RegExpMatchArray | null = str.match(re);
|
||||
|
||||
if (found)
|
||||
return found[1];
|
||||
else
|
||||
return undefined;
|
||||
|
||||
return found ? found[1] : undefined;
|
||||
}
|
||||
Reference in New Issue
Block a user