How to use addSuffixToFilePath method in Playwright Internal

Best JavaScript code snippet using playwright-internal

index.js

Source:index.js Github

copy

Full Screen

1 /*2 -----------------3 GLOBAL Util Module4 -----------------5 */6 7 function namespace(namespaceString) {8 var parts = namespaceString.split('.'),9 parent = window,10 currentPart = '';11 12 for(var i = 0, length = parts.length; i < length; i++) {13 currentPart = parts[i];14 parent[currentPart] = parent[currentPart] || {};15 parent = parent[currentPart];16 }17 18 return parent;19 }20 21 /*22 -----------------23 Anonymous Application Module24 -----------------25 26 Name: HSC app27 28 */29 namespace("com.compro.application");30 31 com.compro.application.hsc = (function() {32 33 var version = 7;34 var emailConfig = {35 adminEmail : "deshbir.dugal@comprotechnologies.com", 36 subject : "Pearson HSC Error Report",37 // "cc" is an array. Add other values in comma separated format. 38 cc : ["preeti.gupta@comprotechnologies.com"]39 }40 41 // Add separate Log Settings from Mascula for different logs.42 var musculaLogSettingsConfig = {43 "default-log" : {44 logId:"aaa4d152-e808-4f89-9cde-3e7b396ae1f8",45 suppressErrors: false,46 branding: 'none'47 },48 "q1-pearson-hsc.herokuapp.com" : {49 logId:"MnDNuBC-RkEpE",50 suppressErrors: false,51 branding: 'none'52 },53 "d1-pearson-hsc.herokuapp.com" : {54 logId:"s5zFzBC-Ug6Ff",55 suppressErrors: false,56 branding: 'none'57 },58 "p-pearson-hsc.herokuapp.com" : {59 logId:"xhbkHCC-xfrzib",60 suppressErrors: false,61 branding: 'none'62 }63 }64 //Logger config65 var JSLogsSettingsConfig = {66 "loggerPrefix" : "App.Login",67 "maxLogSize" : "50"68 }69 70 71 72 /********************************************************/73 /* DEPENDENCIES */74 /********************************************************/75 76 //JS Library Dependencies77 78 //DOM Dependencies79 var idTopContainer = "#bb-container";80 var clsMainHeader = ".main-header";81 var currentPanelId = -1;82 var isIE = false;83 var globalAjaxOptions = {84 elProgress : "#loadingIcon",85 cssProgressLoading : "",86 disableLoadingProgress : false87 }88 89 /********************************************************/90 /* PRIVATE MEMBERS */91 /********************************************************/92 93 // SoundManager config 94 var soundManagerConfig = {95 soundManagerObject : null,96 musicPlaying : false,97 musicStopped : true98 };99 100 // Config 101 var config = {102 };103 104 //User Logged In Flag105 var userinfo = {106 loggedin: false,107 name: "John Doe",108 email: "(john@pearson.com)",109 facebookuser: false,110 admin: false111 }112 113 //Global Flashcards holder (object of SwipeJs)114 var flashcards;115 116 //Logger117 var logger = JSLog.Register(JSLogsSettingsConfig.loggerPrefix);118 119 //...120 var facebookLoginCheckTimer;121 var facebookLoginTries=20;122 123 /*124 * Backbone Initialization125 * 126 * 127 */128 function backbone_init_routers() {129 HomeView.routerInitialize();130 DisciplineView.routerInitialize();131 ProductView.routerInitialize();132 TestView.routerInitialize();133 134 //One time loading of common Header View135 HeaderView.initialize();136 }137 138 /*139 * Global Viewas140 * 141 * 142 */143 var appHeader;144 145 146 147 /*148 * Global errorHandler 149 */150 function ajax_init_global_handlers() {151 /* ------------- Ajax events fire in following order ----------------*/152 153 $(document).ajaxStart(function () {154 155 var elProgress = globalAjaxOptions.elProgress;156 var cssProgressLoading = globalAjaxOptions.cssProgressLoading;157 158 if(!globalAjaxOptions.disableLoadingProgress) {159 //Show Waiting Icon160 $(globalAjaxOptions.elProgress).show();161 }162 163 164 });165 166 $(document).ajaxSend(function (e, xhr, opts) {167 /* Do Nothing */168 });169 170 $(document).ajaxError(function(event, xhr, settings, exception) {171 var msgHeader = "Ajax Error!";172 var msgTitle = "Oops!";173 var statusCode = "?..";174 175 var msgDesc = "An error has occured. Please try again by refreshing your browser or restarting the Application. If the problem persists, please contact your System Administrator.";176 177 if (xhr.status == 0) { // Not connected. Verify Network178 statusCode = xhr.status;179 msgHeader = statusCode + " :No Network Detected!";180 msgDesc = xhr.responseText;181 } else if (xhr.status == 401) { // UnAuthorized182 Backbone.history.navigate("#/home");183 return true;184 } else if (xhr.status == 403) { // Requested page not found. [404]185 statusCode = xhr.status;186 msgHeader = statusCode + " :The requested url is forbidden.";187 msgDesc = xhr.responseText;188 } else if (xhr.status == 404) { // Requested page not found. [404]189 statusCode = xhr.status;190 msgHeader = statusCode + " :Requested page not found.";191 msgDesc = xhr.responseText;192 } else if (xhr.status > 400 && xhr.status< 500) { // Requested page not found. [404]193 statusCode = xhr.status;194 msgHeader = statusCode + " :Client-Side Error.";195 msgDesc = xhr.responseText;196 } else if (xhr.status >= 500) { //Internal Server Error [500]197 statusCode = xhr.status;198 msgHeader = statusCode + " :Internal Server Error";199 msgDesc = xhr.responseText;200 } else if (exception === 'parsererror') { //Requested JSON parse failed201 msgHeader = statusCode + " :Response Parsing Error (Invalid JSON)";202 msgDesc = xhr.responseText;203 } else if (exception === 'timeout') { //Server Timeout - Check Connection204 msgHeader = statusCode + "Request to server has timed out";205 msgTitle = " :No Network Detected!";206 msgDesc = "You don't seem to be connected to the network. Please check network settings or connectivity and try again.";207 } else if (exception === '') { //Server Aborted request208 msgHeader = statusCode + " :Server Aborted Request";209 msgDesc = xhr.responseText210 } else { //Unknown Error211 msgHeader = statusCode + " :Unknown Error"; 212 msgDesc = xhr.responseText 213 }214 logger.error("Ajax Error - statusCode:"+statusCode+" msgHeader :"+msgHeader);215 var regex = new RegExp("\<style.*style\>");216 msgDesc = msgDesc.replace(regex, "");217 $("#ajax-error-label").text(msgTitle);218 $('#ajax-error-modal .modal-body .content-header').text(msgHeader);219 $('#message').html(msgDesc);220 $('#headers').html("<ul>"); 221 $('#headers').append("<li>url: " + settings.url + "</li>");222 $('#headers').append("<li>type: " + settings.type + "</li>");223 $('#headers').append("<li>data: " + settings.data + "</li></ul>");224 if(statusCode == 0){225 $('#ajax-error-modal .modal-body .content-body').hide();226 $('#no-network').show();227 } else {228 $('#no-network').hide();229 $('#ajax-error-modal .modal-body .content-body').show();230 }231 $('#ajax-error-modal').modal();232 $('#ajax-error-label').append(" <small>version " + version+"</small>");233 return true;234 }); 235 $(document).ajaxSuccess(function (e, xhr, opts) {236 /* Do Nothing */237 });238 239 $(document).ajaxComplete(function (e, xhr, opts) {240 /* Do Nothing */241 });242 243 $(document).ajaxStop(function () {244 //Stop loading animation245 $(globalAjaxOptions.elProgress).hide();246 });247 }248 249 function handleLoginSuccess(isFacebookUser) {250 251 //Check for double call252 if(userinfo.loggedin) {253 return;254 }255 userinfo.facebookuser = isFacebookUser;256 userinfo.loggedin = true;257 UserModel.get().fetch({258 success: function(model, response){259 if(model.get('isAdmin')){260 userinfo.admin = true;261 }262 /*263 * 1st parameter - update header for login264 * 2nd parameter - showHomeLink265 * 3rd parameter - setBackLink 266 */267 setHeaderOptions(true, false, false);268 }269 }); 270 Backbone.history.navigate("#/discipline");271 272 }273 274 275 function backbone_start_navigation() {276 Backbone.history.start();277 if (location.href.indexOf("?isFacebookLoginSuccess=") != -1) { //Facebook login success in iOS Home Screen Apps278 facebookLoginCheckTimer=setInterval(function(){getFBLoginStatus()}, 500);279 }280 }281 282 function getFBLoginStatus(){283 284 FB.getLoginStatus(function(response) {285 if (response.status === 'connected') {286 clearInterval(facebookLoginCheckTimer);287 handleLoginSuccess(true);288 }289 else290 {291 facebookLoginTries--;292 if(facebookLoginTries == 0) {293 //No more checking294 clearInterval(facebookLoginCheckTimer);295 facebookLoginTries=20;296 alert("Unable to login via Facebook. Did not recive a timely response from Facebook.")297 }298 }299 });300 }301 302 function soundmanager2_init() {303 soundManager.setup({304 // disable or enable debug output305 debugMode: false,306 // use HTML5 audio for MP3/MP4, if available307 preferFlash: false,308 useFlashBlock: false,309 // path to directory containing SM2 SWF310 url: 'images/sm/',311 // optional: enable MPEG-4/AAC support (requires flash 9)312 flashVersion: 9313 });314 }315 316 // Util function - for adding suffix in images317 function addSuffixToFilepath(filepath, suffix) {318 319 if(typeof filepath === 'undefined' || typeof suffix === 'undefined') {320 return filepath;321 }322 var retVal = filepath;323 324 var arr=new Array()325 arr=filepath.split('.')326 327 if (typeof arr[1] !== 'undefined' && arr[1] !== null) {328 retVal=arr[0] + suffix + "." + arr[1] 329 }330 return retVal;331 } 332 333 function muscula_log_init() {334 var domain = document.domain;335 if(!musculaLogSettingsConfig[domain]) {336 // Add the errors to the default logs file if the domain don't have separate logs config. 337 domain = "default-log";338 }339 var masculaLogSettings = musculaLogSettingsConfig[domain];340 341 window.Muscula = { settings:{342 logId:masculaLogSettings.logId,343 suppressErrors: masculaLogSettings.suppressErrors,344 branding: masculaLogSettings.branding345 }};346 (function () {347 var m = document.createElement('script'); m.type = 'text/javascript'; m.async = true;348 m.src = (window.location.protocol == 'https:' ? 'https:' : 'http:') +349 '//musculahq.appspot.com/Muscula.js';350 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(m, s);351 window.Muscula.run=function(c){eval(c);window.Muscula.run=function(){};};352 window.Muscula.errors=[];window.onerror=function(){window.Muscula.errors.push(arguments);353 return window.Muscula.settings.suppressErrors===undefined;}354 })();355 }356 function modalEventRegistration(){357 $('#ajax-error-modal').on('show', function () {358 var innerHTML = getJSLogsAsList;359 $('#logs').html(innerHTML);360 });361 362 $('#error-report').on('show', function () {363 var innerHTML = getJSLogsAsList;364 var date = new Date();365 var dateString = date.toString(); 366 $('#error-report .modal-body .date .date-data').html(dateString);367 $('#error-report .modal-body .date .version-data').html(version);368 $('#error-report .modal-body .content-header').html($('#ajax-error-modal .modal-body .content-header').html());369 $('#error-report .modal-body .content-body .logs').html(innerHTML);370 $('#error-report .modal-body .content-body .params').html($('#headers').html());371 $('#error-report .modal-body .content-body .message').html($('#message').html());372 });373 $("#ajax-error-modal .modal-footer .generateErrorReport").click(function(){374 $('#error-report').modal();375 }); 376 377 } 378 function getJSLogsAsList() {379 var logs = JSLog.Logs['App.Login'];380 var innerHTML = "<ol>";381 var planeLogs = "";382 for (var i = 0, len = logs.length; i < len; i++) {383 innerHTML += "<li value="+(logs.length - i)+">" +logs[logs.length - i - 1] + "</li>";384 // planeLogs is required so that tags are not included in the text for email. Required to add HTML in email.385 planeLogs += logs[i]+" ~~ ";386 }387 innerHTML += "</ol>";388 return innerHTML;389 }390 391 function setHeaderOptions(updateHeader, showHomeLink, showBackLink, showProfileButton) {392 if (updateHeader) {393 if (showProfileButton != undefined) {394 HeaderView.setHeaderMenu(showProfileButton);395 } else {396 HeaderView.setHeaderMenu();397 }398 }399 400 HeaderView.setHomeIcon(showHomeLink);401 HeaderView.setBackIcon(showBackLink);402 } 403 404 function transitionAppPanel(newPanelId, callback) {405 var panelContainer = $('#panel-container');406 var panelItems = $('.panel-item');407 if(this.currentPanelId == -1) //First time408 { 409 panelItems.hide();410 $(newPanelId).show("fast",function() {411 if(!(typeof callback === 'undefined') ) {412 callback(); 413 }414 //set fixed width of panel on loading first time415 panelContainer.removeClass('easing');416 });417 }418 else{419 $(this.currentPanelId).width($(this.currentPanelId).width());420 $(newPanelId).width($(this.currentPanelId).width());421 panelContainer.width($(newPanelId).outerWidth(true) +$(this.currentPanelId).outerWidth(true));422 /*var that=this;423 $('.panel-item').each(function(){424 if(that.currentPanelId.indexOf($(this).attr("id"))<0){425 $(this).hide();426 }427 });*/428 var translationWidth = 0;429 if($(newPanelId).attr("data-order")>$(this.currentPanelId).attr("data-order")){430 translationWidth = $(this.currentPanelId).outerWidth(true);431 applyTransition(panelContainer, 0);432 }else{433 applyTransition(panelContainer, -$(this.currentPanelId).outerWidth(true));434 }435 $(newPanelId).show();436 panelItems.css("float","left");437 $(newPanelId).outerWidth(true) +$(this.currentPanelId).outerWidth(true);438 panelContainer.addClass('easing');439 applyTransition(panelContainer, -translationWidth);440 if(!(typeof callback === 'undefined') ) {441 callback(); 442 }443 }444 this.currentPanelId = newPanelId;445 if(getInternetExplorerVersion()>-1 && getInternetExplorerVersion()<=9 ){446 transitionEndHandler();447 }448 }449 450 /*451 * function to apply cross browser transition effect for sliding452 * (works for only X coordinate)453 * @params 454 * - element(jquery wrapper) to apply the trasition on455 * - width to be translated (can be -ve or +ve)456 * */457 function applyTransition(element, width){458 element.css({459 "transform":"translate3d("+width+"px,0,0)",460 "-webkit-transform":"translate3d("+width+"px,0,0)",461 "-moz-transform":"translate3d("+width+"px,0,0)",462 // For IE 10.0463 "-ms-transform":"translate3d("+width+"px,0,0)",464 // For IE 9.0465 "-ms-transform":"translateX("+width+"px)",466 "-o-transform":"translate3d("+width+"px,0,0)"467 });468 }469 /*function to accomodate resizing of browser window or content.470 * @params - currentPanelId471 * */472 function onResizeTranslationHandler(panelId){473 /*$("#panel-container").removeClass('easing');474 var itemWidth = $("#bb-container").width();475 $("#panel-container").width(itemWidth * $(".panel-item").length);476 $('.panel-item').width(itemWidth);477 var translationWidth = $(panelId).attr("data-order") * -itemWidth;478 applyTransition($("#panel-container"), translationWidth);479 $("#bb-container").height($(panelId).height());*/480 }481 482 //function to handle "transitionend" event of panel-container483 function transitionEndHandler(event){ 484 /*485 * temporary check -- needs to be fixed486 * transitionend fired on buttons by bootstrap487 */488 if(event && event.target!=$("#panel-container")[0]){489 //logger.info("transitionend fired on" + event.target);490 return;491 }492 493 //removing the styles added for trasitioning 494 $("#panel-container").removeClass('easing');495 applyTransition($("#panel-container"),0);496 $("#panel-container").width("auto");497 $('.panel-item').css({498 "float":"none",499 "width":"auto"500 });501 var myApp = com.compro.application.hsc;502 $('.panel-item').each(function(){503 if(myApp.currentPanelId.indexOf($(this).attr("id"))<0){504 $(this).hide();505 }506 });507 $(myApp.currentPanelId).show();508 //$(myApp.currentPanelId).width("auto");509 }510 511 512 //Check if browser is IE513 function getInternetExplorerVersion()514 // Returns the version of Internet Explorer or a -1515 // (indicating the use of another browser).516 {517 var rv = -1; // Return value assumes failure.518 if (navigator.appName == 'Microsoft Internet Explorer')519 {520 var ua = navigator.userAgent;521 var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");522 if (re.exec(ua) != null)523 rv = parseFloat( RegExp.$1 );524 }525 return rv;526 }527 528 //Object can be a dom object/Jquery Object or a selector string529 function resizeColumns (object, isRowByRow){ //for setting the min-height of each column based on the maximun height of that row.530 531 var setCurrentTallest = function(obj, currTallest){532 $(obj).children().each(function(){533 if (Number.prototype.pxToEm) currTallest = currTallest.pxToEm(); //use ems unless px is specified534 // for ie6, set height since min-height isn't supported535 if ($.browser.msie && $.browser.version == 6.0) { $(this).children().css({'height': currTallest}); }536 $(this).children().css({'min-height': currTallest}); 537 });538 }539 540 var currentTallest = 0;541 $(object).each(function(){542 if(isRowByRow){543 currentTallest = 0;544 }545 $(this).children().each(function(i){546 $(this).children().each(function(){547 if ($(this).height() > currentTallest) { currentTallest = $(this).height(); }548 });549 });550 if(isRowByRow){551 setCurrentTallest(this,currentTallest);552 }553 554 });555 if(!isRowByRow) {556 $(object).each(function(){557 setCurrentTallest(this,currentTallest);558 });559 }560 }561 562 //Object can be a dom object/Jquery Object or a selector string563 function resetColumns (object){ // for removing the min-height of each column.564 $(object).each(function(){565 $(this).children().each(function(){566 if (Number.prototype.pxToEm) currentTallest = currentTallest.pxToEm(); //use ems unless px is specified567 // for ie6, set height since min-height isn't supported568 if ($.browser.msie && $.browser.version == 6.0) { $(this).children().css({'height': ''}); }569 $(this).children().css({'min-height':''}); 570 });571 572 });573 }574 575 576 577 /********************************************************/578 /* ONE TIME INIT FUNCTION */579 /********************************************************/580 581 (function init() {582 //Check if browser is IE583 isIE = navigator.appVersion.indexOf("MSIE") != -1584 $(document).ready(function() {585 586 logger.info("On Ready - Starting Initialization");587 588 logger.info("global error handlers initialization");589 ajax_init_global_handlers();590 591 logger.info("backbone routers initialization");592 backbone_init_routers();593 594 logger.info("backbone navigation start");595 backbone_start_navigation();596 //Initializing error modal to trigger logging in modal box each time it is shown.597 modalEventRegistration();598 logger.info("sound manager initialization");599 soundmanager2_init();600 601 logger.info("muscula initialization");602 muscula_log_init();603 604 //for resetting translate3d on resize605 $(window).bind("resize.translation", _.bind(function(){606 onResizeTranslationHandler(com.compro.application.hsc.currentPanelId);607 //com.compro.application.hsc.transitionAppPanel(com.compro.application.hsc.currentPanelId);608 }, this));609 610 611 //to remove styles added for trasitioning on end of transition612 $("#panel-container").bind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd",transitionEndHandler);613 614 /*! Normalized address bar hiding for iOS & Android (c) @scottjehl MIT License */615 (function( win ){616 var doc = win.document;617 618 // If there's a hash, or addEventListener is undefined, stop here619 if( !location.hash && win.addEventListener ){620 621 //scroll to 1622 window.scrollTo( 0, 1 );623 var scrollTop = 1,624 getScrollTop = function(){625 return win.pageYOffset || doc.compatMode === "CSS1Compat" && doc.documentElement.scrollTop || doc.body.scrollTop || 0;626 },627 628 //reset to 0 on bodyready, if needed629 bodycheck = setInterval(function(){630 if( doc.body ){631 clearInterval( bodycheck );632 scrollTop = getScrollTop();633 win.scrollTo( 0, scrollTop === 1 ? 0 : 1 );634 }635 }, 15 );636 637 win.addEventListener( "load", function(){638 setTimeout(function(){639 //at load, if user hasn't scrolled more than 20 or so...640 if( getScrollTop() < 20 ){641 //reset to hide addr bar at onload642 win.scrollTo( 0, scrollTop === 1 ? 0 : 1 );643 }644 }, 0);645 } );646 }647 })( window );648 649 //FIX: iphone viewport scaling bug. The bug occurs when you set the viewport width650 // to device-width and rotate the phone to landscape view.651/* (function(doc) {652 653 var addEvent = 'addEventListener',654 type = 'gesturestart',655 qsa = 'querySelectorAll',656 scales = [1, 1],657 meta = qsa in doc ? doc[qsa]('meta[name=viewport]') : [];658 659 function fix() {660 meta.content = 'width=device-width,minimum-scale=' + scales[0] + ',maximum-scale=' + scales[1];661 doc.removeEventListener(type, fix, true);662 }663 664 if ((meta = meta[meta.length - 1]) && addEvent in doc) {665 fix();666 scales = [.25, 1.6];667 doc[addEvent](type, fix, true);668 }669 670 }(document)); */ 671 672 logger.info("On Ready - Completed Initialization");673 });674 675 676 })();677 678 /********************************************************/679 /* Public */680 /********************************************************/681 682 return {683 "config":config,684 "soundManagerConfig":soundManagerConfig,685 "userinfo": userinfo,686 "flashcards":flashcards,687 "appHeader":appHeader,688 "setHeaderOptions":setHeaderOptions,689 "idTopContainer" : idTopContainer,690 "clsMainHeader" : clsMainHeader,691 "currentPanelId" : currentPanelId,692 "globalAjaxOptions" : globalAjaxOptions,693 "transitionAppPanel" : transitionAppPanel,694 "isIE":isIE,695 "onResizeTranslationHandler":onResizeTranslationHandler,696 "handleLoginSuccess" : handleLoginSuccess,697 "logger" : logger,698 "addSuffixToFilepath" : addSuffixToFilepath,699 "JSLogsSettingsConfig" : JSLogsSettingsConfig,700 "resizeColumns":resizeColumns,701 "resetColumns":resetColumns,702 "version" : version703 }704 ...

Full Screen

Full Screen

testview.js

Source:testview.js Github

copy

Full Screen

1TestView = new function() {2 3 /* ----- Global View Variables -----------------*/4 var bbTestView = null;5 var bbTrainView = null;6 /* -------------------------------------------------*/7 8 var mainApp = com.compro.application.hsc;9 var clsMainHeader = mainApp.clsMainHeader;10 11 12 var Router = Backbone.Router.extend({13 routes: {14 'product/:productId/test/:testId':'testhome'15 }, 16 17 testhome : function(productId, testId) {18 19 if (bbTestView == null) { //First OR After Browser Refresh20 21 bbTestView = new View({productId:productId,testId:testId});22 23 } else { //If the View has been created (bbView) never re-create24 25 bbTestView.loadCollection(productId,testId);26 bbTestView.collection.fetch({27 success: function(){28 bbTestView.render();29 }30 }); 31 }32 },33 34 });35 var View = Backbone.View.extend({36 37 /*--------------- Static Class Variable ------------*/38 myPanelId:"#panel_test-home",39 /*------------------------------------------------------*/40 events: {41 "click .next" : "nextQuestion",42 "click .previous" : "prevQuestion",43 "click .resize" : "resizeContainer",44 "click .radio-control" : "switchRadioState"45 },46 initialize: function() {47 48 /* -------------- Setup and Initialize INSTANCE Variables -----------------*/49 this.template_header="";50 this.template_body="";51 this.current_product_id=-1;52 this.current_test_id=-1;53 this.current_mode="";54 this.requested_product_id=-1;55 this.requested_test_id=-1;56 this.requested_mode="asses";57 /* ------------------------------------------------------------------------*/ 58 59 this.loadCollection(this.options.productId,this.options.testId);60 61 //Fill Templates62 var that = this; 63 TemplateManager.get('test-home', 64 function(template){65 that.template_body = template;66 that.collection.fetch({67 success: function(){68 //Always call render from initialize - as Backbone does not automatically call it.69 that.render();70 }71 });72 });73 },74 loadCollection: function(product_Id,test_Id, mode) {75 this.requested_mode=mode;76 this.requested_product_id=product_Id;77 this.requested_test_id=test_Id;78 79 if(this.current_product_id!=this.requested_product_id || this.current_test_id!=this.requested_test_id) { 80 this.collection = TestCollection.get(this.requested_product_id,this.requested_test_id);81 }82 }, 83 // Updating method name from "render" to "custiomRender" for logging.84 customRender : function() {85 86 /*87 * 1st parameter - update header for login88 * 2nd parameter - showHomeLink89 * 3rd parameter - setBackLink 90 */91 mainApp.setHeaderOptions(true, true, true);92 93 // Check if we need to update the PANEL HTML - 94 // if we're back the same/previous product, then do NOT re-create the DOM 95 if(this.current_product_id!=this.requested_product_id || this.current_test_id!=this.requested_test_id || this.current_mode!=this.requested_mode) { 96 var attribs = this.collection.first().attributes;97 //Getting all the questions98 var questions = attribs.tests[0].questions;99 //Shuffling options100 for(var i=0;i<questions.length;i++){101 var optionArray = [];102 for(var j=1;j<=7;j++){103 if(questions[i]["option"+j])104 //Storing options in array105 optionArray.push(questions[i]["option"+j]);106 }107 //Adding new parameter options which stores shuffled options.108 questions[i].options=_.shuffle(optionArray);109 }110 111 if (attribs.type == "book") {112 attribs.book = true;113 attribs.lab = false;114 } else {115 attribs.book = false;116 attribs.lab = true;117 }118 attribs.thumbnail = mainApp.addSuffixToFilepath(attribs.image, "-thumb2");119 120 var compiled_template_body = Mustache.render(this.template_body, this.collection.toJSON());121 $(this.myPanelId).html(compiled_template_body);122 this.setElement("#test-home");123 124 this.current_product_id=this.requested_product_id;125 this.current_test_id=this.requested_test_id;126 this.current_mode="asses";127 }128 129 /*130 * SLIDE myPanelID into com.compro.application.hsc.currentPanelId131 */132 var self = this;133 mainApp.transitionAppPanel(this.myPanelId, function() {134 $("#body-set > .body").css("display", "block");135 if(document.activeElement)136 $(document.activeElement).blur();137 window.scrollTo(0, 0);138 mainApp.flashcards = new Swipe(document.getElementById('flashcard'), {"containersequence":1,callback:self.afterQuestionSwipeHandler}); 139 self.afterQuestionSwipeHandler();140 });141 142 143 return this; //Do this at the end to allow for method chaining. 144 },145 nextQuestion: function() {146 mainApp.flashcards.next();147 //Calling function for IE browsers148 if(mainApp.isIE)149 this.afterQuestionSwipeHandler();150 return false;151 },152 prevQuestion: function() {153 mainApp.flashcards.prev();154 //Calling function for IE browsers155 if(mainApp.isIE)156 this.afterQuestionSwipeHandler();157 return false;158 },159 afterQuestionSwipeHandler:function(){160 $("#current-question-no-home").html(mainApp.flashcards.getPos()+1);161 if(mainApp.flashcards.getPos()==0){162 $("#flashcard .previous").attr("disabled","disabled");163 $("#flashcard .previous").addClass("disabled");164 } else if($("#flashcard .previous.disabled")){165 $("#flashcard .previous.disabled").removeAttr("disabled");166 $("#flashcard .previous.disabled").removeClass("disabled");167 }168 },169 resizeContainer: function() {170 return false;171 },172 switchRadioState: function(e){173 if(this.timeOutObj){174 clearTimeout(this.timeOutObj);175 this.timeOutObj = null;176 }177 //Dummy settign for correct answer178 var correct = $(e.currentTarget);179 //Getting current clicked div element180 var currentOptionparentDiv = mainApp.flashcards.slides[mainApp.flashcards.index];181 var answered = correct;182 183 $(e.currentTarget).find("i.radio-options").toggleClass("icon-quiz-circle icon-quiz-selected");184 //Calculating correct answer matching text185 var correctAns = this.collection.first().attributes.tests[0].questions[mainApp.flashcards.getPos()].answer1.trim().toUpperCase();186 if(($(e.currentTarget).find("span").text()).trim().toUpperCase() !=correctAns){187 $(currentOptionparentDiv).find(".options").children().each(function(){188 if($(this).find("span").text().trim().toUpperCase() == correctAns){189 correct = this;190 return false;191 }192 })193 } 194 195 //Clearing already marked ans if any196 this.clearMarkedAnswer(currentOptionparentDiv);197 var self = this;198 //Calling markCorrectAnswer after the delay199 this.timeOutObj = _.delay(function(){self.markCorrectAnswer(correct,answered,currentOptionparentDiv)},500);200 },201 markCorrectAnswer: function(correct,answered,currentOptionparentDiv){202 $(correct).addClass('correct-ans');203 $(correct).find("i.radio-options").attr("class" , "radio-options icon-quiz-correct");204 /*var answerExplanation =$(currentOptionparentDiv).find("div.answer-explanation");205 $(answerExplanation).removeClass("hide");206 $(answerExplanation).children(".explainanswer").text(this.collection.first().attributes.questions[mainApp.flashcards.getPos()].answerDetails)207 */if(answered!=correct){208 $(answered).addClass('wrong-ans');209 $(answered).find("i.radio-options").toggleClass("icon-quiz-selected icon-quiz-wrong");210 }211 mainApp.onResizeTranslationHandler(mainApp.currentPanelId);212 },213 clearMarkedAnswer: function(currentOptionparentDiv){214 $(currentOptionparentDiv).find('.correct-ans').removeClass('correct-ans');215 $(currentOptionparentDiv).find('.wrong-ans').removeClass('wrong-ans');216 $(currentOptionparentDiv).find('i.icon-quiz-correct').toggleClass("icon-quiz-correct icon-quiz-circle");217 $(currentOptionparentDiv).find('i.icon-quiz-wrong').toggleClass("icon-quiz-wrong icon-quiz-circle");218 /*var answerExplanation =$(currentOptionparentDiv).find("div.answer-explanation");219 $(answerExplanation).addClass("hide");220 $(answerExplanation).children(".explainanswer").text("");*/221 }222 }); 223 224 this.routerInitialize = function(){225 router = new Router(); 226 };...

Full Screen

Full Screen

productview.js

Source:productview.js Github

copy

Full Screen

1ProductView = new function() {2 /* ----- Global View Variables ----------------------*/3 var bbView = null;4 var pagePlayer = new PagePlayer();5 /* -------------------------------------------------*/6 var pagePlayerPlay = pagePlayer.events.play;7 var mainApp = com.compro.application.hsc;8 pagePlayer.config.updatePageTitle = false;9 pagePlayer.events.play = function(){10 $("#music").show();11 $("#music i").removeClass('icon-pause-hsc');12 $("#music i").addClass('icon-mute-hsc');13 mainApp.soundManagerConfig.musicPlaying = true;14 mainApp.soundManagerConfig.musicStopped = false;15 var soundManager = this;16 mainApp.soundManagerConfig.soundManagerObject = soundManager;17 pagePlayerPlay.call(soundManager);18 $("#product-home .sm2_playing i").toggleClass('icon-volume-up icon-pause');19 }20 var pagePlayerPause = pagePlayer.events.pause;21 pagePlayer.events.pause = function(){22 $("#music i").addClass('icon-pause-hsc');23 $("#music i").removeClass('icon-mute-hsc');24 mainApp.soundManagerConfig.musicPlaying = false;25 pagePlayerPause.call(this);26 $("#product-home .sm2_paused i").toggleClass('icon-volume-up icon-pause');27 }28 var pagePlayerResume = pagePlayer.events.resume;29 pagePlayer.events.resume = function(){30 mainApp.soundManagerConfig.musicPlaying = true;31 $("#music i").removeClass('icon-pause-hsc');32 $("#music i").addClass('icon-mute-hsc');33 pagePlayerResume.call(this);34 $("#product-home .sm2_playing i").addClass('icon-volume-up');35 $("#product-home .sm2_playing i").addClass('icon-pause'); 36 }37 var pagePlayerStop = pagePlayer.events.stop;38 pagePlayer.events.stop = function(){39 $("#music i").addClass('icon-pause-hsc');40 $("#music i").removeClass('icon-mute-hsc');41 mainApp.soundManagerConfig.musicPlaying = false;42 mainApp.soundManagerConfig.musicStopped = true;43 $("#product-home .sm2_playing i").removeClass('icon-volume-up');44 $("#product-home .sm2_playing i").removeClass('icon-pause');45 pagePlayerStop.call(this);46 }47 var pagePlayerFinish = pagePlayer.events.finish;48 pagePlayer.events.finish = function(){49 $("#music").hide();50 mainApp.soundManagerConfig.musicPlaying = false;51 mainApp.soundManagerConfig.musicStopped = true;52 $("#product-home .sm2_playing i").removeClass('icon-volume-up');53 $("#product-home .sm2_playing i").removeClass('icon-pause');54 pagePlayerFinish.call(this);55 }56 var mainApp = com.compro.application.hsc;57 var clsMainHeader = mainApp.clsMainHeader;58 59 var Router = Backbone.Router.extend({60 routes: {61 'discipline/:displineId/product/:productId':'producthome'62 }, 63 64 producthome : function(displineId, productId) {65 66 if (bbView == null) { //First OR After Browser Refresh67 68 bbView = new View({displineId:displineId,productId:productId});69 } 70 else { //If the View has been created (bbView) never re-create71 72 bbView.loadCollection(displineId,productId);73 bbView.collection.fetch({74 success: function(){75 bbView.render();76 }77 }); 78 79 }80 }81 82 });83 84 var View = Backbone.View.extend({85 86 /*--------------- Static Class Variable ------------*/87 myPanelId:"#panel_product-home",88 /*------------------------------------------------------*/89 90 events: {91 "click .flashcardAssess" : "flashcardassess",92 "click .flashcardTraining" : "flashcardtraining",93 },94 95 96 initialize: function() {97 98 /* -------------- Setup and Initialize INSTANCE Variables -----------------*/99 this.template_header="";100 this.template_body="";101 this.current_discipline_id=-1;102 this.current_product_id=-1;103 this.requested_discipline_id=-1;104 this.requested_product_id=-1;105 /* ------------------------------------------------------------------------*/106 107 108 this.loadCollection(this.options.displineId,this.options.productId);109 110 //Fill Templates111 var that = this; 112 TemplateManager.get('product-home', 113 function(template){114 that.template_body = template;115 that.collection.fetch({116 success: function(){ 117 //Always call render from initialize - as Backbone does not automatically call it.118 that.render();119 soundManager.onready(function() {120 pagePlayer.init(typeof PP_CONFIG !== 'undefined' ? PP_CONFIG : null);121 }); 122 }123 });124 125 });126 },127 128 loadCollection: function(discipline_id, product_id) {129 130 this.requested_discipline_id=discipline_id;131 this.requested_product_id=product_id;132 133 if(this.current_discipline_id!=this.requested_discipline_id || this.current_product_id!=this.requested_product_id) { 134 this.collection = ProductCollection.get(this.requested_discipline_id, this.requested_product_id);135 }136 137 },138 139 // Updating method name from "render" to "custiomRender" for logging.140 customRender: function() {141 /*142 * 1st parameter - update header for login143 * 2nd parameter - showHomeLink144 * 3rd parameter - setBackLink 145 */146 mainApp.setHeaderOptions(false, true, true);147 // Check if we need to update the PANEL HTML - 148 // if we're back the same/previous product, then do NOT re-create the DOM149 if(this.current_discipline_id!=this.requested_discipline_id || this.current_product_id!=this.requested_product_id) {150 151 var attribs = this.collection.first().attributes;152 if (attribs.type == "book") {153 attribs.book = true;154 attribs.lab = false;155 attribs.thumbnail = mainApp.addSuffixToFilepath(attribs.image, "-thumb1");156 } else {157 attribs.book = false;158 attribs.lab = true;159 attribs.thumbnail = mainApp.addSuffixToFilepath(attribs.image, "-thumb2");160 }161 162 var compiled_template_body = Mustache.render(this.template_body, this.collection.toJSON());163 164 $(this.myPanelId).html(compiled_template_body);165 166 this.setElement("#product-home");167 168 this.current_discipline_id=this.requested_discipline_id;169 this.current_product_id=this.requested_product_id;170 }171 /*172 * SLIDE myPanelID into com.compro.application.hsc.currentPanelId173 */174 mainApp.transitionAppPanel(this.myPanelId);175 if($("#product-home i.icon-pause").length > 0 && !($("#product-home .sm2_playing").length > 0)){176 $("#product-home i.icon-pause").toggleClass('icon-volume-up icon-pause');177 }178 return this; //Do this at the end to allow for method chaining.179 },180 flashcardassess : function(e) {181 var productid = this.requested_product_id;182 var testid = e.currentTarget.id;183 Backbone.history.navigate("#/product/" + productid + "/test/"+testid);184 },185 186 flashcardtraining : function(e) {187 var productid = this.requested_product_id;188 var testid = e.currentTarget.id;189 Backbone.history.navigate("#/product/" + productid + "/testtraining/"+testid);190 } 191 });192 this.routerInitialize = function(){193 194 if (this.router == null) {195 this.router = new Router();196 }197 };...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const {addSuffixToFilePath} = require('playwright/lib/utils/utils');2const path = require('path');3const filePath = path.join(__dirname, 'test.txt');4const newFilePath = addSuffixToFilePath(filePath, '-suffix');5console.log('newFilePath', newFilePath);6const {addSuffixToFilePath} = require('playwright/lib/utils/utils');7const path = require('path');8const filePath = path.join(__dirname, 'test.txt');9const newFilePath = addSuffixToFilePath(filePath, '-suffix');10console.log('newFilePath', newFilePath);11const {addSuffixToFilePath} = require('playwright/lib/utils/utils');12const path = require('path');13const filePath = path.join(__dirname, 'test.txt');14const newFilePath = addSuffixToFilePath(filePath, '-suffix');15console.log('newFilePath', newFilePath);16const {addSuffixToFilePath} = require('playwright/lib/utils/utils');17const path = require('path');18const filePath = path.join(__dirname, 'test.txt');19const newFilePath = addSuffixToFilePath(filePath, '-suffix');20console.log('newFilePath', newFilePath);21const {addSuffixToFilePath} = require('playwright/lib/utils/utils');22const path = require('path');23const filePath = path.join(__dirname, 'test.txt');24const newFilePath = addSuffixToFilePath(filePath, '-suffix');25console.log('newFilePath', newFilePath);26const {addSuffixToFilePath} = require('playwright/lib/utils/utils');27const path = require('path');28const filePath = path.join(__dirname, 'test.txt');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { addSuffixToFilePath } = require('playwright/lib/utils/utils');2const suffix = 'suffix';3const filePath = 'file.js';4console.log(addSuffixToFilePath(filePath, suffix));5const { addSuffixToFilePath } = require('playwright/lib/utils/utils');6const suffix = 'suffix';7const filePath = 'file';8console.log(addSuffixToFilePath(filePath, suffix));9const { addSuffixToFilePath } = require('playwright/lib/utils/utils');10const suffix = 'suffix';11const filePath = 'file.js';12console.log(addSuffixToFilePath(filePath, suffix, '-'));13const { addSuffixToFilePath } = require('playwright/lib/utils/utils');14const suffix = 'suffix';15const filePath = 'file';16console.log(addSuffixToFilePath(filePath, suffix, '-'));17const { addSuffixToFilePath } = require('playwright/lib/utils/utils');18const suffix = 'suffix';19const filePath = 'file.js';20console.log(addSuffixToFilePath(filePath, suffix, '-'));21const { addSuffixToFilePath } = require('playwright/lib/utils/utils');22const suffix = 'suffix';23const filePath = 'file';24console.log(addSuffixToFilePath(filePath, suffix, '-'));25const { addSuffixToFilePath } = require('playwright/lib/utils/utils');26const suffix = 'suffix';27const filePath = 'file.js';28console.log(addSuffixToFilePath(filePath, suffix, '-'));29const { addSuffixToFilePath } = require('playwright/lib/utils/utils');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { addSuffixToFilePath } = require('playwright/lib/utils/utils');2const path = require('path');3const filePath = '/Users/abc/Downloads/file.pdf';4console.log(addSuffixToFilePath(filePath, '-suffix'));5Your name to display (optional):6Your name to display (optional):

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