Untitled
unknown
plain_text
11 days ago
22 kB
2
Indexable
Never
{ "test initialize code": { "prefix": "eg_init_js", "body": [ "(function () {", " try {", " /* main variables */", " var debug = 0;", " var variation_name = \"\";", "", " /* all Pure helper functions */", "", " function waitForElement(selector, trigger, delayInterval, delayTimeout) {", " var interval = setInterval(function () {", " if (", " document &&", " document.querySelector(selector) &&", " document.querySelectorAll(selector).length > 0", " ) {", " clearInterval(interval);", " trigger();", " }", " }, delayInterval);", " setTimeout(function () {", " clearInterval(interval);", " }, delayTimeout);", " }", "", " /* Variation functions */", "", " /* Variation Init */", " function init() {", " /* start your code here */", "", " console.log(", " \"Hello dev please check console if fecli triggering correctly\"", " );", " }", "", " /* Initialise variation */", " waitForElement(\"${1:body}\", init, 50, 15000);", " } catch (e) {", " if (debug) console.log(e, \"error in Test\" + variation_name);", " }", "})();", "" ], "description": "test initialize code" }, "Get Number With Ordinal": { "prefix": "eg_getNumberWithOrdinal", "body": [ "function getNumberWithOrdinal(n) {", " var s = [\"th\", \"st\", \"nd\", \"rd\"],", " v = n % 100;", " return n + (s[(v - 20) % 10] || s[v] || s[0]);", "}" ], "description": "Get Number With Ordinal" }, "Wait for element": { "prefix": "eg_waitForElement", "body": [ "function waitForElement(selector, trigger, delayInterval, delayTimeout) {", " var interval = setInterval(function () {", " if (", " document &&", " document.querySelector(selector) &&", " document.querySelectorAll(selector).length > 0", " ) {", " clearInterval(interval);", " trigger();", " }", " }, delayInterval);", " setTimeout(function () {", " clearInterval(interval);", " }, delayTimeout);", " }" ], "description": "Wait for element" }, "marketo load": { "prefix": "eg_MarketoLoad", "body": ["MktoForms2.loadForm(baseUrl, munchkinId, formId, callback);"], "description": "marketo load" }, "marketo success": { "prefix": "eg_MarketoSuccess", "body": [ "MktoForms2.loadForm(baseUrl, munchkinId, formId, function(form) {", " form.onSuccess(function(values, followUpUrl) {", "", " });", "});" ], "description": "marketo success" }, "marketo whenReady": { "prefix": "eg_MarketoWhenReady", "body": ["MktoForms2.whenReady(function (form) {", "});", ""], "description": "marketo whenReady" }, "marketo submit": { "prefix": "eg_MarketoSubmit", "body": [ "MktoForms2.loadForm(\"{1}\", \"{2}\", ${3}, function(form) {", " // Add an onSubmit handler", " form.onSubmit(function(){", " ", " });", "}); " ], "description": "marketo submit" }, "Jquery Library wait": { "prefix": "eg_WaitForJqueryLibrary", "body": [ "function onLoadJqueryLibrary(trigger, delayInterval, delayTimeout) {", " var interval = setInterval(function() {", " if (window.jQuery && window.jQuery.fn && window.jQuery.fn.${1:owlCarousel}) {", " clearInterval(interval);", " trigger();", " }", " }, delayInterval);", " setTimeout(function() {", " clearInterval(interval);", " }, delayTimeout);", "}" ], "description": "Jquery Library wait" }, "onDataHelperWait": { "prefix": "eg_OnDataHelperWait", "body": [ "function onDataHelperLoad(callback) {", " var waitForDatalayer = setInterval(function() {", " if (typeof window.dataLayer && window.DataLayerHelper) {", " clearInterval(waitForDatalayer);", " callback();", " }", " }, 30);", " setTimeout(function() {", " clearInterval(waitForDatalayer);", " }, 8000);", " }" ], "description": "onDataHelperWait" }, "Adobe analytics event trigger": { "prefix": "eg_AdobeTriggerEvent", "body": [ "function triggerEvent(name) {", " var s = window.s_Obj;", " s.linkTrackVars = \"eVar114\";", " s.eVar114 = name;", " s.tl(true, \"o\", name);", " }" ], "description": "Adobe analytics event trigger" }, "Trigger event using GA object": { "prefix": "eg_trackGAEvent", "body": [ "function trackGAEvent($eventCategory, $eventAction, $eventLabel) {", " if ('ga' in window) {", " ga.getAll()[0].send('event', {", " eventCategory: $eventCategory,", " eventAction: $eventAction,", " eventLabel: $eventLabel,", " });", " }", " }" ], "description": "Trigger event using GA object" }, "fe push event": { "prefix": "eg_FePushEvent", "body": [ "function pushEvent(eventName) {", " var waitForFunnelEnvy = setInterval(function () {", " if (typeof window.funnelEnvy !== \"undefined\") {", " clearInterval(waitForFunnelEnvy);", " window.funnelEnvy = window.funnelEnvy || [];", " window.funnelEnvy.push({", " event: eventName", " });", " }", " }, 50);", " setTimeout(function () {", " clearInterval(waitForFunnelEnvy);", " }, 5000);", " }," ], "description": "fe push event" }, "marketo wait": { "prefix": "eg_MarketoWait", "body": [ "function waitforMarketo(trigger){", " var interval = setInterval(function() {", " if ( ", " window.MktoForms2", " ) {", " clearInterval(interval); ", " trigger(); ", " }", " }, 50); ", " setTimeout(function() {", " clearInterval(interval);", " }, 10000);", " }," ], "description": "marketo wait" }, "init owl": { "prefix": "eg_OwlInit", "body": [ "$('${1}')", ".owlCarousel({", " loop: true,", " stagePadding: 50,", " autoplay: true,", " autoplayHoverPause: true,", " center: true,", " responsive: {", " 0: {", " items: 2", " },", " 600: {", " items: 3", " },", " 1000: {", " items: 4", " }", " }", "});" ], "description": "init owl" }, "load image": { "prefix": "eg_LoadImage", "body": [ "function loadImage() {", " var imgEL = document.createElement('img');", " imgEL.src = \"${1}\";", " imgEL.style.display = \"none\";", " document.querySelector(\"body\").appendChild(imgEL);", " }" ], "description": "load image" }, "onDataHelperHelper": { "prefix": "eg_OnDataHelperHelper", "body": [ "function onDataHelperLoad(function() {", " var feListener = function(model, message) {", " console.log(message);", " if (message.event === \"\") {", " if (message.referrer.indexOf('') != -1) {", " trialType = \"\";", " } else if (message.referrer.indexOf('') != -1) {", " trialType = \"\";", " }", " }", " //checkout page goal added", " if (window.location.href.indexOf('') != -1) {", " if (message.event === \"gtm.click\") {", " ", " }", " if (message.event === \"gtm.historyChange\") {", " ", " }", " }", " }", " var feLayer = new DataLayerHelper(dataLayer, feListener, true);", " });" ], "description": "onDataHelperHelper" }, "ajax call": { "prefix": "eg_JsAjaxCall", "body": [ "var xhttp = new XMLHttpRequest();", " xhttp.onreadystatechange = function() {", " if (this.readyState == 4 && this.status == 200) {", " ", " }", " };", " xhttp.open(\"GET\", \"${1}\", true);", " xhttp.send();" ], "description": "ajax call" }, "destroy slick": { "prefix": "eg_DestroySlick", "body": ["$('${1}').slick('unslick');"], "description": "destroy slick" }, "exit intend": { "prefix": "eg_ExitIntent", "body": [ "document.addEventListener(\"mouseout\", function(e) {", " if (e.toElement == null && e.relatedTarget == null) {", " ", " }", "}); " ], "description": "exit intend" }, "eg_helper_basic_snippet": { "prefix": "eg_HelperBasicSnippet", "body": [ "(function() {", " var FEHelper = {", " onLoadElement: function(selector, trigger, delayInterval, delayTimeout) {", " var interval = setInterval(function() {", " if (", " document &&", " document.querySelectorAll(selector) &&", " document.querySelectorAll(selector).length > 0", " ) {", " clearInterval(interval);", " trigger();", " }", " }, delayInterval);", " setTimeout(function() {", " clearInterval(interval);", " }, delayTimeout);", " },", " };", " ", " function init() {", "", " }", " ", " FEHelper.onLoadElement('wait selector', init, 50, 10000);", " })();" ], "description": "eg_helper_basic_snippet" }, "create session": { "prefix": "eg_CreateSession", "body": [ "function createSession() {", " if(sessionStorage.getItem('${1}') == null) {", " sessionStorage.setItem('${2}', '1');", " }", " }" ], "description": "create session" }, "js ajax complete": { "prefix": "eg_AjaxCompleteJS", "body": [ "const send = XMLHttpRequest.prototype.send", " XMLHttpRequest.prototype.send = function() { ", " this.addEventListener('load', function() {", " console.log('global handler', this.responseText)", " // add your global handler here", " })", " return send.apply(this, arguments)", " }" ], "description": "js ajax complete" }, "eg_sticky": { "prefix": "eg_StickyHtml", "body": [ "<div class=\"eg_sticky\">", " <div class=\"eg_sticky_cross\">×</div>", " <a class=\"eg_sticky_inr\" href=\"url\">", " <div>", " <h2></h2>", " <div></div>", " </div>", " </a>", "</div>", "" ], "description": "eg_sticky" }, "eg_slick_add_script": { "prefix": "eg_SlickAddScript", "body": [ "function addScript() {", " var bmScript = document.createElement('script');", " bmScript.src = 'sliderscript';", " document.getElementsByTagName('head')[0].appendChild(bmScript);", " }" ], "description": "eg_slick_add_script" }, "eg_slick_load_helper": { "prefix": "eg_SlickLoadHelper", "body": [ "function onLoadSlick(trigger, delayInterval, delayTimeout) {", " var interval = setInterval(function() {", " if ($.fn && $.fn.slick) {", " clearInterval(interval);", " trigger();", " }", " }, delayInterval);", " setTimeout(function() {", " clearInterval(interval);", " }, delayTimeout);", "}" ], "description": "eg_slick_load_helper" }, "eg_slick_init": { "prefix": "eg_SlickInit", "body": [ " $('selector').slick({", " infinite: true,", " slidesToShow: 1,", " slidesToScroll: 1,", " dots: true,", " });" ], "description": "eg_slick_init" }, "eg_emailvalidate_helper": { "prefix": "eg_validateEmail", "body": [ "function validateEmail(email) {", " var re = /^(([^<>()\\[\\]\\.,;:\\s@\"]+(\\.[^<>()\\[\\]\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;", " return re.test(String(email).toLowerCase());", "}" ], "description": "eg_validateEmail" }, "eg_insertAfter": { "prefix": "eg_insertAfter", "body": [ "function insertAfter(afterElement, targetElement) {", " targetElement.parentNode.insertBefore(", " afterElement,", " targetElement.nextSibling", " );", "}" ], "description": "eg_insertAfter" }, "eg_insertBefore": { "prefix": "eg_insertBefore", "body": [ "function insertBefore(beforeElement, targetElement) {", " targetElement.parentNode.insertBefore(beforeElement, targetElement);", "}" ], "description": "eg_insertBefore" }, "eg_removeClass": { "prefix": "eg_removeClass", "body": [ "function removeClass(element, className) {", " if (element.classList) element.classList.remove(className);", " else", " element.className = element.className.replace(", " new RegExp('\\b' + className + '\\b', 'g'),", " ''", " );", "}" ], "description": "eg_removeClass" }, "eg_addClass": { "prefix": "eg_addClass", "body": [ "function addClass(element, className) {", " if (element.classList) element.classList.add(className);", " else if (!this.hasClass(element, className))", " element.className += ' ' + className;", "}" ], "description": "eg_addClass" }, "set cookie": { "prefix": "eg_SetCookie", "body": [ "function setCookie(name,value,days) {", " var expires = \"\";", " if (days) {", " var date = new Date();", " date.setTime(date.getTime() + (days*24*60*60*1000));", " expires = \"; expires=\" + date.toUTCString();", " }", " document.cookie = name + \"=\" + (value || \"\") + expires + \"; path=/\";", "}" ], "description": "set cookie" }, "get cookie": { "prefix": "eg_GetCookie", "body": [ "function getCookie(name) {", " var nameEQ = name + \"=\";", " var ca = document.cookie.split(';');", " for(var i=0;i < ca.length;i++) {", " var c = ca[i];", " while (c.charAt(0)==' ') c = c.substring(1,c.length);", " if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);", " }", " return null;", "}" ], "description": "get cookie" }, "optimizely custom event goal": { "prefix": "eg_OptimizelyCustomEvent", "body": [ "// ensures the optimizely object is defined globally using", "window['optimizely'] = window['optimizely'] || [];", "", "// sends a tracking call to Optimizely for the given event name. ", "window['optimizely'].push({", " type: \"event\",", " eventName: \"eventName\"", "});" ], "description": "optimizely custom event goal" }, "for loop": { "prefix": "eg_forLoop", "body": "for (var ${1:i} = 0, ${2:len} = ${3:iterable}.length; ${1:i} < ${2:len}; ${1:i}++) {\n\t${0}\n}", "description": "for loop" }, "while loop": { "prefix": "eg_whileLoop", "body": "while (${1:condition}) {\n\t${0}\n}", "description": "while loop" }, "try/catch": { "prefix": "eg_tryCatch", "body": "try {\n\t${0}\n} catch (${1:err}) {\n\t\n}", "description": "try/catch" }, "switch case": { "prefix": "eg_switchCase", "body": "switch (${1:expr}) {\n\tcase ${2:value}:\n\t\treturn $0;\n\tdefault:\n\t\treturn;\n}", "description": "switch case" }, "if statement": { "prefix": "eg_ifCondition", "body": "if (${1:condition}) {\n\t${0}\n}", "description": "if statement" }, "if/else statement": { "prefix": "eg_ifelse", "body": "if (${1:condition}) {\n\t${0}\n} else {\n\t\n}", "description": "if/else statement" }, "event listener": { "prefix": "eg_addEventListener", "body": [ "${1:selector}.addEventListener(${2:eventType}, function() {", "", "})" ], "description": "event listener" }, "Get Height": { "prefix": "eg_getHeight", "body": [ "function getHeight(selector){", " var item = document.querySelector(selector);", " return item ? item.offsetHeight : 0;", " }" ], "description": "Get Height" }, "Scroll To Element": { "prefix": "eg_scrollToEl", "body": [ "function scrollToEl(el){", " var scrollHeight = document.querySelector(el).getBoundingClientRect().top;", " var top = scrollHeight - 100;", " scrollTo({top: top, behavior: 'smooth'}) ", "}" ], "description": "Scroll To Element" }, "Wait For Variable": { "prefix": "eg_waitForVariable", "body": [ "function onLoadVariable(trigger){", " var interval = setInterval(function(){", " if(typeof window.${1:Flickity} != \"undefined\"){", " trigger();", " clearInterval(interval);", " }", " }, 50);", " setTimeout(function(){", " clearInterval(interval);", " }, 15000)", " }" ], "description": "Wait For Variable" }, "Execute Flickity Slider": { "prefix": "eg_execute_flickity", "body": [ "var el = document.querySelector(${1:selector});", "new Flickity( el , {", " contain: true,", " pageDots: false,", " prevNextButtons: true", "});" ], "description": "Execute Flickity Slider" }, "check date gap":{ "prefix": "eg_check_date_gap", "body":[ "function checkGap() {", "const calanderDate = document.querySelector('$1').innerHTML;", "const eg_date = new Date(calanderDate);", "const now = new Date();", "const diff = eg_date.getTime() - now.getTime();", "const gap = Math.ceil(diff * (1 / 1000) * (1 / 60) * (1 / 60) * (1 / 24));", "return gap;", " }" ], "description": "CHecking gap between dates" }, "Live function":{ "prefix": "eg_live", "body":[ "function live(selector, event, callback, context) {", /****Helper Functions****/ // helper for enabling IE 8 event bindings "function addEvent(el, type, handler) {", " if (el.attachEvent) el.attachEvent('on' + type, handler);", " else el.addEventListener(type, handler);", "}", // matches polyfill "this.Element &&", "(function (ElementPrototype) {", "ElementPrototype.matches =", " ElementPrototype.matches ||", "ElementPrototype.matchesSelector ||", "ElementPrototype.webkitMatchesSelector ||", " ElementPrototype.msMatchesSelector ||", "function (selector) {", "var node = this,", " nodes = (node.parentNode || node.document).querySelectorAll(selector),", " i = -1;", "while (nodes[++i] && nodes[i] != node);", "return !!nodes[i];", " };", " })(Element.prototype);", // live binding helper using matchesSelector "function live(selector, event, callback, context) {", " addEvent(context || document, event, function (e) {", "var found,", " el = e.target || e.srcElement;", "while (el && el.matches && el !== context && !(found = el.matches(selector))) el = el.parentElement;", "if (found) callback.call(el, e);", " });", "}", "live(selector, event, callback, context);", " };" ], "description": "Execute Live function" }, "Listener function":{ "prefix": "eg_listener", "body":[ "function listener() {", "window.addEventListener('locationchange', function() {", "waitForElement('', , 50, 15000);})", "history.pushState = ((f) =>", "function pushState() {", "var ret = f.apply(this, arguments);", "window.dispatchEvent(new Event('pushstate'));", "window.dispatchEvent(new Event('locationchange'));", "return ret;", "})(history.pushState);", "history.replaceState = ((f) =>", "function replaceState() {", "var ret = f.apply(this, arguments);", "window.dispatchEvent(new Event('replacestate));", "window.dispatchEvent(new Event('locationchange));", "return ret;", "})(history.replaceState);", "window.addEventListener('popstate, () => {", "window.dispatchEvent(new Event('locationchange'));", "});", "}" ], "description": "Call Listner function" }, "Wrap function":{ "prefix": "eg_wrap", "body": [ "function wrap(el, wrapper) {", "el.parentNode.insertBefore(wrapper, el);", "wrapper.appendChild(el);", "}", "wrap(document.querySelector('.primary-menu'), document.createElement('div'));", "document.querySelector('createdNewDiv').classList.add('');" ], "description": "wrap previous content inside new div" }, "GA Event":{ "prefix": "eg_gaEvent", "body": [ "function trackGAEvent(eventCategory, eventAction, eventLabel) {", "if ('ga' in window) {", "ga.getAll()[0].send('event', {", "eventCategory: eventCategory,", "eventAction: eventAction,", "eventLabel: eventLabel,", "});", "}", "}" ], "description": "add GA event" } }
Leave a Comment