var aerio_request_base_url = 'https://aerbook.com';var aerio_items_to_load = []; jQuery(document).ready(function() { loadAerioPreviewLinks(); }); function loadAerioPreviewLinks() { jQuery(".aerio_preview").each(function() { //for each aerio product buy button, load the buy buttons for each var check_isbn = jQuery(this).attr('data-isbn'); var social = (typeof(jQuery(this).attr("data-social")) != "undefined") ? jQuery(this).attr("data-social") : 1; var retail = (typeof(jQuery(this).attr("data-retail")) != "undefined") ? jQuery(this).attr("data-retail") : 1; var newtab = (typeof(jQuery(this).attr("data-newtab")) != "undefined") ? jQuery(this).attr("data-newtab") : 0; var imprint = (typeof(jQuery(this).attr("data-imprint")) != "undefined") ? jQuery(this).attr("data-imprint") : ""; var email_cap = (typeof(jQuery(this).attr("data-emailcap")) != "undefined") ? jQuery(this).attr("data-emailcap") : 0; var custom_link = (typeof(jQuery(this).attr("data-link_text")) != "undefined") ? jQuery(this).attr("data-link_text") : 1; if (typeof(check_isbn) != "undefined") { check_isbn = check_isbn.replace(/-/g, ""); } aerio_items_to_load.push({isbn: check_isbn, social: social, retail: retail,custom_link:custom_link, email_cap:email_cap,url: window.location.href, newtab:newtab, imprint:imprint}); }); if (aerio_items_to_load.length>0) { jQuery.ajax({ url: aerio_request_base_url + "/maker/api/embedded_preview_links.php", jsonp: "callback", contentType: "application/json", dataType: "jsonp", beforeSend: setHeader, data: {products:JSON.stringify(aerio_items_to_load)}, success: function (resp) { } }); } } function setHeader(xhr) { xhr.setRequestHeader('Access-Control-Allow-Origin', '*'); } function createAerioPreviewLink(vals) { //console.log("creating an Aerio button"); var isbn = vals.isbn; var buttons = vals.buttons; //console.log(vals); if (jQuery(".aerio_preview[data-isbn='" + isbn + "']").length >0) { // if (typeof(vals.isbn) !="undefined" && vals['isbn'] != null && vals.isbn != "") { //console.log("creating button from ISBN"); jQuery(".aerio_preview[data-isbn='" + isbn + "']").html(buttons); } }