Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- https://adoric.atlassian.net/browse/ADORIC-5232
- sessionStorage:
- adoric_referrer_url
- UTM test parameters:
- ?adoricnikotest&utm_source=utm_source-testValue&utm_medium=utm_medium-testValue&utm_campaign=utm_campaign-testValue&utm_term=utm_term-testValue&utm_content=utm_content-testValue
- //показать все лайтбоксы на странице:
- <script>
- adoric.lightboxes.filter(function(lb) { return lb.isShowing})
- </script>
- <a href="javascript:void(0)"></a>
- javascript:void(0)
- <style>
- .featured.module:nth-of-type(3n+3) {
- padding-right:0;
- background:red;
- }
- </style>
- {
- "versionId":"649c3c17b6c3cf0cc3556613",
- "identifier":"__ADORIC__2",
- "campaignId":"649c3c17b6c3cf0cc3556614",
- "campaignTitle":"קמפיין צריכים עזרה אזור אישי",
- "versionTitle":"Variation #1",
- "currentStep":0,
- "domainId":"64648a8870a1a321990fef00",
- "device":"mobile"
- }
- node.outerHTML => convert HTML element to string
- pattern="[0-9]{9,10}" => phone validation pattern
- pattern="[0-9]{10,11}"
- pattern="[0][0-9]{9}"
- pattern="^[0-9]*$" => only digits
- as for zoom on iPhones. Add please this embed code to mobile lightboxes
- <style>INPUT.element-input-text {font-size: 16px !important}</style>
- ======================================================================================================================================
- Youtube Embed - Autoplay, Loop, Responsive with No Controls!
- https://forum.webflow.com/t/youtube-embed-autoplay-loop-responsive-with-no-controls/25041
- https://www.youtube.com/embed/1F6aj05cIq8?autoplay=1&loop=1&playlist=1F6aj05cIq8
- https://www.youtube.com/embed/DsaC9Wd81Gw?autoplay=1&mute=1&loop=1&playlist=DsaC9Wd81Gw
- ======================================================================================================================================
- pattern="([A-Za-z\u05D0-\u05F3 ]{1,150})" => name Hebrew and English symbols validation pattern
- pattern="\d{1,2}/\d{1,2}/\d{4}" placeholder="dd/mm/yyyy"
- <script>
- (function() {
- function updateZindex() {
- var currentCanvas = document.querySelector('.' + self.identifier + '.__ADORIC__ [tabindex]');
- currentCanvas.style.zIndex = '10';
- currentCanvas.parentNode.style.zIndex = '10';
- }
- updateZindex();
- setTimeout(function() {
- updateZindex();
- }, 1000);
- window.addEventListener('resize', function() {
- updateZindex();
- });
- window.addEventListener('scroll', function() {
- updateZindex();
- });
- })();
- </script>
- adoric.lightboxes.forEach(function(item) {
- if (item.isShowing && item.options.campaignId === self.campaignId) {
- item.close(4);
- }
- });
- ===============================Wait element by selector ===========================
- <script>
- var productsTimer = 10;
- function waitPageProducts() {
- productsTimer--;
- var pageProducts = document.querySelectorAll('.product-details-container');
- if (pageProducts.length < 1 && productsTimer > 0) {
- setTimeout(waitPageProducts, 500);
- } else {
- checkProductList();
- }
- }
- waitPageProducts();
- </script>
- <script >
- document.addEventListener('DOMNodeInserted', OnNodeInserted, false);
- function OnNodeInserted(event) {
- if (event.target.classList.contains('details-list-container')) {
- adoric && adoric.trigger('showAdoricCouponCampaign');
- }
- }
- </script>
- ===================================================================================
- <script>
- (function() {
- var NEW_CTA_LINK = 'https://iqosclubcanarias.com/client/';
- var ELEMENTS_TO_UPDATE = [
- '#main section a[href="https://www.myiqos.es/friends"]',
- '#main #Enjoy-privileges a[href="https://www.myiqos.es/friends"]',
- '#main #Enjoy-privileges a[href="https://www.myiqos.es/exclusive"]',
- '#main #Enjoy-privileges a[href="https://www.myiqos.es/life"]',
- '#main #Enjoy-privileges a[href="https://www.myiqos.es/for-you"]',
- ];
- function updatePageLinksForCanary() {
- ELEMENTS_TO_UPDATE.forEach(function(selector) {
- document.querySelector(selector).setAttribute('href', NEW_CTA_LINK);
- });
- }
- if (document.readyState === 'loading') {
- document.addEventListener('DOMContentLoaded', updatePageLinksForCanary);
- } else {
- updatePageLinksForCanary();
- }
- })();
- </script>
- ==============================get lb id ========================================
- console.log(item.options.campaignTitle);
- function getLbIdentifier(campaignId) {
- var lbIdentifier = null;
- window.adoric && adoric.lightboxes.forEach(function(item) {
- if (item.options.campaignId === campaignId) {
- lbIdentifier = item.identifier;
- }
- });
- return lbIdentifier;
- }
- var res = getLbIdentifier('5da83882f4a10c00109e49d4');
- console.log(res);
- =========================set IMPORTANT CSS Style===============================
- .setProperty('display', 'flex', 'important');
- ===============================================================================
- =========================== INPUT VALIDATION ===========================
- var phone = document.querySelector('#ADORIC_dynamicParamsForm2 INPUT[name="fld_40487"]');
- var submit = document.querySelector('#ADORIC_dynamicParamsForm2 INPUT[name="submit"]');
- document.querySelector('#ADORIC_dynamicParamsForm2 INPUT[name="fld_40487"]').addEventListener("input", function() {
- if (isValidPhoneNumber(this.value)) {
- this.style.border = "none";
- submit.disabled = false;
- } else {
- this.style.border = "1px solid red";
- submit.disabled = true;
- }
- });
- =========================== touch event trigger ==============================================
- var e = new Event('touchstart');
- target.dispatchEvent(e);
- =========================== Open URL in new tab ==============================================
- function openInNewTab(url) {
- var win = window.open(url, '_blank');
- win.focus();
- }
- =========================== Custom validation messages ==============================================
- <input type="text" id="username" required placeholder="Enter Name"
- oninvalid="this.setCustomValidity('Enter User Name Here')"
- oninput="this.setCustomValidity('')" />
- oninvalid="if(this.value.indexOf('@') != -1) {this.setCustomValidity('Standart error message about @')} else {this.setCustomValidity('Enter User Email Here')}""
- ======================================= Add UTM to FORM ===========================================
- function getUrlParameter(name) {
- name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
- var regex = new RegExp("[\\?&]" + name + "=([^&#]*)");
- var results = regex.exec(location.search);
- return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, " "));
- }
- function addHiddenInput(name, val) {
- var inp = document.createElement('INPUT');
- inp.type = 'hidden';
- inp.name = name;
- inp.value = val;
- $form.appendChild(inp);
- }
- if (getUrlParameter('utm_source')) {
- addHiddenInput('utm_source', getUrlParameter('utm_source'));
- }
- if (getUrlParameter('utm_medium')) {
- addHiddenInput('utm_medium', getUrlParameter('utm_medium'));
- }
- if (getUrlParameter('utm_campaign')) {
- addHiddenInput('utm_campaign', getUrlParameter('utm_campaign'));
- }
- if (getUrlParameter('utm_term')) {
- addHiddenInput('utm_term', getUrlParameter('utm_term'));
- }
- if (getUrlParameter('utm_content')) {
- addHiddenInput('utm_content', getUrlParameter('utm_content'));
- }
- ===========================JSON to URI ================================================================
- function jsonToURI(json) {
- var s = [];
- Object.keys(json).forEach(function(key) {
- s.push(encodeURIComponent(key) + '=' + encodeURIComponent(json[key]))
- });
- return s.join('&');
- }
- ======================================= send data to Adoric list ===========================================
- <script>
- (function() {
- function getCampaignData(campaignId) {
- var campaignData = null;
- window.adoric && adoric.lightboxes.forEach(function(item) {
- if (item.options.campaignId === campaignId) {
- campaignData = item;
- }
- });
- return campaignData;
- }
- var allCampaignData = getCampaignData('5d89fcd6c7ffd20019734884');
- var form = document.getElementById('adoricCustomAPOSLeadInpage');
- form.addEventListener('submit', function() {
- adoric.Util.ajax("https://api.adoric-om.com/list/subscribe", "POST", {
- subscribe: {
- "name": form.querySelector('INPUT[name="fld_60897"]').value,
- "phone": form.querySelector('INPUT[name="fld_60898"]').value,
- "list": form.querySelector('INPUT[name="list"]').value
- },
- referrer: document.referrer,
- country: sessionStorage.getItem('country_code_cache'),
- campaignData: {
- options: {
- id: allCampaignData.id,
- userId: allCampaignData.options.userId,
- domainId: allCampaignData.statistic.domainId,
- accountId: allCampaignData.options.userId,
- campaignTitle: allCampaignData.options.campaignTitle,
- title: allCampaignData.options.title,
- type: allCampaignData.options.type
- }
- }
- }, function test(response, XMLHttpRequest) {
- console.log('calback response - ', response, XMLHttpRequest);
- });
- });
- })();
- adoric.on("form:before:submit", function(params) {
- if (params.target.classList.contains("ADORIC_Double_Integration_Form")) {
- var formData = adoric.Util.serializeListForm(document.querySelector(".__ADORIC__ FORM.inner-element"));
- formData.subscribe.list = "5e3bd85f136615001756c58a";
- formData.campaignData = {
- options: {
- id: params.lightboxId,
- userId: params.lightbox.options.userId,
- domainId: "5e01ea6ff9f749001089d4a9",
- accountId: params.lightbox.options.userId,
- campaignTitle: params.lightbox.options.campaignTitle,
- title: params.lightbox.options.title,
- type: params.lightbox.options.type
- }
- };
- adoric.Util.ajax("https://adoric.com/list/subscribe", "POST", formData);
- }
- });
- </script>
- ===========================ADD UTM to form=============================
- <script>
- (function() {
- function getLbIdentifier() {
- var lbData = null;
- window.adoric && adoric.lightboxes.forEach(function(item) {
- var form = document.querySelector('.' + self.identifier + '.__ADORIC__ [tabindex] form');
- if (item.isShowing === true && form) {
- lbData = item;
- }
- });
- return lbData;
- }
- function getUrlParameter(name) {
- name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
- var regex = new RegExp("[\\?&]" + name + "=([^&#]*)");
- var results = regex.exec(location.search);
- return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, " "));
- }
- function addHiddenInput(name, val) {
- var inp = document.createElement('INPUT');
- inp.type = 'hidden';
- inp.name = name;
- inp.value = val;
- if (currentForm) {
- currentForm.appendChild(inp);
- }
- }
- var allCampaignData = getLbIdentifier();
- var currentForm = document.querySelector('.' + allCampaignData.identifier + '.__ADORIC__ [tabindex] form');
- if (getUrlParameter('utm_source')) {
- addHiddenInput('utm_source', getUrlParameter('utm_source'));
- }
- if (getUrlParameter('utm_medium')) {
- addHiddenInput('utm_medium', getUrlParameter('utm_medium'));
- }
- if (getUrlParameter('utm_campaign')) {
- addHiddenInput('utm_campaign', getUrlParameter('utm_campaign'));
- }
- if (getUrlParameter('utm_term')) {
- addHiddenInput('utm_term', getUrlParameter('utm_term'));
- }
- if (getUrlParameter('utm_content')) {
- addHiddenInput('utm_content', getUrlParameter('utm_content'));
- }
- })();
- </script>
- =============================================================================
- ================================ add URL in hidden field ====================
- <script>
- (function() {
- var URL_FIELD_NAME = 'URL';
- function getLbIdentifier() {
- var lbData = null;
- window.adoric && adoric.lightboxes.forEach(function(item) {
- var form = document.querySelector('.' + item.identifier + '.__ADORIC__ [tabindex] form');
- if (item.isShowing === true && form) {
- lbData = item;
- }
- });
- return lbData;
- }
- function addHiddenInput(name, val) {
- var inp = document.createElement('INPUT');
- inp.type = 'hidden';
- inp.name = name;
- inp.value = val;
- if (currentForm) {
- currentForm.appendChild(inp);
- }
- }
- var allCampaignData = getLbIdentifier();
- var currentForm = document.querySelector('.' + allCampaignData.identifier + '.__ADORIC__ [tabindex] form');
- var currentURL = window.location.href;
- addHiddenInput(URL_FIELD_NAME, currentURL);
- })();
- </script>
- ================================ add suctom video like inpage =============================================
- <script>
- (function() {
- var videoWrapper = document.querySelector('.tabs-content-exp-container > .tabs-content-exp');
- if (videoWrapper) {
- videoWrapper.style.position = 'relative';
- }
- var adoricVideoWrapper = document.getElementById('adoricVideoWrapper');/*adoricVideoWrapper - id embed code div element*/
- var videoTeg = '<video autoplay="autoplay" loop="loop" muted="" width="100%" height="100%" style="top: 0%; left: -3%; position: absolute; width: 109%; height: 100%;"><source src="https://i01.appmifile.com/webfile/globalimg/products/pc/redmik20/index_design.mp4" type="video/mp4"></video>';
- adoricVideoWrapper.innerHTML = videoTeg;
- })();
- </script>
- =================================form after submit response============================================
- adoric.on('form:after:submit', function(res) {
- console.log('response - ', res.response);
- });
- ========================= check device type ====================================================
- var SB_TYPE_MOBILE = 'mobile';
- var SB_TYPE_TABLET = 'tablet';
- var SB_TYPE_DESKTOP = 'desktop';
- var SCREEN_WIDTH = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
- var DEVICE_TYPE = (SCREEN_WIDTH > 800) && SB_TYPE_DESKTOP || (SCREEN_WIDTH < 600) && SB_TYPE_MOBILE || SB_TYPE_TABLET;
- console.log(DEVICE_TYPE);
- =============================================================================
- ===============================upload the image to adoric list========================================
- <!-- example campaign: -->
- <!--https://adoric.com/campaign/5e26c12d5592880010779523/edit-->
- <script src="//static.filestackapi.com/filestack-js/3.x.x/filestack.min.js"></script>
- <style>
- #adoric_smartbox_e396dc8514f5a .element-fieldset {
- width: 140px !important;
- height: 25px !important;
- }
- #adoric_smartbox_e396dc8514f5a .element-input-checkbox-label {
- color: rgb(0, 0, 0) !important;
- font-weight: 600 !important;
- font-size: 10px !important;
- line-height: 1.4 !important;
- font-family: Assistant, sans-serif !important;
- white-space: unset !important;
- overflow-wrap: break-word !important;
- lay: block !important;
- opacity: 1 !important;
- width: 230px !important;
- vertical-align: top !important;
- letter-spacing: 0em !important;
- margin-right: 0em !important;
- text-shadow: none !important;
- }
- #adoric_smartbox_e396dc8514f5a .element-fieldset[data-name="Checkbox"] {
- width: 250px !important;
- }
- </style>
- <script>
- (function() {
- var adoricCustomLoadImagesButton = document.getElementById('adoricCustomLoadImages');
- var imageLoadedIcon = '<svg id="Capa_1" enable-background="new 0 0 482.239 482.239" height="100%" viewBox="0 0 482.239 482.239" width="100%" xmlns="http://www.w3.org/2000/svg" class="inner-element" aria-label="undefined" role="img" preserveAspectRatio="none" style="width: 100%; height: 100%; opacity: 1; box-shadow: none; border-radius: 0px;" data-event-name="Conversion" data-shadow-distance="0" data-init-color="#b20000" data-width="NaN" data-height="NaN" data-left="NaN" data-top="NaN"><path d="m465.016 0h-447.793c-9.52 0-17.223 7.703-17.223 17.223v447.793c0 9.52 7.703 17.223 17.223 17.223h447.793c9.52 0 17.223-7.703 17.223-17.223v-447.793c0-9.52-7.703-17.223-17.223-17.223zm-17.223 447.793h-413.347v-413.347h413.348v413.347z" data-init-color="#000000" style="fill: rgb(178, 0, 0);"></path><path d="m373.856 184.405-24.354-24.354-142.828 142.828-73.937-73.937-24.354 24.354 98.291 98.291z" data-init-color="#000000" style="fill: rgb(178, 0, 0);"></path></svg>';
- adoricCustomLoadImagesButton.addEventListener('touchend', function() {
- adoricCustomLoadImagesButton.style.border = '2px dashed';
- if (filestack) {
- const client = filestack.init('AitrLF34lQmScrkzumAPAz');
- const options = {
- onUploadDone: function(responce) {
- var files = responce.filesUploaded;
- if (files && files.length > 0) {
- adoricCustomLoadImagesButton.style.border = 'none';
- document.getElementById('adoricUploadDynamicIcon').innerHTML = imageLoadedIcon;
- files.forEach(function(item) {
- if (item.url != '') {
- var form = document.querySelector('#adoricSendingImageForm');
- form.querySelector('INPUT[name="images"]').value = item.url;
- var isFileAdded = document.querySelector('INPUT[name="isFileAdded"]');
- form.removeChild(isFileAdded);
- }
- });
- }
- }
- };
- client.picker(options).open();
- }
- });
- })();
- </script>
- ===========================================Responcive native slider!!===============================
- <script>
- function updateCarouselWidth() {
- var screenWidth = window.innerWidth;
- var itemWidth = 300;
- var carouselElement = document.querySelector('.' + self.identifier + ' .element-slider');
- if (carouselElement) {
- var maximumVisibleElements = parseInt(((screenWidth / 100) * 90) / itemWidth);
- if (maximumVisibleElements > 5) {
- maximumVisibleElements = 5
- }
- carouselElement.style.width = itemWidth * maximumVisibleElements + 'px';
- document.querySelector('.' + self.identifier + ' .slider-container').setAttribute('data-visible-items', maximumVisibleElements);
- }
- adoric.lightboxes.filter(function(lb) {
- return document.querySelector('.' + lb.identifier + ' .element-slider')
- })[0].startSliders();
- }
- updateCarouselWidth();
- window.addEventListener('resize', updateCarouselWidth);
- </script>
- ===================================================================================================
- ===============================Remove all text without wrapper from element!!===============================
- <div id="foo">
- first
- <div id="bar1">
- jumps over a lazy dog!
- </div>
- second
- <div id="bar2">
- another jumps over a lazy dog!
- </div>
- third
- </div>
- <script>
- function removeAllTextWithoutWrapper(element) {
- if (element == null || element == undefined) return null;
- var nextSibling;
- while (element) {
- nextSibling = element.nextSibling;
- if (element.nodeType == 3) {
- element.parentNode.removeChild(element);
- }
- element = nextSibling;
- }
- }
- removeAllTextWithoutWrapper(document.getElementById("foo").firstChild);
- </script>
- ======================Random indexes =====================================================================
- var indexes = [];
- while(indexes.length < 10) {
- var newNUmber = Math.floor(Math.random() * 10);
- if(indexes.indexOf(newNUmber) == -1) {
- indexes.push(newNUmber);
- } else {
- console.log('ysy');
- }
- console.log(newNUmber);
- }
- console.log(indexes)
- ====================COPY TEXT TO BUFFER====================
- <script>
- (function() {
- var copyButton = document.getElementById('adoricCopyCoupon');
- if (copyButton) {
- copyButton.addEventListener('touchend', function() {
- var input = document.createElement("input");
- document.body.appendChild(input);
- input.setAttribute("value", "BABELKI15");
- input.select();
- document.execCommand("copy");
- document.body.removeChild(input);
- });
- }
- })();
- </script>
- =======================EMBED WEBHOOK to Adoric=======================
- <script>
- (function() {
- function getLbIdentifier() {
- var lbData = null;
- adoric.lightboxes.forEach(function(item) {
- if (item.options.campaignId === self.campaignId) {
- lbData = item;
- }
- });
- return lbData;
- }
- var form = document.querySelector('.' + self.identifier + ' [tabindex] form');
- var allCampaignData = getLbIdentifier();
- form.addEventListener('submit', function() {
- var allFormInputs = form.querySelectorAll('INPUT');
- var formData = {};
- for (var i = 0; i < allFormInputs.length; i++) {
- if (allFormInputs[i].getAttribute('name') !== 'submit') {
- fieldName = allFormInputs[i].getAttribute('name');
- fieldValue = allFormInputs[i].value;
- formData[fieldName] = fieldValue;
- console.log(fieldName, '=', fieldValue);
- }
- }
- formData.groupID = '182216';
- formData.adoricApiKey = '1637152141706';
- formData.userId = '5e4ea052e98c750012b2c583';
- formData.adoricSessionParams = '{}';
- formData.header = '{}';
- var data = {
- subscribe: formData,
- referrer: document.referrer,
- country: sessionStorage.getItem('country_code_cache'),
- action: 'http://www.pulseem.com/Pulseem/PulseemServices.asmx/PostNewClient',
- enctype: '#',
- method: 'GET',
- campaignData: {
- options: {
- id: allCampaignData.id,
- userId: allCampaignData.options.userId,
- domainId: "5faba3ce59900100102a034a",
- accountId: allCampaignData.options.userId,
- campaignTitle: allCampaignData.options.campaignTitle,
- title: allCampaignData.options.title,
- type: allCampaignData.options.type
- }
- }
- };
- var xhr = new XMLHttpRequest();
- xhr.addEventListener('readystatechange', function() {
- if (this.readyState === 4) {
- console.log('response - ', this.responseText);
- }
- });
- xhr.open('POST', 'https://app.adoric-om.com/v1/forms/webhook');
- xhr.setRequestHeader('cache-control', 'no-cache');
- xhr.send(JSON.stringify(data));
- });
- })();
- </script>
- ======================checkbox 0 and 1 ===============================
- <input type="hidden" name="accept" value="1" draggable="false">
- <script>
- (function() {ч
- var currentLBSelector = '.' + getLbIdentifier('5cffa536c004f30274c83567') + '.__ADORIC__ [tabindex]';
- var form = document.querySelector(currentLBSelector + ' form');
- var checkBox = form.querySelector('INPUT[type="checkbox"]');
- checkBox.addEventListener('change', function() {
- if (this.checked) {
- form.querySelector('INPUT[name="mailPermisionCheflavan1"]').value = 1;
- } else {
- form.querySelector('INPUT[name="mailPermisionCheflavan1"]').value = 0;
- }
- });
- })();
- </script>
- ======================================================================
- ======================send information to GA===============================
- <script>
- window.ga && window.ga('t0.send', 'event', {
- eventCategory: 'Adoric - פופאפ עמוד דגם חדש',
- eventAction: 'click',
- eventLabel: 'Button redirection link'
- });
- window.ga && window.ga('t0.send', 'event', {
- eventCategory: 'Adoric - פופאפ עמוד דגם חדש',
- eventAction: 'click',
- eventLabel: 'Form submited - ' + self.versionTitle
- });
- </script>
- ======================star rating element===============================
- <div class="rating">
- <span class="icon" data-rate="1"></span>
- <span class="icon" data-rate="2"></span>
- <span class="icon" data-rate="3"></span>
- <span class="icon" data-rate="4"></span>
- <span class="icon" data-rate="5"></span>
- </div>
- <style>
- .icon {
- width: 20px;
- height: 20px;
- background-image: url(https://static.adoric.com/1591654474652_yn65zk2agjb/star1.png);
- display: block;
- background-size: contain;
- }
- .icon.filled {
- background-image: url(https://static.adoric.com/1591654474534_u28rf661h07/star2.jpg) !important;
- }
- .rating {
- display: flex;
- }
- </style>
- <script>
- (function() {
- function fillNewRate(rate) {
- if (rate < 0 || rate > 5) return;
- var rateIcons = document.querySelectorAll('.rating .icon');
- for(var i = 0; i < 5; i ++) {
- if (i < rate) {
- rateIcons[i].classList.add('filled');
- } else {
- rateIcons[i].classList.remove('filled');
- }
- }
- }
- var rating = document.querySelector('.rating');
- rating.addEventListener('click', function(event) {
- var currentRate = event.target.dataset.rate;
- if (currentRate) {
- fillNewRate(currentRate);
- }
- console.log(event.target.dataset.rate);
- })
- })();
- </script>
- ======================================================================
- =====================Adoric leads ====================================
- <script>
- (function() {
- function getLbIdentifier() {
- var lbData = null;
- window.adoric && adoric.lightboxes.forEach(function(item) {
- if (item.options.campaignId === self.campaignId) {
- lbData = item;
- }
- });
- return lbData;
- }
- try {
- var allCampaignData = getLbIdentifier();
- var form = document.querySelector('.' + self.identifier + ' form.inner-element');
- form.addEventListener('submit', function() {
- var allFormInputs = form.querySelectorAll('INPUT');
- var formData = {};
- for (var i = 0; i < allFormInputs.length; i++) {
- if (allFormInputs[i].getAttribute('name') !== 'sumbit') {
- fieldName = allFormInputs[i].getAttribute('name');
- fieldValue = allFormInputs[i].value;
- formData[fieldName] = fieldValue;
- }
- }
- var data = {
- subscribe: formData,
- referrer: document.referrer,
- country: sessionStorage.getItem('country_code_cache'),
- campaignData: {
- options: {
- id: allCampaignData.id,
- userId: allCampaignData.options.userId,
- domainId: self.domainId,
- campaignId: allCampaignData.options.campaignId,
- accountId: allCampaignData.options.userId,
- campaignTitle: allCampaignData.options.campaignTitle,
- title: allCampaignData.options.title,
- type: allCampaignData.options.type
- }
- }
- };
- var xhr = new XMLHttpRequest();
- xhr.addEventListener('readystatechange', function() {
- if (this.readyState === 4) {
- console.log('response - ', this.responseText);
- }
- });
- xhr.open('POST', 'https://app.adoric-om.com/v1/forms/leads/subscribe', true);
- xhr.send(JSON.stringify(data));
- });
- } catch (error) {
- console.log(error);
- }
- })();
- </script>
- ======================================================================
- ======================carousel with dots ==================================
- <div class="adoric_element element-group ADORIC_customPagingDots editing" data-items="8" style="left: 896px; top: 231px; position: absolute; width: 61px; height: 8px; opacity: 1; z-index: 65; " data-width="164" data-height="10" data-left="888" data-top="229"><div class="element-shape editing adoric-inner-group active" data-radius="0.00" style="left: 0px; top: 0.411585px; width: 8.23171px; position: absolute; height: 8.23171px; line-height: 0; opacity: 1; z-index: 11;" data-width="206" data-height="206" data-left="1176" data-top="477"><!--?xml version="1.0" encoding="utf-8"?--> <!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="100%" height="100%" viewBox="0 0 500 500" enable-background="new 0 0 500 500" xml:space="preserve" class="inner-element" aria-label="Shapes circle " role="img" preserveAspectRatio="none" style="width: 100%; height: 100%; opacity: 1; -webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none; -webkit-border-radius: 0px; -moz-border-radius: 0px; border-radius: 0px; " data-event-name="Conversion" data-shadow-distance="0" data-init-color="rgb(0, 0, 0)" data-hover-color="#000000" onmouseover="var t=this.querySelectorAll("path, rect, circle, ellipse, line, polyline, polygon, stop"),e=this.getAttribute("data-hover-color");Array.prototype.forEach.call(t,function(t){t.style.fill=e})" onmouseout="var t=this.querySelectorAll("path, rect, circle, ellipse, line, polyline, polygon, stop"),e=this.getAttribute("data-init-color");Array.prototype.forEach.call(t,function(t){t.style.fill=e})"> <path d="M250-1c138.066,0,250,111.929,250,250c0,138.066-111.934,250-250,250C111.929,499,0,387.066,0,249 C0,110.929,111.929-1,250-1z" data-init-color="#ea7878" style="fill: rgb(0, 0, 0);"></path> </svg> </div><div class="element-shape editing adoric-inner-group" data-radius="0.00" style="left: 17.2866px; top: 0.411585px; width: 8.23171px; position: absolute; height: 8.23171px; line-height: 0; opacity: 1; z-index: 10;" data-width="206" data-height="206" data-left="1176" data-top="477"><!--?xml version="1.0" encoding="utf-8"?--> <!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="100%" height="100%" viewBox="0 0 500 500" enable-background="new 0 0 500 500" xml:space="preserve" class="inner-element" aria-label="Shapes circle " role="img" preserveAspectRatio="none" style="width: 100%; height: 100%; opacity: 1; -webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none; -webkit-border-radius: 0px; -moz-border-radius: 0px; border-radius: 0px; " data-event-name="Conversion" data-shadow-distance="0" data-init-color="#000000"> <path d="M250-1c138.066,0,250,111.929,250,250c0,138.066-111.934,250-250,250C111.929,499,0,387.066,0,249 C0,110.929,111.929-1,250-1z" data-init-color="#ea7878" style="fill: rgb(0, 0, 0);"></path> </svg> </div><div class="element-shape editing adoric-inner-group" data-radius="0.00" style="left: 34.5732px; top: 0.411585px; width: 8.23171px; position: absolute; height: 8.23171px; line-height: 0; opacity: 1; z-index: 9;" data-width="206" data-height="206" data-left="1176" data-top="477"><!--?xml version="1.0" encoding="utf-8"?--> <!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="100%" height="100%" viewBox="0 0 500 500" enable-background="new 0 0 500 500" xml:space="preserve" class="inner-element" aria-label="Shapes circle " role="img" preserveAspectRatio="none" style="width: 100%; height: 100%; opacity: 1; -webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none; -webkit-border-radius: 0px; -moz-border-radius: 0px; border-radius: 0px; " data-event-name="Conversion" data-shadow-distance="0" data-init-color="#000000"> <path d="M250-1c138.066,0,250,111.929,250,250c0,138.066-111.934,250-250,250C111.929,499,0,387.066,0,249 C0,110.929,111.929-1,250-1z" data-init-color="#ea7878" style="fill: rgb(0, 0, 0);"></path> </svg> </div><div class="element-shape editing adoric-inner-group" data-radius="0.00" style="left: 52.6829px; top: 0.411585px; width: 8.23171px; position: absolute; height: 8.23171px; line-height: 0; opacity: 1; z-index: 8;" data-width="10" data-height="10" data-left="955" data-top="347"><!--?xml version="1.0" encoding="utf-8"?--> <!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="100%" height="100%" viewBox="0 0 500 500" enable-background="new 0 0 500 500" xml:space="preserve" class="inner-element" aria-label="Shapes circle " role="img" preserveAspectRatio="none" style="width: 100%; height: 100%; opacity: 1; -webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none; -webkit-border-radius: 0px; -moz-border-radius: 0px; border-radius: 0px; " data-event-name="Conversion" data-shadow-distance="0" data-init-color="#000000"> <path d="M250-1c138.066,0,250,111.929,250,250c0,138.066-111.934,250-250,250C111.929,499,0,387.066,0,249 C0,110.929,111.929-1,250-1z" data-init-color="#ea7878" style="fill: rgb(0, 0, 0);"></path> </svg> </div></div>
- <style>
- .ADORIC_customPagingDots .element-shape {
- cursor: pointer;
- }
- .ADORIC_customPagingDots .active SVG PATH {
- fill: #CACACA !important;
- }
- .adoric_sliderWithDotsContainer .slider-arrow-left,
- .adoric_sliderWithDotsContainer .slider-arrow-right {
- display: none;
- }
- </style>
- <script>
- (function() {
- var dotsContainer = document.querySelector('.ADORIC_customPagingDots');
- dotsContainer.addEventListener('touchend', function(e) {
- var target = e.target || e.currentTarget;
- if (target.classList.contains('element-shape') || target.parentNode.classList.contains('element-shape') || target.parentNode.parentNode.classList.contains('element-shape')) {
- if (!(target.classList.contains('element-shape'))) {
- if (target.parentNode.classList.contains('element-shape')) {
- target = target.parentNode;
- } else if (target.parentNode.parentNode.classList.contains('element-shape')) {
- target = target.parentNode.parentNode;
- }
- }
- var activeDot = dotsContainer.querySelector('.element-shape.active');
- var nodes = Array.prototype.slice.call(dotsContainer.children);
- var targetIndex = nodes.indexOf(target);
- var activeIndex = 0;
- if (activeDot) {
- var activeIndex = nodes.indexOf(activeDot);
- }
- console.log('activeIndex', activeIndex, 'targetIndex', targetIndex);
- if (activeIndex > targetIndex) {
- for (var i = 0; i < (activeIndex - targetIndex); i++) {
- setTimeout(function() {
- document.querySelector('.adoric_sliderWithDotsContainer .slider-arrow-left').click();
- }, 600 * i);
- }
- }
- if (activeIndex < targetIndex) {
- for (var i = 0; i < (targetIndex - activeIndex); i++) {
- setTimeout(function() {
- document.querySelector('.adoric_sliderWithDotsContainer .slider-arrow-right').click();
- }, 600 * i);
- }
- }
- activeDot.classList.remove('active');
- target.classList.add('active');
- }
- });
- })();
- </script>
- ==============================dynamic carousel from google sheet ===========================
- <script>
- (function() {
- var DOC_KEY = '1uLbXW7Lzmv3vjom3qJZDxecX-XUSt6Z6O41-Z9vdEEM';
- var API_KEY = 'AIzaSyDB7Mk0_X06DqZHWlllSOont--5XAZ4tao';
- var SHEET_PAGE = 'data';
- var SHEET_SCOPE = '!A2:AT7505';
- function fillDynamicContent(dataArray) {
- console.log(dataArray);
- var carousel = document.querySelector('.adoricCustomProductsCarousel');
- var thumbTemplate = carousel.querySelector('.slider-item.tmp-cloned').cloneNode(true);
- carousel.innerHTML = '';
- carousel.appendChild(thumbTemplate);
- dataArray.forEach(function(pr) {
- var duplicateThumb = thumbTemplate.cloneNode(true);
- duplicateThumb.querySelector('IMG.inner-element').src = pr[0];
- duplicateThumb.querySelector('SPAN.adoricCustomTitle.inner-element FONT').innerText = pr[1];
- duplicateThumb.querySelector('.element-button.adoric-slider-item-inner A').href = pr[3];
- duplicateThumb.querySelector('SPAN.adoricCustomPrice.inner-element').innerHTML = pr[2];
- carousel.appendChild(duplicateThumb);
- });
- }
- var URL = "https://sheets.googleapis.com/v4/spreadsheets/" + DOC_KEY + "/values/" + SHEET_PAGE + SHEET_SCOPE + "?key=" + API_KEY;
- console.log(URL);
- var data = null;
- var xhr = new XMLHttpRequest();
- xhr.addEventListener("readystatechange", function() {
- if (this.readyState === 4) {
- var result = JSON.parse(this.responseText);
- var dataArray = result.values;
- console.log(dataArray);
- if(dataArray.length > 4) {
- fillDynamicContent(dataArray);
- }
- }
- });
- xhr.open("GET", URL);
- xhr.setRequestHeader("cache-control", "no-cache");
- xhr.send(data);
- })();
- </script>
- https://docs.google.com/spreadsheets/d/1D0AzyzWhREOJ_vbUkLHe09YNSjG4b0IZnhe6T6S79tw/edit?usp=sharing
- =======================================remarkety integration with phone ==============================================
- <script>
- (function() {
- function getLbIdentifier(campaignId) {
- var lbIdentifier = null;
- window.adoric && adoric.lightboxes.forEach(function(item) {
- if (item.options.campaignId === campaignId) {
- lbIdentifier = item.identifier;
- }
- });
- return lbIdentifier;
- }
- var allCampaignData = getLbIdentifier(self.campaignId);
- var form = document.querySelector('.' + self.identifier + ' FORM.inner-element');
- var firstNameField = form.querySelector('INPUT[name="firstName"]');
- var lastNameField = form.querySelector('INPUT[name="lastName"]');
- var emailField = form.querySelector('INPUT[name="email"]');
- var phoneField = form.querySelector('INPUT[name="sms_phone_number"]');
- var birthdayField = form.querySelector('INPUT[name="birthday"]');
- var marketingAllowedINput = form.querySelector('INPUT[name="marketingAllowed"]');
- try {
- form.addEventListener('submit', function() {
- var data = {
- subscribe: {
- firstName: firstNameField.value,
- lastName: lastNameField.value,
- email: emailField.value,
- tags: 'Adoric',
- marketingAllowed: marketingAllowedINput.value,
- properties: {
- phone: phoneField.value,
- birth_date: birthdayField.value
- },
- userId: '5e4ea052e98c750012b2c583',
- adoricApiKey: "1635110566828"
- },
- referrer: '',
- country: '',
- action: 'https://app.remarkety.com/api/v1/stores/Emqzjg4w/contacts',
- enctype: '#',
- method: 'POST',
- campaignData: {
- options: {
- id: allCampaignData.id,
- userId: allCampaignData.options.userId,
- domainId: allCampaignData.statistic.domainId,
- accountId: allCampaignData.options.userId,
- campaignTitle: allCampaignData.options.campaignTitle,
- title: allCampaignData.options.title,
- type: allCampaignData.options.type
- }
- }
- };
- var xhr = new XMLHttpRequest();
- xhr.addEventListener('readystatechange', function() {
- var response = JSON.parse(this.responseText);
- if (this.readyState === 4) {
- var response = JSON.parse(this.responseText);
- console.log('response - ', response);
- }
- });
- xhr.open('POST', 'https://app.adoric-om.com/v1/forms/webhook');
- xhr.setRequestHeader('cache-control', 'no-cache');
- xhr.send(JSON.stringify(data));
- });
- } catch(error) {
- console.log('Error - ', error);
- }
- })();
- </script>
- ==============================================================================================
- =================================================== responcive carousel===================================================
- <style>
- #adoric_smartbox_75fe6e6416fd9 .adoric_element.element-slider {
- width: 100% !important;
- left: 0px !important;
- }
- </style>
- <script>
- (function() {
- function updateCarouselWidth() {
- var screenWidth = window.innerWidth;
- var itemWidth = 290;
- var marginWidth = 50;
- var carouselElement = document.querySelector('#adoric_smartbox_75fe6e6416fd9 .element-slider');
- var carouselSlider = carouselElement.querySelector('.slider-container');
- if (carouselElement) {
- var maximumVisibleElements = parseInt(window.innerWidth / itemWidth);
- console.log('maximumVisibleElements', maximumVisibleElements);
- carouselElement.style.width = itemWidth * maximumVisibleElements + 'px';
- carouselSlider.setAttribute('data-visible-items', maximumVisibleElements);
- }
- }
- updateCarouselWidth();
- window.addEventListener('resize', updateCarouselWidth);
- })();
- </script>
- ======================================================================================================
- =================================================== text element variable ===================================================
- <script>
- (function() {
- var currentLb = document.querySelector('.' + self.identifier + '.__ADORIC__ [tabindex]');
- var allTextElements = currentLb.querySelectorAll('span');
- var dynamicVariable = '[[cityName]]';
- var dynamicTextValue = '';
- for (var i = 0; i < allTextElements.length; i++) {
- var dynamicText = allTextElements[i].textContent;
- dynamicText = dynamicText.replaceAll(dynamicVariable, dynamicTextValue);
- allTextElements[i].textContent = dynamicText;
- }
- })();
- </script>
- =================================================== hide native element ===================================================
- <script>
- (function() {
- var nativeElementWrapper = document.querySelector('.wrapp-recommended .container');
- if (nativeElementWrapper) {
- var rowElement = nativeElementWrapper.querySelector('.row');
- nativeElementWrapper.style.position = 'relative';
- var adoricElementToCover = document.createElement('div');
- adoricElementToCover.style.width = '100%';
- adoricElementToCover.style.height = '100%';
- adoricElementToCover.style.position = 'absolute';
- adoricElementToCover.style.left = '0px';
- adoricElementToCover.style.right = '0px';
- adoricElementToCover.style.background = '#fff';
- adoricElementToCover.style.zIndex = '9';
- nativeElementWrapper.insertBefore(adoricElementToCover, rowElement);
- }
- })();
- </script>
- =================================================== double form integration ===================================================
- <script>
- (function() {
- var form = document.querySelector('.' + self.identifier + ' FORM.inner-element');
- form.addEventListener('submit', function() {
- try {
- var xhr = new XMLHttpRequest();
- let json = JSON.stringify({
- 'First name': form.querySelector('INPUT[name="firstName"]').value,
- 'Last name': form.querySelector('INPUT[name="lastName"]').value,
- 'phone': form.querySelector('INPUT[name="phone"]').value,
- 'email': form.querySelector('INPUT[name="Email"]').value,
- 'checkbox': form.querySelector('INPUT[type="checkbox"]').value
- });
- /* the old action link => xhr.open("POST", 'https://hooks.zapier.com/hooks/catch/3542992/ocft0nm/');*/
- xhr.open("POST", 'https://hooks.zapier.com/hooks/catch/3542992/o0vgniq/');
- xhr.send(json);
- xhr.onload = function() {
- console.log('Zapier Result: ', xhr.response);
- };
- } catch(error) {
- console.log(error);
- }
- });
- })();
- </script>
- =================================================== dynamic content for adoric slider ===================================================
- <script>
- (function() {
- function updateSlideContent(campaignSlide, sourceSlide) {
- var productLink = sourceSlide.querySelector('.deal section > a');
- if (productLink) {
- campaignSlide.querySelector('.product-link a').href = productLink.href;
- }
- }
- var sliderItems = document.querySelectorAll('.' + self.identifier + '.__ADORIC__ [tabindex] .slider-item');
- var sliderWrapper = document.querySelector('.' + self.identifier + '.__ADORIC__ [tabindex] .slider-content');
- try {
- var URL = 'https://www.zap.co.il/deals/category/bestseller';
- var parser = new DOMParser();
- var doc = '';
- var data = null;
- var xhr = new XMLHttpRequest();
- xhr.withCredentials = true;
- xhr.addEventListener('readystatechange', function () {
- if (this.readyState === 4) {
- doc = parser.parseFromString(this.responseText, 'text/html');
- var pageProducts = doc.querySelectorAll('.deal');
- for(var i = 1; i < sliderItems.length; i++) {
- var pageItemIndex = i-1;
- if (i <= pageProducts.length) {
- updateSlideContent(sliderItems[i], pageProducts[pageItemIndex]);
- } else {
- sliderWrapper.removeChild(sliderItems[i]);
- }
- if (i == sliderItems.length - 1 && pageProducts.length >= i) {
- updateSlideContent(sliderItems[0], pageProducts[i]);
- }
- }
- }
- });
- xhr.open('GET', URL);
- xhr.setRequestHeader('cache-control', 'no-cache');
- xhr.send(data);
- } catch(error) {
- console.log(error);
- }
- })();
- </script>
- =================================================== Accessibility ===================================================
- <script>
- (function() {
- var currentLBSelector = '.' + self.identifier + '.__ADORIC__ [tabindex]';
- var closeLbButton = document.querySelector(currentLBSelector + ' .closeLightboxButton BUTTON');
- var submitButton = document.querySelector(currentLBSelector + ' a[role="link"]');
- var firstField = document.querySelector(currentLBSelector + ' form INPUT');
- closeLbButton.focus();
- setTimeout(function() {
- closeLbButton.focus();
- }, 1500);
- closeLbButton.addEventListener('keydown', function(e) {
- var key = e.which || e.keyCode;
- var code = e.code;
- console.log('key - ', key);
- console.log('code - ', code);
- if (key === 9 || code.toLowerCase() === 'tab') {
- e.preventDefault();
- e.stopPropagation();
- firstField.focus();
- }
- });
- submitButton.addEventListener('keydown', function(e) {
- var key = e.which || e.keyCode;
- var code = e.code;
- if (key === 9 || code.toLowerCase() === 'tab') {
- e.preventDefault();
- e.stopPropagation();
- closeLbButton.focus();
- }
- });
- })();
- </script>
- ============================================== event from iframe ==============================================
- <script>
- window.postMessage('showAdocirFreeShippingBar!');
- window.addEventListener('message', (event) => {
- console.log('event.origin - ', event.origin);
- if (event.origin.indexOf('showAdocirFreeShippingBar') != -1 ) {
- console.log('showAdocirFreeShippingBar must show!')
- }
- }, false)
- </script>
- ============================================== update adoric count down ==============================================
- <script>
- function restartTimer(endDate) {
- var timerStart = new CustomEvent("timerStart");
- var timerEnd = new CustomEvent("timerEnd");
- function timer_ADORIC_timer__kqaxxx47() {
- this.initDomElement();
- this.running = false;
- this.timeZoneOffset = new Date().getTimezoneOffset() / 60;
- this.startDate = Date.now();
- this.endDate = endDate + (this.timeZoneOffset * 60 * 60 * 1000);
- this.duration = (this.endDate - this.startDate) / 1000;
- this.timerTimeoutInstance = null;
- this.format = ['HH', 'MM', 'SS'];
- this.callbackData = {};
- this.resetView();
- };
- timer_ADORIC_timer__kqaxxx47.prototype.initDomElement = function() {
- this.timerContainer = document.querySelectorAll('#ADORIC_timer__kqaxxx47').item(document.querySelectorAll('#ADORIC_timer__kqaxxx47').length - 1);
- this.daysOutput = this.timerContainer.querySelector('.element-timer-digit[data-digit="DD"]');
- this.hoursOutput = this.timerContainer.querySelector('.element-timer-digit[data-digit="HH"]');
- this.minutesOutput = this.timerContainer.querySelector('.element-timer-digit[data-digit="MM"]');
- this.secondsOutput = this.timerContainer.querySelector('.element-timer-digit[data-digit="SS"]');
- };
- timer_ADORIC_timer__kqaxxx47.prototype.resetView = function() {
- this.daysOutput.textContent = '00';
- this.hoursOutput.textContent = '00';
- this.minutesOutput.textContent = '00';
- this.secondsOutput.textContent = '00';
- };
- timer_ADORIC_timer__kqaxxx47.prototype.start = function() {
- this.initDomElement();
- if (this.running) {
- return false;
- }
- this.running = true;
- var that = this;
- this.timerContainer.dispatchEvent(timerStart);
- (function timer() {
- var diff = Math.floor(that.duration - (((Date.now() - that.startDate) / 1000)));
- var days = 0,
- hours = 0,
- minutes = 0,
- seconds = 0;
- if (diff > 0) {
- seconds = (!!~that.format.indexOf('MM') ? (diff % 60) : diff);
- minutes = (!!~that.format.indexOf('HH') ? Math.floor((diff / 60) % 60) : Math.floor(diff / 60));
- hours = (!!~that.format.indexOf('DD') ? Math.floor(((diff / 60) / 60) % 24) : Math.floor((diff / 60) / 60));
- days = Math.floor(((diff / 60) / 60) / 24);
- } else {
- that.timerContainer.dispatchEvent(timerEnd);
- that.kill();
- }
- that.daysOutput.textContent = days;
- that.hoursOutput.textContent = (hours.toString().length > 1 ? hours : '0' + hours.toString());
- that.minutesOutput.textContent = (minutes.toString().length > 1 ? minutes : '0' + minutes.toString());
- that.secondsOutput.textContent = (seconds.toString().length > 1 ? seconds : '0' + seconds.toString());
- that.running && (that.timerTimeoutInstance = setTimeout(timer, 1000));
- })();
- };
- timer_ADORIC_timer__kqaxxx47.prototype.stop = function() {
- this.running = false;
- clearTimeout(this.timerTimeoutInstance);
- };
- timer_ADORIC_timer__kqaxxx47.prototype.kill = function() {
- this.stop();
- this.start = null;
- clearTimeout(this.timerTimeoutInstance);
- this.timerTimeoutInstance = null;
- delete window.timerInstance_ADORIC_timer__kqaxxx47;
- };
- delete window.timerInstance_ADORIC_timer__kqaxxx47;
- window.timerInstance_ADORIC_timer__kqaxxx47 = new timer_ADORIC_timer__kqaxxx47();
- if (window.timerInstance_ADORIC_timer__kqaxxx47.duration > 0) {
- window.timerInstance_ADORIC_timer__kqaxxx47.start();
- }
- }
- var endDate = new Date(Date.parse('2021-06-25T13:00:00.000+01:00'));
- endDate = endDate.getTime();
- restartTimer(endDate);
- </script>
- ==========================================================================================================================================
- =============================================submit unique email from the form:=============================================
- function isEmailSubmitted(newEmail) {
- var allSubmittedEmails = window.localStorage.getItem('adoricSentEmails');
- if (!allSubmittedEmails) {
- allSubmittedEmails = [];
- allSubmittedEmails.push(newEmail);
- window.localStorage.setItem('adoricSentEmails', allSubmittedEmails.toString());
- return false;
- } else {
- allSubmittedEmails = allSubmittedEmails.split(',');
- }
- for (let i = 0; i < allSubmittedEmails.length; i++) {
- if (allSubmittedEmails[i].indexOf(newEmail) != -1) {
- return true;
- }
- }
- allSubmittedEmails.push(newEmail);
- window.localStorage.setItem('adoricSentEmails', allSubmittedEmails.toString());
- return false;
- }
- =======================================================================================================================================
- <script>
- //How to separate Drag and Swipe from Click and Touch events
- let isSwiping = false;
- document.getElementById('demo').addEventListener('mousedown', () => {
- this.isSwiping = false;
- });
- document.getElementById('demo').addEventListener('mousemove', () => {
- this.isSwiping = true;
- });
- document.getElementById('demo').addEventListener('mouseup', e => {
- if (this.isSwiping && e.button === 0) {
- console.log('dragging');
- } else {
- console.log('not dragging');
- }
- this.isSwiping = false;
- });
- document.getElementById('demo').addEventListener('touchstart', () => {
- this.isSwiping = false;
- });
- document.getElementById('demo').addEventListener('touchmove', () => {
- this.isSwiping = true;
- });
- document.getElementById('demo').addEventListener('touchend', e => {
- e.preventDefault();
- if (this.isSwiping) {
- console.log('swiping');
- } else {
- console.log('not swiping');
- }
- this.isSwiping = false;
- });
- </script>
- ===================================================TTL to show again ====================================================================================
- <script>
- (function() {
- var campaignIdentifier = 'entrance_email_capture';
- var campaignIdentifierCounter = 'entrance_email_capture_counter';
- function writeCookie(key, value, expires) {
- var now = new Date();
- var cookieString = '';
- if (expires) {
- var time = now.getTime();
- time += expires;
- now.setTime(time);
- cookieString = key + '=' + value + '; expires=' + now.toUTCString() + '; path=/';
- } else {
- cookieString = key + '=' + value + '; expires=Fri, 31 Dec 9999 23:59:59 GMT"; path=/';
- }
- window.document.cookie = cookieString;
- return value;
- };
- function getCookie(cname) {
- var name = cname + "=";
- var decodedCookie = decodeURIComponent(document.cookie);
- var ca = decodedCookie.split(';');
- for (var i = 0; i < ca.length; i++) {
- var c = ca[i];
- while (c.charAt(0) == ' ') {
- c = c.substring(1);
- }
- if (c.indexOf(name) == 0) {
- return c.substring(name.length, c.length);
- }
- }
- return "";
- }
- writeCookie(campaignIdentifier, '12hTTL', true);
- var isCounterExist = getCookie(campaignIdentifierCounter);
- if (isCounterExist) {
- isCounterExist = parseInt(isCounterExist);
- isCounterExist++;
- writeCookie(campaignIdentifierCounter, isCounterExist);
- } else {
- writeCookie(campaignIdentifierCounter, 1);
- }
- })();
- </script>
- /*=================== GET IP ===================*/
- <script>
- try {
- fetch('https://ifconfig.co/json', {
- method: 'GET'
- })
- .then(res => res.json())
- .then(json => {
- console.log('!======== currentIPdata - ', json.ip);
- if (!json.ip) {
- var result = JSON.parse(json);
- console.log('currentIPdata - ', result.ip);
- }
- console.log('All IP information - ', json);
- });
- } catch (error) {
- console.log('error - ', error.message);
- res.status(500).send(error.message);
- }
- {
- "name": "sample-http",
- "version": "0.0.1",
- "dependencies": {
- "node-fetch": "2.6.1"
- },
- "main": "index.js"
- }
- </script>
- /*=================== GET IP ===================*/
- Soda custom event sending:
- function pushCustomGAEvent(eventType, eventElementType, elementId) {
- if (window.preDataLayer) {
- preDataLayer.push({
- event: 'newEvent',
- newEventData: {
- type: eventType,
- elementType: eventElementType,
- elementId: elementId
- }
- });
- }
- }
- pushCustomGAEvent('Adoric', 'submission', 'Email capture disengagement');
- =================== Check list ===================
- I don't see my campaign on the site, what I have to do?
- 0. just call Niko, they will help!)))
- 1. Be sure that you testing the campaign in a new incognito window.
- 2. Check the placement option URL and URL that you using in the test browser window(https://cln.sh/iKw5aK)
- a) for direct link case, the best way to be sure it's same URLs,
- copy the URL from the browser and in campaigns settings and
- paste it in some text editor with two lines like that: https://cln.sh/pb1GJk
- b) for the option 'contain' keyword in the URL
- window.addEventListener('beforeunload', function(e) {e.preventDefault(); e.returnValue = '';});
- async function getMyLocation1() {
- try {
- var promise = new Promise(function(resolve, reject) {
- fetch('https://ipinfo.io/json', {
- method: 'GET'
- }).then(res => res.json()).then(response => {
- resolve(response.country);
- }).catch(error => {
- reject('error');
- });
- });
- return await promise;
- } catch (error) {
- return error.message;
- }
- }
- var result1 = await getMyLocation1();
- async function getMyLocation2() {
- try {
- var promise = new Promise(function(resolve, reject) {
- fetch('https://api.ipregistry.co/?key=tryout', {
- method: 'GET'
- }).then(res => res.json()).then(response => {
- if (response.location && response.location.country && response.location.country.code) {
- resolve(response.location.country.code);
- }
- }).catch(error => {
- reject('error');
- });
- });
- return await promise;
- } catch (error) {
- return error.message;
- }
- }
- function getFormattedDate(date) {
- var year = date.getFullYear();
- var month = (1 + date.getMonth()).toString();
- month = month.length > 1 ? month : '0' + month;
- var day = date.getDate().toString();
- day = day.length > 1 ? day : '0' + day;
- return day + '-' + month + '-' + year;
- }
- try {
- console.log('check IP start');
- const response = await fetch('https://ifconfig.co/json');
- const data = await response.json();
- console.log('check IP response - ', data);
- } catch (error) {
- console.log('check IP failed');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement