How to use updateOptions method in Playwright Internal

Best JavaScript code snippet using playwright-internal

sequencer-editor.js

Source:sequencer-editor.js Github

copy

Full Screen

1/* This Source Code Form is subject to the terms of the MIT license2 * If a copy of the MIT license was not distributed with this file, you can3 * obtain one at https://raw.github.com/mozilla/butter/master/LICENSE */4define( [ "localized", "util/mediatypes", "editor/editor", "util/time",5 "util/uri", "ui/widget/textbox", "l10n!/layouts/sequencer-editor.html" ],6 function( Localized, MediaUtils, Editor, Time, URI, Textbox, LAYOUT_SRC ) {7 Editor.register( "sequencer", LAYOUT_SRC,8 function( rootElement, butter ) {9 var _this = this;10 var _rootElement = rootElement,11 _trackEvent,12 _butter,13 _manifest,14 _popcornOptions,15 _mediaType;16 var _fields = {};17 // Creates an "off-on" toggler18 function Toggler( el, property, isReverse, customUpdateUI ) {19 var hiddenInput = el.querySelector( "input" );20 function updateUI() {21 var val = _popcornOptions[ property ];22 if ( val && !isReverse || !val && isReverse ) {23 el.classList.add( "on" );24 } else {25 el.classList.remove( "on" );26 }27 hiddenInput.checked = val;28 if ( customUpdateUI ) {29 customUpdateUI( el );30 }31 }32 function updateTrackEvent( val ) {33 var properties = {};34 properties[ property ] = val;35 updateUI( val );36 _this.updateTrackEventSafe( _trackEvent, properties );37 }38 el.addEventListener( "click", function() {39 // Toggle the state40 updateTrackEvent( !hiddenInput.checked );41 });42 updateUI( _popcornOptions[ property ] );43 return {44 el: el,45 updateUI: updateUI46 };47 }48 // Creates a standard input49 function Input( el, property, callback, customUpdate ) {50 _this.attachInputChangeHandler( el, _trackEvent, property, callback );51 function updateUI() {52 var val = _popcornOptions[ property ];53 el.value = val;54 if ( customUpdate ) {55 customUpdate( el );56 }57 }58 updateUI( _popcornOptions[ property ] );59 return {60 el: el,61 updateUI: updateUI62 };63 }64 function StartEnd( el ) {65 var container = _this.createStartEndInputs( _trackEvent, _this.updateTrackEventSafe ),66 startEl = container.querySelector( "[data-manifest-key=start]" ),67 endEl = container.querySelector( "[data-manifest-key=end]" );68 el.appendChild( container );69 function updateUI() {70 startEl.value = Time.toTimecode( _popcornOptions.start );71 endEl.value = Time.toTimecode( _popcornOptions.end );72 }73 updateUI();74 return {75 el: el,76 updateUI: updateUI77 };78 }79 // Our custom trimmer thingy80 function Trimmer( el ) {81 var MIN_VISUAL_WIDTH = 5;82 var rightHandle = el.querySelector( ".trimmer-resizable-e" ),83 leftHandle = el.querySelector( ".trimmer-resizable-w" ),84 outInput = _rootElement.querySelector( ".trimmer-input-right" ),85 inInput = _rootElement.querySelector( ".trimmer-input-left" ),86 clipSection = el.querySelector( ".clip-section" ),87 clipEndLabel = el.querySelector( ".clip-end" );88 var firstX,89 startLeft,90 startWidth,91 activeHandle,92 updateOptions = {};93 // Converting px <=> time, normalizing94 function positionToTime( pos ) {95 var max1 = _popcornOptions.duration,96 max2 = el.offsetWidth;97 return ( pos / max2 ) * max1;98 }99 function timeToPosition( time ) {100 var max1 = _popcornOptions.duration,101 max2 = el.offsetWidth;102 return ( time / max1 ) * max2;103 }104 // Updating functions105 function updateUI( options ) {106 var start,107 end,108 from;109 options = options || _popcornOptions;110 start = options.start;111 end = options.end;112 from = options.from;113 if ( !from && from !== 0 ) {114 from = _popcornOptions.from;115 }116 if ( !end && end !== 0 ) {117 end = _popcornOptions.end;118 }119 if ( !start && start !== 0 ) {120 start = _popcornOptions.start;121 }122 // Adjust UI to account for very small durations123 if ( timeToPosition( end - start ) < MIN_VISUAL_WIDTH ) {124 clipSection.classList.add( "small" );125 } else {126 clipSection.classList.remove( "small" );127 }128 clipSection.style.left = timeToPosition( from ) + "px";129 inInput.value = Time.toTimecode( from );130 clipSection.style.width = timeToPosition( end - start ) + "px";131 outInput.value = Time.toTimecode( from + end - start );132 if ( options.duration ) {133 clipEndLabel.innerHTML = Time.toTimecode( options.duration );134 }135 }136 function updateEndAfterExpand() {137 var track = _trackEvent.track;138 track.removeTrackEvent( _trackEvent );139 track.addTrackEvent( _trackEvent );140 _this.updateTrackEventSafe( _trackEvent, updateOptions );141 _butter.unlisten( "mediaready", updateEndAfterExpand );142 _butter.currentTime = _popcornOptions.start;143 updateUI();144 updateOptions = {};145 }146 function updateTrackEvent( options ) {147 if ( !_butter.currentMedia.paused ) {148 _butter.currentMedia.pause();149 }150 // If the end time is greater than the duration of the video, expand it to fit.151 // We have to set an event listener on "mediaready" to update the trackevent after the base duration has been changed152 if ( options.end && options.end > _butter.duration ) {153 _butter.currentMedia.url = "#t=," + options.end;154 _butter.listen( "mediaready", updateEndAfterExpand );155 } else {156 _this.updateTrackEventSafe( _trackEvent, options );157 updateOptions = {};158 updateUI();159 }160 }161 function onResizeStop() {162 var accuracy,163 start = updateOptions.start || _popcornOptions.start,164 end = updateOptions.end || _popcornOptions.end;165 el.classList.remove( "editing" );166 if ( activeHandle === "left" ) {167 accuracy = start * Math.pow( 10, Time.timeAccuracy - 1 );168 butter.currentTime = start === 0 ? start : Math.ceil( start * accuracy ) / accuracy;169 } else if ( activeHandle === "right" ) {170 accuracy = end * Math.pow( 10, Time.timeAccuracy - 1 );171 butter.currentTime = Math.floor( end * accuracy ) / accuracy;172 }173 updateTrackEvent( updateOptions );174 activeHandle = "";175 document.removeEventListener( "mousemove", onResizingRight, false );176 document.removeEventListener( "mousemove", onResizingLeft, false );177 document.removeEventListener( "mouseup", onResizeStop, false );178 }179 function onResizingLeft( e ) {180 e.preventDefault();181 var left = startLeft + e.clientX - firstX,182 width = startWidth - ( e.clientX - firstX );183 if ( left < 0 ) {184 width += left;185 left = 0;186 }187 if ( width < 0 ) {188 return;189 }190 updateOptions.end = _popcornOptions.start + positionToTime( width );191 updateOptions.from = positionToTime( left );192 updateUI({193 from: updateOptions.from,194 end: updateOptions.end195 });196 }197 function onResizingRight( e ) {198 e.preventDefault();199 var left = clipSection.offsetLeft,200 width = startWidth + e.clientX - firstX;201 if ( left + width > el.offsetWidth ) {202 width = el.offsetWidth - left;203 }204 if ( width < 0 ) {205 return;206 }207 updateOptions.end = _popcornOptions.start + positionToTime( width );208 updateUI({209 end: updateOptions.end210 });211 }212 function onResizeStart( e ) {213 e.preventDefault(); // Prevent selection214 el.classList.add( "editing" );215 firstX = e.clientX;216 startLeft = clipSection.offsetLeft;217 startWidth = clipSection.offsetWidth;218 if ( this === rightHandle ) {219 document.addEventListener( "mousemove", onResizingRight );220 activeHandle = "right";221 } else if ( this === leftHandle ) {222 activeHandle = "left";223 document.addEventListener( "mousemove", onResizingLeft );224 }225 document.addEventListener( "mouseup", onResizeStop );226 }227 function onDragStop() {228 el.classList.remove( "editing" );229 updateTrackEvent( updateOptions );230 document.removeEventListener( "mouseup", onDragStop, false );231 document.removeEventListener( "mousemove", onDragging, false );232 }233 function onDragging( e ) {234 e.preventDefault(); // Prevent selection235 var left = startLeft + e.clientX - firstX,236 width = clipSection.offsetWidth;237 if ( left < 0 ) {238 left = 0;239 }240 if ( left + width > el.offsetWidth ) {241 left = el.offsetWidth - width;242 }243 if ( width < 0 ) {244 return;245 }246 updateOptions.from = positionToTime( left );247 updateUI({248 from: updateOptions.from249 });250 }251 function onDragStart( e ) {252 e.preventDefault();253 if ( e.target !== clipSection ) {254 // We are resizing, not dragging.255 return;256 }257 el.classList.add( "editing" );258 firstX = e.clientX;259 startLeft = clipSection.offsetLeft;260 startWidth = clipSection.offsetWidth;261 document.addEventListener( "mousemove", onDragging );262 document.addEventListener( "mouseup", onDragStop );263 }264 function onRightInputChange() {265 var val = Time.toSeconds( this.value );266 updateOptions.end = _popcornOptions.start + val - _popcornOptions.from;267 updateTrackEvent( updateOptions );268 }269 function onLeftInputChange() {270 var val = Time.toSeconds( this.value );271 updateOptions.from = val;272 updateOptions.end = _popcornOptions.end + ( _popcornOptions.from - val );273 updateTrackEvent( updateOptions );274 }275 function onWindowMousedownRight( e ) {276 e.stopPropagation();277 e.preventDefault();278 // This triggers a change event.279 outInput.blur();280 outInput.addEventListener( "keydown", onRightKeydown );281 window.removeEventListener( "mousedown", onWindowMousedownRight, true );282 }283 function onWindowMousedownLeft( e ) {284 e.stopPropagation();285 e.preventDefault();286 // This triggers a change event.287 inInput.blur();288 inInput.addEventListener( "keydown", onLeftKeydown );289 window.removeEventListener( "mousedown", onWindowMousedownLeft, true );290 }291 function onRightKeydown() {292 outInput.removeEventListener( "keydown", onRightKeydown, false );293 window.addEventListener( "mousedown", onWindowMousedownRight, true );294 }295 function onLeftKeydown() {296 inInput.removeEventListener( "keydown", onLeftKeydown, false );297 window.addEventListener( "mousedown", onWindowMousedownLeft, true );298 }299 // Setup300 outInput.addEventListener( "change", onRightInputChange );301 inInput.addEventListener( "change", onLeftInputChange );302 outInput.addEventListener( "keydown", onRightKeydown );303 inInput.addEventListener( "keydown", onLeftKeydown );304 rightHandle.addEventListener( "mousedown", onResizeStart );305 leftHandle.addEventListener( "mousedown", onResizeStart );306 clipSection.addEventListener( "mousedown", onDragStart );307 updateUI();308 return {309 el: el,310 updateUI: updateUI311 };312 }313 function setup( trackEvent ) {314 _trackEvent = trackEvent;315 _popcornOptions = _trackEvent.popcornOptions,316 _manifest = _trackEvent.manifest.options;317 var sourceEl = _rootElement.querySelector( "[data-manifest-key=source]" ),318 startEndContainer = _rootElement.querySelector( ".start-end-container" ),319 fallbackEl = _rootElement.querySelector( "[data-manifest-key=fallback]" ),320 fallbackContainer = _rootElement.querySelector( ".fallback-container" ),321 muteEl = _rootElement.querySelector( "#mute-toggler" ),322 hiddenEl = _rootElement.querySelector( "#hidden-toggler" ),323 titleEl = _rootElement.querySelector( "[data-manifest-key=title]" ),324 clipTrimmerEl = _rootElement.querySelector( ".clip-duration" ),325 sliderEl = _rootElement.querySelector( ".butter-slider" ),326 sliderContainer = _rootElement.querySelector( ".slider-container" ),327 videoToggleContainer = _rootElement.querySelector( ".video-toggler" );328 // Custom callbacks and UI updating functions329 var sourceCallback = function( trackEvent, updateOptions ) {330 if ( !Array.isArray( updateOptions.source ) ) {331 updateOptions.source = [ updateOptions.source ];332 }333 if ( _mediaType && _mediaType !== "HTML5" ) {334 updateOptions.fallback = [ "" ];335 }336 updateOptions.source[ 0 ] = updateOptions.source[ 0 ] || _popcornOptions.source[ 0 ];337 updateOptions.source[ 0 ] = updateOptions.source[ 0 ].trim().split( " " ).join( "" );338 // Bail early to prevent the same video being reloaded due to butteruid.339 if ( URI.stripUnique( updateOptions.source[ 0 ] ).toString() ===340 URI.stripUnique( _popcornOptions.source[ 0 ] ).toString() ) {341 return;342 }343 MediaUtils.getMetaData( updateOptions.source[ 0 ], function( data ) {344 _mediaType = data.type;345 updateOptions.duration = data.duration;346 updateOptions.denied = data.denied;347 updateOptions.title = data.title;348 if ( _mediaType === "SoundCloud" ) {349 videoToggleContainer.classList.add( "butter-hidden" );350 updateOptions.hidden = true;351 } else {352 videoToggleContainer.classList.remove( "butter-hidden" );353 updateOptions.hidden = false;354 }355 if ( _mediaType === "Archive" || _mediaType === "Clyp" ) {356 updateOptions.source[ 0 ] = data.source;357 updateOptions.linkback = data.linkback;358 }359 trackEvent.update( updateOptions );360 });361 },362 sourceUpdateUI = function( el ) {363 var source;364 if ( !Array.isArray( _popcornOptions.source ) ) {365 _popcornOptions.source = [ _popcornOptions.source ];366 }367 source = _popcornOptions.linkback || _popcornOptions.source[ 0 ];368 _mediaType = MediaUtils.checkUrl( source );369 if ( _mediaType === "HTML5" ) {370 fallbackContainer.classList.add( "show" );371 }372 if ( _mediaType === "SoundCloud" ||373 _popcornOptions.contentType.indexOf( "audio" ) === 0 ||374 _popcornOptions.contentType.indexOf( "application/ogg" ) === 0 ) {375 videoToggleContainer.classList.add( "butter-hidden" );376 fallbackContainer.classList.remove( "show" );377 } else {378 videoToggleContainer.classList.remove( "butter-hidden" );379 fallbackContainer.classList.remove( "show" );380 }381 if ( _mediaType === "Archive" || _mediaType === "Clyp" ) {382 el.value = _popcornOptions.linkback;383 } else {384 el.value = URI.stripUnique( source ).toString();385 }386 },387 fallbackUpdateUI = function( el ) {388 if ( !_popcornOptions.fallback || !_popcornOptions.fallback.length ) {389 return;390 } else if ( !Array.isArray( _popcornOptions.fallback ) ) {391 _popcornOptions.fallback = [ _popcornOptions.fallback ];392 }393 el.value = URI.stripUnique( _popcornOptions.fallback[ 0 ] ).toString();394 },395 muteUpdateUI = function() {396 if ( _popcornOptions.mute === true ) {397 sliderContainer.classList.add( "disabled" );398 } else {399 sliderContainer.classList.remove( "disabled" );400 }401 };402 _fields.startEnd = new StartEnd( startEndContainer, "start", _this.updateTrackEventSafe );403 _fields.source = new Input( sourceEl, "source", sourceCallback, sourceUpdateUI );404 _fields.fallback = new Input( fallbackEl, "fallback", _this.updateTrackEventSafe, fallbackUpdateUI );405 _fields.title = new Input( titleEl, "title", _this.updateTrackEventSafe );406 _fields.mute = new Toggler( muteEl, "mute", "reverse", muteUpdateUI );407 _fields.hidden = new Toggler( hiddenEl, "hidden", "reverse" );408 _fields.from = new Trimmer( clipTrimmerEl );409 _this.attachSliderChangeHandler( sliderEl, _trackEvent, "volume" );410 Textbox.applyTo( _fields.source.el, "textarea" );411 Textbox.applyTo( _fields.fallback.el, "textarea" );412 } //setup413 function onTrackEventUpdated( e ) {414 _trackEvent = e.target;415 _popcornOptions = _trackEvent.popcornOptions;416 for ( var key in _manifest ) {417 if ( _manifest.hasOwnProperty( key ) ) {418 if ( key === "start" || key === "end" ) {419 key = "startEnd";420 }421 if ( _fields[ key ] && _fields[ key ].updateUI ) {422 _fields[ key ].updateUI();423 }424 }425 }426 _this.setErrorState( false );427 }428 // Extend this object to become a TrackEventEditor429 Editor.TrackEventEditor.extend( _this, butter, rootElement, {430 open: function( parentElement, trackEvent ) {431 _butter = butter;432 // Update properties when TrackEvent is updated433 trackEvent.listen( "trackeventupdated", onTrackEventUpdated );434 setup( trackEvent );435 },436 close: function() {437 _trackEvent.unlisten( "trackeventupdated", onTrackEventUpdated );438 }439 });440 }, false, function( trackEvent ) {441 var _container,442 _popcornOptions,443 _dragOptions = {444 disableTooltip: true,445 editable: false446 },447 _target;448 _popcornOptions = trackEvent.popcornTrackEvent;449 _container = _popcornOptions._container;450 _target = _popcornOptions._target;451 if ( MediaUtils.checkUrl( _popcornOptions.source[ 0 ] ) === "YouTube" ) {452 _dragOptions.disableTooltip = false;453 _dragOptions.editable = true;454 _dragOptions.tooltip = Localized.get( "Double click to close ads" );455 }456 this.draggable( trackEvent, _container, _target, _dragOptions );457 this.resizable( trackEvent, _container, _target, {458 handlePositions: "n,ne,e,se,s,sw,w,nw",459 minWidth: 10,460 minHeight: 10461 });462 });...

Full Screen

Full Screen

sensorErrorHistory.js

Source:sensorErrorHistory.js Github

copy

Full Screen

1var tableSeh = $('#table-seh');2var tableSensors = $('#table-sensors');3var tableSensorErrorHistory = $('#table-seh');4var trSensor = $('.tr-sensor');5var btnCSV = $('#btn-csv');6var checkGroupIds = $('[name="groupIds"]');7var checkGroupIdsAll = $('#check-groupIds-all');8var checkEnergySensorType = $('[name="energySensorType"]');9var checkEnvSensorType = $('[name="envSensorType"]');10var checkSensorIdsAll = $('#check-sensorIds-all');11var checkSensorIds = $('[name="sensorIds"]');12var checkSensorIdsEnergyAll = $('.check-energy');13var checkSensorIdsEnvAll = $('.check-env');14var selectDisplaySpan = $('[name="displaySpan"]');15var textRangeDate = $('#rangeDate');16var startDate = fbStartDate;17var endDate = fbEndDate;18var updateOptions = {};19var tableColumns;20var tableData;21//***** behavior22checkGroupIdsAll.change(function(){23 24 checkGroupIds.prop('checked', this.checked);25 setSensorVisibility();26});27checkGroupIds.change(function(){28 29 var checkedLen = checkGroupIds.filter(':checked').length;30 if(checkedLen == checkGroupIds.length)31 checkGroupIdsAll.prop('checked', true);32 else33 checkGroupIdsAll.prop('checked', false);34 35 setSensorVisibility();36});37checkEnergySensorType.change(setSensorVisibility);38checkEnvSensorType.change(setSensorVisibility);39checkSensorIdsAll.change(function(){40 checkSensorIds.filter(':visible').prop('checked', this.checked);41});42checkSensorIds.change(function(){43 var visibleSensorLen = checkSensorIds.filter(':visible').length;44 var checkedSensorLen = checkSensorIds.filter(':visible:checked').length;45 46 if(visibleSensorLen == checkedSensorLen)47 checkSensorIdsAll.prop('checked', true);48 else49 checkSensorIdsAll.prop('checked', false);50});51btnCSV.click(function(){52 53 if(updateOptions.sensorIds != null){54 55 var url = "/zeuschart/SensorErrorHistory/GetSensorErrorHistoryCSV.do";56 var form = $("<form></form>").attr("action", url).attr("method", "post");57 form.append($("<input></input>").attr("type", "hidden").attr("name", "startDate").attr("value", updateOptions.startDate));58 form.append($("<input></input>").attr("type", "hidden").attr("name", "endDate").attr("value", updateOptions.endDate));59 form.append($("<input></input>").attr("type", "hidden").attr("name", "sensorIds").attr("value", updateOptions.sensorIds));60 form.appendTo('body').submit().remove();61 }62});63tableSeh.click(function(){64 window.open(contextPath + 'large/sensorErrorHistory/Large.jsp');65});66//_____ behavior67//******************** functions68//***** グループとセンサータイプチェックにより、センサー表示/非表示を設定69function setSensorVisibility(){70 71 var trShowArr = [];72 var checkShowArr = [];73 var trHideArr = [];74 var checkHideArr = [];75 if(checkGroupIds.length > 0){76 77 var trFilterStr, checkFilterStr;78 for(var i = 0; i < checkGroupIds.length; i++){79 80 for(var j = 0; j < checkEnergySensorType.length; j++){81 82 trFilterStr = '.tr-' + checkGroupIds[i].value + '.tr-energy-' + checkEnergySensorType[j].value;83 checkFilterStr = '.check-' + checkGroupIds[i].value + '.check-energy-' + checkEnergySensorType[j].value;84 if(checkGroupIds[i].checked && checkEnergySensorType[j].checked){85 86 trShowArr.push(trFilterStr);87 checkShowArr.push(checkFilterStr);88 }else{89 90 trHideArr.push(trFilterStr);91 checkHideArr.push(checkFilterStr);92 }93 }94 95 for(var j = 0; j < checkEnvSensorType.length; j++){96 97 trFilterStr = '.tr-' + checkGroupIds[i].value + '.tr-env-' + checkEnvSensorType[j].value;98 checkFilterStr = '.check-' + checkGroupIds[i].value + '.check-env-' + checkEnvSensorType[j].value;99 if(checkGroupIds[i].checked && checkEnvSensorType[j].checked){100 101 trShowArr.push(trFilterStr);102 checkShowArr.push(checkFilterStr);103 }else{104 105 trHideArr.push(trFilterStr);106 checkHideArr.push(checkFilterStr);107 }108 }109 }110 }else{111 112 for(var j = 0; j < checkEnergySensorType.length; j++){113 114 trFilterStr = '.tr-energy-' + checkEnergySensorType[j].value;115 checkFilterStr = '.check-energy-' + checkEnergySensorType[j].value;116 if(checkEnergySensorType[j].checked){117 118 trShowArr.push(trFilterStr);119 checkShowArr.push(checkFilterStr);120 }else{121 122 trHideArr.push(trFilterStr);123 checkHideArr.push(checkFilterStr);124 }125 }126 127 for(var j = 0; j < checkEnvSensorType.length; j++){128 129 trFilterStr = '.tr-env-' + checkEnvSensorType[j].value;130 checkFilterStr = '.check-env-' + checkEnvSensorType[j].value;131 if(checkEnvSensorType[j].checked){132 133 trShowArr.push(trFilterStr);134 checkShowArr.push(checkFilterStr);135 }else{136 137 trHideArr.push(trFilterStr);138 checkHideArr.push(checkFilterStr);139 }140 }141 }142 143 for(var i = 0; i < checkShowArr.length; i++)144 checkSensorIds.filter(checkShowArr[i]).prop('disabled', false);145 for(var i = 0; i < trShowArr.length; i++)146 trSensor.filter(trShowArr[i]).show();147 148 for(var i = 0; i < trHideArr.length; i++)149 trSensor.filter(trHideArr[i]).hide();150 for(var i = 0; i < checkHideArr.length; i++)151 checkSensorIds.filter(checkHideArr[i]).prop('disabled', true);152 153 var visibleSensorLen = trSensor.filter(':visible').length;154 if(visibleSensorLen == 0){155 156 checkSensorIdsAll.prop('checked', false);157 checkSensorIdsAll.prop('disabled', true);158 }else{159 160 checkSensorIdsAll.prop('disabled', false);161 162 var checkedSensorLen = checkSensorIds.filter(':visible:checked').length;163 if(checkedSensorLen == visibleSensorLen)164 checkSensorIdsAll.prop('checked', true);165 else166 checkSensorIdsAll.prop('checked', false);167 }168}169//_____ グループとセンサータイプチェックにより、センサー表示/非表示を設定170//***** 一定期間を設けてデータを更新171function updateData(){172 173 $.ajax({174 url: '/zeuschart/SensorErrorHistory/GetSensorErrorHistoryRealtime.do',175 type: 'POST',176 async: true,177 cache: false,178 data: updateOptions,179 success: function(response){180 181 var respObj = JSON.parse(response);182 if(respObj.columns != null){183 184 tableColumns = respObj.columns;185 tableData = respObj.data;186 187 // データテーブル188 tableSeh.bootstrapTable('destroy').bootstrapTable({189 fixedColumns: true,190 fixedNumber: 1,191 striped: false,192 height: 500,193 columns: tableColumns,194 data: tableData195 });196 197 $('.fixed-table-header-columns').find('th').height(tableSeh.find('th').height());198 199 if(updateOptions.optionChangeInterval == null)200 updateOptions.optionChangeInterval = setInterval(optionChangeListener, 10000);201 202 updateOptions.init = false;203 }else{204 205 tableData.pop();206 tableData.unshift(respObj.data);207 208 tableSeh.bootstrapTable('load', tableData);209 }210 },211 error: function(){212 213 console.log('refresh json error');214 tableSeh.bootstrapTable('destroy');215 }216 });217}218//_____ 一定期間を設けてデータを更新219function optionChangeListener() {220 221 var updateUserOptions = {};222 var changed = false;223 // display span224 if(updateOptions.displaySpan != selectDisplaySpan.val()){225 226 updateUserOptions.displaySpan = 'sensor_error_history_display_span=' + selectDisplaySpan.val();227 updateOptions.displaySpan = selectDisplaySpan.val();228 changed = true;229 }230 // 期間231 if(updateOptions.startDate != startDate || updateOptions.endDate != endDate){232 233 changed = true;234 updateOptions.startDate = startDate;235 updateOptions.endDate = endDate;236 }237 // グループ238 if(checkGroupIds.length > 0){239 240 var checkedGroupStr;241 var checkedGroup = checkGroupIds.filter(':checked');242 if(checkedGroup.length > 0)243 checkedGroupStr = checkedGroup.map(function(){244 return this.value;245 }).get().join(',');246 if(updateOptions.groupIds != checkedGroupStr){247 248 changed = true;249 updateUserOptions.groupIds = 'sensor_error_history_group_ids=' + (checkedGroupStr == null? 'null': "'" + checkedGroupStr + "'");250 updateOptions.groupIds = checkedGroupStr;251 }252 }253 // エネルギーセンサータイプ254 var checkedEnergySensorTypeStr;255 var checkedEnergySensorType = checkEnergySensorType.filter(':checked');256 if(checkedEnergySensorType.length > 0)257 checkedEnergySensorTypeStr = checkedEnergySensorType.map(function(){258 return this.value;259 }).get().join(',');260 if(updateOptions.energySensorType != checkedEnergySensorTypeStr){261 262 changed = true;263 updateUserOptions.energySensorType = 'sensor_error_history_energy_sensor_type=' + (checkedEnergySensorTypeStr == null? 'null': "'" + checkedEnergySensorTypeStr + "'");264 updateOptions.energySensorType = checkedEnergySensorTypeStr;265 }266 // 環境センサータイプ267 var checkedEnvSensorTypeStr;268 var checkedEnvSensorType = checkEnvSensorType.filter(':checked');269 if(checkedEnvSensorType.length > 0)270 checkedEnvSensorTypeStr = checkedEnvSensorType.map(function(){271 return this.value;272 }).get().join(',');273 if(updateOptions.envSensorType != checkedEnvSensorTypeStr){274 275 changed = true;276 updateUserOptions.envSensorType = 'sensor_error_history_env_sensor_type=' + (checkedEnvSensorTypeStr == null? 'null': "'" + checkedEnvSensorTypeStr + "'");277 updateOptions.envSensorType = checkedEnvSensorTypeStr;278 }279 // sensorIdsAll280 var checkedAllStr;281 var checkedAll = checkSensorIds.filter(':checked');282 if(checkedAll.length > 0)283 checkedAllStr = checkedAll.map(function(){284 return this.value;285 }).get().join(',');286 if(updateOptions.sensorIdsAll != checkedAllStr){287 288 updateUserOptions.sensorIds = 'sensor_error_history_sensor_ids=' + (checkedAllStr == null? 'null': "'" + checkedAllStr + "'");289 updateOptions.sensorIdsAll = checkedAllStr;290 }291 // sensorIds292 var visibleCheckedStr;293 var visibleChecked = checkSensorIds.filter(':visible:checked');294 if(visibleChecked.length > 0)295 visibleCheckedStr = visibleChecked.map(function(){296 return this.value;297 }).get().join(',');298 if(updateOptions.sensorIds != visibleCheckedStr){299 300 changed = true;301 updateOptions.sensorIds = visibleCheckedStr;302 }303 if(JSON.stringify(updateUserOptions) != '{}'){304 305 $.ajax({306 url: contextPath + 'Ajax/User/UpdateOption.action',307 type: 'POST',308 async: true,309 cache: false,310 data: updateUserOptions,311 success: function(response){312 console.log('update user options success');313 },314 error: function(){315 console.log('update user options failed');316 }317 });318 }319 320 if(changed)321 updateOptions.init = true;322 323 if(updateOptions.sensorIds == null) {324 325 clearInterval(updateOptions.updateDataInterval);326 tableSeh.bootstrapTable('destroy');327 }else{328 329 if(updateOptions.init){330 331 clearInterval(updateOptions.updateDataInterval);332 clearInterval(updateOptions.optionChangeInterval);333 delete updateOptions.optionChangeInterval;334 delete updateOptions.maxDate;335 336 if(updateOptions.sensorIds != null){337 338 updateData();339 updateOptions.updateDataInterval = setInterval(updateData, updateOptions.updateFrequency);340 }341 }else{342 if(!updateOptions.init)343 updateOptions.maxDate = tableData[0].datetime;344 }345 }346}347function datetimeColumnStyle(){348 349 return {350 classes: 'td-with-bg',351 css: {'min-width': '140px'}352 };353}354function headColumnStyle() {355 356 return {357 css: {'min-width': '80px'}358 };359}360//____________________ functions361//******************** init362//***** 更新パラメーター初期化363// 表示期間364updateOptions.displaySpan = selectDisplaySpan.val();365// グループ366if(checkGroupIds.length > 0){367 368 var checkedGroup = checkGroupIds.filter(':checked');369 if(checkedGroup.length > 0)370 updateOptions.groupIds = checkedGroup.map(function(){371 return this.value;372 }).get().join(',');373 374 if(checkedGroup.length == checkGroupIds.length)375 checkGroupIdsAll.prop('checked', true);376 else377 checkGroupIdsAll.prop('checked', false);378}379// エネルギーセンサータイプ380var checkedEnergySensorType = checkEnergySensorType.filter(':checked');381if(checkedEnergySensorType.length > 0)382 updateOptions.energySensorType = checkedEnergySensorType.map(function(){383 return this.value;384 }).get().join(',');385// 環境センサータイプ386var checkedEnvSensorType = checkEnvSensorType.filter(':checked');387if(checkedEnvSensorType.length > 0)388 updateOptions.envSensorType = checkedEnvSensorType.map(function(){389 return this.value;390 }).get().join(',');391// チェックされたセンサー392var checkedSensorIds = checkSensorIds.filter(':checked');393if(checkedSensorIds.length > 0){394 395 updateOptions.sensorIdsAll = checkedSensorIds.map(function(){396 return this.value;397 }).get().join(',');398}399// 更新頻度400updateOptions.updateFrequency = 60 * 1000;401updateOptions.startDate = startDate;402updateOptions.endDate = endDate;403updateOptions.init = true;404//_____ 更新パラメーター初期化405//***** 期間初期化406textRangeDate.daterangepicker(407 {408 timePicker: true,409 timePicker24Hour: true,410 startDate: startDate,411 endDate: endDate,412 opens: 'center',413 autoUpdateInput: true,414 locale: {415 format: 'YYYY-MM-DD HH:mm',416 applyLabel: "確定",417 cancelLabel: 'キャンセル'418 }419 },420 function (start, end, label) {421 422 startDate = start.format('YYYY-MM-DD HH:mm');423 endDate = end.format('YYYY-MM-DD HH:mm');424 }425);426//_____ 期間初期化427//***** センサーテーブル初期化428tableSensors.removeClass('hide');429setSensorVisibility();430//_____ センサーテーブル初期化431var visibleCheckedSensor = checkSensorIds.filter(':visible:checked');432if(visibleCheckedSensor.length > 0)433 updateOptions.sensorIds = visibleCheckedSensor.map(function(){434 return this.value;435 }).get().join(',');436optionChangeListener();437updateOptions.optionChangeInterval = setInterval(optionChangeListener, 10000);...

Full Screen

Full Screen

main.js

Source:main.js Github

copy

Full Screen

...24 height: winy,25 valueRange: [ acc_miny, acc_maxy ],26 visibility: [true, false, false, false, false, false, false, false, false, false, false, false, false, false],27 zoomCallback: function(minX, maxX, yRanges) {28 acc_y.updateOptions({dateWindow: [minX,maxX]});29 acc_z.updateOptions({dateWindow: [minX,maxX]});30 mag_x.updateOptions({dateWindow: [minX,maxX]});31 mag_y.updateOptions({dateWindow: [minX,maxX]});32 mag_z.updateOptions({dateWindow: [minX,maxX]});33 adc_1.updateOptions({dateWindow: [minX,maxX]});34 adc_2.updateOptions({dateWindow: [minX,maxX]});35 },36 }37 );38 var acc_y = new Dygraph(39 document.getElementById("acc_y"),40 r, {41 ylabel: 'acc Y / m/s^2',42 axes: axes_opt,43 animatedZooms: true,44 xlabel: 't/sec',45 width: winx,46 height: winy,47 valueRange: [ acc_miny, acc_maxy ],48 visibility: [false, true, false, false, false, false, false, false, false, false, false, false, false, false],49 zoomCallback: function(minX, maxX, yRanges) {50 acc_x.updateOptions({dateWindow: [minX,maxX]});51 acc_z.updateOptions({dateWindow: [minX,maxX]});52 mag_x.updateOptions({dateWindow: [minX,maxX]});53 mag_y.updateOptions({dateWindow: [minX,maxX]});54 mag_z.updateOptions({dateWindow: [minX,maxX]});55 adc_1.updateOptions({dateWindow: [minX,maxX]});56 adc_2.updateOptions({dateWindow: [minX,maxX]});57 },58 }59 );60 var acc_z = new Dygraph(61 document.getElementById("acc_z"),62 r, {63 ylabel: 'acc Z / m/s^2',64 axes: axes_opt,65 animatedZooms: true,66 xlabel: 't/sec',67 width: winx,68 height: winy,69 valueRange: [ acc_miny, acc_maxy ],70 visibility: [false, false, true, false, false, false, false, false, false, false, false, false, false, false],71 zoomCallback: function(minX, maxX, yRanges) {72 acc_x.updateOptions({dateWindow: [minX,maxX]});73 acc_y.updateOptions({dateWindow: [minX,maxX]});74 mag_x.updateOptions({dateWindow: [minX,maxX]});75 mag_y.updateOptions({dateWindow: [minX,maxX]});76 mag_z.updateOptions({dateWindow: [minX,maxX]});77 adc_1.updateOptions({dateWindow: [minX,maxX]});78 adc_2.updateOptions({dateWindow: [minX,maxX]});79 },80 }81 );82 var mag_x = new Dygraph(83 document.getElementById("mag_x"),84 r, {85 ylabel: 'mag X / T',86 axes: axes_opt,87 animatedZooms: true,88 xlabel: 't/sec',89 width: winx,90 height: winy,91 valueRange: [ mag_miny, mag_maxy ],92 visibility: [false, false, false, true, false, false, false, false, false, false, false, false, false, false],93 zoomCallback: function(minX, maxX, yRanges) {94 acc_x.updateOptions({dateWindow: [minX,maxX]});95 acc_y.updateOptions({dateWindow: [minX,maxX]});96 acc_z.updateOptions({dateWindow: [minX,maxX]});97 mag_y.updateOptions({dateWindow: [minX,maxX]});98 mag_z.updateOptions({dateWindow: [minX,maxX]});99 adc_1.updateOptions({dateWindow: [minX,maxX]});100 adc_2.updateOptions({dateWindow: [minX,maxX]});101 },102 }103 );104 var mag_y = new Dygraph(105 document.getElementById("mag_y"),106 r, {107 ylabel: 'mag Y / T',108 axes: axes_opt,109 animatedZooms: true,110 xlabel: 't/sec',111 width: winx,112 height: winy,113 valueRange: [ mag_miny, mag_maxy ],114 visibility: [false, false, false, false, true, false, false, false, false, false, false, false, false, false],115 zoomCallback: function(minX, maxX, yRanges) {116 acc_x.updateOptions({dateWindow: [minX,maxX]});117 acc_y.updateOptions({dateWindow: [minX,maxX]});118 acc_z.updateOptions({dateWindow: [minX,maxX]});119 mag_x.updateOptions({dateWindow: [minX,maxX]});120 mag_z.updateOptions({dateWindow: [minX,maxX]});121 adc_1.updateOptions({dateWindow: [minX,maxX]});122 adc_2.updateOptions({dateWindow: [minX,maxX]});123 },124 }125 );126 var mag_z = new Dygraph(127 document.getElementById("mag_z"),128 r, {129 ylabel: 'mag Z / T',130 axes: axes_opt,131 animatedZooms: true,132 xlabel: 't/sec',133 width: winx,134 height: winy,135 valueRange: [ mag_miny, mag_maxy ],136 visibility: [false, false, false, false, false, true, false, false, false, false, false, false, false, false],137 zoomCallback: function(minX, maxX, yRanges) {138 acc_x.updateOptions({dateWindow: [minX,maxX]});139 acc_y.updateOptions({dateWindow: [minX,maxX]});140 acc_z.updateOptions({dateWindow: [minX,maxX]});141 mag_x.updateOptions({dateWindow: [minX,maxX]});142 mag_y.updateOptions({dateWindow: [minX,maxX]});143 adc_1.updateOptions({dateWindow: [minX,maxX]});144 adc_2.updateOptions({dateWindow: [minX,maxX]});145 },146 }147 );148 var adc_1 = new Dygraph(149 document.getElementById("adc_1"),150 r, {151 ylabel: 'ADC 1 / V',152 axes: { y: {axisLabelWidth: 50} },153 animatedZooms: true,154 xlabel: 't/sec',155 drawPoints: true,156 width: winx,157 height: winy,158 valueRange: [ adc_miny, adc_maxy ],159 visibility: [false, false, false, false, false, false, false, false, false, false, false, true, false, false],160 zoomCallback: function(minX, maxX, yRanges) {161 acc_x.updateOptions({dateWindow: [minX,maxX]});162 acc_y.updateOptions({dateWindow: [minX,maxX]});163 acc_z.updateOptions({dateWindow: [minX,maxX]});164 mag_x.updateOptions({dateWindow: [minX,maxX]});165 mag_y.updateOptions({dateWindow: [minX,maxX]});166 mag_z.updateOptions({dateWindow: [minX,maxX]});167 adc_2.updateOptions({dateWindow: [minX,maxX]});168 },169 }170 );171 var adc_2 = new Dygraph(172 document.getElementById("adc_2"),173 r, {174 ylabel: 'ADC 2 / V',175 axes: { y: {axisLabelWidth: 50} },176 animatedZooms: true,177 xlabel: 't/sec',178 drawPoints: true,179 width: winx,180 height: winy,181 valueRange: [ adc_miny, adc_maxy ],182 visibility: [false, false, false, false, false, false, false, false, false, false, false, false, true, false],183 zoomCallback: function(minX, maxX, yRanges) {184 acc_x.updateOptions({dateWindow: [minX,maxX]});185 acc_y.updateOptions({dateWindow: [minX,maxX]});186 acc_z.updateOptions({dateWindow: [minX,maxX]});187 mag_x.updateOptions({dateWindow: [minX,maxX]});188 mag_y.updateOptions({dateWindow: [minX,maxX]});189 mag_z.updateOptions({dateWindow: [minX,maxX]});190 adc_1.updateOptions({dateWindow: [minX,maxX]});191 },192 }193 );194 var reset = function() {195 var rng = adc_1.xAxisExtremes() 196 acc_x.updateOptions({dateWindow: rng});197 acc_y.updateOptions({dateWindow: rng});198 acc_z.updateOptions({dateWindow: rng});199 mag_x.updateOptions({dateWindow: rng});200 mag_y.updateOptions({dateWindow: rng});201 mag_z.updateOptions({dateWindow: rng});202 adc_1.updateOptions({dateWindow: rng});203 adc_2.updateOptions({dateWindow: rng});204 };205 var pan = function(dir) {206 var w = adc_1.xAxisRange();207 var scale = w[1] - w[0];208 var amount = scale * 0.25 * dir;209 var rng = [ w[0] + amount, w[1] + amount ];210 acc_x.updateOptions({dateWindow: rng});211 acc_y.updateOptions({dateWindow: rng});212 acc_z.updateOptions({dateWindow: rng});213 mag_x.updateOptions({dateWindow: rng});214 mag_y.updateOptions({dateWindow: rng});215 mag_z.updateOptions({dateWindow: rng});216 adc_1.updateOptions({dateWindow: rng});217 adc_2.updateOptions({dateWindow: rng});218 };219 document.getElementById('full').onclick = function() { reset(); };220 document.getElementById('left').onclick = function() { pan(-1); };221 document.getElementById('right').onclick = function() { pan(+1); };222}223function read_file_contents(fileobj) {224 if (fileobj) {225 var reader = new FileReader();226 reader.readAsText(fileobj, "UTF-8");227 reader.onload = function (evt) {228 document.getElementById("filename").innerHTML = fileobj.name;229 plot_data(evt.target.result);230 }231 reader.onerror = function (evt) {...

Full Screen

Full Screen

Main.test.js

Source:Main.test.js Github

copy

Full Screen

...302 }303 ])304 ) //density/densityType305 const dispatch = jest.fn()306 updateOptions(dispatch)({ attributes: { hello: 5 } })307 expect(fetch.mock.calls.length).toEqual(2)308 return delay(50).then(() => {309 return expect(dispatch.mock.calls.length).toEqual(10)310 })311 })...

Full Screen

Full Screen

update-preset.js

Source:update-preset.js Github

copy

Full Screen

...17 const newIcon = preset.options[key].replace(18 /generated\/.+\/icons/g,19 `generated/${bundleId}/icons`20 );21 updateOptions(preset, key, newIcon);22 }23 });24};25// -----------------------------------------------------------------------------26const updateAndroidPreset = (env, preset, bundle, bundleId, applicationName, newVersion) => {27 const _applicationName = `${applicationName}${env === 'debug' ? '(debug)' : ''}`;28 updateOptions(preset, 'package/name', _applicationName);29 const packageUIDKey = 'package/unique_name';30 const packageUID = (bundle[ANDROID] && bundle[ANDROID][packageUIDKey]) || bundle.uid;31 updateOptions(preset, packageUIDKey, packageUID);32 if (env === 'production' && bundle[ANDROID]['keystore/release_user']) {33 updateOptions(preset, 'keystore/release_user', bundle[ANDROID]['keystore/release_user']);34 }35 if (newVersion) {36 updateOptions(preset, 'version/code', toVersionNumber(newVersion));37 updateOptions(preset, 'version/name', newVersion);38 }39 updateIcons(preset, bundleId);40};41// -----------------------------------------------------------------------------42const updateIOSPreset = (env, preset, bundle, bundleId, applicationName, newVersion) => {43 updateOptions(preset, 'application/name', applicationName);44 const packageUIDKey = 'application/identifier';45 const packageUID = (bundle[IOS] && bundle[IOS][packageUIDKey]) || bundle.uid;46 updateOptions(preset, packageUIDKey, packageUID);47 if (newVersion) {48 updateOptions(preset, 'application/short_version', newVersion);49 updateOptions(preset, 'application/version', newVersion);50 }51 updateIcons(preset, bundleId);52};53// -----------------------------------------------------------------------------54const updateMacOSPreset = (env, preset, bundle, bundleId, applicationName, newVersion) => {55 updateOptions(preset, 'application/name', applicationName);56 const packageUIDKey = 'application/identifier';57 const packageUID = (bundle[IOS] && bundle[IOS][packageUIDKey]) || bundle.uid;58 updateOptions(preset, packageUIDKey, packageUID);59 if (newVersion) {60 updateOptions(preset, 'application/short_version', newVersion);61 updateOptions(preset, 'application/version', newVersion);62 }63 updateIcons(preset, bundleId);64};65// -----------------------------------------------------------------------------66const updatePreset = (bundleId, env, coreConfig, preset, bundle, newVersion) => {67 const {platform} = preset;68 console.log('⚙️ updating the preset:');69 const {subtitle} = bundle;70 const applicationName = subtitle71 ? `${coreConfig.applicationName}: ${subtitle}`72 : coreConfig.applicationName;73 switch (platform) {74 case ANDROID:75 updateAndroidPreset(env, preset, bundle, bundleId, applicationName, newVersion);76 break;77 case IOS:78 updateIOSPreset(env, preset, bundle, bundleId, applicationName, newVersion);79 break;80 case MAC_OSX:81 updateMacOSPreset(env, preset, bundle, bundleId, applicationName, newVersion);82 break;83 default:84 console.log(`\n> platform ${platform} has no preset specificity.`);85 console.log(`> applying default preset options:`);86 updateOptions(preset, 'application/name', applicationName);87 }88 console.log('✅ preset successfully updated.');89 return {90 applicationName91 };92};93// -----------------------------------------------------------------------------...

Full Screen

Full Screen

cursor.js

Source:cursor.js Github

copy

Full Screen

...6 mask: '',7 lazy: false,8 });9 beforeEach(function () {10 masked.updateOptions({mask: '', lazy: false});11 masked.unmaskedValue = '';12 });13 it('should align after XX', function () {14 ['XX*', 'XX[*]'].forEach(mask => {15 masked.updateOptions({mask});16 for (var pos=0; pos<masked._blocks.length; ++pos) {17 assert.equal(masked.nearestInputPos(pos), 2);18 assert.equal(masked.nearestInputPos(pos, DIRECTION.LEFT), 2);19 }20 });21 });22 it('should align before XX with DIRECTION.LEFT', function () {23 ['XX*', 'XX[*]'].forEach(mask => {24 masked.updateOptions({mask, lazy: true});25 for (var pos=0; pos<masked._blocks.length-1; ++pos) {26 assert.equal(masked.nearestInputPos(pos, DIRECTION.LEFT), 0);27 }28 });29 });30 it('should align before XX', function () {31 ['*XX', '[*]XX'].forEach(mask => {32 masked.updateOptions({mask});33 for (var pos=0; pos<masked._blocks.length-1; ++pos) {34 assert.isAtMost(masked.nearestInputPos(pos), 1);35 }36 });37 });38 it('should align before required', function () {39 masked.updateOptions({mask: '[*]XX*'});40 assert.equal(masked.nearestInputPos(masked.value.length, DIRECTION.LEFT), 2);41 masked.updateOptions({mask: '*XX*'});42 assert.equal(masked.nearestInputPos(masked.value.length, DIRECTION.LEFT), 0);43 });44 it('should align after filled', function () {45 masked.updateOptions({mask: '**X*'});46 masked.unmaskedValue = 'a';47 assert.equal(masked.nearestInputPos(1, DIRECTION.LEFT), 1);48 assert.equal(masked.nearestInputPos(masked.value.length, DIRECTION.LEFT), 1);49 masked.unmaskedValue = 'aa';50 assert.equal(masked.nearestInputPos(masked.value.length, DIRECTION.LEFT), 3);51 assert.equal(masked.nearestInputPos(masked.value.length-1, DIRECTION.LEFT), 3);52 });53 it('should align after filled and fixed with lazy', function () {54 masked.updateOptions({55 mask: '0X0',56 lazy: true,57 });58 masked.value = '1X';59 assert.equal(masked.nearestInputPos(masked.value.length, DIRECTION.LEFT), 1);60 });61});62describe('Align RIGHT', function () {63 const masked = new MaskedPattern({64 mask: '',65 lazy: false,66 });67 beforeEach(function () {68 masked.updateOptions({mask: '', lazy: false});69 masked.unmaskedValue = '';70 });71 // TODO72 it('should align right inside block', function () {73 masked.updateOptions({74 mask: 'dw',75 lazy: false,76 blocks: {77 d: {mask: '00'},78 w: {mask: 'aa'},79 }80 });81 // set only chars82 masked.unmaskedValue = 'aa';83 assert.equal(masked.nearestInputPos(1, DIRECTION.RIGHT), 2);84 });85});86describe('Align NONE', function () {87 const masked = new MaskedPattern({88 mask: '',89 lazy: false,90 });91 beforeEach(function () {92 masked.updateOptions({mask: '', lazy: false});93 masked.unmaskedValue = '';94 });95 it('should align after filled', function () {96 masked.updateOptions({97 mask: '0.0',98 });99 masked.value = '1.1';100 assert.equal(masked.nearestInputPos(1, DIRECTION.NONE), 1);101 });102 it('should align before input', function () {103 masked.updateOptions({104 mask: '0.0',105 });106 masked.value = '1.';107 assert.equal(masked.nearestInputPos(2, DIRECTION.NONE), 2);108 });109 it('should align before last fixed', function () {110 masked.updateOptions({111 mask: '0.',112 });113 masked.value = '1.';114 assert.equal(masked.nearestInputPos(2, DIRECTION.NONE), 1);115 });...

Full Screen

Full Screen

insert.js

Source:insert.js Github

copy

Full Screen

...7 mask: '',8 lazy: false,9 });10 beforeEach(function () {11 masked.updateOptions({mask: '', lazy: false});12 masked.unmaskedValue = '';13 });14 it('should skip empty and consider dot', function () {15 masked.updateOptions({mask: '0{.}0'});16 masked.unmaskedValue = '.2';17 assert.equal(masked.value, '_.2');18 });19 it('should skip empty and not consider dot', function () {20 masked.updateOptions({mask: '0.0'});21 masked.unmaskedValue = '.2';22 assert.equal(masked.value, '_._');23 });24 it('should skip in lazy mode', function () {25 ['0.0', '0{.}0'].forEach(mask => {26 masked.updateOptions({mask, lazy: true});27 masked.unmaskedValue = '.2';28 assert.equal(masked.value, '2');29 masked.value = '.2';30 assert.equal(masked.value, '2');31 });32 });33 it('should not skip empty', function () {34 ['0.0', '0{.}0'].forEach(mask => {35 masked.updateOptions({mask});36 masked.value = '.2';37 assert.equal(masked.value, '2._');38 });39 });40 it('should consider equal fixed and skip not equal fixed', function () {41 masked.updateOptions({mask: '+{7}(000)000-00-00'});42 masked.value = '+79998887766';43 assert.equal(masked.unmaskedValue, '79998887766');44 });45 it('should prepare value before insert', function () {46 const prepareStub = sinon.stub().returnsArg(0);47 masked.updateOptions({48 mask: '+{7}(000)000-00-00',49 prepare: prepareStub50 });51 masked.value = '+79998887766';52 assert(prepareStub.called);53 });54 it('should insert value in the middle', function () {55 masked.updateOptions({56 mask: '000',57 });58 masked.splice(1, 0, '1', DIRECTION.NONE);59 assert.equal(masked.value, '_1_');60 });61 it('should not skip blocks', function () {62 masked.updateOptions({63 mask: 'dw',64 lazy: true,65 blocks: {66 d: {67 mask: '00',68 },69 w: {70 mask: 'aa',71 },72 }73 });74 // should not jump over numbers75 masked.value = 'a';76 assert.equal(masked.value, '');77 });78 describe('RAW', function () {79 it('should set insert flag on fixed', function () {80 masked.updateOptions({mask: '+120'});81 masked.rawInputValue = '123';82 assert.equal(masked.rawInputValue, '123');83 masked.updateOptions({mask: '{+12}0'});84 masked.rawInputValue = '123';85 assert.equal(masked.rawInputValue, '123');86 });87 });...

Full Screen

Full Screen

SickBayMedicationScheduleControl.js

Source:SickBayMedicationScheduleControl.js Github

copy

Full Screen

1const moment = require('moment')2const sequelize = require(process.env.PWD + '/config/sequelize-connection')3const SickBayMedicationSchedule = require(process.env.PWD + '/models/SickBayMedicationSchedule')4function SickBayMedicationScheduleControl() {5 this.update = function(req, res, next) {6 let updateOptions = {}7 switch(req.body.Hr) {8 case 'Hr1':9 updateOptions.Ch1 = true10 updateOptions.ChdHr1 = moment().format('HH:mm:ss')11 updateOptions.Matricula1 = req.session.enrollment12 break;13 case 'Hr2':14 updateOptions.Ch2 = true15 updateOptions.ChdHr2 = moment().format('HH:mm:ss')16 updateOptions.Matricula2 = req.session.enrollment17 break;18 case 'Hr3':19 updateOptions.Ch3 = true20 updateOptions.ChdHr3 = moment().format('HH:mm:ss')21 updateOptions.Matricula3 = req.session.enrollment22 break;23 case 'Hr4':24 updateOptions.Ch4 = true25 updateOptions.ChdHr4 = moment().format('HH:mm:ss')26 updateOptions.Matricula4 = req.session.enrollment27 break;28 }29 SickBayMedicationSchedule.update(updateOptions, {30 where: {SickBayMedicationScheduleID : req.body.SickBayMedicationScheduleID}31 }).then(() => {32 next()33 }).catch(err => { next(err) })34 }35}...

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.screenshot({ path: `example.png` });7 await browser.close();8})();

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({ viewport: { width: 1280, height: 720 } });5 const page = await context.newPage();6 await page.screenshot({ path: `example.png` });7 await browser.close();8})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch({ headless: false });4 const context = await browser.newContext({ viewport: { width: 500, height: 500 } });5 const page = await context.newPage();6 await page.screenshot({ path: `example.png` });7 await browser.close();8})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch({4 });5 const context = await browser.newContext({6 });7 await context.updateOptions({8 });9 const page = await context.newPage();10 await browser.close();11})();12const { chromium } = require('playwright');13(async () => {14 const browser = await chromium.launch({15 });16 const context = await browser.newContext({17 });18 await context.updateOptions({19 });20 const page = await context.newPage();21 await browser.close();22})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch({4 });5 const context = await browser.newContext({6 });7 await context.updateOptions({8 });9 const page = await context.newPage();10 await browser.close();11})();12const { chromium } = require('playwright');13(async () => {14 const browser = await chromium.launch({15 });16 const context = await browser.newContext({17 });18 await context.updateOptions({19 });20 const page = await context.newPage();21 await browser.close();22})();

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 userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/90.0.4430.93 Safari/537.36'6 });7 const page = await context.newPage();8 await page.screenshot({ path: `full.png` });9 await browser.close();10})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright-chromium');2const browser = await chromium.launch({ headless: false, slowMo: 500 });3const context = await browser.newContext();4await context.updateOptions({ viewport: { width: 500, height: 500 } });5const page = await context.newPage();6const { chromium } = require('playwright-chromium');7const browser = await chromium.launch({ headless: false, slowMo: 500 });8const context = await browser.newContext();9await context.updateOptions({ viewport: { width: 500, height: 500 } });10const page = await context.newPage();11const { chromium } = require('playwright-chromium');12const browser = await chromium.launch({ headless: false, slowMo: 500 });13const context = await browser.newContext();14await context.updateOptions({ viewport: { width: 500, height: 500 } });15const page = await context.newPage();16const { chromium } = require('playwright-chromium');

Full Screen

Using AI Code Generation

copy

Full Screen

1const browser = await chromium.launch({ headless: false });2const context = await browser.newContext();3const page = await context.newPage();4await page.updateOptions({5 viewport: { width: 1000, height: 500 },6});7await page.screenshot({ path: 'example.png' });8await browser.close();9const browser = await chromium.launch({ headless: false });10const context = await browser.newContext();11const page = await context.newPage();12const element = await page.$('input[name="q"]');13await element.type('Hello World!');14await browser.close();15const browser = await chromium.launch({ headless: false });16const context = await browser.newContext();17const page = await context.newPage();18await page.type('input[name="q"]', 'Hello World!');19await browser.close();20const browser = await chromium.launch({ headless: false });21await browser.createContext();22await browser.close();23const browser = await chromium.launch({ headless: false });24const context = await browser.newContext();25await context.newPage();26await browser.close();27const browser = await chromium.launch({ headless: false });28await browser.launch();29await browser.close();30[MIT]( await chromium.launch({ headless: false, slowMo: 500 });31const context = await browser.newContext();32await context.updateOptions({ viewport: { width: 500, height: 500 } });33const page = await context.newPage();34const { chromium } = require('playwright-chromium');35const browser = await chromium.launch({ headless: false, slowMo: 500 });36const context = await browser.newContext();37await context.updateOptions({ viewport: { width: 500, height: 500 } });38const page = await context.newPage();39const { chromium } = require('playwright-chromium');40const browser = await chromium.launch({ headless:

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 userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/90.0.4430.93 Safari/537.36'6 });7 const page = await context.newPage();8 await page.screenshot({ path: `full.png` });9 await browser.close();10})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright-chromium');2const browser = await chromium.launch({ headless: false, slowMo: 500 });3const context = await browser.newContext();4await context.updateOptions({ viewport: { width: 500, height: 500 } });5const page = await context.newPage();6const { chromium } = require('playwright-chromium');7const browser = await chromium.launch({ headless: false, slowMo: 500 });8const context = await browser.newContext();9await context.updateOptions({ viewport: { width: 500, height: 500 } });10const page = await context.newPage();11const { chromium } = require('playwright-chromium');12const browser = await chromium.launch({ headless: false, slowMo: 500 });13const context = await browser.newContext();14await context.updateOptions({ viewport: { width: 500, height: 500 } });15const page = await context.newPage();16const { chromium } = require('playwright-chromium');17const browser = await chromium.launch({ headless: false, slowMo: 500 });18const context = await browser.newContext();19await context.updateOptions({ viewport: { width: 500, height: 500 } });20const page = await context.newPage();21const { chromium } = require('playwright-chromium');22const browser = await chromium.launch({ headless: false, slowMo: 500 });23const context = await browser.newContext();24await context.updateOptions({ viewport: { width: 500, height: 500 } });25const page = await context.newPage();26const { chromium } = require('playwright-chromium');27const browser = await chromium.launch({ headless:

Full Screen

Using AI Code Generation

copy

Full Screen

1const browser = await chromium.launch({ headless: false });2const context = await browser.newContext({ viewport: null });3const page = await context.newPage();4await page.evaluate(() => {5 window.playwright.updateOptions({6 viewport: { width: 500, height: 500 },7 });8});9await page.screenshot({ path: 'example.png' });10await browser.close();11### `updateOptions(options)`12[Apache-2.0](./LICENSE)

Full Screen

Using AI Code Generation

copy

Full Screen

1async function test() {2 const browser = await chromium.launch();3 const page = await browser.newPage();4 await page.updateOptions({ ignoreHTTPSErrors: true });5 await browser.close();6}7test();8#### `constructor(page, options)`9#### `updateOptions(options)`10#### `goto(url, options)`11#### `waitForNavigation(options)`12#### `waitForRequest(urlOrPredicate, options)`

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