staging first commit

This commit is contained in:
zino
2021-01-20 13:35:16 +01:00
parent 504d9ea337
commit 30e837697d

View File

@@ -0,0 +1,151 @@
var config = {
'DEBUG': true,
'BRANCH': 'seatmap_main',
};
if (config['BRANCH'] === 'seatmap_testing') {
config['SEATMAP_WEBAPI_URL'] = 'https://seatmap-testing.zinomedia.de/seatmap-webapi/api.php';
}
else if (config['BRANCH'] === 'seatmap_main') {
config['SEATMAP_WEBAPI_URL'] = 'https://zinomedia.de/seatmap_main/seatmap-webapi/api.php';
}
jQuery(document).ready(function() {
if (config['DEBUG']) console.log(getFuncName('ready'));
check_inject();
});
function check_inject() {
if (config['DEBUG']) console.log(getFuncName());
var pvo_venue_name = jQuery('.venue span')[0].textContent.toUpperCase();
var url = config['SEATMAP_WEBAPI_URL'] + '/records/halls?filter=PVO_VENUE_NAME,eq,' + pvo_venue_name + '&include=INJECT';
var result = jQuery.get(url, function(data) {})
.done(function(data) {
if (data['records'][0]['INJECT']) {
if (config['DEBUG']) console.log('Starting inject...');
inject_seatmap();
}
else {
if (config['DEBUG']) console.log('Not injecting.');
}
});
}
function inject_seatmap() {
var url, param;
var content = document.getElementsByTagName('html')[0].innerHTML;
var inputsWithValue = getInputs(content);
if (config['DEBUG']) console.log(inputsWithValue);
if (!jQuery.isEmptyObject(inputsWithValue)) {
if (inputsWithValue.hasOwnProperty("trxstate") && inputsWithValue["trxstate"].value == 20) {
if (config['DEBUG']) console.log("trxstate 20 identified");
manipulateDocument();
var note = important_note();
param = getPosturl(content);
if (jQuery('#flash_seat_map_box_id').length) {
url = generateUrl(param, inputsWithValue, note);
if (config['DEBUG']) console.log(url);
jQuery("#viewSeatFlashMapButton").unbind();
jQuery('#viewSeatFlashMapButton').click(function() {
if (config['BRANCH'] === 'seatmap_testing') {
window.location.href = 'https://seatmap-testing.zinomedia.de/seatmap-client/index.html?' + "posturl=" + url;
}
else if (config['BRANCH'] === 'seatmap_main') {
window.location.href = 'https://purchase.tickets.zinomedia.de/?' + "posturl=" + url;
}
else {
throw new Error('Die: Branch not defined.');
}
});
}
}
else if (inputsWithValue.hasOwnProperty("prevtrxstate") && inputsWithValue["prevtrxstate"].value == 30) {
if (config['DEBUG']) console.log("prevtrxstate 30 identified");
// jQuery(".jq_replace")[0].text = 'Abbrechen';
// jQuery('.jq_add').css('display', 'none');
}
}
}
function generateUrl(param, inputsWithValue, note) {
if (config['DEBUG']) console.log(getFuncName());
var url = param[0];
var event = param[1];
var holdcode = param[2];
var parameter = '';
for (var property in inputsWithValue) {
if (inputsWithValue.hasOwnProperty(property)) {
parameter = parameter + property + '=' + inputsWithValue[property].value + '&';
}
}
parameter = parameter.substring(0, parameter.length - 1);
url = url + "&holdcode=" + holdcode + "&event=" + event + '&nocache=0&inclpkg=Y&incloffer=Y&inclcartdetails=Y&inclCart=Y&inclvenue=Y' + parameter;
if (typeof note !== 'undefined') {
url = url + '&note=' + note;
}
url = encodeURIComponent(url);
return url;
}
function getPosturl(content) {
if (config['DEBUG']) console.log(getFuncName());
var posturl = content.match(/posturl:"(.+?)"/)[1];
var event = content.match(/event:"(.+?)"/)[1];
var holdcode = content.match(/holdcode:"(.+?)"/)[1];
return [posturl, event, holdcode, content];
}
function getInputs(content) {
if (config['DEBUG']) console.log(getFuncName());
var inputsWithValue = new Object();
var data = jQuery.parseHTML(content);
var checkoutParam = [
'APPTE', 'age_consent_is_checked', 'agency', 'cancelAndRedirectTrxState', 'cogid', 'coids', 'discount=A=IE', 'discount=A=IV', 'discountdesc=A=IE', 'discountdesc=A=IV', 'discountfees=A=IE', 'discountfees=A=IV', 'discountprice=A=IE', 'discountprice=A=IV', 'dpa_selection', 'etpgcode', 'flashDetected', 'gid', 'hbx_discount_prices', 'hbx_discounts', 'hbx_offered_pg', 'hbx_perf_codes', 'hbx_perf_sub_codes', 'hbx_pids', 'hbx_requested_pg', 'hbx_selected_tixx', 'hbx_upsell_flag', 'request_type', 'invalid_seats', 'inventory_filtering_action', 'inventory_month', 'inventory_year', 'isCapEnabled', 'is_availability_switch_from_map', 'is_ticket_exchange_request', 'ism_map_current_state_json_data', 'jcarousel_auto_off_val', 'listing_type', 'mainEventPID', 'map_coupon_code', 'mlbamsp', 'oid', 'ooids', 'orderkey', 'orgid', 'p_orgid', 'package_pids', 'parent_offer_id', 'pay_pal_token', 'pid', 'prevtrxstate', 'recapToken', 'redeem_voucher_data_event_mapping', 'replay_request', 'request_action', 's_mem_tkt_ren_retrieval', 'schedule', 'secure_trxn_enabled', 'selected_seat_indexes', 'selected_upsell_option', 'supplierCode', 'supplier_code', 'target_name_value', 'target_prev_trxstate', 'target_trxstate', 'target_url', 'timeout_seconds', 'trxstate', 'upsell_selected', 'user_context', 'valid_coupon_code_message'
];
jQuery(data).find('input').each(function() {
if (this.value !== '') {
if (checkoutParam.indexOf(this.name)) {
inputsWithValue[this.name] = this;
}
}
});
return inputsWithValue;
}
function manipulateDocument() {
if (config['DEBUG']) console.log(getFuncName());
jQuery('#flash_seat_map_box_id').css('display', 'block');
jQuery('#get_flash').css('display', 'none');
}
function important_note() {
if (config['DEBUG']) console.log(getFuncName());
var element = document.getElementsByClassName('important_note');
if (element.length > 0) {
var important_note = element[0].textContent;
if (config['DEBUG']) console.log(important_note);
return important_note;
}
}
function getFuncName(arg) {
var caller;
if (getFuncName.caller.name !== '') {
caller = getFuncName.caller.name;
}
else {
caller = arg;
}
return '\n' + '-'.repeat(80) + '\n' + 'PARENT ' + caller + '\n' + '-'.repeat(80);
}