This document provides examples of using variables, regular expressions, JavaScript methods, and jQuery selectors to dynamically insert text and select elements in Launch tags. It demonstrates how to declare variables, use variables to insert text into tags, set and retrieve data elements and cookies to store and access values, and examples of common JavaScript and jQuery methods for selecting elements, testing logic, and matching patterns with regular expressions.
This document provides examples of using variables, regular expressions, JavaScript methods, and jQuery selectors to dynamically insert text and select elements in Launch tags. It demonstrates how to declare variables, use variables to insert text into tags, set and retrieve data elements and cookies to store and access values, and examples of common JavaScript and jQuery methods for selecting elements, testing logic, and matching patterns with regular expressions.
This document provides examples of using variables, regular expressions, JavaScript methods, and jQuery selectors to dynamically insert text and select elements in Launch tags. It demonstrates how to declare variables, use variables to insert text into tags, set and retrieve data elements and cookies to store and access values, and examples of common JavaScript and jQuery methods for selecting elements, testing logic, and matching patterns with regular expressions.
This document provides examples of using variables, regular expressions, JavaScript methods, and jQuery selectors to dynamically insert text and select elements in Launch tags. It demonstrates how to declare variables, use variables to insert text into tags, set and retrieve data elements and cookies to store and access values, and examples of common JavaScript and jQuery methods for selecting elements, testing logic, and matching patterns with regular expressions.
Variables are used to dynamically insert text into Below are some of the most commonly used methods
hods Launch has useful functions built into the platform
site tags (like an eVar or event). Variables are in JavaScript. that help QA tags. The code below can be used in wrapped in %...% syntax. functions or typed directly into your console.
JavaScript Regular Expressions enable debug mode (useful to QA rules)
_satellite.setDebug(true); declare regex variable var RegEx = /pattern/mod use selected element %this.[attribute]% hide browsing activity from Launch use child element %target.[attribute]% modifier function localStorage.setItem('hide_activity',true); /g global matching Dynamically insert the title and inner HTML for: /i case insensitive cross-browser compatible console.log() <a title="link" href="/"><p>Hello!</p></a> /s single line mode _satellite.logger.info('text to display'); //Log title %this.title% /m multi line mode _satellite.logger.log('text to display'); // Another log Output link _satellite.logger.warn('text to display'); //Warning JavaScript Selectors _satellite.logger.error('text to display'); //Error inner HTML %target.innerHTML% Output Hello! Note: Messages from _satellite.logger are only get element by id getElementById('id') get elements by class getElementsByClassName('') viewable in Debug mode. Other example uses: get elements by tag getElementsByTagName('a') href %this.href% get the date of the last library build class %this.className% _satellite.buildInfo.buildDate; alt %this.alt% JavaScript Logic Tests src %this.src% inner text %this.@text% if statement switch statement inner text w/trim %this.@cleanText% if(i<0){some action} switch(i){ custom attribute %this.getAttribute(name)% else if(i<1){some action} case n: Regular Expressions (RegEx) is a method of else{some action} some action; matching that can be used within Launch (and Other useful variables: break; JavaScript and others) to select groups of text. URL pathname %URI% for…next loop default: URL hostname %hostname% for(i=0;i<10;i++){some some action; URL protocol %protocol% Core Patterns action} } pattern function Data Elements are an alternative way of setting a . match any character variable. These are most useful when you use * 0 or more of previous expression value(s) across multiple rules. + 1 or more of previous expression ? 0 or 1 of previous expression using data elements in a rule Below are some common jQuery methods. If ^ start of string %Element Name% available, consider using Sizzle as a selector. $ end of string | “OR” match on both sides set a data element prefixes targeting suffixes {…} explicit quantifier notation _satellite.setVar("Element Name",value); $(this) .parents() .text() […] explicit character set match $('#id') .children() .html() [^…] NOT one of the characters in set get a data element $('.class') .siblings() .val() (…) logical grouping of expression parts _satellite.getVar("Element Name"); $('div') .find() .attr() \ precedes characters above; makes $('div.class') special character literal Note: Each time you call a data element, Launch tries to reset the value. If you need to store a Examples value more permanently, use cookies (below). selectors function $("div img") select all img within div pattern function $("div>img") only direct img children [abc] matches a or b or c Cookies store values that allow you to set and recall $("a[title='equals']") anchor title equals string [a-z] match any letter from a-z (lowercase) without reevaluating (unlike Data Elements). $("a[title!='noequal']") title doesn’t equal string [A-Z] match letter from A-Z (uppercase) $("a:first") select 1st anchor element [0-9] matches any number from 0-9 set a cookie {3} matches 3 of preceding expression $("ul:last li:last") select last ul of last li _satellite.cookie.set(name,value) {3.9} matches 3-9 of preceding expression $("ul li:first-child") first li of every ul _satellite.cookie.set(name,value,{expires: days}) {3,} matches 3 or more $("[id*='contains']") id contains string $("[class$='ends']") class ends with string read a cookie $("[id^='begins']") id begins with string _satellite.cookie.get(name) $(":checked") selects all checked boxes @jimalytics $(":selected") selects active inputs remove a cookie jimalytics.com _satellite.cookie.remove(name)