store = { init: function () { this.initialize(); }, //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ initialize: function () { console.info("--- initialize :: -------------------------------------------------------"); $("head").append(""); $.each(this, function (k, v) { if (k.indexOf("_") == 0) { v["_root"] = "$store"; v["_eventKey"] = $store._conf._eventKey; } }); this._form._css_prefix_ = "str-"; this.css(); this._store.init(this._eventInfo); this._comm._initialize(); this.renderStore(); this.next(true) $("#debug").html(JSON.stringify(this._eventInfo, null, 2)); }, //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ canNext: function (visible) { switch (visible) { case "tickets": $store._store.update(); var ret = $store._store.hasQuantity(); if (!ret) this.renderError("Choose a quantity to purchase"); return ret; case "info": $store._store.update(); } return true; }, //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ next: function (initial) { console.info("next" + (initial ? " :: " + initial : "")); this.renderError(); var visible = $(".str-section:visible"); if (this.canNext(visible.data("store-section"))) { var show = null; var title = ""; switch (visible.data("store-section")) { case "tickets": if ($store._store.infos() == null) { show = "cart"; title = "Checkout"; this.renderCart(); } else { show = "info"; title = "Provide Needed Info(s)"; this.renderInfo(); } break; case "info": console.info("infos") let _valid = this._form.validateUnique(); console.info(_valid); if (_valid != "uniqueCheck") { if (_valid == 1) { show = "cart"; title = "Checkout"; this.renderCart(); } else { show = "info"; title = "Provide Needed Info(s)"; console.info(typeof _valid); this.renderError(typeof _valid == "string" ? _valid : "Provide all required information before continuing."); } } else { return; } break; case "cart": title = "Thank You"; show = "completed"; this.renderCompleted(); break; default: show = "tickets"; title = $store._eventInfo.eventStoreButton; break; } $("#str-navigation-title").html(title); if ($(".str-section:visible").data("storeSection") != show) { $(".str-section:visible").hide(); $("[data-store-section='" + show + "']").show(); if (initial !== true) this.scrollUp(); } } }, //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ nextTo: function (show, title) { $("#str-navigation-title").html(title); if ($(".str-section:visible").data("storeSection") != show) { $(".str-section:visible").hide(); $("[data-store-section='" + show + "']").show(); this.scrollUp(); } }, //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ back: function (from) { console.info("back" + (from ? " :: " + from : "")); this.renderError(); var visible = $(".str-section:visible"); var show = null; var back = false; var title = ""; var current = visible.data("store-section"); switch (from ? from : current) { case "info": case "code": $store._store.update(); title = $store._eventInfo.eventStoreButton; show = "tickets"; break; case "cart": if ($store._store.infos() == null) { title = $store._eventInfo.eventStoreButton; show = "tickets"; } else { show = "info"; title = "Provide Needed Info(s)"; back = true; } break; case "payment": show = "cart"; title = "Cart"; back = true; break; case "completed": show = "payment"; title = "Payment"; back = true; break; default: break; } if (show == "tickets") $store.renderTickets(); $("#str-navigation-title").html(title); console.info(current + " :: " + show); $(".str-section:visible").hide(); $("[data-store-section='" + show + "']").show(); this.scrollUp(); }, //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ renderStore: function () { console.info("--- renderStore -------------------------------------------------------"); var html = ""; html += this.renderEvent(); html += this.renderNav(); html += this.renderTickets(); html += this.renderCode(); html += this.renderInfo(); html += this.renderCart(); //html += this.renderPayment(); html += this.renderCompleted(); this.content(html); html += this.renderTickets(); }, //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ renderEvent: function () { return "
" + this._eventInfo.event.name + " Store
" + this._eventInfo.event.startDate + "
"; }, renderNav: function () { return "" + "" + "" + "" + "
" + "
"; }, renderError: function (msg) { $("#str-error").hide(); if (msg) { console.info(msg); $("#str-error").html(msg); $("#str-error").show(); this.scrollUp(); } }, scrollUp: function () { $([document.documentElement, document.body]).animate({scrollTop: $(".str-navigation").offset().top - 40}, 500); }, //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ renderTickets: function () { if ($("[data-store-section='tickets']").length == 0) { return "
"; } var isLocalhost = window.location.hostname == "localhost"; var html = ""; $.each(this._eventInfo.products, function (i, ticket) { html += $store.renderStoreTicket(ticket, (isLocalhost ? 2 : 0)); }); var storeCodes = $store._store.codes(); $.each(storeCodes, function (key, codeinfo) { var code = undefined; $.each($store._eventInfo.codes, function (i, c) { if (c.code.toUpperCase() == key.toUpperCase()) code = c; }); if (code) { html += $store.renderCode(code, codeinfo); } else { delete storeCodes[key]; } }); $store._store.codes(storeCodes); html = "
" + ($store._eventInfo.hasOwnProperty("codes") && $store._eventInfo.codes.length != 0 ? "" : "") + "
choose quantity for each ticket and press continue
" + "
" + html + "
" + "
" + $store.renderFbPixel("fbpPageView") + "
"; $("[data-store-section='tickets']").html(html); }, //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ renderStoreTicket: function (ticket, index) { console.info("--- renderStoreTicket :: " + ticket.name + " -------------------------------------------------------"); var html = ""; var symbol = $store._eventInfo.currency.symbol; var price = ticket.price; if (price == undefined) { var different = false; $.each(ticket.variations, function (v, variation) { if (price != undefined) { different |= price != variation.price; } price = (price == undefined || price > variation.price ? variation.price : price); }); price = (different ? "from " : "") + symbol + price; } else { price = symbol + price; } html += ""; html += " "; html += " "; html += " "; html += " "; html += " "; html += " "; html += "
" + ticket.name + "" + price + "
" + this._store.inputs.number(ticket.eventProductId, index + "", "str-item-quantity str-override") + "
" + ticket.description + "
"; return html; }, //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ renderCode: function (code, info) { if (!info && $("[data-store-section='code']").length == 0) { return "
"; } var html; if (code) { console.info("--- renderCode ----------------------------------------"); console.info(code); var symbol = $store._eventInfo.currency.symbol; var each = code.applyTo.toUpperCase() == "EACH"; var type = code.amountType; var discount = "- " + (type == "AMOUNT" ? symbol : "") + code.price + (type == "AMOUNT" ? "" : "%") + (each ? " EACH" : ""); if (!each) { var minTotal = 0.00; var maxTotal = 0.00; $.each(code.eventProducts, function (i, ep) { $.each($store._eventInfo.products, function (j, p) { if (p.eventProductId == ep.eventProductId) { var minPrice = null; var maxPrice = null; if (p.hasOwnProperty("price")) { minPrice = p.price; maxPrice = p.price; } else { $.each(p.variations, function (k, v) { if (minPrice == null || minPrice > v.price) { minPrice = v.price; } if (maxPrice == null || maxPrice < v.price) { maxPrice = v.price; } }); } minTotal += minPrice * ep.quantity; maxTotal += maxPrice * ep.quantity; } }); }); discount = symbol + (minTotal - code.price) + (minTotal != maxTotal ? " - " + symbol + (maxTotal - code.price) : ""); } html = (info ? "" : "
choose quantity for each ticket and press continue
"); html += ""; html += " "; html += " "; html += " "; html += " "; html += (each || code.exclusive ? "" : " "); html += (code.exclusive ? " " : ""); html += " "; if (code.eventProducts) { html += " "; html += ""; } html += "
" + code.code.toUpperCase() + "" + discount + (info ? "
" : "") + "
" + this._store.inputs.number(code.code, (info ? info.quantity : 1), "str-item-quantity str-override") + "
" + this._store.inputs.number(code.code, 1, "str-item-quantity str-override") + "
" + code.description + "
" + (each ? "applies to" : "includes") + ":
"; $.each(code.eventProducts, function (i, ep) { $.each($store._eventInfo.products, function (j, p) { if (p.eventProductId == ep.eventProductId) { html += "
" + p.name + (ep.hasOwnProperty("quantity") ? "(" + (each ? "up to " + ep.quantity : ep.quantity + " count") + ")" : "") + "
" + p.description + "
"; } }); }); html += "
"; html += (info ? "" : "
"); if (info) return html; $("#str-navigation-title").html("Promo Code - " + code.code.toUpperCase()); $("[data-store-section='code']").html(html); } else { html = "
enter your promo code below and press continue
" + "
" + "
"; $("#str-navigation-title").html("Promo Code"); $("[data-store-section='code']").html(html); $(".str-section:visible").hide(); $("[data-store-section='code']").show(); } }, //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ processCode: function (code, quantity) { this.renderError(); if (code) { var discountCodes = $store._store.codes(); if (quantity < 1 && discountCodes.hasOwnProperty(code)) { delete discountCodes[code]; } else { $.each($store._eventInfo.codes, function (i, c) { if (c.code == code) { var each = c.applyTo.toUpperCase() == "EACH"; if (!discountCodes.hasOwnProperty(code)) { discountCodes[code] = {code: code, exclusive: c.exclusive}; } discountCodes[code]["eventDiscountCodeId"] = c.eventDiscountCodeId; var quantity = $("[data-form-item-id='" + code + "']").val(); if (!each && !c.exclusive) { if (quantity < 1) { delete discountCodes[code]; } else { discountCodes[code]["quantity"] = parseInt(quantity); } } } }); } $store._store.codes(discountCodes); $("[data-store-section='code']").html(""); $store.back("code"); } else { var val = $("#str-code").val(); var code = null; $.each($store._eventInfo.codes, function (i, c) { if (c.code.toUpperCase() == val.toUpperCase()) code = c; }); if (code != null) { $store.renderCode(code); return; } this.renderError("The promo code you entered is not valid."); } }, //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ renderInfo: function () { if ($("[data-store-section='info']").length == 0) { return "
"; } //console.clear(); console.info("--- renderInfo ----------------------------------------"); var symbol = $store._eventInfo.currency.symbol; var accountInfos = this._storage.store("accountInfos"); var infos = this._store.infos(); var html = "
specify information for each ticket below
"; html += "
" + this._form.required() + "
"; html += "
"; $.each(infos, function (ii, info) { for (var i = 0; i < info.quantity; i++) { var price = info.price; var different = false; var accountInfo = accountInfos[info.eventProductId]; accountInfo = (accountInfo && accountInfo.length > i ? accountInfo = accountInfo[i] : null); if (info.variations) { $.each(info.variations, function (v, variation) { if (price != undefined) { different |= price != variation.price; } }); $.each(info.variations, function (v, variation) { price = (price == undefined || price > variation.price ? variation.price : price); }); } price = (different ? "from " : "") + symbol + price; html += ""; html += " "; html += " "; html += " "; html += " "; html += ""; if (info.variations) { var options = null; var value = (accountInfo && accountInfo["variation"] ? accountInfo["variation"] : ""); $.each(info.variations, function (v, variation) { options += ""; }); html += ""; html += ""; } if (info.form) { $.each(info.form.parts, function (pi, part) { part["product"] = info.name; var datas = undefined; if (info.uniqueAccount && part.key == "emailAddress") { datas = {"unique": "emailAddress"}; } html += ""; html += ""; }); } if (i == 0 && info.quantity > 1) { html += ""; } html += "
" + info.name + (info.quantity > 1 ? " #" + (i + 1) : "") + (info.uniqueAccount ? "(one per email address)" : "") + "" + price + "
" + (info.variationLabel ? info.variationLabel : "Choose a ticket").toLowerCase() + "
" + $store._store.inputs.choice(info.eventProductId, i + 1, options) + "
" + part.name.toLowerCase() + "
" + $store._form.render(info.eventProductId, i + 1, part, (accountInfo && accountInfo[part.key] ? accountInfo[part.key] : ""), datas) + "
"; } html += "
" html += "
"; }); html += $store.renderFbPixel("fbpAddToCart"); $("[data-store-section='info']").html(html); setTimeout($store._form.validate, 500); }, renderFbPixel: function (event, price) { /* fbPixel('fbpPageView') fbPixel('fbpAddToCart') fbPixel('fbpAddPaymentInfo') fbPixel('fbpInitiateCheckout') fbPixel('fbpPurchase',record('confirmation').total) fbPixel('fbpPromoCode') */ if ($store._eventInfo.hasOwnProperty("attributes") && $store._eventInfo.attributes.hasOwnProperty("fbPixel")) { var args = "&dl="+encodeURIComponent(window.location.href); if (event == "fbpPurchase") { args = "&cd[currency]=" + encodeURIComponent($store._eventInfo.currency.code.toUpperCase()) + "&cd[value]=" + encodeURIComponent(price); } return ""; } return ""; }, copyInfos: function (id, quantity) { $("[data-form-item-id='" + id + "'][data-form-item-index='1']").each(function () { for (var index = 2; index < quantity + 1; index++) { $("[data-form-item-id='" + id + "'][data-form-item-index='" + index + "'][data-form-item-name='" + $(this).data("formItemName") + "']").val($(this).val()); } }); $store._form.validate(); }, //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ renderCart: function () { if ($("[data-store-section='cart']").length == 0) { return "
"; } var cart = this._store.cart(); var codes = $store._store.codes(); var html = "
Cart
"; var symbol = "$"; var subtotal = 0.0; var discount = 0.0; var fee = 0.0; var tax = 0.0; var total = 0.0; var cartItemInfo = {}; $.each(cart, function (i, item) { if (!cartItemInfo.hasOwnProperty(item.eventProductId)) { cartItemInfo[item.eventProductId] = {quantity: 0, price: 0.0}; } cartItemInfo[item.eventProductId].quantity++; cartItemInfo[item.eventProductId].price += parseFloat(item.price); symbol = item.symbol; subtotal += item.price; fee += item.fee; html += "" + "" + item.name + "" + "" + symbol + " " + parseFloat(item.price).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + "" + ""; }); $.each(codes, function (key, cc) { var code = undefined; $.each($store._eventInfo.codes, function (i, c) { if (key == c.code) code = c; }); if (code) { if (code.applyTo == "COLLECTION") { discount += parseFloat(code.price) * parseInt(cc.quantity); } if (code.applyTo == "EACH") { $.each(code.eventProducts, function (p, product) { if (code.amountType == "AMOUNT") { var quantity = cartItemInfo.hasOwnProperty(product.eventProductId) ? parseInt(cartItemInfo[product.eventProductId].quantity) : 0; var maxQuantity = (product.hasOwnProperty("quantity") ? parseInt(product.quantity) : 99999); discount += parseFloat(code.price) * (quantity < maxQuantity ? quantity : maxQuantity); } else { discount += parseFloat(code.price) / 100.0 * (cartItemInfo.hasOwnProperty(product.eventProductId) ? parseFloat(cartItemInfo[product.eventProductId].price) : 0); } }); } } }); storeInfo = $store._storage.store("store-info"); var haveBalance = parseFloat(subtotal - discount) > 0.00; subtotal = parseFloat(subtotal).toFixed(2); discount = parseFloat(discount).toFixed(2); fee = (haveBalance ? parseFloat(fee).toFixed(2) : "0.00"); tax = parseFloat((parseFloat(subtotal) - parseFloat(discount) + parseFloat(fee)) * (parseFloat(storeInfo.salesTax) / 100)).toFixed(2); total = parseFloat(parseFloat(subtotal) - parseFloat(discount) + parseFloat(fee) + parseFloat(tax)).toFixed(2); html += ""; html += "SUBTOTAL" + symbol + " " + subtotal.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + ""; html += (discount > 0.0 ? "DISCOUNT" + symbol + " " + parseFloat(discount * -1).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + "" : ""); html += (fee > 0.0 ? "CONVENIENCE FEE" + symbol + " " + fee.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + "" : ""); html += (tax > 0.0 ? "TAX" + symbol + " " + tax.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + "" : ""); html += ""; html += "TOTAL" + symbol + " " + total.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + ""; html += $store.renderFbPixel("fbpInitiateCheckout"); $store._storage.store("store-totals", { subtotal: subtotal, discount: discount, fee: fee, tax: tax, total: total }); $("[data-store-section='cart']").html("
" + html + "
" + this.renderPayment() + "
"); if (haveBalance) { $store._store.stripe.populate(); } setTimeout($store._form.validate, 500); }, //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ _paymentFields: [ { "ordering": 1, "formPartType": "text", "name": "Name on Credit Card", "choices": [], "required": true, "key": "name" }, { "ordering": 2, "formPartType": "email", "name": "e-mail address", "choices": [], "required": true, "key": "emailAddress" }, { "ordering": 3, "formPartType": "phone", "name": "cellphone number", "choices": [], "required": true, "key": "phoneNumber" } ], _purchaseFields: [ { "ordering": 1, "formPartType": "text", "name": "full name", "choices": [], "required": true, "key": "name" }, { "ordering": 2, "formPartType": "email", "name": "e-mail address", "choices": [], "required": true, "key": "emailAddress" }, { "ordering": 3, "formPartType": "phone", "name": "cellphone number", "choices": [], "required": true, "key": "phoneNumber" } ], renderPayment: function () { $store.processingPayment = false; var html = ""; var haveBalance = parseFloat($store._storage.store("store-totals").total) > 0.00; $.each((haveBalance ? this._paymentFields : this._purchaseFields), function (pi, part) { html += "" + part.name.toLowerCase() + ""; html += "" + $store._form.render("paymentInfo-" + part.key, 0, part, "") + ""; }); if (haveBalance) { html += "credit card information"; html += "
"; } return "
" + (haveBalance ? "Payment Information" : "Purchase Information") + "
" + "
" + this._form.required() + "
" + "" + html + "
" + "
" + "
- processing purchase -
"; }, //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ processPayment: function () { if ($store._form.validate()) { var haveBalance = parseFloat($store._storage.store("store-totals").total) > 0.00; $("#str-buttons-payment").hide(); $("#str-message-payment").show(); if (haveBalance) { $store._store.stripe.token(); } else { $store._store.processPurchase(); } } else { this.renderError("Provide all required payment information."); } }, //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ renderCompleted: function () { if ($("[data-store-section='cart']").length == 0) { return "
"; } var html = ""; html += "
"; html += "
Thank you for your purchase!
"; html += "
Your order has been successfully processed.
"; html += "
Your order number is " + $store._eventInfo.receipt.id + ".
"; html += "
View/Print Your Receipt
"; html += "
You should receive an email with your event check-in details and purchase receipt within the next 5 minutes. If you do not, please check your Spam folder! Mark the email as safe if it landed there so your check-in details are easily accessible in your inbox for the event.
"; html += "
If you do not receive an email from us, please email info@bridescan.com or call (865) 531-3941 for quick assistance.
"; html += "
We hope you enjoy the event!
"; html += "
"; html += "
"; html += $store.renderFbPixel("fbpPurchase",$store._storage.store("store-totals").total); $("[data-store-section='completed']").html(html); $store._storage.store("store", {}); $store._storage.store("accountInfos", {}); $store._store.codes({}); }, formatDates: function (json, which, pre) { if (json) { var start = (json.hasOwnProperty("availableStartDate") && (which == null || which == "availableStartDate") && json.availableStartDate != null ? json.availableStartDate : (json.hasOwnProperty("startDate") && json.startDate != null ? json.startDate : null)); var end = (json.hasOwnProperty("availableEndDate") && (which == null || which == "availableStartDate") && json.availableEndDate != null ? json.availableEndDate : (json.hasOwnProperty("endDate") && json.endDate != null ? json.endDate : null)); if (start == null && which != undefined) { start = json[which]; end = json[which]; } if ((start != null && !start.hasOwnProperty("year")) || (end != null && !end.hasOwnProperty("year"))) { return ""; } if (start != null && end != null) { if (start.year.name == end.year.name) { if (start.month.id == end.month.id) { if (start.day.id == end.day.id) { return "" + start.month.short + " " + start.day.name + ", " + start.year.name + ""; } else { return "" + start.month.short + " " + start.day.name + "-" + end.day.name + ", " + start.year.name + ""; } } else { return "" + start.month.short + " " + start.day.name + " - " + end.month.short + " " + end.day.name + ", " + end.year.name + ""; } } else { return "" + start.month.short + " " + start.day.name + ", " + start.year.name + " - " + end.month.short + " " + end.day.name + ", " + end.year.name + ""; } } else if (start != null) { return "" + (pre != undefined ? pre : "from") + " " + start.month.short + " " + start.day.name + ", " + start.year.name + "" } else if (end != null) { return "" + (pre != undefined ? pre : "until") + " " + end.month.short + " " + end.day.name + ", " + end.year.name + "" } return "no dates available"; } }, //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ render: function (type) { switch (type) { //--------------------------------------------------------------------------------------------------- case "receipt": this.next(); $("#str-message-payment").hide(); $("#str-buttons-payment").show(); break; case "error": this.renderError("Error occurred processing payment. " + $store._eventInfo.error.error); $("#str-message-payment").hide(); $("#str-buttons-payment").show(); break; case "uniqueCheck": if ($store._eventInfo.uniqueCheck.status != "success") { this.renderError($store._eventInfo.uniqueCheck.status); } else { $store.nextTo("cart", "Checkout"); $store.renderCart(); } break; } }, //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ content: function (html) { $("#store-" + $store._conf._eventKey.toLowerCase()).html("
" + html + "
"); }, //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ data: function (type, data) { this._eventInfo[type] = data; this.render(type); }, //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ style: { ".str": "max-width: 90%;width: 800px;margin:1% auto;border: 2px solid #aaa;border-radius: 7px;padding: 20px;background-color:#fff;color:#333;", ".str, .str *": "font:13pt Arial;", ".str a": "color:inherit !important;font-size:inherit !important;", ".str table": "border-spacing: 0px;border-collapse: separate;width:100%;", ".str table tr td": "border:0px;padding:2px;text-align:left;", ".str img": "max-width:98%;margin:1px 1%;border-radius:4px;", ".str .fa": "font-size:120%;margin-right:7px;width:15px;text-align:center;", ".str button": "text-align:center;color:inherit;border:1px solid #aaa;background-color:#eee;font-size:90%;border-radius:3px;padding:1px 10px;cursor:pointer;", ".str input, .str select": "padding:10px 2%;width:96% !important;border:1px solid #bbb;border-radius:3px;color:#333", ".str .str-buttons": "text-align:center;padding-top:10px;", ".str .str-buttons button": "padding:10px 30px;margin:5px 3px;", ".str .str-buttons button.str-back": "border:1px solid #ccc;background-color:#fff;", ".str .str-buttons-remove button": "padding:2px 10px;margin:10px;color:#900;background-color:rgba(200,0,0,.08);", ".str .str-message": "display:none;text-align:center;padding:20px;font-style:italic;color:rgb(200,0,0);font-size:90%;", ".str .str-event-info": "text-align:center;background-color:#999;color:#fff;margin:auto;margin-top:-21px;margin-bottom:10px;max-width:80%;font-size:70%;padding:5px; border-radius:0 0 7px 7px;", ".str .str-event-info>div": "text-align:center;font-size:70%;font-style:italic;margin-top:3px;display:none;", ".str .str-navigation": "width:100%;border-bottom:1px solid #ccc;margin-bottom:10px;", ".str .str-navigation tr td": "text-align:center;padding:4px;", ".str .str-navigation tr td.str-title": "font-size:120%;", ".str .str-navigation tr td:first-child, .str .str-navigation tr td:last-child": "width:30px;", ".str .str-error": "text-align:center;border:1px solid rgba(200,0,0,.1);border-radius:5px;background-color:rgba(200,0,0,.05);color:rgb(200,0,0);padding:5px;font-style:italic;font-size:80%;margin-bottom:5px;display:none;", ".str .str-instructions": "font-size:75%;text-align:center;font-style:italic;color:#aaa;padding:5px;", ".str .str-section": "display:none", ".str .str-section-heading": "font-size:120%;margin:20px 2px 2px 2px;", ".str .str-section-heading:first-child": "margin-top:2px", ".str .str-tickets": "border:1px solid #ccc;border-radius:5px;", ".str .str-ticket": "border-top:1px solid #ccc;width:98%;cursor:pointer;margin:5px 1%;padding:5px;", ".str .str-ticket:first-child": "border-top:none;", ".str .str-ticket:hover": "background-color:#f8f8f8;", ".str .str-ticket .str-item-name": "font-size:140%;padding:10px;", ".str .str-ticket .str-item-unique": "font-size:75%;margin-left:5px;font-style:italic;", ".str .str-ticket .str-item-price": "white-space:nowrap;text-align:right;font-size:140%;padding:10px;white-space: nowrap;vertical-align:top;width:1%;", ".str .str-ticket .str-item-price span": "font-size:70%;color:#999;", ".str .str-ticket .str-item-description": "padding:5px 15px 0 15px;font-size:80%;font-style:italic;color:#777;", ".str .str-ticket .str-item-description *": "font-size:inherit;font-style:inherit;", ".str .str-ticket .str-item-description .str-item-quantity": "text-align:center;max-width:80px;font-size:120%;", ".str .str-ticket .str-item-heading": "padding:5px 15px 0 15px;font-size:80%;font-style:italic;color:#777;", ".str .str-item-items": "padding:10px 0 10px 40px;", ".str .str-item-items>div": "font-weight:bold;", ".str .str-item-items>div>span": "font-weight:normal;font-size:70%;margin-left:10px;font-style:italic;", ".str .str-item-items>div>div": "font-weight:normal;color:#777", ".str .str-item-items>div>div>p": "margin:0px 10px;font-size:80%;", ".str .str-code-link": "text-align:right;cursor:pointer;", ".str .str-code": "padding:10px;text-align:center;", ".str .str-code input": "text-align:center;", ".str .str-item-label": "width:100%;font-size:80%;font-style:italic;padding:7px 7px 3px 7px;color:#999;", ".str .str-item-text": "width:100%;", ".str .str-item-full>*": "width:100%;", ".str .str-item-shaded": "background-color:#f0f0f0;", ".str .str-divider": "border-top:1px solid #aaa;padding:0px;", ".str .str-cart": "font-size:90%;font-weight:normal;border:1px solid #ccc;border-radius:5px;padding:10px;", ".str .str-sub-heading": "font-size:120%;border-bottom:1px solid #aaa;padding:5px;background-color:#eee;text-align:center;margin-top:15px;", ".str .str-sub-heading:first-child": "margin-top:0px;", ".str .str-cart .str-cart-item-first .str-cart-item": ";border-top:none;", ".str .str-cart .str-cart-item": "padding:3px;border-top:1px solid #ccc;", ".str .str-cart .str-cart-item-name": "", ".str .str-cart .str-cart-item-price": "text-align:right;white-space:nowrap;width:1%;padding-right:3px;", ".str .str-cart .str-cart-total": "white-space:nowrap;width:1%;font-size:90%;text-align:right;padding-right:5px;padding-left:25px;font-size:70%;color:#999;", ".str .str-completed div": "margin:10px 0;", ".str .str-completed .str-completed-thankyou": "font-size:120%;", ".str .str-completed .str-completed-order-number": "font-size:120%;font-weight:bolder;", ".str .str-completed .str-completed-receipt": "border:1px solid #aaa;padding:10px;display:inline-block;text-decoration: none;margin:15px;", ".str .str-completed .str-completed-instruction": "font-size:80%;", ".str .str-completed .str-completed-enjoy": "font-size:120%;font-weight:bold;color:#111;text-align:center;", ".str .str-form-item-required": "background-color:rgba(221, 119, 0, .05);border:1px solid #aaa;", ".str .StripeElement ": "box-sizing: border-box;padding: 13px;border: 1px solid #999;border-radius: 4px;background-color: white;box-shadow: none;-webkit-transition: box-shadow 150ms ease;transition: box-shadow 150ms ease;", ".str .StripeElement--focus ": "box-shadow: none", ".str .StripeElement--invalid ": "border-color: #fa755a;", ".str .StripeElement--webkit-autofill ": " background-color: #fefde5 !important;", }, css: function () { var css = ""; $.each(this.style, function (k, v) { css += k + "{" + v + "} "; }); $("").appendTo("head"); }, //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ _eventInfo: { "codes": [], "stripeConnectedAccount": "acct_1HzOiCEQ3mpjc6lo", "currency": { "symbol": "$", "code": "usd", "dollarAmount": "2.00", "name": "USD ($)", "id": 1, "percentageAmount": "0.040" }, "stripePublishableKey": "pk_live_7nlSMNC5CczWf6uwLsZ6Khhs", "attributes": {}, "salesTax": "0.00", "storeProductOrdering": "priceDescendingNameAscending", "event": { "eventId": 195, "name": "Huntsville Boat Show", "producer": { "phone": "+1 (865) 919-4180", "name": "Boat Shows", "email": "ashleyjones13@gmail.com" }, "startDate": "January 14, 2024 @ 5:00PM" }, "eventStoreFee": "Processing Fee", "enabled": false, "eventStoreButton": "buy tickets", "products": [] }, _conf: { _uri:"https://www.scan2scan.com", _authKey:"kbs", _eventKey:"hunts" }, //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ _store: { init: function (storeInfo) { if (!this.initialized) { console.info("### STORE :: init"); $("head").append(""); $.each(storeInfo.products, function (i, p) { if (p.hasOwnProperty("variations") && p.variations.length == 0) { delete p.variations; } }); $store._storage.store("store-info", storeInfo); $store._storage.store("store", {}); this["initialized"] = true; setTimeout(this.stripe.init, 2000); } }, update: function () { console.clear(); console.info("### STORE :: update :: " + this._eventKey); var store = $store._storage.store("store"); var codes = $store._store.codes(); $("[data-store='" + this._eventKey + "']").each(function () { var id = $(this).data("formItemId"); var index = $(this).data("formItemIndex"); var name = $(this).data("formItemName"); var val = $(this).val(); if (!codes.hasOwnProperty(id)) { if (val != 0 && val.length == 0) val = null; if (!store.hasOwnProperty(id)) { store[id] = {id: id}; } if (index) { if (!store[id].hasOwnProperty("infos")) { store[id]["infos"] = {}; } if (!store[id].infos.hasOwnProperty(index)) { store[id].infos[index] = {}; } if (val) store[id].infos[index][name] = val; else delete store[id].infos[index][name]; } else { if (val) store[id][name] = val; else delete store[id][name]; } } }); $("[data-store='" + this._eventKey + "']").each(function () { var id = $(this).data("formItemId"); var val = $(this).val(); if (codes.hasOwnProperty(id)) { codes[id].quantity = parseInt(val); if (codes[id].quantity == 0) { delete codes[id]; } else { var code = undefined; $.each($store._eventInfo.codes, function (i, c) { if (id == c.code) code = c; }); if (code && code.applyTo == "COLLECTION") { $.each(code.eventProducts, function (i, p) { if (!store.hasOwnProperty(p.eventProductId)) { store[p.eventProductId] = {id: p.eventProductId, quantity: 0}; } store[p.eventProductId].quantity = parseInt(store[p.eventProductId].quantity) + (parseInt(val) * parseInt(p.quantity)); }); } } $store._store.codes(codes) } }); $store._storage.store("store", store); accountInfos = {}; $.each(store, function (i, item) { if (item.hasOwnProperty("infos")) { $.each(item.infos, function (i, info) { var accountInfo = JSON.parse(JSON.stringify(info)); if (!accountInfos.hasOwnProperty(item.id)) { accountInfos[item.id] = []; } accountInfos[item.id].push(accountInfo); }); } }); if (Object.keys(accountInfos).length > 0) { $store._storage.store("accountInfos", accountInfos); } }, infos: function () { var products = []; var storeInfo = $store._storage.store("store-info"); var store = $store._storage.store("store"); $.each(store, function (id, item) { if (item.quantity > 0) { var product = null; $.each(storeInfo.products, function (ip, p) { if (p.eventProductId == id) product = p; }); if (product && (product.hasOwnProperty("form") || product.hasOwnProperty("variations"))) { console.info(product); var p = {eventProductId: product.eventProductId, variationLabel: product.variationLabel, name: product.name, price: product.price, quantity: item.quantity, form: product.form}; if (product.hasOwnProperty("variations")) { p["variations"] = product.variations; } if (product.hasOwnProperty("uniqueAccount")) { p["uniqueAccount"] = product.uniqueAccount; } products.push(p); } } }); return (products.length != 0 ? products : null) }, codes: function (codes) { if (codes) $store._storage.store("store-codes", codes); return $store._storage.store("store-codes"); }, cart: function () { console.info("### STORE :: cart"); var cart = []; var storeInfo = $store._storage.store("store-info"); var store = $store._storage.store("store"); $.each(store, function (id, item) { var product = null; $.each(storeInfo.products, function (ip, p) { if (p.eventProductId == id) product = p; }); if (product) { for (var i = 0; i < item.quantity; i++) { var variation = null; var info = null; if (item.hasOwnProperty("infos") && item.infos.hasOwnProperty(i + 1)) { info = item.infos[i + 1]; if (product.variations) { $.each(product.variations, function (iv, v) { if (v.eventProductVariationId == info.variation) { variation = v; } }); } } var price = parseFloat(variation ? variation.price : product.price); var dollarAmount = parseFloat(product.feeType.dollarAmount); var cartItem = {id: "p" + id + "-" + i, eventProductId: id, name: product.name + (variation ? " - " + variation.name : ""), price: price, symbol: storeInfo.currency.symbol, quantity: 1, fee: (dollarAmount + ((price + (product.feeType.percentageAmountType == "onFeeAmount" ? dollarAmount : 0.00)) * parseFloat(product.feeType.percentageAmount))),}; if (info) { var accountFields = ",name,companyName,contactName,emailAddress,phoneNumber,mobilePhoneNumber,streetAddress1,streetAddress2,city,state,country,zip,"; var attributes = {}; $.each(info, function (field, value) { if (accountFields.indexOf("," + field + ",") == -1) { attributes[field] = value; } }); if (Object.keys(attributes).length != 0) { info["attributes"] = attributes; } cartItem["accountInfo"] = info; if (info.hasOwnProperty("variation")) { cartItem["eventProductVariationId"] = info.variation; var variationDollarAmount = parseFloat(variation.feeType ? variation.feeType.dollarAmount : product.feeType.dollarAmount); cartItem.fee = (variationDollarAmount + ((price + (product.feeType.percentageAmountType == "onFeeAmount" ? variationDollarAmount : 0.00)) * parseFloat(variation.feeType ? variation.feeType.percentageAmount : product.feeType.percentageAmount))); delete info.variation; } } cart.push(cartItem); } } }); console.info(cart); return cart; }, processPurchase: function (token) { console.info("### STORE :: processPurchase :: " + token); var subtotal = 0.0; var fee = 0.0; var cart = $store._store.cart(); var json = {eventId: $store._eventInfo.event.eventId, name: $("[data-form-item-id='paymentInfo-name']").val(), emailAddress: $("[data-form-item-id='paymentInfo-emailAddress']").val(), phoneNumber: $("[data-form-item-id='paymentInfo-phoneNumber']").val(), paymentType: 1, products: [], eventDiscountCodes: []}; if (token) { json["stripeToken"] = token; } var codes = {}; $.each($store._store.codes(), function (c, storeCode) { codes[storeCode.eventDiscountCodeId] = {eventDiscountCodeId: storeCode.eventDiscountCodeId, eventDiscountCodeCount: 0, code: null}; if (storeCode.hasOwnProperty("quantity")) { codes[storeCode.eventDiscountCodeId].eventDiscountCodeCount = storeCode.quantity; } $.each($store._eventInfo.codes, function (i, c) { if (c.eventDiscountCodeId == storeCode.eventDiscountCodeId) codes[storeCode.eventDiscountCodeId].code = c; }); }); $.each(cart, function (index, item) { var product = JSON.parse(JSON.stringify(item)); delete product.fee; delete product.id; delete product.name; delete product.price; delete product.symbol; json.products.push(product); subtotal += item.price; fee += item.fee; }); $.each(codes, function (c, code) { if (code.code.amountType == "AMOUNT") { var eventDiscountCodeProductCount = 1; if (code.code.applyTo == "COLLECTION") { eventDiscountCodeProductCount = 0; $.each(code.code.eventProducts, function (cp, codeProduct) { eventDiscountCodeProductCount += codeProduct.quantity; }); } $.each(code.code.eventProducts, function (cp, codeProduct) { var avail = 0; var used = 0; if (code.code.applyTo == "EACH") { avail = (codeProduct.hasOwnProperty("quantity") ? parseInt(codeProduct.quantity) : 9999); } else { avail = codeProduct.quantity * code.eventDiscountCodeCount; } $.each(json.products, function (p, cart_product) { if (used < avail && codeProduct.eventProductId == cart_product.eventProductId && !cart_product.hasOwnProperty("eventDiscountCodeId")) { used++; cart_product["eventDiscountCodeId"] = code.eventDiscountCodeId; cart_product["eventDiscountCodeProductCount"] = eventDiscountCodeProductCount; if (code.code.applyTo == "EACH") { code.eventDiscountCodeCount++; } } }); }); } else { $.each(json.products, function (p, product) { product["eventDiscountCodeId"] = code.eventDiscountCodeId; product["eventDiscountCodeProductCount"] = 1; code.eventDiscountCodeCount++; }); } }); $.each(codes, function (c, code) { if (code.eventDiscountCodeCount > 0) { json.eventDiscountCodes.push({eventDiscountCodeId: code.eventDiscountCodeId, eventDiscountCodeCount: code.eventDiscountCodeCount}); } }); json["total"] = parseFloat($store._storage.store("store-totals").total).toFixed(2); console.info(json); $store._comm._post("/api/embedPurchase", json); }, hasQuantity: function () { var store = $store._storage.store("store"); var ret = false; $.each(store, function (key, item) { ret |= item.quantity > 0; }); return ret; }, inputs: { number: function (id, val, cls) { return ""; }, choice: function (id, index, options, cls) { return ""; } }, stripe: { init: function () { try { if ($store._storage.store("store-info").hasOwnProperty("stripeConnectedAccount")) { $store["stripe"] = Stripe($store._storage.store("store-info").stripePublishableKey, {"stripeAccount": $store._storage.store("store-info").stripeConnectedAccount}); } else { $store["stripe"] = Stripe($store._storage.store("store-info").stripePublishableKey); } } catch (e) { setTimeout(this.initStripe, 1000); } }, populate: function () { if ($store.stripe) { if ($store.stripe.elements()) { var style = {base: {color: '#32325d', fontFamily: '"Helvetica Neue", Helvetica, sans-serif', fontSmoothing: 'antialiased', fontSize: '14px', '::placeholder': {color: '#aab7c4'}}, invalid: {color: '#fa755a', iconColor: '#fa755a'}}; var elements = $store.stripe.elements(); $store["card"] = elements.create('card', {style: style}); $store.card.mount('#card-element'); $store.card.addEventListener('change', function (event) { if (event.error) { $store.renderError(event.error.message); } }); } } }, token: function () { var name = $("[data-store-item-id='name']").val(); var emailAddress = $("[data-store-item-id='email']").val(); var phoneNumber = $("[data-store-item-id='phoneNumber']").val(); $store.stripe.createPaymentMethod({type: "card", card: $store.card, billing_details: {name: name, email: emailAddress, phone: phoneNumber}}).then(function (result) { if (result.error) { $("#str-message-payment").hide(); $("#str-buttons-payment").show(); $store.renderError(result.error.message); } else { $store._store.processPurchase(result.paymentMethod.id); } }); } } } , //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ _form: { _css_prefix_: "", render: function (id, index, field, value, datas) { return this[field.formPartType](id, index, field, value, datas); }, text: function (id, index, field, value, datas) { return ""; }, email: function (id, index, field, value, datas) { return ""; }, phone: function (id, index, field, value, datas) { return ""; }, hidden: function (id, index, field, value, datas) { return ""; }, date: function (id, index, field, value, datas) { return ""; }, choice: function (id, index, field, value, datas) { var choices = ""; $.each(field.choices, function (i, c) { choices += ""; }); return ""; }, required: function () { return "required
"; }, datas: function (id, index, field, datas) { var additionalDatas = ""; if (datas) { $.each(datas, function (k, v) { additionalDatas += "data-" + k + "='" + v + "' "; }) } return additionalDatas + "data-store='" + this._eventKey + "' " + "data-form-item-id='" + id + "' " + "data-form-item-lbl-id='" + id + "-" + (index ? index + "-" : "") + field.key + "' " + (index ? "data-form-item-index='" + index + "' " : "") + "data-form-item-name='" + field.key + "' data-form-item-product='" + field.product + "' data-form-item-lbl='" + field.name + "' data-form-item-type='" + field.formPartType + "' " + "data-form-item-required='" + field.required + "' " + "data-form-item-required-css='" + this._css_prefix_ + "form-item-required' " + (field.parentKey ? "data-form-item-parent='" + field.parentKey + "' " : "") + (field.parentChoiceKey ? "data-form-item-parent-value='" + field.parentChoiceKey + "' " : "") + "onkeyup=\"" + this._root + "._form.validate('" + id + "')\" " + "onchange=\"" + this._root + "._form.validate('" + id + "')\""; }, lbldatas: function (id, index, field) { return " data-form-lbl-id='" + id + "-" + (index ? index + "-" : "") + field.key + "' "; }, validate: function (iid) { var _valid = true; $("[data-store='" + $store._form._eventKey + "']").each(function () { var parentKey = $(this).data("formItemParent"); var parentValue = $(this).data("formItemParentValue") + ""; var index = $(this).data("formItemIndex"); if (parentKey != null) { var parent = $("[data-store='" + $store._form._eventKey + "'][data-form-item-name='" + parentKey + "']" + (index ? "[data-form-item-index='" + index + "']" : "") + ":visible"); var value = parent.val() + ""; if (parent.length == 0 || value != parentValue) { $(this).hide(); $("[data-form-lbl-id='" + $(this).data("formItemLblId") + "']").hide(); } else { $(this).show(); $("[data-form-lbl-id='" + $(this).data("formItemLblId") + "']").show(); } } }); $("[data-store='" + $store._form._eventKey + "']:visible").each(function () { var id = $(this).data("formItemId"); var val = $(this).val(); var name = $(this).data("formItemName"); var type = $(this).data("formItemType"); var required = $(this).data("formItemRequired"); var requiredCss = $(this).data("formItemRequiredCss"); if (iid == undefined || (iid != undefined && (iid == id))) { $(this).removeClass(requiredCss); valid = true; if (id && required && !val) { valid = false; } if (val) { switch (type) { case "email": valid = $store._form.validateEmailAddress(val); break; case "phone": valid = $store._form.validatePhone(val); break; } switch (name) { case "state": valid = $store._form.validateState(val); break; case "zip": valid = $store._form.validateZip(val); break; } } _valid &= valid; if (!valid) $(this).addClass(requiredCss); } }); return _valid; }, validateUnique: function (iid) { var _valid = this.validate(); if (_valid) { var uniques = {}; var duplicates = false; $("[data-unique]").each(function () { console.info($(this).data()); if (!uniques.hasOwnProperty($(this).val())) { uniques[$(this).val()] = $(this).data("formItemId"); } else { duplicates = true; _valid = "Only one " + $(this).data("formItemProduct") + " per " + $(this).data("formItemLbl") + " can be purchased."; } }); if (!duplicates) { var emailsProducts = []; $.each(uniques, function (email, eventProductId) { emailsProducts.push({emailAddress: email, eventProductId: eventProductId}); }); if (emailsProducts.length != 0) { $store._comm._post("/api/purchasedProductCheck", emailsProducts); return "uniqueCheck"; } } } return _valid; }, validateEmailAddress: function (value) { return /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(value); }, validatePhone: function (value) { return /^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$/im.test(value); }, validateState: function (value) { return /^(A[BLKSZRAEP]|BC|C[AOT]|D[EC]|F[LM]|G[AU]|HI|I[ADLN]|K[SY]|LA|M[ABDEHINOPST]|N[BCDEHJLMVSY]|O[NHKR]|P[AERW]|QC|RI|S[CDK]|T[NX]|UT|V[AIT]|W[AIVY])$/.test(value); }, validateZip: function (value) { return /^[0-9A-Z -]{1,10}$/.test(value); } } , //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ _storage: { store: function (key, value) { if (window.localStorage) { if (key !== undefined) { if (value !== undefined) { if (value != null) { value = JSON.stringify(value); window.localStorage[this._eventKey + "-" + key] = value; if (window.localStorage[this._eventKey + "-" + key] != value) alert("SYSTEM ERROR: Unable to store local data!!!"); return window.localStorage[this._eventKey + "-" + key] == value; } else { delete window.localStorage[this._eventKey + "-" + key]; } } else { if (window.localStorage[this._eventKey + "-" + key]) { return JSON.parse(window.localStorage[this._eventKey + "-" + key]); } return {}; } } } } } , //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ _comm: { _uri: "https://www.scan2scan.com", _initialize: function () { $("body") .append("") .append("
") .append("
"); }, _get: function (url) { url = this._uri + (url.indexOf("/") == 0 ? "" : "/") + url; $("#comm-" + this._eventKey.toLowerCase() + "-form-get").attr("action", url); $("#comm-" + this._eventKey.toLowerCase() + "-form-get").submit(); }, _post: function (url, json) { url = this._uri + (url.indexOf("/") == 0 ? "" : "/") + url; var ljson = JSON.stringify(json); $("#comm-" + this._eventKey.toLowerCase() + "-form-post").attr("action", url); $("#comm-" + this._eventKey.toLowerCase() + "-form-post-json").val(ljson); $("#comm-" + this._eventKey.toLowerCase() + "-form-post").submit(); } } , //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------ _xyz: {} }; $(function () { eval("window.$store = store").init(); }); window.addEventListener("message", function (event) { if (typeof event.data === "string") { var parts = event.data.split("::"); if (parts.length == 2) { var type = parts[0]; var data = JSON.parse(parts[1]); $store.data(type, data); } } });