How to use doubleEscape method in Cypress

Best JavaScript code snippet using cypress

parser.js

Source:parser.js Github

copy

Full Screen

...14};15function getMethod(input) {16    return input.match(/^[\w\.]+/)[0];17}18function doubleEscape(input) {19    return input.replace(/\\/g, '\\\\');20}21function getArgs(input) {22    return doubleEscape(input.replace(/^[\w\.]+\(|\)$/g, ''));23}24function getTokenArgs(token, parts) {25    parts = _.map(parts, doubleEscape);26    var i = 0,27        l = parts.length,28        arg,29        ender,30        out = [];31    function concat(from, ending) {32        var end = new RegExp('\\' + ending + '$'),33            i = from,34            out = '';35        while (!(end).test(out) && i < parts.length) {36            out += ' ' + parts[i];37            parts[i] = null;38            i += 1;39        }40        if (!end.test(out)) {41            throw new Error('Malformed arguments sent to tag.');42        }43        return out.replace(/^ /, '');44    }45    for (i; i < l; i += 1) {46        arg = parts[i];47        if (arg === null || (/^\s+$/).test(arg)) {48            continue;49        }50        if (51            ((/^\"/).test(arg) && !(/\"[\]\}]?$/).test(arg))52                || ((/^\'/).test(arg) && !(/\'[\]\}]?$/).test(arg))53                || ((/^\{/).test(arg) && !(/\}$/).test(arg))54                || ((/^\[/).test(arg) && !(/\]$/).test(arg))55        ) {56            switch (arg.substr(0, 1)) {57            case "'":58                ender = "'";59                break;60            case '"':61                ender = '"';62                break;63            case '[':64                ender = ']';65                break;66            case '{':67                ender = '}';68                break;69            }70            out.push(concat(i, ender));71            continue;72        }73        out.push(arg);74    }75    return out;76}77exports.parseVariable = function (token, escape) {78    if (!token) {79        return {80            type: null,81            name: '',82            filters: [],83            escape: escape84        };85    }86    var filters = [],87        parts = token.replace(/^\{\{ *| *\}\}$/g, '').split('|'),88        varname = parts.shift(),89        i = 0,90        l = parts.length,91        args = null,92        filter_name,93        part;94    if ((/\(/).test(varname)) {95        args = getArgs(varname.replace(/^\w+\./, ''));96        varname = getMethod(varname);97    }98    for (i; i < l; i += 1) {99        part = parts[i];100        if (part && ((/^[\w\.]+\(/).test(part) || (/\)$/).test(part)) && !(/^[\w\.]+\([^\)]*\)$/).test(part)) {101            parts[i] += '|' + parts[i + 1];102            parts[i + 1] = false;103        }104    }105    parts = _.without(parts, false);106    i = 0;107    l = parts.length;108    for (i; i < l; i += 1) {109        part = parts[i];110        filter_name = getMethod(part);111        if ((/\(/).test(part)) {112            filters.push({113                name: filter_name,114                args: getArgs(part)115            });116        } else {117            filters.push({ name: filter_name, args: '' });118        }119    }120    return {121        type: VAR_TOKEN,122        name: varname,123        args: args,124        filters: filters,125        escape: escape126    };127};128exports.parse = function (data, tags, autoescape) {129    var rawtokens = data.replace(/(^\s+)|(\s+$)/g, '').split(/(\{%[^\r]*?%\}|\{\{.*?\}\}|\{#[^\r]*?#\})/),130        escape = !!autoescape,131        last_escape = escape,132        stack = [[]],133        index = 0,134        i = 0,135        j = rawtokens.length,136        filters = [],137        filter_name,138        varname,139        token,140        parts,141        part,142        names,143        matches,144        tagname,145        lines = 1,146        curline = 1,147        newlines = null,148        lastToken,149        rawStart = /^\{\% *raw *\%\}/,150        rawEnd = /\{\% *endraw *\%\}$/,151        inRaw = false;152    for (i; i < j; i += 1) {153        token = rawtokens[i];154        curline = lines;155        newlines = token.match(/\n/g);156        if (newlines) {157            lines += newlines.length;158        }159        if (inRaw !== false && !rawEnd.test(token)) {160            inRaw += token;161            continue;162        }163        // Ignore empty strings and comments164        if (token.length === 0 || commentRegexp.test(token)) {165            continue;166        } else if (/^(\s|\n)+$/.test(token)) {167            token = token.replace(/ +/, ' ').replace(/\n+/, '\n');168        } else if (variableRegexp.test(token)) {169            token = exports.parseVariable(token, escape);170        } else if (logicRegexp.test(token)) {171            if (rawEnd.test(token)) {172                // Don't care about the content in a raw tag, so end tag may not start correctly173                token = inRaw + token.replace(rawEnd, '');174                inRaw = false;175                stack[index].push(token);176                continue;177            }178            if (rawStart.test(token)) {179                // Have to check the whole token directly, not just parts, as the tag may not end correctly while in raw180                inRaw = token.replace(rawStart, '');181                continue;182            }183            parts = token.replace(/^\{%\s*|\s*%\}$/g, '').split(' ');184            tagname = parts.shift();185            if (index > 0 && (/^end/).test(tagname)) {186                lastToken = _.last(stack[stack.length - 2]);187                if ('end' + lastToken.name === tagname) {188                    if (lastToken.name === 'autoescape') {189                        escape = last_escape;190                    }191                    stack.pop();192                    index -= 1;193                    continue;194                }195                throw new Error('Expected end tag for "' + lastToken.name + '", but found "' + tagname + '" at line ' + lines + '.');196            }197            if (!tags.hasOwnProperty(tagname)) {198                throw new Error('Unknown logic tag at line ' + lines + ': "' + tagname + '".');199            }200            if (tagname === 'autoescape') {201                last_escape = escape;202                escape = (!parts.length || parts[0] === 'on') ? ((parts.length >= 2) ? parts[1] : true) : false;203            }204            token = {205                type: LOGIC_TOKEN,206                line: curline,207                name: tagname,208                compile: tags[tagname],209                parent: _.uniq(stack[stack.length - 2])210            };211            token.args = getTokenArgs(token, parts);212            if (tags[tagname].ends) {213                stack[index].push(token);214                stack.push(token.tokens = []);215                index += 1;216                continue;217            }218        }219        // Everything else is treated as a string220        stack[index].push(token);221    }222    if (inRaw !== false) {223        throw new Error('Missing expected end tag for "raw" on line ' + curline + '.');224    }225    if (index !== 0) {226        lastToken = _.last(stack[stack.length - 2]);227        throw new Error('Missing end tag for "' + lastToken.name + '" that was opened on line ' + lastToken.line + '.');228    }229    return stack[index];230};231exports.compile = function compile(indent, parentBlock) {232    var code = '',233        tokens = [],234        parent,235        filepath,236        blockname,237        varOutput;238    indent = indent || '';239    // Precompile - extract blocks and create hierarchy based on 'extends' tags240    // TODO: make block and extends tags accept context variables241    if (this.type === TEMPLATE) {242        _.each(this.tokens, function (token, index) {243            // Load the parent template244            if (token.name === 'extends') {245                filepath = token.args[0];246                if (!helpers.isStringLiteral(filepath) || token.args.length > 1) {247                    throw new Error('Extends tag on line ' + token.line + ' accepts exactly one string literal as an argument.');248                }249                if (index > 0) {250                    throw new Error('Extends tag must be the first tag in the template, but "extends" found on line ' + token.line + '.');251                }252                token.template = this.compileFile(filepath.replace(/['"]/g, ''));253                this.parent = token.template;254            } else if (token.name === 'block') { // Make a list of blocks255                blockname = token.args[0];256                if (!helpers.isValidBlockName(blockname) || token.args.length !== 1) {257                    throw new Error('Invalid block tag name "' + blockname + '" on line ' + token.line + '.');258                }259                if (this.type !== TEMPLATE) {260                    throw new Error('Block "' + blockname + '" found nested in another block tag on line' + token.line + '.');261                }262                try {263                    if (this.hasOwnProperty('parent') && this.parent.blocks.hasOwnProperty(blockname)) {264                        this.blocks[blockname] = compile.call(token, indent + '  ', this.parent.blocks[blockname]);265                    } else if (this.hasOwnProperty('blocks')) {266                        this.blocks[blockname] = compile.call(token, indent + '  ');267                    }268                } catch (error) {269                    throw new Error('Circular extends found on line ' + token.line + ' of "' + this.id + '"!');270                }271            }272            tokens.push(token);273        }, this);274        if (tokens.length && tokens[0].name === 'extends') {275            this.blocks = _.extend({}, this.parent.blocks, this.blocks);276            this.tokens = this.parent.tokens;277        }278    }279    // If this is not a template then just iterate through its tokens280    _.each(this.tokens, function (token, index) {281        if (typeof token === 'string') {282            code += '__output += "' + doubleEscape(token).replace(/\n/g, '\\n').replace(/\r/g, '\\r').replace(/"/g, '\\"') + '";\n';283            return code;284        }285        if (typeof token !== 'object') {286            return; // Tokens can be either strings or objects287        }288        if (token.type === VAR_TOKEN) {289            var name = token.name.replace(/\W/g, '_'),290                args = (token.args && token.args.length) ? token.args : '';291            code += 'if (typeof __context !== "undefined" && typeof __context.' + name + ' === "function") {\n';292            code += '    __output += ' + helpers.wrapMethod('', { name: name, args: args }, '__context') + ';\n';293            code += '} else {\n';294            code += helpers.setVar('__' + name, token);295            code += '    __output += __' + name + ';\n';296            code += '}\n';...

Full Screen

Full Screen

member_modal.js

Source:member_modal.js Github

copy

Full Screen

...195        /* make sure the item to remove wasn't just added now */196        if ( modal.add.indexOf(modal.remove[index]) == -1 ) {197            var url;198            if ( category == "site" ) {199                url = API_URL + "/v2/sites/" + modal.doubleEscape(ampname) +200                        "/meshes/" + modal.doubleEscape(modal.remove[index])201            } else {202                url = API_URL + "/v2/meshes/" + modal.doubleEscape(ampname) +203                        "/sites/" + modal.doubleEscape(modal.remove[index])204            }205            requests.push($.ajax({206                type: "DELETE",207                url: url,208            }));209        }210    });211    /* make a request to add each new set of endpoints to the test */212    $.each(this.add, function(index) {213        /* make sure the item to add wasn't immediately removed */214        if ( modal.remove.indexOf(modal.add[index]) == -1 ) {215            var url;216            var data;217            if ( category == "site" ) {218                url = API_URL + "/v2/sites/" +219                        modal.doubleEscape(ampname) + "/meshes"220                data = {"mesh": modal.add[index]};221            } else {222                url = API_URL + "/v2/meshes/" + modal.doubleEscape(ampname) +223                        "/sites"224                data = {"site": modal.add[index]};225            }226            requests.push($.ajax({227                type: "POST",228                url: url,229                data: JSON.stringify(data),230                contentType: "application/json",231            }));232        }233    });234    /* wait for all outstanding requests and then close the modal when done */235    $.when.apply(this, requests).done(function() {236        $("#modal-foo").modal("hide");...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

...122        if (!exePath) {123            // exhausted available paths124            throw (0, errors_1.notInstalledErr)(browser.name);125        }126        let path = doubleEscape(exePath);127        return fse.pathExists(path)128            .then((exists) => {129            (0, log_1.log)('found %s ?', path, exists);130            if (!exists) {131                return tryNextExePath();132            }133            return getVersionString(path)134                .then((val) => {135                (0, log_1.log)(val);136                return val;137            })138                .then(getVersion)139                .then((version) => {140                (0, log_1.log)('browser %s at \'%s\' version %s', browser.name, exePath, version);141                return {142                    name: browser.name,143                    version,144                    path: exePath,145                };146            });147        })148            .catch((err) => {149            (0, log_1.log)('error while looking up exe, trying next exePath %o', { exePath, exePaths, err });150            return tryNextExePath();151        });152    });153    return tryNextExePath();154}155function doubleEscape(s) {156    // Converts all types of paths into windows supported double backslash path157    // Handles any number of \\ in the given path158    return path_1.win32.join(...s.split(path_1.win32.sep)).replace(/\\/g, '\\\\');159}160exports.doubleEscape = doubleEscape;161function getVersionString(path) {162    // on Windows using "--version" seems to always start the full163    // browser, no matter what one does.164    const args = [165        'datafile',166        'where',167        `name="${path}"`,168        'get',169        'Version',170        '/value',171    ];172    return utils_1.utils.execa('wmic', args)173        .then((val) => val.stdout)174        .then((val) => val.trim());175}176exports.getVersionString = getVersionString;177function getVersionNumber(version) {178    if (version.indexOf('Version=') > -1) {179        return version.split('=')[1];180    }181    return version;182}183exports.getVersionNumber = getVersionNumber;184function getPathData(pathStr) {185    const test = new RegExp(/^.+\.exe:(.+)$/);186    const res = test.exec(pathStr);187    let browserKey = '';188    let path = pathStr;189    if (res) {190        const pathParts = path.split(':');191        browserKey = pathParts.pop() || '';192        path = doubleEscape(pathParts.join(':'));193        return { path, browserKey };194    }195    path = doubleEscape(path);196    if (pathStr.indexOf('chrome.exe') > -1) {197        return { path, browserKey: 'chrome' };198    }199    if (pathStr.indexOf('edge.exe') > -1) {200        return { path, browserKey: 'edge' };201    }202    if (pathStr.indexOf('firefox.exe') > -1) {203        return { path, browserKey: 'firefox' };204    }205    return { path };206}207exports.getPathData = getPathData;208function detect(browser) {209    return getWindowsBrowser(browser);...

Full Screen

Full Screen

LSNotesPeekTextDecode.js

Source:LSNotesPeekTextDecode.js Github

copy

Full Screen

1///LND: Ðàñêîäèðîâàíèå òåêñòà, ñêîïèðîâàííîãî èç NotesPeek2// http://akelpad.sourceforge.net/forum/viewtopic.php?p=7982#79823// Version: 1.0 (2011.04.13)4//eval(AkelPad.ReadFile(AkelPad.GetAkelDir(5) + "\\converter.js"));		//âðåìåííî çàêîìåí÷åíî (æä¸ì âûäåëåíèå ôóíêöèé äëÿ êîíâåðòàöèè â îòäåëüíóþ áèáëèîòåêó)5var CP_NOT_CONVERT = -2;6var CP_CURRENT     = -1;7var oSys = AkelPad.SystemFunction();8var pText = AkelPad.GetSelText() || AkelPad.SetSel(0, -1) || AkelPad.GetSelText();9pText = decodeEscapes(pText);10pText = convertToUnicode(pText, 1251);11pText = pText.replace(/\x05/gm, "");		//ðóáèì òóïûå êâàäðàòèêè12pText = pText.replace(new RegExp('"\r\t"', "gm"), "");		//óáèðàåì íåíóæíûå ðàçðûâû âíóòðè ñòðîê13AkelPad.ReplaceSel(pText);14// Infocatcher's code15function decodeEscapes(str) {16/*17	if(customEscapesDecoder)18		return decodeEscapesCustom(str);19*/20	// Keep some escaped chars inside string literals21	// "ab\ncd" => "ab\\ncd" => eval() => "ab\ncd"22	var doubleEscape = function(s) {23		return s.replace(24			/(\\+)([nrt'"])?/g,25			function(s, bs, chr) {26				if(bs.length % 2 == 0 || chr) // \ => \\ (*2)27					return new Array(bs.length + 1).join("\\") + s;28				// \\\ => \\ + \ => (\\)*2 + \29				return new Array(Math.floor(bs.length/2)*2 + 1).join("\\") + s;30			}31		);32	};33	str = str // Single RegExp like /("|')(?:\\\1|[^\1])*\1/g fail34		.replace(/"(?:\\"|[^"\n\r])*"/g, doubleEscape)35		.replace(/'(?:\\'|[^'\n\r])*'/g, doubleEscape);36	var fixEsc = function(s, bs, chr, hex) {37		return bs.length % 2 == 0 && /[^0-9a-f]/i.test(hex)38			? bs + chr + hex39			: s;40	};41	try {42		str = eval(43			'"' +44			str // Make valid string45				.replace(46					/(\\*)["']/g,47					function(s, bs) {48						return bs.length % 2 == 049							? "\\" + s50							: s;51					}52				)53				.replace(54					/\\+$/, // Fix qwe\ => "qwe\" => eval() error55					function(s) {56						return s.length % 2 != 057							? "\\" + s58							: s;59					}60				)61				// Fix invalid \u and \x62				.replace(/(\\*)\\(x)([\s\S]{2})/g, fixEsc)63				.replace(/(\\*)\\(u)([\s\S]{4})/g, fixEsc)64				.replace(/\n/g, "\\n")65				.replace(/\r/g, "\\r")66				.replace(/\x00/g, "\\x00")67				.replace(/\u2028/g, "\\u2028")68				.replace(/\u2029/g, "\\u2029") +69			'"'70		);71	}72	catch(e) {73		throw new (e.constructor || SyntaxError)('eval("string") fail\n' + e.message);74	}75	return str;76}77function convertToUnicode(str, cp) {78   if(cp == CP_NOT_CONVERT)79      return str;80   if(cp == CP_CURRENT || cp === undefined)81      cp = AkelPad.GetEditCodePage(0);82   var ret = "";83   if(84      cp == 1200 //UTF-16LE85      || cp == 1201 //UTF-16BE86      || cp == 12000 //UTF-32LE87      || cp == 12001 //UTF-32BE88   ) {89      var isLE = cp == 1200 || cp == 12000;90      var step = cp == 12000 || cp == 12001 ? 4 : 2;91      if(str.length % step != 0)92         throw "Invalid unicode string";93      for(var i = 0, l = str.length; i < l; i += step) {94         var chars = str.substr(i, step);95         if(isLE) {96            var b1 = chars.charCodeAt(0);97            var b2 = chars.charCodeAt(1);98         }99         else {100            var b1 = chars.charCodeAt(step - 1);101            var b2 = chars.charCodeAt(step - 2);102         }103         ret += String.fromCharCode((b2 << 8) + b1);104      }105      return ret;106   }107   // based on Fr0sT's code: http://akelpad.sourceforge.net/forum/viewtopic.php?p=7972#7972108   // current code page is UTF16* or UTF32* - set ansi current code page109   // (WideChar <-> MultiByte functions don't work with this code pages)110   if(cp == 1 || cp == 1200 || cp == 1201 || cp == 12000 || cp == 12001)111      cp = 0;112   try {113      var strLen = str.length;114      var pMBBuf = AkelPad.MemAlloc(strLen * 1 /*sizeof(char)*/);115      if(!pMBBuf)116         throw new Error("MemAlloc fail");117      for(var i = 0; i < strLen; i++)118         AkelPad.MemCopy(pMBBuf + i, str.charCodeAt(i), 5 /*DT_BYTE*/);119      // get required buffer size120      var bufLen = oSys.Call(121         "Kernel32::MultiByteToWideChar",122         cp,       //   __in   UINT CodePage,123         0,        //   __in   DWORD dwFlags,124         pMBBuf,   //   __in   LPCSTR lpMultiByteStr,125         strLen,   //   __in   int cbMultiByte,126         0,        //   __out  LPWSTR lpWideCharStr,127         0         //   __in   int cchWideChar128      );129      if(!bufLen)130         throw new Error("MultiByteToWideChar fail " + oSys.GetLastError());131      bufLen *= 2 /*sizeof(wchar_t)*/;132      var pWCBuf = AkelPad.MemAlloc(bufLen);133      if(!pWCBuf)134         throw new Error("MemAlloc fail");135      // convert buffer136      bufLen = oSys.Call(137         "Kernel32::MultiByteToWideChar",138         cp,       //   __in   UINT CodePage,139         0,        //   __in   DWORD dwFlags,140         pMBBuf,   //   __in   LPCSTR lpMultiByteStr,141         strLen,   //   __in   int cbMultiByte,142         pWCBuf,   //   __out  LPWSTR lpWideCharStr,143         bufLen    //   __in   int cchWideChar144      );145      if(!bufLen)146         throw new Error("MultiByteToWideChar fail " + oSys.GetLastError());147      //ret = AkelPad.MemRead(pWCBuf, 1 /*DT_UNICODE*/);148      for(var pCurr = pWCBuf, bufMax = pWCBuf + bufLen*2; pCurr < bufMax; pCurr += 2)149         ret += String.fromCharCode(AkelPad.MemRead(pCurr, 4 /*DT_WORD*/));150   }151   catch(e) {152      throw e;153   }154   finally {155      pMBBuf && AkelPad.MemFree(pMBBuf);156      pWCBuf && AkelPad.MemFree(pWCBuf);157   }158   return ret;...

Full Screen

Full Screen

convertEscapes.js

Source:convertEscapes.js Github

copy

Full Screen

1// (c) Infocatcher 20102// version 0.1.6 - 2010-12-093//===================4// Convert JavaScript escape sequences like "\u00a9" or "\xa9" ((c) symbol)5// Arguments:6//   -mode=0  - (default) auto encode or decode7//   -mode=1  - encode8//   -mode=2  - decode9// Usage:10//   Call("Scripts::Main", 1, "convertEscapes.js", "-mode=0")11//===================12function _localize(s) {13	var strings = {14		"Nothing to recode!": {15			ru: "Íå÷åãî ïåðåêîäèðîâàòü!"16		}17	};18	var lng;19	switch(AkelPad.SystemFunction().Call("kernel32::GetUserDefaultLangID") & 0x3ff /*PRIMARYLANGID*/) {20		case 0x19: lng = "ru"; break;21		default:   lng = "en";22	}23	_localize = function(s) {24		return strings[s] && strings[s][lng] || s;25	};26	return _localize(s);27}28// Read arguments:29var args = {};30for(var i = 0, argsCount = WScript.Arguments.length; i < argsCount; i++)31	if(/^-(\w+)(=(.+))?$/i.test(WScript.Arguments(i)))32		args[RegExp.$1.toLowerCase()] = RegExp.$3 ? eval(RegExp.$3) : true;33function getArg(argName, defaultVal) {34	return typeof args[argName] == "undefined" // argName in args35		? defaultVal36		: args[argName];37}38var MODE_AUTO   = 0;39var MODE_ENCODE = 1;40var MODE_DECODE = 2;41var mode = getArg("mode", MODE_AUTO);42var auto   = mode == MODE_AUTO;43var encode = mode == MODE_ENCODE;44var decode = mode == MODE_DECODE;45//var AkelPad = new ActiveXObject("AkelPad.document");46var hMainWnd = AkelPad.GetMainWnd();47var hWndEdit = AkelPad.GetEditWnd();48var oSys = AkelPad.SystemFunction();49if(hMainWnd && !AkelPad.GetEditReadOnly(hWndEdit))50	convertEscapes();51function convertEscapes() {52	var text = AkelPad.GetSelText();53	var selectAll = false;54	if(!text) {55		text = getAllText();56		selectAll = true;57	}58	var res;59	if(encode || auto) {60		res = encodeEscapes(text);61		if(auto)62			decode = res == text; // Can't encode63	}64	if(decode) {65		res = decodeEscapes(text);66		if(res == null) // Decode error67			return;68	}69	if(res == text) {70		AkelPad.MessageBox(hMainWnd, _localize("Nothing to recode!"), WScript.ScriptName, 48 /*MB_ICONEXCLAMATION*/);71		return;72	}73	insertNoScroll(res, selectAll);74}75function encodeEscapes(str) {76	return str.replace(77		/[^!-~ \t\n\r]/ig,78		function(s) {79			var hex = s.charCodeAt(0).toString(16);80			return "\\u" + "0000".substr(hex.length) + hex;81		}82	);83}84function decodeEscapes(str) {85	// Keep some escaped chars inside string literals86	// "ab\ncd" => "ab\\ncd" => eval() => "ab\ncd"87	var doubleEscape = function(s) {88		return s.replace(89			/(\\+)([nrt'"])?/g,90			function(s, bs, chr) {91				if(bs.length % 2 == 0 || chr) // \ => \\ (*2)92					return new Array(bs.length + 1).join("\\") + s;93				// \\\ => \\ + \ => (\\)*2 + \94				return new Array(Math.floor(bs.length/2)*2 + 1).join("\\") + s;95			}96		);97	};98	str = str // Single RegExp like /("|')(?:\\\1|[^\1])*\1/g fail99		.replace(/"(?:\\"|[^"\n\r])*"/g, doubleEscape)100		.replace(/'(?:\\'|[^'\n\r])*'/g, doubleEscape);101	try {102		// Stupid, but sample :D103		str = eval(104			'"' +105			str // Make valid string106				.replace(107					/(\\*)["']/g,108					function(s, bs) {109						return bs.length % 2 == 0110							? "\\" + s111							: s;112					}113				)114				.replace(/\n/g, "\\n")115				.replace(/\r/g, "\\r")116				.replace(/\u2028/g, "\\u2028")117				.replace(/\u2029/g, "\\u2029") +118			'"'119		);120	}121	catch(e) {122		AkelPad.MessageBox(hMainWnd, e.name + '\neval("string") fail\n' + e.message, WScript.ScriptName, 16 /*MB_ICONERROR*/);123		return null;124	}125	return str;126}127function getAllText() {128	if(typeof AkelPad.GetTextRange != "undefined")129		return AkelPad.GetTextRange(0, -1);130	var lpPoint = AkelPad.MemAlloc(8 /*sizeof(POINT)*/);131	if(!lpPoint)132		return "";133	setRedraw(hWndEdit, false);134	AkelPad.SendMessage(hWndEdit, 1245 /*EM_GETSCROLLPOS*/, 0, lpPoint);135	var columnSel = AkelPad.SendMessage(hWndEdit, 3127 /*AEM_GETCOLUMNSEL*/, 0, 0);136	var ss = AkelPad.GetSelStart();137	var se = AkelPad.GetSelEnd();138	AkelPad.SetSel(0, -1);139	var str = AkelPad.GetSelText();140	AkelPad.SetSel(ss, se);141	columnSel && AkelPad.SendMessage(hWndEdit, 3128 /*AEM_UPDATESEL*/, 0x1 /*AESELT_COLUMNON*/, 0);142	AkelPad.SendMessage(hWndEdit, 1246 /*EM_SETSCROLLPOS*/, 0, lpPoint);143	AkelPad.MemFree(lpPoint);144	setRedraw(hWndEdit, true);145	return str;146}147function insertNoScroll(str, selectAll) {148	var lpPoint = AkelPad.MemAlloc(8 /*sizeof(POINT)*/);149	if(!lpPoint)150		return;151	setRedraw(hWndEdit, false);152	AkelPad.SendMessage(hWndEdit, 1245 /*EM_GETSCROLLPOS*/, 0, lpPoint);153	selectAll && AkelPad.SetSel(0, -1);154	//var ss = AkelPad.GetSelStart();155	AkelPad.ReplaceSel(str, true);156	//if(ss != AkelPad.GetSelStart())157	//	AkelPad.SetSel(ss, ss + str.length);158	AkelPad.SendMessage(hWndEdit, 1246 /*EM_SETSCROLLPOS*/, 0, lpPoint);159	setRedraw(hWndEdit, true);160	AkelPad.MemFree(lpPoint);161}162function setRedraw(hWnd, bRedraw) {163	AkelPad.SendMessage(hWnd, 11 /*WM_SETREDRAW*/, bRedraw, 0);164	bRedraw && oSys.Call("user32::InvalidateRect", hWnd, 0, true);...

Full Screen

Full Screen

string.js

Source:string.js Github

copy

Full Screen

1// ==========================2// String in JavaScript 3//==============================4// 'string' "string"5// Numeric Literal6// String Literal7// Boolean Literal 8// String Literal9var string = 'Hello World'10// String() constructor11new String(string)12String(string)13console.log(string);14console.log(String);15console.log(String(string));16// String() constructor17var numberString = 1000;18console.log(String(numberString));19var result = numberString.toString();20console.log(result);21// Escape characters in JavaScript22// \b	Backspace23// \f	Form Feed24// \n	New Line 25// \r	Carriage Return26// \t	Horizontal Tabulator27// \v	Vertical Tabulator28// \'	Single quote29// \"	Double quote30// \\	Backslash31var doubleEscape = "They call it an \"escape\" character";32console.log(doubleEscape);33var singleEscape = 'They call it an \'escape\' character';34console.log(singleEscape);35// String Methods 36// length()37// lastIndexOf()38// indexOf()39// search()40// slice(start, end)41// substring(start, end)42// substr(start, length)43// toLocaleLowerCase44// toLocaleUpperCase45// trim46// charAt47// startsWith48// split49var a = 'I am'50var b = 'hello world this is     string methods'51result = a.concat(' ', b);52console.log(result);53reuslt2 = result.charAt(5);54console.log(reuslt2);55result3 = result.startsWith('I am');56console.log(result3);57result4 = result.endsWith('methods');58console.log(result4);59result5 = result.toLocaleLowerCase()60console.log(result5);61result6 = result.toLocaleUpperCase();62console.log(result6);63result7 = result.trim();64console.log(result7);65console.log('      space       trim'.trim());66result8 = result.split(' ');...

Full Screen

Full Screen

og.js

Source:og.js Github

copy

Full Screen

...24  const superSubtitle = prettyRange(startDate, endDate);25  const image =26    imageDomain +27    "/w_1000,c_fit,co_white,l_text:Lato_80_bold:" +28    doubleEscape(title) +29    ",g_north_west,x_100,y_100" +30    "/w_1000,c_fit,co_white,l_text:Lato_40:" +31    doubleEscape(subtitle) +32    ",g_north_west,x_100,y_360" +33    "/w_1000,c_fit,co_white,l_text:Lato_40_bold:" +34    doubleEscape(superSubtitle) +35    ",g_north_west,x_100,y_430" +36    "/" +37    imageTemplate;38  return image;39};40function doubleEscape(txt) {41  return encodeURIComponent(encodeURIComponent(txt));...

Full Screen

Full Screen

escape.js

Source:escape.js Github

copy

Full Screen

1var doubleEscape = "";...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Cypress Test', function() {2  it('Does not do much!', function() {3    cy.contains('type').click()4    cy.url().should('include', '/commands/actions')5    cy.get('.action-email')6      .type('

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.doubleEscape()2Cypress.Commands.add("doubleEscape", () => {3  cy.get('body').trigger('keydown', { keyCode: 27, which: 27, force: true })4  cy.get('body').trigger('keyup', { keyCode: 27, which: 27, force: true })5})6cy.get('body').doubleEscape()7Cypress.Commands.add("doubleEscape", { prevSubject: "element" }, (subject) => {8  cy.wrap(subject).trigger('keydown', { keyCode: 27, which: 27, force: true })9  cy.wrap(subject).trigger('keyup', { keyCode: 27, which: 27, force: true })10})

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.Commands.add('doubleEscape', () => {2    cy.get('body').type('{esc}{esc}', { force: true })3})4Cypress.Commands.add('doubleEscape', () => {5    cy.get('body').type('{esc}{esc}', { force: true })6})7Cypress.Commands.add('doubleEscape', () => {8    cy.get('body').type('{esc}{esc}', { force: true })9})10Cypress.Commands.add('doubleEscape', () => {11    cy.get('body').type('{esc}{esc}', { force: true })12})13Cypress.Commands.add('doubleEscape', () => {14    cy.get('body').type('{esc}{esc}', { force: true })15})16Cypress.Commands.add('doubleEscape', () => {17    cy.get('body').type('{esc}{esc}', { force: true })18})19Cypress.Commands.add('doubleEscape', () => {20    cy.get('body').type('{esc}{esc}', { force: true })21})22Cypress.Commands.add('doubleEscape', () => {23    cy.get('body').type('{esc}{esc}', { force: true })24})25Cypress.Commands.add('doubleEscape', () => {26    cy.get('body').type('{esc}{esc}', { force: true })27})28Cypress.Commands.add('doubleEscape', () => {29    cy.get('body').type('{esc}{esc}', { force: true })30})

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.Commands.add("doubleEscape", () => {2  cy.get('body').type('{esc}{esc}');3});4describe("test", () => {5  it("test", () => {6    cy.login();7    cy.doubleEscape();8  });9});

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.get('input[name="username"]').type('username')2cy.get('input[name="password"]').type('password')3cy.get('button').click()4cy.get('input[name="username"]').type('username')5cy.get('input[name="password"]').type('password')6cy.get('button').click()7cy.get('input[name="username"]').type('username')8cy.get('input[name="password"]').type('password')9cy.get('button').click()10cy.get('input[name="username"]').type('username')11cy.get('input[name="password"]').type('password')12cy.get('button').click()13cy.get('input[name="username"]').type('username')14cy.get('input[name="password"]').type('password')15cy.get('button').click()16cy.get('input[name="username"]').type('username')17cy.get('input[name="password"]').type('password')18cy.get('button').click()19cy.get('input[name="username"]').type('username')20cy.get('input[name="password"]').type('password')21cy.get('button').click()22cy.get('input[name="username"]').type('username')23cy.get('input[name="password"]').type('password')24cy.get('button').click()25cy.get('input[name="username"]').type('username')26cy.get('input[name="password"]').type('password')27cy.get('button').click()28cy.get('input[name="username"]').type('username')29cy.get('input[name="password"]').type('password')30cy.get('button').click()

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.get('input').type('Hello World')2cy.get('input').type('{selectall}{backspace}')3cy.get('input').type('Hello World')4cy.get('input').type('Hello World')5cy.get('input').type('{esc}')6cy.get('input').type('Hello World')7cy.get('input').type('Hello World')8cy.get('input').type('{selectall}{backspace}')9cy.get('input').type('Hello World')10cy.get('input').type('Hello World')11cy.get('input').type('{esc}')12cy.get('input').type('Hello World')13cy.get('input').type('Hello World')14cy.get('input').type('{selectall}{backspace}')15cy.get('input').type('Hello World')16cy.get('input').type('Hello World')17cy.get('input').type('{esc}')18cy.get('input').type('Hello World')19cy.get('input').type('Hello World')20cy.get('input').type('{selectall}{backspace}')21cy.get('input').type('Hello World')22cy.get('input').type('Hello World')23cy.get('input').type('{esc}')24cy.get('input').type('Hello World')25cy.get('input').type('Hello World')26cy.get('input').type('{selectall}{backspace}')27cy.get('input').type('Hello World')28cy.get('input').type('Hello World')29cy.get('input').type('{esc}')30cy.get('input').type('Hello World')31cy.get('input').type('Hello World')32cy.get('input').type('{selectall}{backspace}')33cy.get('input').type('Hello World')34cy.get('input').type('Hello World')35cy.get('input').type('{esc}')36cy.get('input').type('Hello World')37cy.get('input').type('Hello World')38cy.get('

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.get('input').type(doubleEscape('foo{enter}'))2cy.get('input').type(doubleEscape('foo{enter}'))3Cypress.Commands.add('doubleEscape', (value) => {4  return value.replace(/\\/g, '\\\\')5})6cy.get('input').type('foo\\bar')7cy.get('input').type(doubleEscape('foo\\bar'))8Cypress.Commands.add('doubleEscape', (value) => {9  return value.replace(/\\/g, '\\\\')10})

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.get('input').type(doubleEscape('abc'))2cy.get('input').type(doubleEscape('abc'))3Escape Sequence Meaning \t Tab \b Backspace \n Newline \r Carriage return \f Form feed \0 Null \e Escape \v Vertical tab \xhh Hexadecimal character code \uhhhh Unicode character code \u{hhhhhh} Unicode character code4cy.get('input').type('abc{enter}def{enter}ghi{enter}')5cy.get('input').type('abc{enter}def{enter}ghi{enter}')6Character Meaning { } {e

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test', function() {2  it('test', function() {3    cy.log(Cypress._.doubleEscape('test'));4  });5});6describe('Test', function() {7  it('test', function() {8    cy.log(Cypress._.doubleEscape('test'));9  });10});11describe('Test', function() {12  it('test', function() {13    cy.log(Cypress._.doubleEscape('test'));14  });15});16describe('Test', function() {17  it('test', function() {18    cy.log(Cypress._.doubleEscape('test'));19  });20});21describe('Test', function() {22  it('test', function() {23    cy.log(Cypress._.doubleEscape('test'));24  });25});26describe('Test', function() {27  it('test', function() {28    cy.log(Cypress._.doubleEscape('test'));29  });30});31describe('Test', function() {32  it('test', function() {33    cy.log(Cypress._.doubleEscape('test'));34  });35});36describe('Test', function() {37  it('test', function() {

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful