window['TOP_GLOBAL_CALLBACK_LAYER'] = { on(id){ const that = this; return function(){ let params = arguments; if(that[id] && that[id].length){ that[id].forEach(fun => { fun.apply(this,params); }); } } }, add(id,fun){ if(!this[id]){ this[id] = [] } this[id].push(fun) }, register(pixelObj){ if(!pixelObj){return false;} Object.keys(pixelObj).map(key=>{ this.add(key,pixelObj[key]) }) } }; function callback_add_to_cart(ec_data) { window['TOP_GLOBAL_CALLBACK_LAYER'].on('add_to_cart')(ec_data); moi.onEvent('callback_add_to_cart',ec_data) console.log('callback_add_to_cart'); console.log(ec_data); try { window['callback_facebook_add_to_cart'] && callback_facebook_add_to_cart(ec_data);callback_event_script_add_to_cart(ec_data); } catch (e) { console.log(e); } } //remove_from_cart function callback_remove_from_cart(ec_data) { window['TOP_GLOBAL_CALLBACK_LAYER'].on('remove_from_cart')(ec_data); moi.onEvent('callback_remove_from_cart',ec_data) console.log('callback_remove_from_cart'); console.log(ec_data); try {callback_facebook_remove_from_cart(ec_data);callback_event_script_remove_from_cart(ec_data); } catch (e) { console.log(e); } } function callback_login() { window['TOP_GLOBAL_CALLBACK_LAYER'].on('login')(); moi.onEvent('callback_login') console.log('callback_login'); try {callback_facebook_login();callback_script_event_login(); } catch (e) { console.log(e); } } function callback_sign_up() { window['TOP_GLOBAL_CALLBACK_LAYER'].on('sign_up')(); moi.onEvent('callback_sign_up') console.log('callback_sign_up'); try {callback_facebook_sign_up(); callback_event_script_sign_up(); } catch (e) { console.log(e); } } function callback_share_product(ec_data, platform) { window['TOP_GLOBAL_CALLBACK_LAYER'].on('share_product')(ec_data, platform); moi.onEvent('callback_share_product',{ec_data:ec_data, platform:platform}) console.log('callback_share_product'); console.log(ec_data); console.log(platform); try {callback_facebook_share_product(ec_data, platform);callback_event_script_share_product(ec_data, platform); callback_base_share_product(ec_data, platform); } catch (e) { console.log(e); } } function callback_generate_lead() { window['TOP_GLOBAL_CALLBACK_LAYER'].on('generate_lead')(); moi.onEvent('callback_generate_lead') console.log('callback_generate_lead'); try {callback_facebook_generate_lead();callback_event_script_generate_lead(); } catch (e) { console.log(e); } } function callback_begin_checkout() { window['TOP_GLOBAL_CALLBACK_LAYER'].on('begin_checkout')(); moi.onEvent('callback_begin_checkout') console.log('callback_begin_checkout'); try {window['callback_facebook_begin_checkout'] && callback_facebook_begin_checkout(); callback_event_script_begin_checkout(); } catch (e) { console.log(e); } } function callback_add_address_information() { window['TOP_GLOBAL_CALLBACK_LAYER'].on('add_address_information')(); window['moi'] && moi.onEvent('callback_add_address_information') console.log('callback_add_address_information'); try {window['callback_facebook_add_address_information'] && callback_facebook_add_address_information();callback_event_script_add_address_information(); } catch (e) { console.log(e); } } function callback_add_shipping_information() { window['TOP_GLOBAL_CALLBACK_LAYER'].on('add_shipping_information')(); window['moi'] && moi.onEvent('callback_add_shipping_information') console.log('callback_add_shipping_information'); try {window['callback_facebook_add_shipping_information'] && callback_facebook_add_shipping_information();callback_event_script_add_shipping_information(); } catch (e) { console.log(e); } } function callback_add_payment_information() { window['TOP_GLOBAL_CALLBACK_LAYER'].on('add_payment_information')(); moi.onEvent('callback_add_payment_information') console.log('callback_add_payment_information'); try {window['callback_facebook_add_payment_information'] && callback_facebook_add_payment_information();callback_event_script_add_payment_information(); } catch (e) { console.log(e); } } function callback_add_to_wishlist(ec_data) { window['TOP_GLOBAL_CALLBACK_LAYER'].on('add_to_wishlist')(ec_data); moi.onEvent('callback_add_to_wishlist',ec_data) console.log('callback_add_to_wishlist'); try { callback_facebook_to_wishlist(ec_data); } catch (e) { console.log(e); } } function callback_place_an_order(ec_data) { window['TOP_GLOBAL_CALLBACK_LAYER'].on('place_an_order')(ec_data); window["callback_event_script_place_an_order"] && callback_event_script_place_an_order(); }