How to use attributeString method in Playwright Internal

Best JavaScript code snippet using playwright-internal

parameterBlockDirective.js

Source:parameterBlockDirective.js Github

copy

Full Screen

1/*-2 * ============LICENSE_START=======================================================3 * VID4 * ================================================================================5 * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.6 * Modifications Copyright (C) 2019 IBM.7 * ================================================================================8 * Licensed under the Apache License, Version 2.0 (the "License");9 * you may not use this file except in compliance with the License.10 * You may obtain a copy of the License at11 * 12 * http://www.apache.org/licenses/LICENSE-2.013 * 14 * Unless required by applicable law or agreed to in writing, software15 * distributed under the License is distributed on an "AS IS" BASIS,16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.17 * See the License for the specific language governing permissions and18 * limitations under the License.19 * ============LICENSE_END=========================================================20 */2122"use strict";2324var parameterBlockDirective = function($log, PARAMETER, UtilityService, $compile) {25 /*26 * If "IS_SINGLE_OPTION_AUTO_SELECTED" is set to "true" ...27 * 28 * IF these 3 conditions all exist:29 * 30 * 1) The parameter type is PARAMETER.SELECT31 * 32 * 2) AND the "prompt" attribute is set to a string.33 *34 * 3) AND the optionList" only contains a single entry35 * 36 * THEN the "prompt" will not be displayed as an initial select option.37 */3839 var IS_SINGLE_OPTION_AUTO_SELECTED = true;4041 /*42 * Optionally remove "nameStyle" and "valueStyle" "width" entries to set43 * dynamic sizing.44 */45 var tableStyle = "width: auto; margin: 0 auto; border-collapse: collapse; border: none;";46 var nameStyle = "width: 220px; text-align: left; vertical-align: middle; font-weight: bold; padding: 3px 5px; border: none;";47 var valueStyle = "width: 400px; text-align: left; vertical-align: middle; padding: 3px 5px; border: none;";48 var checkboxValueStyle = "width: 400px; text-align: center; vertical-align: middle; padding: 3px 5px; border: none;"49 var textInputStyle = "height: 25px; padding: 2px 5px;";50 var checkboxInputStyle = "height: 18px; width: 18px; padding: 2px 5px;";51 var selectStyle = "height: 25px; padding: 2px; text-align: center;";52 var requiredLabelStyle = "width: 25px; padding: 5px 10px 10px 5px;";535455 var getParameterHtml = function(parameter, editable) {56 var style = valueStyle;57 var attributeString = "";58 if (parameter.type === PARAMETER.BOOLEAN) {59 style = checkboxValueStyle;60 }61 if (UtilityService.hasContents(parameter.description)) {62 attributeString += " title=' " + parameter.description + " '";63 }64 var rowstyle='';65 if(parameter.type == 'file' && !parameter.isVisiblity){66 rowstyle = ' style="display:none;"';67 }68 var html = "<tr"+rowstyle+"><td style='" + nameStyle + "'" + attributeString + ">"69 + getNameHtml(parameter) + "</td>";70 if (editable === undefined) {71 if (UtilityService.hasContents(parameter.value)) {72 html += "<td data-tests-id='" + getParameterName(parameter) + "' style='" + style + "'>" + parameter.value;73 } else {74 html += "<td data-tests-id='" + getParameterName(parameter) + "' style='" + style + "'>";75 }76 } else {77 html += "<td style='" + style + "'>" + getValueHtml(parameter);78 }79 html += "</td></tr>";80 return html;81 };8283 var updateParameter = function(parameter, element, editable) {84 $(element).parent().parent().children("td").first().html(85 getNameHtml(parameter));86 if (editable === undefined) {87 $(element).html(parameter.value);88 } else {89 $(element).parent().html(getValueHtml(parameter));90 }91 };9293 var getNameHtml = function(parameter) {94 if (parameter.isVisible === false) {95 return "";96 }97 var name = getParameterName(parameter);9899 var requiredLabel = "";100 if (parameter.isRequired) {101 requiredLabel = "<img src='app/vid/images/asterisk.png' style='"102 + requiredLabelStyle + "'></img>";103 }104 return name + ":" + requiredLabel;105 };106107 var getParameterName = function(parameter) {108 var name = "";109 if (UtilityService.hasContents(parameter.name)) {110 name = parameter.name;111 } else {112 name = parameter.id;113 }114 return name;115 }116117 var getValueHtml = function(parameter) {118119 var textInputPrompt = "Enter data";120 var attributeString = " data-tests-id='" + parameter.id +"' parameter-id='" + parameter.id + "'";121 var additionalStyle = "";122 if (parameter.isEnabled === false) {123 attributeString += " disabled='disabled'";124 }125 if (parameter.isRequired) {126 attributeString += " is-required='true'";127 }128 if (UtilityService.hasContents(parameter.description)) {129 attributeString += " title=' " + parameter.description + " '";130 }131 if (UtilityService.hasContents(parameter.isReadOnly) && (parameter.isReadOnly === true)) {132 attributeString += " readonly";133 }134 if ( (UtilityService.hasContents(parameter.maxLength)) && (UtilityService.hasContents(parameter.minLength)) ) {135 attributeString += " pattern='.{" + parameter.minLength + "," + parameter.maxLength + "}' required";136 }137 else if (UtilityService.hasContents(parameter.maxLength)) {138 attributeString += " maxlength='" + parameter.maxLength + "'";139 }140 else if (UtilityService.hasContents(parameter.minLength)) {141 attributeString += " pattern='.{" + parameter.minLength + ",}'"142 }143 if (parameter.isVisible === false) {144 additionalStyle = " visibility: hidden;";145 }146147 var name = "";148 if (UtilityService.hasContents(parameter.name)) {149 name = parameter.name;150 } else {151 name = parameter.id;152 }153 attributeString += " parameter-name='" + name + "'";154155 if ( parameter.type === PARAMETER.MAP ) {156 textInputPrompt = "{<key1>: <value1>,\.\.\.,<keyN>: <valueN>}";157 }158159 if ( parameter.type === PARAMETER.LIST ) {160 textInputPrompt = "[<value1>,\.\.\.,<valueN>]";161 }162163 switch (parameter.type) {164 case PARAMETER.BOOLEAN:165 if (parameter.value) {166 return "<select" + attributeString + " style='" + selectStyle167 + additionalStyle + "'>" + "<option value=true>true</option>"168 + "<option value=false>false</option>"169 + "</select>";170 }else{171 return "<select" + attributeString + " style='" + selectStyle172 + additionalStyle + "'>" + "<option value=false>false</option>"173 + "<option value=true>true</option>"174 + "</select>";175 }176 break;177 case PARAMETER.CHECKBOX:178 if (parameter.value) {179 return "<input type='checkbox' "+attributeString+ " checked='checked' style='"+checkboxInputStyle+"'"180 + " value='true'/>";181 }else{182 return "<input type='checkbox' "+attributeString+ "' style='"+checkboxInputStyle+"'"183 + " value='false'/>";184 }185 break;186 case PARAMETER.FILE:187 return "<input type='file' "+attributeString+ " id='"+parameter.id+"' value='"+parameter.value+"'/>";188 break;189 case PARAMETER.NUMBER:190 var value=parameter.value;191 var parameterSpec = "<input type='number'" + attributeString + " style='" + textInputStyle + additionalStyle + "'";192193 if ( UtilityService.hasContents(parameter.min) ) {194 parameterSpec += " min='" + parameter.min + "'";195 }196 if ( UtilityService.hasContents(parameter.max) ) {197 parameterSpec += " max='" + parameter.max + "'";198 }199 if (UtilityService.hasContents(value)) {200 parameterSpec += " value='" + value + "'";201 }202 parameterSpec += ">";203204 /*if(!isNaN(value) && value.toString().index('.') != -1){205 //float206 return "<input type='text'" + attributeString + " style='"207 + textInputStyle + additionalStyle + "' only-integers" + value208 + "></input>";209 } else {210 //integer211 return "<input type='text'" + attributeString + " style='"212 + textInputStyle + additionalStyle + "' only-float" + value213 + "></input>";214 }*/215 return (parameterSpec);216 break;217 case PARAMETER.SELECT:218 if (UtilityService.hasContents(parameter.prompt)) {219 attributeString += " prompt='" + parameter.prompt + "'";220 }221 return "<select" + attributeString + " style='" + selectStyle222 + additionalStyle + "'>" + getOptionListHtml(parameter)223 + "</select>";224 break;225 case PARAMETER.MULTI_SELECT:226 return '<multiselect id="' + parameter.id + '"' + attributeString + ' ng-model="multiselectModel.' + parameter.id + '" options="getOptionsList(\'' + parameter.id + '\')" display-prop="name" id-prop="id"></multiselect>';227 break;228 case PARAMETER.STRING:229 default:230 var value = "";231 if (UtilityService.hasContents(parameter.value)) {232 value = " value='" + parameter.value + "'";233 }234 if (UtilityService.hasContents(parameter.prompt)) {235 attributeString += " placeholder='" + parameter.prompt + "'";236 } else if (textInputPrompt !== "") {237 attributeString += " placeholder='" + textInputPrompt + "'";238 }239 var finalString = "<input type='text'" + attributeString + " style='"240 + textInputStyle + additionalStyle + "'" + value241 + ">";242 return finalString;243 }244 };245246247 var getBooleanListHtml = function(parameter){248 var html = "";249250 };251252 var getOptionListHtml = function(parameter) {253254 var html = "";255256 if (!angular.isArray(parameter.optionList)257 || parameter.optionList.length === 0) {258 return "";259 }260261 if (UtilityService.hasContents(parameter.prompt)) {262 html += "<option value=''>" + parameter.prompt + "</option>";263 }264265 for (var i = 0; i < parameter.optionList.length; i++) {266 var option = parameter.optionList[i];267 var name = option.name;268 var value = "";269 if (option.id === undefined) {270 value = option.name;271 } else {272 if (name === undefined) {273 name = option.id;274 }275 value = option.id;276 }277 html += getOptionHtml(option.isPermitted, option.isDataLoading, value, name, parameter);278 }279 return html;280 };281282 function getOptionHtml(isPermitted, isDefault, value, name, parameter) {283 var html = "";284 if (isDefault === undefined || isDefault === false ) {285 if(isPermitted)286 html = "<option class='" + parameter.id + "Option' value='" + value + "'>" + name + "</option>";287 else {288 html = "<option class='" + parameter.id + "Option' value='" + value + "' disabled>" + name + "</option>";289 }290 }291 else {292 if(isPermitted)293 html = "<option class='" + parameter.id + "Option' value='" + value + "'>" + "' selected>" + name + "</option>";294 else {295 html = "<option class='" + parameter.id + "Option' value='" + value + "' disabled>" + "' selected>" + name + "</option>";296 }297 }298 return html;299 }300301 var getParameter = function(element, expectedId) {302 var id = $(element).attr("parameter-id");303 if (!id || (expectedId !== undefined && expectedId !== id)) {304 return undefined;305 }306 var parameter = {307 id : id308 };309 if ($(element).prop("type") === "checkbox") {310 parameter.value = $(element).prop("checked");311 }else if ($(element).prop("type") === "file") {312 parameter.value = $('#'+id).attr("value");313314 } else {315 if ($(element).prop("type") === "text") {316 $(element).val($(element).val().trim());317 }318 parameter.value = $(element).val();319 }320 if ($(element).prop("selectedIndex") === undefined) {321 parameter.selectedIndex = -1;322 } else {323 parameter.selectedIndex = $(element).prop("selectedIndex");324 if (UtilityService.hasContents($(element).attr("prompt"))) {325 parameter.selectedIndex--;326 }327 }328 return parameter;329 };330331 var getRequiredField = function(element) {332 if($(element).is("multiselect")) {333 if(!$(element).find(".active").text().trim()) {334 return '"' + $(element).attr("parameter-name") + '"';335 }336 }337 else {338 if ($(element).prop("type") === "text") {339 $(element).val($(element).val().trim());340 }341 if ($(element).val() === "" || $(element).val() === null) {342 return '"' + $(element).attr("parameter-name") + '"';343 }344 }345 return "";346 };347348 var callback = function(element, scope) {349 scope.callback({350 id : $(element).attr("parameter-id")351 });352 };353354 return {355 restrict : "EA",356 replace : true,357 template : "<div><table style='" + tableStyle + "'></table></div>",358 scope : {359 control : "=",360 callback : "&"361 },362 link : function(scope, element, attrs) {363364 var control = scope.control || {};365 scope.multiselectModel = {};366367 scope.getOptionsList = function (parameterId) {368 return _.find(scope.parameterList, {'id': parameterId})["optionList"];369 };370 control.setList = function(parameterList) {371 scope.parameterList = parameterList;372 scope.multiselectModel = {};373 var html = "";374 for (var i = 0; i < parameterList.length; i++) {375 html += getParameterHtml(parameterList[i], attrs.editable);376 }377 element.replaceWith($compile(element.html(html))(scope));378379 element.find("input, select").unbind("change.namespace1");380 element.find("input, select").bind("change.namespace1", function() {381 callback(this, scope);382 });383 }384385 control.updateList = function(parameterList) {386 element.find("input, select").each(387 function() {388 for (var i = 0; i < parameterList.length; i++) {389 if (parameterList[i].id === $(this).attr(390 "parameter-id")) {391 updateParameter(parameterList[i], this,392 attrs.editable);393 }394 }395 });396 element.find("input, select").unbind("change.namespace2");397 element.find("input, select").bind("change.namespace2", function() {398 callback(this, scope);399 });400 };401402 control.getList = function(expectedId) {403 var parameterList = new Array();404 element.find("input, select").each(function() {405 var parameter = getParameter(this, expectedId);406 if (parameter !== undefined) {407 parameterList.push(parameter);408 }409 });410 angular.forEach(scope.multiselectModel, function(value, key) {411 parameterList.push({id: key, value: value});412 });413 return parameterList;414 };415416 control.getRequiredFields = function() {417 var requiredFields = "";418 var count = 0;419 element.find("input, select, multiselect").each(function() {420 if ($(this).attr("is-required") === "true") {421 var requiredField = getRequiredField(this);422 if (requiredField !== "") {423 if (++count == 1) {424 requiredFields = requiredField;425 }426 }427 }428 });429 if (--count <= 0) {430 return requiredFields;431 } else if (count == 1) {432 return requiredFields + " and 1 other field";433 } else {434 return requiredFields + " and " + count + " other fields";435 }436 };437 }438 }439};440441appDS2.directive('parameterBlock', [ "$log", "PARAMETER", "UtilityService", "$compile",442 parameterBlockDirective ]);443444445appDS2.directive('onlyIntegers', function () {446 return {447 restrict: 'A',448 link: function (scope, elm, attrs, ctrl) {449 elm.on('keydown', function (event) {450 if(event.shiftKey){event.preventDefault(); return false;}451 //console.log(event.which);452 if ([8, 13, 27, 37, 38, 39, 40].indexOf(event.which) > -1) {453 // backspace, enter, escape, arrows454 return true;455 } else if (event.which >= 49 && event.which <= 57) {456 // numbers457 return true;458 } else if (event.which >= 96 && event.which <= 105) {459 // numpad number460 return true;461 }462 // else if ([110, 190].indexOf(event.which) > -1) {463 // // dot and numpad dot464 // return true;465 // }466 else {467 event.preventDefault();468 return false;469 }470 });471 }472 };473});474475appDS2.directive('onlyFloat', function () {476 return {477 restrict: 'A',478 link: function (scope, elm, attrs, ctrl) {479 elm.on('keydown', function (event) {480 if ([110, 190].indexOf(event.which) > -1) {481 // dot and numpad dot482 event.preventDefault();483 return true;484 }485 else{486 return false;487 }488 });489 }490 }; ...

Full Screen

Full Screen

ShortcodeHelper_TinyMCE.js

Source:ShortcodeHelper_TinyMCE.js Github

copy

Full Screen

1jQuery(document).ready(function() {2 setLoginShortcodeHelpHandler_tinyMCE();3 setLogoutShortcodeHelpHandler_tinyMCE();4 setConfirmForgotPasswordShortcodeHelpHandler_tinyMCE();5 setAccountDetailsShortcodeHelpHandler_tinyMCE();6 setForgotPasswordShortcodeHelpHandler_tinyMCE();7 setEditProfileShortcodeHelpHandler_tinyMCE();8 setLoginLogoutToggleShortcodeHelpHandler_tinyMCE();9 setRegisterShortcodeHelpHandler_tinyMCE();10 //setResetPasswordShortcodeHelpHandler_tinyMCE();11 setUserDataShortcodeHelpHandler_tinyMCE();12 setUserListShortcodeHelpHandler_tinyMCE();13 setUserProfileShortcodeHelpHandler_tinyMCE();14 setUserSearchShortcodeHelpHandler_tinyMCE();15 setRestrictedShortcodeHelpHandler_tinyMCE();16});17function setLoginShortcodeHelpHandler_tinyMCE() {18 tinymce.PluginManager.add('keyup_event', function(editor, url) {19 // Create keyup event20 editor.on('keyup', function(e) {21 var tinymce_content = tinyMCE.activeEditor.getContent();22 if (tinymce_content.indexOf("[login help") >= 0) {23 var AttributeString = "[login <br />";24 AttributeString += "redirect_page='#' the page to redirect visitors after a successful login <br />";25 AttributeString += "redirect_field='' advanced redirect feature based on a specific field<br />";26 AttributeString += "redirect_array_string='' the array of redirects based on the redirect field attribute<br />";27 AttributeString += "]";28 tinymce_content = tinymce_content.replace('[login help', AttributeString);29 tinyMCE.activeEditor.setContent(tinymce_content)30 }31 });32 });33}34function setLogoutShortcodeHelpHandler_tinyMCE() {35 tinymce.PluginManager.add('keyup_event', function(editor, url) {36 // Create keyup event37 editor.on('keyup', function(e) {38 var tinymce_content = tinyMCE.activeEditor.getContent();39 if (tinymce_content.indexOf("[logout help") >= 0) {40 var AttributeString = "[logout <br />";41 AttributeString += "no_message='No' set to Yes to have no message appear on logout<br />";42 AttributeString += "redirect_page='#' the page to redirect visitors after a successful logout<br />";43 AttributeString += "]";44 tinymce_content = tinymce_content.replace('[logout help', AttributeString);45 tinyMCE.activeEditor.setContent(tinymce_content)46 }47 });48 });49}50function setConfirmForgotPasswordShortcodeHelpHandler_tinyMCE() {51 tinymce.PluginManager.add('keyup_event', function(editor, url) {52 // Create keyup event53 editor.on('keyup', function(e) {54 var tinymce_content = tinyMCE.activeEditor.getContent();55 if (tinymce_content.indexOf("[confirm-forgot-password help") >= 0) {56 var AttributeString = "[confirm-forgot-password <br />";57 AttributeString += "redirect_page='#' the page to redirect visitors after a successful submission<br />";58 AttributeString += "login_page='' the URL of your login page if you want a link to appear<br />";59 AttributeString += "]";60 tinymce_content = tinymce_content.replace('[confirm-forgot-password help', AttributeString);61 tinyMCE.activeEditor.setContent(tinymce_content)62 }63 });64 });65}66function setAccountDetailsShortcodeHelpHandler_tinyMCE() {67 tinymce.PluginManager.add('keyup_event', function(editor, url) {68 // Create keyup event69 editor.on('keyup', function(e) {70 var tinymce_content = tinyMCE.activeEditor.getContent();71 if (tinymce_content.indexOf("[account-details help") >= 0) {72 var AttributeString = "[account-details <br />";73 AttributeString += "redirect_page='#' the page to redirect visitors after a successful submission<br />";74 AttributeString += "login_page='' the URL of your login page if you want a link to appear<br />";75 AttributeString += "]";76 tinymce_content = tinymce_content.replace('[account-details help', AttributeString);77 tinyMCE.activeEditor.setContent(tinymce_content)78 }79 });80 });81}82function setForgotPasswordShortcodeHelpHandler_tinyMCE() {83 tinymce.PluginManager.add('keyup_event', function(editor, url) {84 // Create keyup event85 editor.on('keyup', function(e) {86 var tinymce_content = tinyMCE.activeEditor.getContent();87 if (tinymce_content.indexOf("[forgot-password help") >= 0) {88 var AttributeString = "[forgot-password <br />";89 AttributeString += "redirect_page='#' the page to redirect visitors after a successful submission<br />";90 AttributeString += "loggedin_page='/' the page to redirect users to if they're logged in and viewing this page<br />";91 AttributeString += "reset_email_url='' the URL of your page with the confirm-forgot-password shortcode<br />";92 AttributeString += "]";93 tinymce_content = tinymce_content.replace('[forgot-password help', AttributeString);94 tinyMCE.activeEditor.setContent(tinymce_content)95 }96 });97 });98}99function setEditProfileShortcodeHelpHandler_tinyMCE() {100 tinymce.PluginManager.add('keyup_event', function(editor, url) {101 // Create keyup event102 editor.on('keyup', function(e) {103 var tinymce_content = tinyMCE.activeEditor.getContent();104 if (tinymce_content.indexOf("[edit-profile help") >= 0) {105 var AttributeString = "[edit-profile <br />";106 AttributeString += "redirect_page='#' the page to redirect visitors after a successful submission<br />";107 AttributeString += "login_page='' the URL of your login page if you want a link to appear when a non-logged in visitor views this page<br />";108 AttributeString += "omit_fields='' fields to not include for editing (if you want them locked after registration)<br />";109 AttributeString += "]";110 tinymce_content = tinymce_content.replace('[edit-profile help', AttributeString);111 tinyMCE.activeEditor.setContent(tinymce_content)112 }113 });114 });115}116function setLoginLogoutToggleShortcodeHelpHandler_tinyMCE() {117 tinymce.PluginManager.add('keyup_event', function(editor, url) {118 // Create keyup event119 editor.on('keyup', function(e) {120 var tinymce_content = tinyMCE.activeEditor.getContent();121 if (tinymce_content.indexOf("[login-logout-toggle help") >= 0) {122 var AttributeString = "[login-logout-toggle <br />";123 AttributeString += "login_redirect_page='#' the page to redirect visitors after a visitor logs in<br />";124 AttributeString += "logout_redirect_page='#' the page to redirect visitors after a visitor logs out<br />";125 AttributeString += "]";126 tinymce_content = tinymce_content.replace('[login-logout-toggle help', AttributeString);127 tinyMCE.activeEditor.setContent(tinymce_content)128 }129 });130 });131}132function setRegisterShortcodeHelpHandler_tinyMCE() {133 tinymce.PluginManager.add('keyup_event', function(editor, url) {134 // Create keyup event135 editor.on('keyup', function(e) {136 var tinymce_content = tinyMCE.activeEditor.getContent();137 if (tinymce_content.indexOf("[register help") >= 0) {138 var AttributeString = "[register <br />";139 AttributeString += "redirect_page='#' the page to redirect visitors after a successful registration<br />";140 AttributeString += "redirect_field='' advanced redirect feature based on a specific field<br />";141 AttributeString += "redirect_array_string='' the array of redirects based on the redirect field attribute<br />";142 AttributeString += "]";143 tinymce_content = tinymce_content.replace('[register help', AttributeString);144 tinyMCE.activeEditor.setContent(tinymce_content)145 }146 });147 });148}149/*function setResetPasswordShortcodeHelpHandler_tinyMCE() {150 tinymce.PluginManager.add('keyup_event', function(editor, url) {151 // Create keyup event152 editor.on('keyup', function(e) {153 var tinymce_content = tinyMCE.activeEditor.getContent();154 if (tinymce_content.indexOf("[reset-password help") >= 0) {155 var AttributeString = "[reset-password <br />";156 AttributeString += "redirect_page='#' the page to redirect visitors after a successful submission<br />";157 AttributeString += "login_page='' the URL of your login page if you want a link to appear<br />";158 AttributeString += "]";159 tinymce_content = tinymce_content.replace('[reset-password help', AttributeString);160 tinyMCE.activeEditor.setContent(tinymce_content)161 }162 });163 });164}*/165function setUserDataShortcodeHelpHandler_tinyMCE() {166 tinymce.PluginManager.add('keyup_event', function(editor, url) {167 // Create keyup event168 editor.on('keyup', function(e) {169 var tinymce_content = tinyMCE.activeEditor.getContent();170 if (tinymce_content.indexOf("[user-data help") >= 0) {171 var AttributeString = "[user-data <br />";172 AttributeString += "field_name='Username' the name of the field that you want to display the user's information for<br />";173 AttributeString += "plain_text='Yes' set to No to add HTML to style the data<br />";174 AttributeString += "]";175 tinymce_content = tinymce_content.replace('[user-data help', AttributeString);176 tinyMCE.activeEditor.setContent(tinymce_content)177 }178 });179 });180}181function setUserListShortcodeHelpHandler_tinyMCE() {182 tinymce.PluginManager.add('keyup_event', function(editor, url) {183 // Create keyup event184 editor.on('keyup', function(e) {185 var tinymce_content = tinyMCE.activeEditor.getContent();186 if (tinymce_content.indexOf("[user-list help") >= 0) {187 var AttributeString = "[user-list <br />";188 AttributeString += "login_page='' the URL of your login page if you want a link to appear when a non-logged in visitor views this page if login necessary is set to Yes<br />";189 AttributeString += "field_name='' the name of the field to filter users by - leave blank to show all users<br />";190 AttributeString += "field_value='' the value of the field you're showing (ex: Male if field name is Gender)<br />";191 AttributeString += "login_necessary='Yes' set to No to allow anyone to view this list<br />";192 AttributeString += "display_field='Username' the field you want to display for using matching your list criteria<br />";193 AttributeString += "user_profile_page='' the URL of the page with the user profile shortcode, if you want to link to user profiles<br />";194 AttributeString += "]";195 tinymce_content = tinymce_content.replace('[user-list help', AttributeString);196 tinyMCE.activeEditor.setContent(tinymce_content)197 }198 });199 });200}201function setUserProfileShortcodeHelpHandler_tinyMCE() {202 tinymce.PluginManager.add('keyup_event', function(editor, url) {203 // Create keyup event204 editor.on('keyup', function(e) {205 var tinymce_content = tinyMCE.activeEditor.getContent();206 if (tinymce_content.indexOf("[user-profile help") >= 0) {207 var AttributeString = "[user-profile (premium shortcode) <br />";208 AttributeString += "login_page='' the URL of your login page if you want a link to appear when a non-logged in visitor views this page if login necessary is set to Yes<br />";209 AttributeString += "omit_fields='' a comma-separated list of fields that you don't want to display<br />";210 AttributeString += "login_necessary='Yes' set to No to allow anyone to view profiles<br />";211 AttributeString += "]";212 tinymce_content = tinymce_content.replace('[user-profile help', AttributeString);213 tinyMCE.activeEditor.setContent(tinymce_content)214 }215 });216 });217}218function setUserSearchShortcodeHelpHandler_tinyMCE() {219 tinymce.PluginManager.add('keyup_event', function(editor, url) {220 // Create keyup event221 editor.on('keyup', function(e) {222 var tinymce_content = tinyMCE.activeEditor.getContent();223 if (tinymce_content.indexOf("[user-search help") >= 0) {224 var AttributeString = "[user-search <br />";225 AttributeString += "login_page='' the URL of your login page if you want a link to appear when a non-logged in visitor views this page if login necessary is set to Yes<br />";226 AttributeString += "login_necessary='Yes' set to No to allow anyone to search users<br />";227 AttributeString += "search_fields='Username' what field(s) should be searchable?<br />";228 AttributeString += "display_field='Username' what field should be displayed for the matching users<br />";229 AttributeString += "search_logic='OR' set to AND to only display matching meeting all of the search criteria<br />";230 AttributeString += "user_profile_page='' the URL of the page with the user profile shortcode, if you want to link to user profiles<br />";231 AttributeString += "]";232 tinymce_content = tinymce_content.replace('[user-search help', AttributeString);233 tinyMCE.activeEditor.setContent(tinymce_content)234 }235 });236 });237}238function setRestrictedShortcodeHelpHandler_tinyMCE() {239 tinymce.PluginManager.add('keyup_event', function(editor, url) {240 // Create keyup event241 editor.on('keyup', function(e) {242 var tinymce_content = tinyMCE.activeEditor.getContent();243 if (tinymce_content.indexOf("[restricted help") >= 0) {244 var AttributeString = "[restricted <br />";245 AttributeString += "login_page='' the URL of your login page if you want a link to appear when a non-logged in visitor views this page<br />";246 AttributeString += "block_logged_in='No' set to Yes to restrict this content to only non-logged in users<br />";247 AttributeString += "no_message='No' set to Yes to not show a message when content is hidden from a visitor<br />";248 AttributeString += "minimum_level='' the minimum user level that can access this page - OK to leave blank<br />";249 AttributeString += "maximum_level='' the maximum user level that can access this page - OK to leave blank<br />";250 AttributeString += "level='' the only user level that can access this page - OK to leave blank<br />";251 AttributeString += "field_name='' the name of the field you want to use to restrict access - OK to leave blank<br />";252 AttributeString += "field_value='' the value of the field you want to use to restrict access - OK to leave blank<br />";253 AttributeString += "sneak_peak_characters='0' the number of characters of the content that should be shown if a user isn't able to access the content<br />";254 AttributeString += "sneak_peak_words='0' the number of words of the content that should be shown if a user isn't able to access the content<br />";255 AttributeString += "]";256 tinymce_content = tinymce_content.replace('[restricted help', AttributeString);257 tinyMCE.activeEditor.setContent(tinymce_content)258 }259 });260 });...

Full Screen

Full Screen

js2xmlparser.js

Source:js2xmlparser.js Github

copy

Full Screen

1/* jshint node:true */23/**4 * js2xmlparser5 * Copyright © 2012 Michael Kourlas and other contributors6 *7 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated8 * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to10 * permit persons to whom the Software is furnished to do so, subject to the following conditions:11 *12 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the13 * Software.14 *15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE16 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS17 * OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR18 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.19 */2021(function () {22 "use strict";2324 var xmlDeclaration = true;25 var xmlVersion = "1.0";26 var xmlEncoding = "UTF-8";27 var attributeString = "@";28 var aliasString = "=";29 var valueString = "#";30 var prettyPrinting = true;31 var indentString = "\t";32 var convertMap = {};33 var useCDATA = false;3435 module.exports = function (root, data, options) {36 return toXML(init(root, data, options));37 };3839 // Initialization40 var init = function (root, data, options) {41 // Set option defaults42 setOptionDefaults();4344 // Error checking for root element45 if (typeof root !== "string") {46 throw new Error("root element must be a string");47 }48 else if (root === "") {49 throw new Error("root element cannot be empty");50 }5152 // Error checking and variable initialization for options53 if (typeof options === "object" && options !== null) {54 if ("declaration" in options) {55 if ("include" in options.declaration) {56 if (typeof options.declaration.include === "boolean") {57 xmlDeclaration = options.declaration.include;58 }59 else {60 throw new Error("declaration.include option must be a boolean");61 }62 }6364 if ("encoding" in options.declaration) {65 if (typeof options.declaration.encoding === "string" || options.declaration.encoding === null) {66 xmlEncoding = options.declaration.encoding;67 }68 else {69 throw new Error("declaration.encoding option must be a string or null");70 }71 }72 }73 if ("attributeString" in options) {74 if (typeof options.attributeString === "string") {75 attributeString = options.attributeString;76 }77 else {78 throw new Error("attributeString option must be a string");79 }80 }81 if ("valueString" in options) {82 if (typeof options.valueString === "string") {83 valueString = options.valueString;84 }85 else {86 throw new Error("valueString option must be a string");87 }88 }89 if ("aliasString" in options) {90 if (typeof options.aliasString === "string") {91 aliasString = options.aliasString;92 }93 else {94 throw new Error("aliasString option must be a string");95 }96 }97 if ("prettyPrinting" in options) {98 if ("enabled" in options.prettyPrinting) {99 if (typeof options.prettyPrinting.enabled === "boolean") {100 prettyPrinting = options.prettyPrinting.enabled;101 }102 else {103 throw new Error("prettyPrinting.enabled option must be a boolean");104 }105 }106107 if ("indentString" in options.prettyPrinting) {108 if (typeof options.prettyPrinting.indentString === "string") {109 indentString = options.prettyPrinting.indentString;110 }111 else {112 throw new Error("prettyPrinting.indentString option must be a string");113 }114 }115 }116 if ("convertMap" in options) {117 if (Object.prototype.toString.call(options.convertMap) === "[object Object]") {118 convertMap = options.convertMap;119 }120 else {121 throw new Error("convertMap option must be an object");122 }123 }124 if ("useCDATA" in options) {125 if (typeof options.useCDATA === "boolean") {126 useCDATA = options.useCDATA;127 }128 else {129 throw new Error("useCDATA option must be a boolean");130 }131 }132 }133134 // Error checking and variable initialization for data135 if (typeof data !== "string" && typeof data !== "object" && typeof data !== "number" &&136 typeof data !== "boolean" && data !== null) {137 throw new Error("data must be an object (excluding arrays) or a JSON string");138 }139140 if (data === null) {141 throw new Error("data must be an object (excluding arrays) or a JSON string");142 }143144 if (Object.prototype.toString.call(data) === "[object Array]") {145 throw new Error("data must be an object (excluding arrays) or a JSON string");146 }147148 if (typeof data === "string") {149 data = JSON.parse(data);150 }151152 var tempData = {};153 tempData[root] = data; // Add root element to object154155 return tempData;156 };157158 // Convert object to XML159 var toXML = function (object) {160 // Initialize arguments, if necessary161 var xml = arguments[1] || "";162 var level = arguments[2] || 0;163164 var i = null;165 var tempObject = {};166167 for (var property in object) {168 if (object.hasOwnProperty(property)) {169 // Element name cannot start with a number170 var elementName = property;171 if (/^\d/.test(property)) {172 elementName = "_" + property;173 }174175 // Skip alias string property176 if (elementName === aliasString) {177 continue;178 }179180 // When alias string property is present, use as alias for element name181 if (Object.prototype.toString.call(object[property]) === "[object Object]" &&182 aliasString in object[property]) {183 elementName = object[property][aliasString];184 }185186 // Arrays187 if (Object.prototype.toString.call(object[property]) === "[object Array]") {188 // Create separate XML elements for each array element189 for (i = 0; i < object[property].length; i++) {190 tempObject = {};191 tempObject[property] = object[property][i];192193 xml = toXML(tempObject, xml, level);194 }195 }196 // JSON-type objects with properties197 else if (Object.prototype.toString.call(object[property]) === "[object Object]") {198 xml += addIndent("<" + elementName, level);199200 // Add attributes201 var lengthExcludingAttributes = Object.keys(object[property]).length;202 if (Object.prototype.toString.call(object[property][attributeString]) === "[object Object]") {203 lengthExcludingAttributes -= 1;204 for (var attribute in object[property][attributeString]) {205 if (object[property][attributeString].hasOwnProperty(attribute)) {206 xml += " " + attribute + "=\"" +207 toString(object[property][attributeString][attribute], true) + "\"";208 }209 }210 }211 else if (typeof object[property][attributeString] !== "undefined") {212 // Fix for the case where an object contains a single property with the attribute string as its213 // name, but this property contains no attributes; in that case, lengthExcludingAttributes214 // should be set to zero to ensure that the object is considered an empty object for the215 // purposes of the following if statement.216 lengthExcludingAttributes -= 1;217 }218219 if (lengthExcludingAttributes === 0) { // Empty object220 xml += addBreak("/>");221 }222 else if ((lengthExcludingAttributes === 1 ||223 (lengthExcludingAttributes === 2 && aliasString in object[property])) &&224 valueString in object[property]) { // Value string only225 xml += addBreak(">" + toString(object[property][valueString], false) + "</" + elementName +226 ">");227 }228 else { // Object with properties229 xml += addBreak(">");230231 // Create separate object for each property and pass to this function232 for (var subProperty in object[property]) {233 if (object[property].hasOwnProperty(subProperty) && subProperty !== attributeString &&234 subProperty !== valueString) {235 tempObject = {};236 tempObject[subProperty] = object[property][subProperty];237238 xml = toXML(tempObject, xml, level + 1);239 }240 }241242 xml += addBreak(addIndent("</" + elementName + ">", level));243 }244 }245 // Everything else246 else {247 xml += addBreak(addIndent("<" + elementName + ">" + toString(object[property], false) + "</" +248 elementName + ">", level));249 }250 }251 }252253 // Finalize XML at end of process254 if (level === 0) {255 // Strip trailing whitespace256 xml = xml.replace(/\s+$/g, "");257258 // Add XML declaration259 if (xmlDeclaration) {260 if (xmlEncoding === null) {261 xml = addBreak("<?xml version=\"" + xmlVersion + "\"?>") + xml;262 }263 else {264 xml = addBreak("<?xml version=\"" + xmlVersion + "\" encoding=\"" + xmlEncoding + "\"?>") + xml;265 }266 }267 }268269 return xml;270 };271272 // Add indenting to data for pretty printing273 var addIndent = function (data, level) {274 if (prettyPrinting) {275276 var indent = "";277 for (var i = 0; i < level; i++) {278 indent += indentString;279 }280 data = indent + data;281 }282283 return data;284 };285286 // Add line break to data for pretty printing287 var addBreak = function (data) {288 return prettyPrinting ? data + "\n" : data;289 };290291 // Convert anything into a valid XML string representation292 var toString = function (data, isAttribute) {293 // Recursive function used to handle nested functions294 var functionHelper = function (data) {295 if (Object.prototype.toString.call(data) === "[object Function]") {296 return functionHelper(data());297 }298 else {299 return data;300 }301 };302303 // Convert map304 if (Object.prototype.toString.call(data) in convertMap) {305 data = convertMap[Object.prototype.toString.call(data)](data);306 }307 else if ("*" in convertMap) {308 data = convertMap["*"](data);309 }310 // Functions311 else if (Object.prototype.toString.call(data) === "[object Function]") {312 data = functionHelper(data());313 }314 // Empty objects315 else if (Object.prototype.toString.call(data) === "[object Object]" && Object.keys(data).length === 0) {316 data = "";317 }318319 // Cast data to string320 if (typeof data !== "string") {321 data = (data === null || typeof data === "undefined") ? "" : data.toString();322 }323324 // Output as CDATA instead of escaping if option set (and only if not an attribute value)325 if (useCDATA && !isAttribute) {326 data = "<![CDATA[" + data.replace(/]]>/gm, "]]]]><![CDATA[>") + "]]>";327 }328 else {329 // Escape illegal XML characters330 data = data.replace(/&/gm, "&amp;")331 .replace(/</gm, "&lt;")332 .replace(/>/gm, "&gt;")333 .replace(/"/gm, "&quot;")334 .replace(/'/gm, "&apos;");335 }336337 return data;338 };339340 // Revert options back to their default settings341 var setOptionDefaults = function () {342 useCDATA = false;343 convertMap = {};344 xmlDeclaration = true;345 xmlVersion = "1.0";346 xmlEncoding = "UTF-8";347 attributeString = "@";348 aliasString = "=";349 valueString = "#";350 prettyPrinting = true;351 indentString = "\t";352 }; ...

Full Screen

Full Screen

ShortcodeHelper.js

Source:ShortcodeHelper.js Github

copy

Full Screen

1jQuery(document).ready(function() {2 setLoginShortcodeHelpHandler();3 setLogoutShortcodeHelpHandler();4 setConfirmForgotPasswordShortcodeHelpHandler();5 setAccountDetailsShortcodeHelpHandler();6 setForgotPasswordShortcodeHelpHandler();7 setEditProfileShortcodeHelpHandler();8 setLoginLogoutToggleShortcodeHelpHandler();9 setRegisterShortcodeHelpHandler();10 setResetPasswordShortcodeHelpHandler();11 setUserDataShortcodeHelpHandler();12 setUserListShortcodeHelpHandler();13 setUserProfileShortcodeHelpHandler();14 setUserSearchShortcodeHelpHandler();15 setRestrictedShortcodeHelpHandler();16});17function setLoginShortcodeHelpHandler() {18 jQuery('.wp-editor-area').on('keyup', function(){19 if (jQuery(this).val().indexOf("[login help") >= 0) {20 var AttributeString = "[login \n";21 AttributeString += "redirect_page='#' the page to redirect visitors after a successful login \n";22 AttributeString += "redirect_field='' advanced redirect feature based on a specific field\n";23 AttributeString += "redirect_array_string='' the array of redirects based on the redirect field attribute\n";24 AttributeString += "]";25 var text = jQuery(this).val();26 text = text.replace('[login help', AttributeString);27 jQuery(this).val(text);28 }29 })30}31function setLogoutShortcodeHelpHandler() {32 jQuery('.wp-editor-area').on('keyup', function(){33 if (jQuery(this).val().indexOf("[logout help") >= 0) {34 var AttributeString = "[logout \n";35 AttributeString += "no_message='No' set to Yes to have no message appear on logout\n";36 AttributeString += "redirect_page='#' the page to redirect visitors after a successful logout\n";37 AttributeString += "]";38 var text = jQuery(this).val();39 text = text.replace('[logout help', AttributeString);40 jQuery(this).val(text);41 }42 })43}44function setConfirmForgotPasswordShortcodeHelpHandler() {45 jQuery('.wp-editor-area').on('keyup', function(){46 if (jQuery(this).val().indexOf("[confirm-forgot-password help") >= 0) {47 var AttributeString = "[confirm-forgot-password \n";48 AttributeString += "redirect_page='#' the page to redirect visitors after a successful submission\n";49 AttributeString += "login_page='' the URL of your login page if you want a link to appear\n";50 AttributeString += "]";51 var text = jQuery(this).val();52 text = text.replace('[confirm-forgot-password help', AttributeString);53 jQuery(this).val(text);54 }55 })56}57function setAccountDetailsShortcodeHelpHandler() {58 jQuery('.wp-editor-area').on('keyup', function(){59 if (jQuery(this).val().indexOf("[account-details help") >= 0) {60 var AttributeString = "[account-details \n";61 AttributeString += "redirect_page='#' the page to redirect visitors after a successful submission\n";62 AttributeString += "login_page='' the URL of your login page if you want a link to appear\n";63 AttributeString += "]";64 var text = jQuery(this).val();65 text = text.replace('[account-details help', AttributeString);66 jQuery(this).val(text);67 }68 })69}70function setForgotPasswordShortcodeHelpHandler() {71 jQuery('.wp-editor-area').on('keyup', function(){72 if (jQuery(this).val().indexOf("[forgot-password help") >= 0) {73 var AttributeString = "[forgot-password \n";74 AttributeString += "redirect_page='#' the page to redirect visitors after a successful submission\n";75 AttributeString += "loggedin_page='/' the page to redirect users to if they're logged in and viewing this page\n";76 AttributeString += "reset_email_url='' the URL of your page with the confirm-forgot-password shortcode\n";77 AttributeString += "]";78 var text = jQuery(this).val();79 text = text.replace('[forgot-password help', AttributeString);80 jQuery(this).val(text);81 }82 })83}84function setEditProfileShortcodeHelpHandler() {85 jQuery('.wp-editor-area').on('keyup', function(){86 if (jQuery(this).val().indexOf("[edit-profile help") >= 0) {87 var AttributeString = "[edit-profile \n";88 AttributeString += "redirect_page='#' the page to redirect visitors after a successful submission\n";89 AttributeString += "login_page='' the URL of your login page if you want a link to appear when a non-logged in visitor views this page\n";90 AttributeString += "omit_fields='' fields to not include for editing (if you want them locked after registration)\n";91 AttributeString += "]";92 var text = jQuery(this).val();93 text = text.replace('[edit-profile help', AttributeString);94 jQuery(this).val(text);95 }96 })97}98function setLoginLogoutToggleShortcodeHelpHandler() {99 jQuery('.wp-editor-area').on('keyup', function(){100 if (jQuery(this).val().indexOf("[login-logout-toggle help") >= 0) {101 var AttributeString = "[login-logout-toggle \n";102 AttributeString += "login_redirect_page='#' the page to redirect visitors after a visitor logs in\n";103 AttributeString += "logout_redirect_page='#' the page to redirect visitors after a visitor logs out\n";104 AttributeString += "]";105 var text = jQuery(this).val();106 text = text.replace('[login-logout-toggle help', AttributeString);107 jQuery(this).val(text);108 }109 })110}111function setRegisterShortcodeHelpHandler() {112 jQuery('.wp-editor-area').on('keyup', function(){113 if (jQuery(this).val().indexOf("[register help") >= 0) {114 var AttributeString = "[register \n";115 AttributeString += "redirect_page='#' the page to redirect visitors after a successful registration\n";116 AttributeString += "redirect_field='' advanced redirect feature based on a specific field\n";117 AttributeString += "redirect_array_string='' the array of redirects based on the redirect field attribute\n";118 AttributeString += "]";119 var text = jQuery(this).val();120 text = text.replace('[register help', AttributeString);121 jQuery(this).val(text);122 }123 })124}125function setResetPasswordShortcodeHelpHandler() {126 jQuery('.wp-editor-area').on('keyup', function(){127 if (jQuery(this).val().indexOf("[reset-password help") >= 0) {128 var AttributeString = "[reset-password \n";129 AttributeString += "redirect_page='#' the page to redirect visitors after a successful submission\n";130 AttributeString += "login_page='' the URL of your login page if you want a link to appear\n";131 AttributeString += "]";132 var text = jQuery(this).val();133 text = text.replace('[reset-password help', AttributeString);134 jQuery(this).val(text);135 }136 })137}138function setUserDataShortcodeHelpHandler() {139 jQuery('.wp-editor-area').on('keyup', function(){140 if (jQuery(this).val().indexOf("[user-data help") >= 0) {141 var AttributeString = "[user-data \n";142 AttributeString += "field_name='Username' the name of the field that you want to display the user's information for\n";143 AttributeString += "plain_text='Yes' set to No to add HTML to style the data\n";144 AttributeString += "]";145 var text = jQuery(this).val();146 text = text.replace('[user-data help', AttributeString);147 jQuery(this).val(text);148 }149 })150}151function setUserListShortcodeHelpHandler() {152 jQuery('.wp-editor-area').on('keyup', function(){153 if (jQuery(this).val().indexOf("[user-list help") >= 0) {154 var AttributeString = "[user-list \n";155 AttributeString += "login_page='' the URL of your login page if you want a link to appear when a non-logged in visitor views this page if login necessary is set to Yes\n";156 AttributeString += "field_name='' the name of the field to filter users by - leave blank to show all users\n";157 AttributeString += "field_value='' the value of the field you're showing (ex: Male if field name is Gender)\n";158 AttributeString += "login_necessary='Yes' set to No to allow anyone to view this list\n";159 AttributeString += "display_field='Username' the field you want to display for using matching your list criteria\n";160 AttributeString += "order_by='' the field you want to order your results based on\n";161 AttributeString += "order='ASC' the direction of the ordering (ASC OR DESC)\n";162 AttributeString += "user_profile_page='' the URL of the page with the user profile shortcode, if you want to link to user profiles\n";163 AttributeString += "]";164 var text = jQuery(this).val();165 text = text.replace('[user-list help', AttributeString);166 jQuery(this).val(text);167 }168 })169}170function setUserProfileShortcodeHelpHandler() {171 jQuery('.wp-editor-area').on('keyup', function(){172 if (jQuery(this).val().indexOf("[user-profile help") >= 0) {173 var AttributeString = "[user-profile (premium shortcode)\n";174 AttributeString += "login_page='' the URL of your login page if you want a link to appear when a non-logged in visitor views this page if login necessary is set to Yes\n";175 AttributeString += "omit_fields='' a comma-separated list of fields that you don't want to display\n";176 AttributeString += "login_necessary='Yes' set to No to allow anyone to view profiles\n";177 AttributeString += "]";178 var text = jQuery(this).val();179 text = text.replace('[user-profile help', AttributeString);180 jQuery(this).val(text);181 }182 })183}184function setUserSearchShortcodeHelpHandler() {185 jQuery('.wp-editor-area').on('keyup', function(){186 if (jQuery(this).val().indexOf("[user-search help") >= 0) {187 var AttributeString = "[user-search \n";188 AttributeString += "login_page='' the URL of your login page if you want a link to appear when a non-logged in visitor views this page if login necessary is set to Yes\n";189 AttributeString += "login_necessary='Yes' set to No to allow anyone to search users\n";190 AttributeString += "search_fields='Username' what field(s) should be searchable?\n";191 AttributeString += "display_field='Username' what field should be displayed for the matching users\n";192 AttributeString += "search_logic='OR' set to AND to only display matching meeting all of the search criteria\n";193 AttributeString += "order_by='' the field you want to order your results based on\n";194 AttributeString += "order='ASC' the direction of the ordering (ASC OR DESC)\n";195 AttributeString += "user_profile_page='' the URL of the page with the user profile shortcode, if you want to link to user profiles\n";196 AttributeString += "]";197 var text = jQuery(this).val();198 text = text.replace('[user-search help', AttributeString);199 jQuery(this).val(text);200 }201 })202}203function setRestrictedShortcodeHelpHandler() {204 jQuery('.wp-editor-area').on('keyup', function(){205 if (jQuery(this).val().indexOf("[restricted help") >= 0) {206 var AttributeString = "[restricted \n";207 AttributeString += "login_page='' the URL of your login page if you want a link to appear when a non-logged in visitor views this page\n";208 AttributeString += "block_logged_in='No' set to Yes to restrict this content to only non-logged in users\n";209 AttributeString += "no_message='No' set to Yes to not show a message when content is hidden from a visitor\n";210 AttributeString += "minimum_level='' the minimum user level that can access this page - OK to leave blank\n";211 AttributeString += "maximum_level='' the maximum user level that can access this page - OK to leave blank\n";212 AttributeString += "level='' the only user level that can access this page - OK to leave blank\n";213 AttributeString += "field_name='' the name of the field you want to use to restrict access - OK to leave blank\n";214 AttributeString += "field_value='' the value of the field you want to use to restrict access - OK to leave blank\n";215 AttributeString += "sneak_peak_characters='0' the number of characters of the content that should be shown if a user isn't able to access the content\n";216 AttributeString += "sneak_peak_words='0' the number of words of the content that should be shown if a user isn't able to access the content\n";217 AttributeString += "]";218 var text = jQuery(this).val();219 text = text.replace('[restricted help', AttributeString);220 jQuery(this).val(text);221 }222 })...

Full Screen

Full Screen

custom_block_definitions.js

Source:custom_block_definitions.js Github

copy

Full Screen

1Blockly.defineBlocksWithJsonArray([2 // Custom Block Category: Actions3 {4 type: "actions_pressed_space",5 message0: "press spacebar",6 // Special case action block outputs Boolean7 output: "Boolean",8 colour: "0",9 tooltip: "Spacebar is pressed.",10 extensions: ["parent_tooltip_when_inline"]11 },12 {13 type: "actions_pressed_e",14 message0: "press \"E\"",15 output: "ActionBoolean",16 colour: "120",17 tooltip: "Enter is pressed.",18 extensions: ["parent_tooltip_when_inline"]19 },20 {21 type: "actions_player_jump",22 message0: "character jump",23 previousStatement: null,24 check: "Logic",25 colour: "0",26 tooltip: "Player jumps.",27 extensions: ["parent_tooltip_when_inline"]28 },29 {30 type: "actions_player_double_jump",31 message0: "mid-air boost",32 previousStatement: null,33 colour: "0",34 tooltip: "Player performs double jump.",35 extensions: ["parent_tooltip_when_inline"]36 },37 {38 type: "actions_is_jumping",39 message0: "character is jumping",40 output: "ActionBoolean",41 colour: "120",42 tooltip: "Play has made character jump.",43 extensions: ["parent_tooltip_when_inline"]44 },45 {46 type: "actions_collect_gem",47 message0: "collect gem",48 previousStatement: null,49 colour: "0",50 tooltip: "Gem is added to player's inventory.",51 extensions: ["parent_tooltip_when_inline"]52 },53 {54 type: "actions_near_gem",55 message0: "walk into gem",56 output: "ActionBoolean",57 colour: "120",58 tooltip: "Player is within interactable area for gem.",59 extensions: ["parent_tooltip_when_inline"]60 },61 {62 type: "actions_space_available",63 message0: "space in inventory",64 output: "ActionBoolean",65 colour: "120",66 tooltip: "Player is within interactable area for gem.",67 extensions: ["parent_tooltip_when_inline"]68 },69 {70 type: "actions_on_ground",71 message0: "on ground",72 output: "ActionBoolean",73 colour: "0",74 tooltip: "Player is on the ground.",75 extensions: ["parent_tooltip_when_inline"]76 },77 {78 type: "actions_move_left",79 message0: "Move Left %1",80 previousStatement: null,81 args0: [82 {83 type: "input_value",84 name: "NAME"85 }86 ],87 colour: "0"88 },89 {90 type: "actions_move_right",91 message0: "Move Right %1",92 previousStatement: null,93 args0: [94 {95 type: "input_value",96 name: "NAME"97 }98 ],99 colour: "0"100 },101 {102 type: "actions_move_down",103 message0: "Move Down %1",104 args0: [105 {106 type: "input_value",107 name: "NAME"108 }109 ],110 colour: "0"111 },112 {113 type: "actions_move_up",114 message0: "Move Up %1",115 args0: [116 {117 type: "input_value",118 name: "NAME"119 }120 ],121 colour: "0"122 },123 {124 type: "actions_in_green",125 message0: "beetle in green zone",126 output: "Boolean",127 colour: "0",128 tooltip: "The beetle is in the green zone.",129 extensions: ["parent_tooltip_when_inline"]130 },131 {132 type: "actions_in_blue",133 message0: "beetle in blue zone",134 output: "Boolean",135 colour: "0",136 tooltip: "The beetle is in the blue zone.",137 extensions: ["parent_tooltip_when_inline"]138 },139 {140 type: "actions_in_purple",141 message0: "beetle in purple zone",142 output: "Boolean",143 colour: "0",144 tooltip: "The beetle is in the purple zone.",145 extensions: ["parent_tooltip_when_inline"]146 },147 // Custom Block Category: Attributes148 {149 type: "attributes_color",150 message0: "has color: %1",151 output: "AttributeString",152 args0: [153 {154 type: "field_colour",155 "name": "COLOUR",156 colour: "#DD540D"157 }158 ],159 colour: "65",160 extensions: ["set_flame_colours_extension"]161 },162 {163 type: "attributes_up",164 message0: "up",165 output: "AttributeString",166 colour: "65"167 },168 {169 type: "attributes_down",170 message0: "down",171 output: "AttributeString",172 colour: "65"173 },174 // Custom Block Category: Logic175 {176 type: "logic_when_do",177 message0: "when %1",178 args0: [{179 type: "input_value",180 name: "WHEN0",181 check: "Boolean"182 }],183 message1: "do %1",184 args1: [{185 type: "input_statement",186 name: "DO0"187 }],188 style: "logic_blocks",189 tooltip: "When a value is true, then do something."190 },191 {192 type: "logic_action_and",193 message0: "%1 %2 %3",194 args0: [195 {196 type: "input_value",197 name: "A"198 },199 {200 type: "field_dropdown",201 name: "OP",202 options: [203 ["%{BKY_LOGIC_OPERATION_AND}", "AND"]204 ]205 },206 {207 type: "input_value",208 name: "B"209 }210 ],211 output: "Boolean",212 inputsInline: true,213 tooltip: "When two actions are simultaneously occuring the statement is true.",214 style: "logic_blocks"215 },216 // Custom Block Category: Objects217 {218 type: "objects_flame",219 message0: "Flame %1",220 args0: [{221 type: "input_value",222 "name": "FLAME_COLOUR0",223 check: "AttributeString"224 }],225 colour: "25",226 tooltip: "The flame."227 },228 {229 type: "objects_lever1",230 message0: "Lever \#1 %1",231 args0: [{232 type: "input_value",233 "name": "ORIENTATION",234 check: "AttributeString"235 }],236 colour: "25",237 tooltip: "Lever one."238 },239 {240 type: "objects_lever2",241 message0: "Lever \#2 %1",242 args0: [{243 type: "input_value",244 "name": "ORIENTATION",245 check: "AttributeString"246 }],247 colour: "25",248 tooltip: "Lever two."249 },250 {251 type: "objects_lever4",252 message0: "Lever \#4 %1",253 args0: [{254 type: "input_value",255 "name": "ORIENTATION",256 check: "AttributeString"257 }],258 colour: "25",259 tooltip: "Lever four."260 },261 {262 type: "objects_pedestal1",263 message0: "Pedestal 1 %1",264 args0: [265 {266 type: "input_value",267 name: "GEM_INPUT",268 check: "AttributeString"269 }270 ],271 colour: "355",272 tooltip: "Pedestal number n"273 },274 {275 type: "objects_pedestal2",276 message0: "Pedestal 2 %1",277 args0: [278 {279 type: "input_value",280 name: "GEM_INPUT",281 check: "AttributeString"282 }283 ],284 colour: "355",285 tooltip: "Pedestal number n"286 },287 {288 type: "objects_pedestal3",289 message0: "Pedestal 3 %1",290 args0: [291 {292 type: "input_value",293 name: "GEM_INPUT",294 check: "AttributeString"295 }296 ],297 colour: "355",298 tooltip: "Pedestal number n"299 },300 {301 type: "objects_pedestal4",302 message0: "Pedestal 4 %1",303 args0: [304 {305 type: "input_value",306 name: "GEM_INPUT",307 check: "AttributeString"308 }309 ],310 colour: "355",311 tooltip: "Pedestal number n"312 },313 {314 type: "objects_pedestal5",315 message0: "Pedestal 5 %1",316 args0: [317 {318 type: "input_value",319 name: "GEM_INPUT",320 check: "AttributeString"321 }322 ],323 colour: "355",324 tooltip: "Pedestal number n"325 },326 {327 type: "objects_gem_blue",328 message0: "blue gem",329 output: "AttributeString",330 colour: "65"331 },332 {333 type: "objects_gem_gold",334 message0: "gold gem",335 output: "AttributeString",336 colour: "65"337 },338 {339 type: "objects_gem_purple",340 message0: "purple gem",341 output: "AttributeString",342 colour: "65"343 },344 {345 type: "objects_gem_green",346 message0: "green gem",347 output: "AttributeString",348 colour: "65"349 },350 {351 type: "objects_gem_orange",352 message0: "orange gem",353 output: "AttributeString",354 colour: "65"355 }356]);357// Custom Extensions358Blockly.Extensions.register('set_flame_colours_extension',359 function() {360 var field = this.getField("COLOUR");361 field.setColours(362 ['#DD540D', '#FFFFFF', '#37ff22',363 '#FF0DA9', '#0Df3FF', '#002CAD'],364 ['Orange', 'White', 'Green',365 'Pink', 'Cyan', 'Blue']);366 field.setColumns(3);367 }...

Full Screen

Full Screen

csv-attributes.js

Source:csv-attributes.js Github

copy

Full Screen

1const errorStringText = "#ERROR";2// These functions are used to prepare cell values for .csv files when exporting raw data.3// Positive numbers.4function addPositiveNumberAttribute(origValue, allowOptional, aList)5{6 var numberCast = castValueToNumber(origValue);7 var correctType = Number.isInteger(numberCast);8 var attributeString = "";9 10 if (correctType === true && numberCast > 0)11 {12 attributeString = String(numberCast);13 }14 else if (allowOptional === true)15 {16 attributeString = "";17 }18 else19 {20 attributeString = errorStringText;21 }22 23 // Adds prepared string to .csv row.24 aList.push(attributeString);25}26// Zero-Positive numbers.27function addZeroPositiveNumberAttribute(origValue, allowOptional, aList)28{29 var numberCast = castValueToNumber(origValue);30 var correctType = Number.isInteger(numberCast);31 var attributeString = "";32 33 if (correctType === true && numberCast >= 0)34 {35 attributeString = String(numberCast);36 }37 else if (allowOptional === true)38 {39 attributeString = "";40 }41 else42 {43 attributeString = errorStringText;44 }45 46 aList.push(attributeString);47}48// Flag numbers.49function addFlagNumberAttribute(origValue, allowOptional, aList)50{51 var numberCast = castValueToNumber(origValue);52 var correctType = Number.isFinite(numberCast);53 var attributeString = "";54 55 if (correctType === true && numberCast > 0)56 {57 attributeString = "1";58 }59 else if (correctType === true && numberCast < 0)60 {61 attributeString = "-1";62 }63 else if (correctType === true && numberCast === 0)64 {65 attributeString = "0";66 }67 else if (allowOptional === true)68 {69 attributeString = "";70 }71 else72 {73 attributeString = errorStringText;74 }75 76 aList.push(attributeString);77}78// Booleans.79function addTrueFalseAttribute(origValue, allowOptional, aList)80{81 var attributeString = "";82 83 if (origValue === true)84 {85 attributeString = "true";86 }87 else if (origValue === false)88 {89 attributeString = "false";90 }91 else if (allowOptional === true)92 {93 attributeString = "";94 }95 else96 {97 attributeString = errorStringText;98 }99 100 aList.push(attributeString);101}102// Node type flag.103function addNodeTypeAttribute(origValue, aList)104{105 var numberCast = castValueToNumber(origValue);106 var correctType = Number.isFinite(numberCast);107 var attributeString = "";108 109 if (correctType === true && numberCast > 0)110 {111 attributeString = "End";112 }113 else if (correctType === true && numberCast < 0)114 {115 attributeString = "Start";116 }117 else if (correctType === true)118 {119 attributeString = "";120 }121 else122 {123 attributeString = errorStringText;124 }125 126 aList.push(attributeString);127}128// Converts given value to number.129function castValueToNumber(oVal)130{131 var castRes = NaN;132 133 if (oVal !== undefined && oVal !== null)134 {135 castRes = Number(oVal);136 }137 138 return castRes;139}140module.exports =141{142 errorString: errorStringText,143 addPositiveNumber: addPositiveNumberAttribute,144 addZeroPositiveNumber: addZeroPositiveNumberAttribute,145 addFlagNumber: addFlagNumberAttribute,146 addTrueFalse: addTrueFalseAttribute,147 addNodeType: addNodeTypeAttribute...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const {chromium} = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.fill('input[name="q"]', 'playwright');7 await page.click('input[type="submit"]');8 await page.waitForNavigation();9 const attributeString = await page.evaluate(element => element.getAttribute('href'), element);10 console.log(attributeString);11 await browser.close();12})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { attributeString } = require('playwright/lib/server/dom');2const { chromium } = require('playwright');3const path = require('path');4(async () => {5 const browser = await chromium.launch({ headless: false });6 const page = await browser.newPage();7 const elementHandle = await page.$('input');8 const attributeString = await elementHandle.evaluate((element, name) => {9 return element.getAttribute(name);10 }, 'value');11 console.log(attributeString);12 await browser.close();13})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { attributeString } = require('playwright/lib/server/dom.js');2const { test, expect } = require('@playwright/test');3test('attributeString test', async ({ page }) => {4 await page.setContent(`<div id="myDiv" data-test="test" data-test2="test2"></div>`);5 const elementHandle = await page.$('#myDiv');6 const attributeStringResult = attributeString(await elementHandle.getAttribute('data-test'), await elementHandle.getAttribute('data-test2'));7 expect(attributeStringResult).toBe('data-test="test" data-test2="test2"');8});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const page = await browser.newPage();5 const html = '<p>some text</p>';6 await page.setContent(html);7 const selector = 'p';8 const text = await page.attributeString(selector, 'textContent');9 await browser.close();10})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { attributeString } = require('@playwright/test/lib/utils/attributedString');2const string = attributeString('Hello World', 'bold');3console.log(string);4const { attributeString } = require('@playwright/test/lib/utils/attributedString');5const string = attributeString('Hello World', 'bold');6console.log(string);7const { attributeString } = require('@playwright/test/lib/utils/attributedString');8const string = attributeString('Hello World', 'bold');9console.log(string);10const { attributeString } = require('@playwright/test/lib/utils/attributedString');11const string = attributeString('Hello World', 'bold');12console.log(string);13const { attributeString } = require('@playwright/test/lib/utils/attributedString');14const string = attributeString('Hello World', 'bold');15console.log(string);

Full Screen

Using AI Code Generation

copy

Full Screen

1const { attributeString } = require('playwright/lib/internal/attributes');2const { assert } = require('chai');3const button = await page.$('button');4const buttonAttributes = await attributeString(button);5assert(buttonAttributes.includes('disabled'));6assert(buttonAttributes.includes('class="btn"'));7assert(buttonAttributes.includes('id="my_button"'));8assert(buttonAttributes.includes('data-test-id="my_button"'));9assert(buttonAttributes.includes('role="button"'));10const { attributeString } = require('playwright/lib/internal/attributes');11const { debugLogger } = require('playwright/lib/debug/debugLogger');12const { test } = require('playwright');13const { chromium } = require('playwright');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { attributeString } = require('playwright/lib/server/dom.js');2const attribute = attributeString('data-testid', 'my-test-id');3console.log(attribute);4const { attributeString } = require('playwright/lib/server/dom.js');5const attribute = attributeString('data-testid', 'my-test-id');6const selector = `div${attribute}`;7test('Playwright Internal API', async ({ page }) => {8 await page.setContent('<div data-testid="my-test-id"></div>');9 await page.click(selector);10});

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal 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