Best JavaScript code snippet using testcafe
oos.js
Source:oos.js
1var host = 'https://outofstock.eastsideco.io';2if (window.hasOwnProperty('escOutOfStock_devTranslations')) {3 var translation = window.escOutOfStock_devTranslations;4 5} else {6 var translation = JSON.parse('\x7B\x22id\x22\x3A630,\x22created_at\x22\x3A\x222017\x2D06\x2D29\x2018\x3A44\x3A35\x22,\x22updated_at\x22\x3A\x222017\x2D06\x2D29\x2018\x3A44\x3A35\x22,\x22shop_id\x22\x3A796,\x22title\x22\x3A\x22Item\x20out\x20of\x20stock\x20\x2D\x20notify\x20me\x21\x22,\x22sms_email_heading\x22\x3A\x22Enter\x20your\x20phone\x20number\x20or\x20email\x20address\x20below\x20to\x20be\x20notified\x20when\x20this\x20item\x20is\x20back\x20in\x20stock\x3A\x22,\x22email_only_heading\x22\x3A\x22Enter\x20your\x20email\x20address\x20below\x20to\x20be\x20notified\x20when\x20this\x20item\x20is\x20back\x20in\x20stock\x3A\x22,\x22country_heading\x22\x3A\x22Select\x20country\x3A\x22,\x22sms_btn\x22\x3A\x22Text\x20Me\x22,\x22sms_error\x22\x3A\x22Enter\x20valid\x20mobile\x20phone\x20number\x22,\x22sms_success\x22\x3A\x22Thank\x20you\x20\x2D\x20we\x27ll\x20send\x20you\x20an\x20SMS\x20when\x20your\x20item\x20becomes\x20available\x22,\x22email_placeholder\x22\x3A\x22you\x40example.com\x22,\x22email_btn\x22\x3A\x22Email\x20Me\x22,\x22email_error\x22\x3A\x22Enter\x20valid\x20email\x20address\x22,\x22email_already_tracked\x22\x3A\x22Whoops\x21\x20You\x27ve\x20already\x20signed\x20up\x20to\x20be\x20notified\x22,\x22sms_already_tracked\x22\x3A\x22Whoops\x21\x20You\x27ve\x20already\x20signed\x20up\x20to\x20be\x20notified\x22,\x22email_success\x22\x3A\x22Thank\x20you\x20\x2D\x20we\x27ll\x20send\x20you\x20an\x20email\x20when\x20your\x20item\x20becomes\x20available\x22,\x22email_unsubscribed\x22\x3A\x22Email\x20address\x20currently\x20unsubscribed\x22,\x22product_back_in_stock\x22\x3A\x22Product\x20now\x20back\x20in\x20stock\x21\x20Refresh\x20your\x20page\x22\x7D');7 8}9var $escOosTag = $('[data-app="esc-out-of-stock"]');10/*11 var productVariants = $escOosTag.html();12productVariants = $.parseJSON(productVariants);13*/14var productId = $escOosTag.data('product-id');15var invPolicyAllowOosEnabled = $escOosTag.attr('inventory-policy-allow-oos-enabled');16var selectedVariantId = null;17if (productId) {18 var productAvailable = $escOosTag.data('product-available');19 if (productAvailable == false) insertAlertBtns();20 onAlertClick();21} else {22 // If selectedVariantId is false, Shopify has defaulted to the first in stock variant23 selectedVariantId = getVariantId();24 console.log('selectedVariantId', selectedVariantId);25 if (!selectedVariantId) {26 console.log('No variant id');27 } else {28 var variantInventoryManagement = getVariantInventoryManagement();29 console.log('inventory management', variantInventoryManagement);30 var variantInventoryPolicy = getVariantInventoryPolicy();31 console.log('inventory policy', variantInventoryPolicy);32 console.log('invPolicyAllowOosEnabled', invPolicyAllowOosEnabled);33 if (variantInventoryManagement == 'shopify' && (variantInventoryPolicy == 'deny' || invPolicyAllowOosEnabled )) {34 if (invPolicyAllowOosEnabled) {35 console.log('invPolicyAllowOosEnabled', invPolicyAllowOosEnabled);36 }37 var quantity = variantStockCheck();38 console.log('Stock quantity', quantity);39 if (Number.isInteger(quantity) && quantity <= 0) {40 console.log('Call setupOosForm()');41 setupOosForm();42 } else {43 $('#esc-oos-form').empty();44 }45 } else {46 $('#esc-oos-form').empty();47 console.log('NBIS not allowed');48 }49 }50 var $allInputs = $addToCart.find('select,input').filter(':not(.esc-sms-input)').filter(':not(.esc-email-input)');51 console.log('$allInputs1', $allInputs);52 $allInputs.change(inputsChanged);53}54function getVariantId() {55 var selectedVariantId = null;56 var search = window.location.search;57 if (search.length == 0) {58 // Check are all variants ?59 var productOutOfStock = getProductOutOfStock();60 console.log('productOutOfStock', productOutOfStock);61 if (productOutOfStock) {62 var variant = productVariants[0];63 selectedVariantId = variant.id;64 return selectedVariantId;65 } else {66 return false;67 }68 }69 search = search.split('?');70 if (search) {71 search = search[1].split('&');72 }73 $.each(search, function(k, e){74 var param = e.split('=');75 if (param[0] == 'variant') selectedVariantId = param[1];76 });77 return selectedVariantId;78}79function onAlertClick(productId) {80 console.log('onAlertClick()');81 console.log('esc-btn', $(".esc-btn" ));82 $(".esc-btn" ).on( "click", function() {83 console.log('onAlertClick clicked');84 $('.esc-notification').empty();85 var alertType = $(this).data('alert-type');86 if (alertType == 'email') {87 var destination = $('.esc-email-input').val();88 if (validateEmail(destination) == false) {89 $('.esc-email-notification').removeClass('esc-error')90 .addClass('esc-error')91 .html(translation.email_error);92 return;93 }94 }95 var country = $('.countrySelect').val();96 if (alertType == 'sms') {97 var country = $("#phone").intlTelInput("getSelectedCountryData").iso2.toUpperCase();98 var destination = $("#phone").intlTelInput("getNumber");99 }100 $(this).prop('disabled', 'disabled');101 insertOosProduct(destination, alertType, country, productId);102 });103}104function validateEmail(x) {105 var atpos = x.indexOf("@");106 var dotpos = x.lastIndexOf(".");107 if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length) {108 return false;109 } else return true;110 }111function insertOosProduct(destination, alertType, country, productId) {112 var url = host + '/api/create-alert';113 var data = {114 product_id : productId,115 variant_id : selectedVariantId,116 destination : destination,117 alertType : alertType,118 domain: "heroinescom.myshopify.com",119 country : country120 };121 console.log('Create alert:', data);122 $.ajax({123 data : data,124 url : url,125 type : 'post',126 dataType: 'text',127 success : function(res) {128 $('.esc-btn').removeAttr('disabled');129 if (res == 1) {130 $('.esc-email-notification')131 .removeClass('esc-error')132 .addClass('esc-success')133 .html(translation.email_success);134 $('.esc-email-input').hide();135 $('.esc-email-container button').hide();136 } else if (res == 2) {137 $('.esc-sms-notification')138 .removeClass('esc-error')139 .addClass('esc-success')140 .html(translation.sms_success);141 $('.esc-sms-container .intl-tel-input').hide();142 $('.esc-sms-select-country-title').hide();143 $('.esc-sms-input').hide();144 $('.esc-sms-container button').hide();145 } else if (res == -1) {146 $('.esc-sms-notification').removeClass('esc-error')147 .addClass('esc-error')148 .html(translation.sms_error);149 } else if (res == -2) {150 $('.esc-email-notification').removeClass('esc-error')151 .addClass('esc-error')152 .html(translation.email_error);153 } else if (res == -3) {154 $('.esc-email-notification').removeClass('esc-error')155 .addClass('esc-error')156 .html(translation.email_already_tracked);157 } else if (res == -4) {158 $('.esc-sms-notification').removeClass('esc-error')159 .addClass('esc-error')160 .html(translation.sms_already_tracked);161 } else if (res == -5) {162 $('.esc-email-notification').removeClass('esc-error')163 .addClass('esc-error')164 .html(translation.email_unsubscribed);165 } else if (res == -6) {166 $('.esc-email-notification').removeClass('esc-error')167 .addClass('esc-error')168 .html(translation.product_back_in_stock);169 } else if (res == -7) {170 $('.esc-email-notification').removeClass('esc-error')171 .addClass('esc-error')172 .html("There was an error creating alert");173 } else if (res == -9) {174 console.log('Now Back in Stock shop domain not recevied');175 } else if (res == -10) {176 console.log('Now Back in Stock shop does not exist');177 }178 }179 });180 }181function setupOosForm(id) {182 setTimeout(function(){183 insertAlertBtns(id);184 onAlertClick(id);185 },100);186 187}188function insertAlertBtns(id){189 console.log('insertAlertBtns()');190 var smsPlan = "";191 if (smsPlan == 1) {192 var oosSubTitleHtml = translation.sms_email_heading;193 } else {194 var oosSubTitleHtml = translation.email_only_heading;195 }196 var container = $('<div>').attr('id', 'esc-out-of-stock-inputs');197 var oosTitle = $('<div>', { class: 'esc-out-of-stock-title'})198 .html('Ikke på lager');199 container.append(oosTitle);200 var oosSubTitle = $('<div>', { class: 'esc-out-of-stock-subtitle'})201 .html('Indtast din e-mail adresse nedenfor for at blive underrettet, når dette produkt er tilbage på lager');202 container.append(oosSubTitle);203 if (smsPlan == 1) {204 var sms = getSmsContainer();205 $(container).append(sms);206 }207 var email = $('<div>',{208 class : 'esc-email-container',209 });210 var emailInput = $('<input class="esc-email-input">').attr('placeholder', 'hej@dinemail.com');211 $(email).append(emailInput);212 var emailBtn = $('<button>', {213 class : 'esc-btn',214 'data-alert-type' : 'email',215 html : 'Send mig email'216 });217 $(email).append(emailBtn);218 var emailNotfication = $('<div>',{219 class : 'esc-notification esc-email-notification'220 });221 email.append(emailNotfication);222 $(container).append(email);223 $('#esc-oos-form-'+id).html('').append(container);224 $('.countrySelect').change(function(){225 var isoCountry = $(this).val();226 if(topCountryCodes.hasOwnProperty(isoCountry)){227 var code = topCountryCodes[isoCountry].code;228 } else {229 var code = bottomCountryCodes[isoCountry].code;230 }231 $smsInput = $('.esc-sms-input');232 $smsInput.val('+' + code);233 $smsInput.off("keydown");234 disableCodeEdit($smsInput, code);235 });...
gulpfile.js
Source:gulpfile.js
1var gulp = require('gulp');2var path = require('path');3var filesystem = require('fs');4var wpPot = require('gulp-wp-pot');5var gettext = require('gulp-gettext');6var sort = require('gulp-sort');7var pofill = require('gulp-pofill');8var rename = require('gulp-rename');9var clean = require('gulp-clean');10var languagesFolder = './languages/';11var options = require('./transifex-config.json');12function getFolders(dir) {13 return filesystem.readdirSync(dir)14 .filter(function (file) {15 return filesystem.statSync(path.join(dir, file)).isDirectory();16 });17}18var transifex = require('gulp-transifex').createClient(options);19// Create POT out of i18n.php.20gulp.task('prepare-source', function () {21 gulp.src('**/*.php')22 .pipe(sort())23 .pipe(wpPot({24 destFile : 'freemius.pot',25 package : 'freemius',26 bugReport : 'https://github.com/Freemius/wordpress-sdk/issues',27 lastTranslator : 'Vova Feldman <vova@freemius.com>',28 team : 'Freemius Team <admin@freemius.com>',29 /*gettextMethods: {30 instances: ['this', '_fs'],31 methods: [32 'get_text_inline'33 ]34 },*/35 gettextFunctions: [36 {name: 'get_text_inline'},37 {name: 'fs_text_inline'},38 {name: 'fs_echo_inline'},39 {name: 'fs_esc_js_inline'},40 {name: 'fs_esc_attr_inline'},41 {name: 'fs_esc_attr_echo_inline'},42 {name: 'fs_esc_html_inline'},43 {name: 'fs_esc_html_echo_inline'},44 {name: 'get_text_x_inline', context: 2},45 {name: 'fs_text_x_inline', context: 2},46 {name: 'fs_echo_x_inline', context: 2},47 {name: 'fs_esc_attr_x_inline', context: 2},48 {name: 'fs_esc_js_x_inline', context: 2},49 {name: 'fs_esc_js_echo_x_inline', context: 2},50 {name: 'fs_esc_html_x_inline', context: 2},51 {name: 'fs_esc_html_echo_x_inline', context: 2}52 /*,53 {name: '_fs_text'},54 {name: '_fs_x', context: 2},55 {name: '_fs_echo'},56 {name: '_fs_esc_attr'},57 {name: '_fs_esc_attr_echo'},58 {name: '_fs_esc_html'},59 {name: '_fs_esc_html_echo'},60 {name: '_fs_ex', context: 2},61 {name: '_fs_esc_attr_x', context: 2},62 {name: '_fs_esc_html_x', context: 2},63 {name: '_fs_n', plural: 2},64 {name: '_fs_n_noop', plural: 2},65 {name: '_fs_nx', plural: 2, context: 4},66 {name: '_fs_nx_noop', plural: 2, context: 3}*/67 ]68 }))69 .pipe(gulp.dest(languagesFolder + 'freemius.pot'));70 // Create English PO out of the POT.71 return gulp.src(languagesFolder + 'freemius.pot')72 .pipe(pofill({73 items: function (item) {74 // If msgstr is empty, use identity translation75 if (!item.msgstr.length) {76 item.msgstr = [''];77 }78 if (!item.msgstr[0]) {79 item.msgstr[0] = item.msgid;80 }81 return item;82 }83 }))84 .pipe(rename('freemius-en.po'))85 .pipe(gulp.dest(languagesFolder));86});87// Push updated po resource to transifex.88gulp.task('update-transifex', ['prepare-source'], function () {89 return gulp.src(languagesFolder + 'freemius-en.po')90 .pipe(transifex.pushResource());91});92// Download latest *.po translations.93gulp.task('download-translations', ['update-transifex'], function () {94 return gulp.src(languagesFolder + 'freemius-en.po')95 .pipe(transifex.pullResource());96});97// Move translations to languages root.98gulp.task('prepare-translations', ['download-translations'], function () {99 var folders = getFolders(languagesFolder);100 return folders.map(function (folder) {101 return gulp.src(path.join(languagesFolder, folder, 'freemius-en.po'))102 .pipe(rename('freemius-' + folder + '.po'))103 .pipe(gulp.dest(languagesFolder));104 });105});106// Feel up empty translations with English.107gulp.task('translations-feelup', ['prepare-translations'], function () {108 return gulp.src(languagesFolder + '*.po')109 .pipe(pofill({110 items: function (item) {111 // If msgstr is empty, use identity translation112 if (0 == item.msgstr.length) {113 item.msgstr = [''];114 }115 if (0 == item.msgstr[0].length) {116// item.msgid[0] = item.msgid;117 item.msgstr[0] = item.msgid;118 }119 return item;120 }121 }))122 .pipe(gulp.dest(languagesFolder));123});124// Cleanup temporary translation folders.125gulp.task('cleanup', ['prepare-translations'], function () {126 var folders = getFolders(languagesFolder);127 return folders.map(function (folder) {128 return gulp.src(path.join(languagesFolder, folder), {read: false})129 .pipe(clean());130 });131});132// Compile *.po to *.mo binaries for usage.133gulp.task('compile-translations', ['translations-feelup'], function () {134 // Compile POs to MOs.135 return gulp.src(languagesFolder + '*.po')136 .pipe(gettext())137 .pipe(gulp.dest(languagesFolder))138});139gulp.task('default', [], function () {140 gulp.run('prepare-source');141 gulp.run('update-transifex');142 gulp.run('download-translations');143 gulp.run('prepare-translations');144 gulp.run('translations-feelup');145 gulp.run('cleanup');146 gulp.run('compile-translations');...
ESCStatus.js
Source:ESCStatus.js
1// Auto-generated. Do not edit!2// (in-package mavros_msgs.msg)3"use strict";4const _serializer = _ros_msg_utils.Serialize;5const _arraySerializer = _serializer.Array;6const _deserializer = _ros_msg_utils.Deserialize;7const _arrayDeserializer = _deserializer.Array;8const _finder = _ros_msg_utils.Find;9const _getByteLength = _ros_msg_utils.getByteLength;10let ESCStatusItem = require('./ESCStatusItem.js');11let std_msgs = _finder('std_msgs');12//-----------------------------------------------------------13class ESCStatus {14 constructor(initObj={}) {15 if (initObj === null) {16 // initObj === null is a special case for deserialization where we don't initialize fields17 this.header = null;18 this.esc_status = null;19 }20 else {21 if (initObj.hasOwnProperty('header')) {22 this.header = initObj.header23 }24 else {25 this.header = new std_msgs.msg.Header();26 }27 if (initObj.hasOwnProperty('esc_status')) {28 this.esc_status = initObj.esc_status29 }30 else {31 this.esc_status = [];32 }33 }34 }35 static serialize(obj, buffer, bufferOffset) {36 // Serializes a message object of type ESCStatus37 // Serialize message field [header]38 bufferOffset = std_msgs.msg.Header.serialize(obj.header, buffer, bufferOffset);39 // Serialize message field [esc_status]40 // Serialize the length for message field [esc_status]41 bufferOffset = _serializer.uint32(obj.esc_status.length, buffer, bufferOffset);42 obj.esc_status.forEach((val) => {43 bufferOffset = ESCStatusItem.serialize(val, buffer, bufferOffset);44 });45 return bufferOffset;46 }47 static deserialize(buffer, bufferOffset=[0]) {48 //deserializes a message object of type ESCStatus49 let len;50 let data = new ESCStatus(null);51 // Deserialize message field [header]52 data.header = std_msgs.msg.Header.deserialize(buffer, bufferOffset);53 // Deserialize message field [esc_status]54 // Deserialize array length for message field [esc_status]55 len = _deserializer.uint32(buffer, bufferOffset);56 data.esc_status = new Array(len);57 for (let i = 0; i < len; ++i) {58 data.esc_status[i] = ESCStatusItem.deserialize(buffer, bufferOffset)59 }60 return data;61 }62 static getMessageSize(object) {63 let length = 0;64 length += std_msgs.msg.Header.getMessageSize(object.header);65 object.esc_status.forEach((val) => {66 length += ESCStatusItem.getMessageSize(val);67 });68 return length + 4;69 }70 static datatype() {71 // Returns string type for a message object72 return 'mavros_msgs/ESCStatus';73 }74 static md5sum() {75 //Returns md5sum for a message object76 return '145d49eaf5cfecbdfd50ae4a22fe82d4';77 }78 static messageDefinition() {79 // Returns full string definition for message80 return `81 # ESCStatus.msg82 #83 #84 # See mavlink message documentation here:85 # https://mavlink.io/en/messages/common.html#ESC_STATUS86 87 std_msgs/Header header88 89 mavros_msgs/ESCStatusItem[] esc_status90 91 ================================================================================92 MSG: std_msgs/Header93 # Standard metadata for higher-level stamped data types.94 # This is generally used to communicate timestamped data 95 # in a particular coordinate frame.96 # 97 # sequence ID: consecutively increasing ID 98 uint32 seq99 #Two-integer timestamp that is expressed as:100 # * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')101 # * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')102 # time-handling sugar is provided by the client library103 time stamp104 #Frame this data is associated with105 string frame_id106 107 ================================================================================108 MSG: mavros_msgs/ESCStatusItem109 # ESCStatusItem.msg110 #111 #112 # See mavlink message documentation here:113 # https://mavlink.io/en/messages/common.html#ESC_STATUS114 115 std_msgs/Header header116 117 int32 rpm118 float32 voltage119 float32 current120 121 `;122 }123 static Resolve(msg) {124 // deep-construct a valid message object instance of whatever was passed in125 if (typeof msg !== 'object' || msg === null) {126 msg = {};127 }128 const resolved = new ESCStatus(null);129 if (msg.header !== undefined) {130 resolved.header = std_msgs.msg.Header.Resolve(msg.header)131 }132 else {133 resolved.header = new std_msgs.msg.Header()134 }135 if (msg.esc_status !== undefined) {136 resolved.esc_status = new Array(msg.esc_status.length);137 for (let i = 0; i < resolved.esc_status.length; ++i) {138 resolved.esc_status[i] = ESCStatusItem.Resolve(msg.esc_status[i]);139 }140 }141 else {142 resolved.esc_status = []143 }144 return resolved;145 }146};...
iso-2022-jp-decoder.any.js
Source:iso-2022-jp-decoder.any.js
1function decode(input, output, desc) {2 test(function() {3 var d = new TextDecoder("iso-2022-jp"),4 buffer = new ArrayBuffer(input.length),5 view = new Int8Array(buffer)6 for(var i = 0, l = input.length; i < l; i++) {7 view[i] = input[i]8 }9 assert_equals(d.decode(view), output)10 }, "iso-2022-jp decoder: " + desc)11}12decode([0x1b, 0x24], "�$", "Error ESC")13decode([0x1b, 0x24, 0x50], "�$P", "Error ESC, character")14decode([0x1b, 0x28, 0x42, 0x50], "P", "ASCII ESC, character")15decode([0x1b, 0x28, 0x42, 0x1b, 0x28, 0x42, 0x50], "�P", "Double ASCII ESC, character")16decode([0x50, 0x1b, 0x28, 0x42, 0x50], "PP", "character, ASCII ESC, character")17decode([0x5C, 0x5D, 0x7E], "\\]~", "characters")18decode([0x0D, 0x0E, 0x0F, 0x10], "\x0D��\x10", "SO / SI")19decode([0x1b, 0x28, 0x4A, 0x5C, 0x5D, 0x7E], "Â¥]â¾", "Roman ESC, characters")20decode([0x1b, 0x28, 0x4A, 0x0D, 0x0E, 0x0F, 0x10], "\x0D��\x10", "Roman ESC, SO / SI")21decode([0x1b, 0x28, 0x4A, 0x1b, 0x1b, 0x28, 0x49, 0x50], "�ï¾", "Roman ESC, error ESC, Katakana ESC")22decode([0x1b, 0x28, 0x49, 0x50], "ï¾", "Katakana ESC, character")23decode([0x1b, 0x28, 0x49, 0x1b, 0x24, 0x40, 0x50, 0x50], "�佩", "Katakana ESC, multibyte ESC, character")24decode([0x1b, 0x28, 0x49, 0x1b, 0x50], "�ï¾", "Katakana ESC, error ESC, character")25decode([0x1b, 0x28, 0x49, 0x1b, 0x24, 0x50], "�、ï¾", "Katakana ESC, error ESC #2, character")26decode([0x1b, 0x28, 0x49, 0x50, 0x1b, 0x28, 0x49, 0x50], "ï¾ï¾", "Katakana ESC, character, Katakana ESC, character")27decode([0x1b, 0x28, 0x49, 0x0D, 0x0E, 0x0F, 0x10], "����", "Katakana ESC, SO / SI")28decode([0x1b, 0x24, 0x40, 0x50, 0x50], "佩", "Multibyte ESC, character")29decode([0x1b, 0x24, 0x42, 0x50, 0x50], "佩", "Multibyte ESC #2, character")30decode([0x1b, 0x24, 0x42, 0x1b, 0x50, 0x50], "�佩", "Multibyte ESC, error ESC, character")31decode([0x1b, 0x24, 0x40, 0x1b, 0x24, 0x40], "�", "Double multibyte ESC")32decode([0x1b, 0x24, 0x40, 0x1b, 0x24, 0x40, 0x50, 0x50], "�佩", "Double multibyte ESC, character")33decode([0x1b, 0x24, 0x40, 0x1b, 0x24, 0x42, 0x50, 0x50], "�佩", "Double multibyte ESC #2, character")34decode([0x1b, 0x24, 0x40, 0x1b, 0x24, 0x50, 0x50], "�ã°ï¿½", "Multibyte ESC, error ESC #2, character")35decode([0x1b, 0x24, 0x40, 0x50, 0x1b, 0x24, 0x40, 0x50, 0x50], "�佩", "Multibyte ESC, single byte, multibyte ESC, character")36decode([0x1b, 0x24, 0x40, 0x20, 0x50], "��", "Multibyte ESC, lead error byte")37decode([0x1b, 0x24, 0x40, 0x50, 0x20], "�", "Multibyte ESC, trail error byte")38decode([0x50, 0x1b], "P�", "character, error ESC")39decode([0x50, 0x1b, 0x24], "P�$", "character, error ESC #2")40decode([0x50, 0x1b, 0x50], "P�P", "character, error ESC #3")41decode([0x50, 0x1b, 0x28, 0x42], "P", "character, ASCII ESC")42decode([0x50, 0x1b, 0x28, 0x4A], "P", "character, Roman ESC")43decode([0x50, 0x1b, 0x28, 0x49], "P", "character, Katakana ESC")44decode([0x50, 0x1b, 0x24, 0x40], "P", "character, Multibyte ESC")...
ansi.js
Source:ansi.js
1'use strict';2const isTerm = process.env.TERM_PROGRAM === 'Apple_Terminal';3const colors = require('ansi-colors');4const utils = require('./utils');5const ansi = module.exports = exports;6const ESC = '\u001b[';7const BEL = '\u0007';8let hidden = false;9const code = ansi.code = {10 bell: BEL,11 beep: BEL,12 beginning: `${ESC}G`,13 down: `${ESC}J`,14 esc: ESC,15 getPosition: `${ESC}6n`,16 hide: `${ESC}?25l`,17 line: `${ESC}2K`,18 lineEnd: `${ESC}K`,19 lineStart: `${ESC}1K`,20 restorePosition: ESC + (isTerm ? '8' : 'u'),21 savePosition: ESC + (isTerm ? '7' : 's'),22 screen: `${ESC}2J`,23 show: `${ESC}?25h`,24 up: `${ESC}1J`25};26const cursor = ansi.cursor = {27 get hidden() {28 return hidden;29 },30 hide() {31 hidden = true;32 return code.hide;33 },34 show() {35 hidden = false;36 return code.show;37 },38 forward: (count = 1) => `${ESC}${count}C`,39 backward: (count = 1) => `${ESC}${count}D`,40 nextLine: (count = 1) => `${ESC}E`.repeat(count),41 prevLine: (count = 1) => `${ESC}F`.repeat(count),42 up: (count = 1) => count ? `${ESC}${count}A` : '',43 down: (count = 1) => count ? `${ESC}${count}B` : '',44 right: (count = 1) => count ? `${ESC}${count}C` : '',45 left: (count = 1) => count ? `${ESC}${count}D` : '',46 to(x, y) {47 return y ? `${ESC}${y + 1};${x + 1}H` : `${ESC}${x + 1}G`;48 },49 move(x = 0, y = 0) {50 let res = '';51 res += (x < 0) ? cursor.left(-x) : (x > 0) ? cursor.right(x) : '';52 res += (y < 0) ? cursor.up(-y) : (y > 0) ? cursor.down(y) : '';53 return res;54 },55 restore(state = {}) {56 let { after, cursor, initial, input, prompt, size, value } = state;57 initial = utils.isPrimitive(initial) ? String(initial) : '';58 input = utils.isPrimitive(input) ? String(input) : '';59 value = utils.isPrimitive(value) ? String(value) : '';60 if (size) {61 let codes = ansi.cursor.up(size) + ansi.cursor.to(prompt.length);62 let diff = input.length - cursor;63 if (diff > 0) {64 codes += ansi.cursor.left(diff);65 }66 return codes;67 }68 if (value || after) {69 let pos = (!input && !!initial) ? -initial.length : -input.length + cursor;70 if (after) pos -= after.length;71 if (input === '' && initial && !prompt.includes(initial)) {72 pos += initial.length;73 }74 return ansi.cursor.move(pos);75 }76 }77};78const erase = ansi.erase = {79 screen: code.screen,80 up: code.up,81 down: code.down,82 line: code.line,83 lineEnd: code.lineEnd,84 lineStart: code.lineStart,85 lines(n) {86 let str = '';87 for (let i = 0; i < n; i++) {88 str += ansi.erase.line + (i < n - 1 ? ansi.cursor.up(1) : '');89 }90 if (n) str += ansi.code.beginning;91 return str;92 }93};94ansi.clear = (input = '', columns = process.stdout.columns) => {95 if (!columns) return erase.line + cursor.to(0);96 let width = str => [...colors.unstyle(str)].length;97 let lines = input.split(/\r?\n/);98 let rows = 0;99 for (let line of lines) {100 rows += 1 + Math.floor(Math.max(width(line) - 1, 0) / columns);101 }102 return (erase.line + cursor.prevLine()).repeat(rows - 1) + erase.line + cursor.to(0);...
ansi-codes.js
Source:ansi-codes.js
...19const noColorProps = { open: '', close: '' };20const esc = supported ? ([open, close]) => ({ open: `\x1b[${open}m`, close: `\x1b[${close}m` }) : () => noColorProps;21export const baseCodes = {22 // misc23 reset: esc([0, 0]),24 inverse: esc([7, 27]),25 hidden: esc([8, 28]),26 // styles27 bold: esc([1, 22]),28 dim: esc([2, 22]),29 faint: esc([2, 22]), // alias for dim30 italic: esc([3, 23]),31 underline: esc([4, 24]),32 doubleUnderline: esc([21, 24]),33 strikethrough: esc([9, 29]),34 strike: esc([9, 29]), // alias for strikethrough35 frame: esc([51, 54]),36 encircle: esc([52, 54]),37 overline: esc([53, 55]),38 // foreground colors39 black: esc([30, 39]),40 red: esc([31, 39]),41 green: esc([32, 39]),42 yellow: esc([33, 39]),43 blue: esc([34, 39]),44 magenta: esc([35, 39]),45 cyan: esc([36, 39]),46 white: esc([37, 39]),47 gray: esc([90, 39]), // US spelling alias for blackBright48 grey: esc([90, 39]), // UK spelling alias for blackBright49 blackBright: esc([90, 39]),50 redBright: esc([91, 39]),51 greenBright: esc([92, 39]),52 yellowBright: esc([93, 39]),53 blueBright: esc([94, 39]),54 magentaBright: esc([95, 39]),55 cyanBright: esc([96, 39]),56 whiteBright: esc([97, 39]),57 // background colors58 bgBlack: esc([40, 49]),59 bgRed: esc([41, 49]),60 bgGreen: esc([42, 49]),61 bgYellow: esc([43, 49]),62 bgBlue: esc([44, 49]),63 bgMagenta: esc([45, 49]),64 bgCyan: esc([46, 49]),65 bgWhite: esc([47, 49]),66 bgBlackBright: esc([100, 49]),67 bgRedBright: esc([101, 49]),68 bgGreenBright: esc([102, 49]),69 bgYellowBright: esc([103, 49]),70 bgBlueBright: esc([104, 49]),71 bgMagentaBright: esc([105, 49]),72 bgCyanBright: esc([106, 49]),73 bgWhiteBright: esc([107, 49]),74};75export const extendedCodes = {76 ansi256: supported ? (code) => ({ open: `\x1B[38;5;${code}m`, close: '\x1B[39m' }) : () => noColorProps,77 bgAnsi256: supported ? (code) => ({ open: `\x1B[48;5;${code}m`, close: '\x1B[49m' }) : () => noColorProps,78 rgb: supported ? (r, g, b) => ({ open: `\x1B[38;2;${r};${g};${b}m`, close: '\x1B[39m' }) : () => noColorProps,79 bgRgb: supported ? (r, g, b) => ({ open: `\x1B[48;2;${r};${g};${b}m`, close: '\x1B[49m' }) : () => noColorProps,...
requisicao-ajax.js
Source:requisicao-ajax.js
1$(document).ready(function () {2//Requisição dos dados do Secretário selecionado, atribuição destes dados e disparo do modal.3 $('.visualizar-secEsc').on('click', function () {4 var secEscId = $(this).val();5 $.ajax({6 method: 'post',7 url: 'secescola/verificacao.php',8 data: {9 idSecEsc: secEscId,10 acao: 'getById'11 },12 dataType: 'json',13 success: function (data) {14 $('#nomeSecEsc').html(data.nomeSecEsc);15 16 if(data.nomeEscola === undefined){17 $('#escolaSecEsc').html("---");18 } else {19 $('#escolaSecEsc').html(data.nomeEscola);20 }21 22 if (data.cargo === 'Diretor') {23 $('#cargoSecEsc').html('Diretor');24 } else if (data.cargo === 'Secretario') {25 $('#cargoSecEsc').html('Secretário');26 }27 28 $('#cpfSecEsc').html(data.cpf);29 $('#rgSecEsc').html(data.rg);30 $('#enderecoSecEsc').html(data.endereco);31 $('#numeroSecEsc').html(data.numero);32 $('#emailSecEsc').html(data.email);33 $('#nascimentoSecEsc').html(data.dataDeNascimento);34 $('#celularSecEsc').html(data.celular);35 }36 });37 $('#modalVisualizarSecEsc').modal('show');38 });39//Função retira os dados colocados no modal apos ele ser fechado40 $('.modal').on('hide.bs.modal', function () {41 $('span').empty();42 });43//Requisição dos dados do Secretário selecionado, atribuição destes dados e disparo do modal referente a exclusão deste usuário.44 $('.excluir-secEsc').on('click', function () {45 var idSecEsc = $(this).val();46 $.ajax({47 method: 'post',48 url: 'secescola/verificacao.php',49 data: {50 idSecEsc: idSecEsc,51 acao: 'getDataSecEsc'52 },53 dataType: 'json',54 success: function (data) {55 $('#nomeExcluirSecEsc').html(data.nomeSecEsc);56 $('#idSecEsc').val(data.id);57 }58 });59 $('#modalExcluirSecEsc').modal('show');60 });61 62//Submissão da exclusão de um Secretário caso a confirmação seja clicada63 $('#excluirSecEsc').on('click', function () {64 var idSecEsc = $('#idSecEsc').val();65 $.ajax({66 method: 'post',67 url: 'secescola/verificacao.php',68 data: {69 idSecEsc: idSecEsc,70 acao: 'excluir'71 },72 success: function () {73 location.reload();74 }75 });76 });...
index.js
Source:index.js
1'use strict';2var ESC = '\u001b[';3var x = module.exports;4x.cursorTo = function (x, y) {5 if (arguments.length === 0) {6 return ESC + 'H';7 }8 if (arguments.length === 1) {9 return ESC + (x + 1) + 'G';10 }11 return ESC + (y + 1) + ';' + (x + 1) + 'H';12};13x.cursorMove = function (x, y) {14 var ret = '';15 if (x < 0) {16 ret += ESC + (-x) + 'D';17 } else if (x > 0) {18 ret += ESC + x + 'C';19 }20 if (y < 0) {21 ret += ESC + (-y) + 'A';22 } else if (y > 0) {23 ret += ESC + y + 'B';24 }25 return ret;26};27x.cursorUp = function (count) {28 return ESC + (typeof count === 'number' ? count : 1) + 'A';29};30x.cursorDown = function (count) {31 return ESC + (typeof count === 'number' ? count : 1) + 'B';32};33x.cursorForward = function (count) {34 return ESC + (typeof count === 'number' ? count : 1) + 'C';35};36x.cursorBackward = function (count) {37 return ESC + (typeof count === 'number' ? count : 1) + 'D';38};39x.cursorLeft = ESC + '1000D';40x.cursorSavePosition = ESC + 's';41x.cursorRestorePosition = ESC + 'u';42x.cursorGetPosition = ESC + '6n';43x.cursorNextLine = ESC + 'E';44x.cursorPrevLine = ESC + 'F';45x.cursorHide = ESC + '?25l';46x.cursorShow = ESC + '?25h';47x.eraseLines = function (count) {48 var clear = '';49 for (var i = 0; i < count; i++) {50 clear += x.cursorLeft + x.eraseEndLine + (i < count - 1 ? x.cursorUp() : '');51 }52 return clear;53};54x.eraseEndLine = ESC + 'K';55x.eraseStartLine = ESC + '1K';56x.eraseLine = ESC + '2K';57x.eraseDown = ESC + 'J';58x.eraseUp = ESC + '1J';59x.eraseScreen = ESC + '2J';60x.scrollUp = ESC + 'S';61x.scrollDown = ESC + 'T';62x.clearScreen = '\u001bc';63x.beep = '\u0007';64x.image = function (buf, opts) {65 opts = opts || {};66 var ret = '\u001b]1337;File=inline=1';67 if (opts.width) {68 ret += ';width=' + opts.width;69 }70 if (opts.height) {71 ret += ';height=' + opts.height;72 }73 if (opts.preserveAspectRatio === false) {74 ret += ';preserveAspectRatio=0';75 }76 return ret + ':' + buf.toString('base64') + '\u0007';77};78x.iTerm = {};79x.iTerm.setCwd = function (cwd) {80 return '\u001b]50;CurrentDir=' + (cwd || process.cwd()) + '\u0007';...
Using AI Code Generation
1import { Selector } from 'testcafe';2test('My first test', async t => {3 .typeText('#developer-name', 'John Smith')4 .click('#macos')5 .click('#submit-button');6});7test('My second test', async t => {8 .typeText('#developer-name', 'John Smith')9 .click('#macos')10 .click('#submit-button');11});
Using AI Code Generation
1import { Selector } from 'testcafe';2test('My first test', async t => {3 .typeText('#developer-name', 'John Smith')4 .click('#tried-test-cafe')5 .click(Selector('label').withText('JavaScript API'))6 .click('#submit-button');7});
Using AI Code Generation
1import { Selector } from 'testcafe';2test('My test', async t => {3 .typeText('#developer-name', 'John Smith')4 .click('#submit-button')5 .expect(Selector('#article-header').textContent).eql('Thank you, John Smith!');6});7import { Selector } from 'testcafe';8test('My test', async t => {9 .typeText('#developer-name', 'John Smith')10 .click('#submit-button')11 .expect(Selector('#article-header').textContent).eql('Thank you, John Smith!');12});
Using AI Code Generation
1import { Selector } from 'testcafe';2test('My test', async t => {3 const developerNameInput = Selector('#developer-name');4 const osOption = Selector('label').withText('Windows');5 const submitButton = Selector('#submit-button');6 .typeText(developerNameInput, 'Peter')7 .click(osOption)8 .click(submitButton)9 .wait(1000);10});11testcafe firefox:headless test.js --screenshots onEveryAction --screenshots-path ./screenshots --screenshot-path-pattern "${DATE}_${TIME}/test-${TEST_INDEX}/${USERAGENT}/${FILE_INDEX}.png"
Using AI Code Generation
1import { Selector } from 'testcafe';2test('My first test', async t => {3 const developerNameInput = Selector('#developer-name');4 const articleHeader = Selector('.result-content').find('h1');5 .typeText(developerNameInput, 'Peter')6 .click('#submit-button')7 .expect(articleHeader.innerText).eql('Thank you, Peter!');8});9- [testcafe-reporter-xunit](
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!