How to use shuffle method in Playwright Internal

Best JavaScript code snippet using playwright-internal

jquery.shuffle.min.js

Source:jquery.shuffle.min.js Github

copy

Full Screen

...349 // We already got the container's width above, no need to cause another reflow getting it again...350 // Calculate the number of columns there will be351 this._setColumns( containerWidth );352 // Kick off!353 this.shuffle( this.group, this.initialSort );354 // The shuffle items haven't had transitions set on them yet355 // so the user doesn't see the first layout. Set them now that the first layout is done.356 if ( this.supported ) {357 defer(function() {358 this._setTransitions();359 this.element.style[ TRANSITION ] = 'height ' + this.speed + 'ms ' + this.easing;360 }, this);361 }362};363/**364 * Returns a throttled and proxied function for the resize handler.365 * @return {Function}366 * @private367 */368Shuffle.prototype._getResizeFunction = function() {369 var resizeFunction = $.proxy( this._onResize, this );370 return this.throttle ?371 this.throttle( resizeFunction, this.throttleTime ) :372 resizeFunction;373};374/**375 * Retrieve an element from an option.376 * @param {string|jQuery|Element} option The option to check.377 * @return {?Element} The plain element or null.378 * @private379 */380Shuffle.prototype._getElementOption = function( option ) {381 // If column width is a string, treat is as a selector and search for the382 // sizer element within the outermost container383 if ( typeof option === 'string' ) {384 return this.$el.find( option )[0] || null;385 // Check for an element386 } else if ( option && option.nodeType && option.nodeType === 1 ) {387 return option;388 // Check for jQuery object389 } else if ( option && option.jquery ) {390 return option[0];391 }392 return null;393};394/**395 * Ensures the shuffle container has the css styles it needs applied to it.396 * @param {Object} styles Key value pairs for position and overflow.397 * @private398 */399Shuffle.prototype._validateStyles = function(styles) {400 // Position cannot be static.401 if ( styles.position === 'static' ) {402 this.element.style.position = 'relative';403 }404 // Overflow has to be hidden405 if ( styles.overflow !== 'hidden' ) {406 this.element.style.overflow = 'hidden';407 }408};409/**410 * Filter the elements by a category.411 * @param {string} [category] Category to filter by. If it's given, the last412 * category will be used to filter the items.413 * @param {ArrayLike} [$collection] Optionally filter a collection. Defaults to414 * all the items.415 * @return {jQuery} Filtered items.416 * @private417 */418Shuffle.prototype._filter = function( category, $collection ) {419 category = category || this.lastFilter;420 $collection = $collection || this.$items;421 var set = this._getFilteredSets( category, $collection );422 // Individually add/remove concealed/filtered classes423 this._toggleFilterClasses( set.filtered, set.concealed );424 // Save the last filter in case elements are appended.425 this.lastFilter = category;426 // This is saved mainly because providing a filter function (like searching)427 // will overwrite the `lastFilter` property every time its called.428 if ( typeof category === 'string' ) {429 this.group = category;430 }431 return set.filtered;432};433/**434 * Returns an object containing the filtered and concealed elements.435 * @param {string|Function} category Category or function to filter by.436 * @param {ArrayLike.<Element>} $items A collection of items to filter.437 * @return {!{filtered: jQuery, concealed: jQuery}}438 * @private439 */440Shuffle.prototype._getFilteredSets = function( category, $items ) {441 var $filtered = $();442 var $concealed = $();443 // category === 'all', add filtered class to everything444 if ( category === ALL_ITEMS ) {445 $filtered = $items;446 // Loop through each item and use provided function to determine447 // whether to hide it or not.448 } else {449 each($items, function( el ) {450 var $item = $(el);451 if ( this._doesPassFilter( category, $item ) ) {452 $filtered = $filtered.add( $item );453 } else {454 $concealed = $concealed.add( $item );455 }456 }, this);457 }458 return {459 filtered: $filtered,460 concealed: $concealed461 };462};463/**464 * Test an item to see if it passes a category.465 * @param {string|Function} category Category or function to filter by.466 * @param {jQuery} $item A single item, wrapped with jQuery.467 * @return {boolean} Whether it passes the category/filter.468 * @private469 */470Shuffle.prototype._doesPassFilter = function( category, $item ) {471 if ( $.isFunction( category ) ) {472 return category.call( $item[0], $item, this );473 // Check each element's data-groups attribute against the given category.474 } else {475 var groups = $item.data( FILTER_ATTRIBUTE_KEY );476 var keys = this.delimeter && !$.isArray( groups ) ?477 groups.split( this.delimeter ) :478 groups;479 return $.inArray(category, keys) > -1;480 }481};482/**483 * Toggles the filtered and concealed class names.484 * @param {jQuery} $filtered Filtered set.485 * @param {jQuery} $concealed Concealed set.486 * @private487 */488Shuffle.prototype._toggleFilterClasses = function( $filtered, $concealed ) {489 $filtered490 .removeClass( Shuffle.ClassName.CONCEALED )491 .addClass( Shuffle.ClassName.FILTERED );492 $concealed493 .removeClass( Shuffle.ClassName.FILTERED )494 .addClass( Shuffle.ClassName.CONCEALED );495};496/**497 * Set the initial css for each item498 * @param {jQuery} [$items] Optionally specifiy at set to initialize499 */500Shuffle.prototype._initItems = function( $items ) {501 $items = $items || this.$items;502 $items.addClass([503 Shuffle.ClassName.SHUFFLE_ITEM,504 Shuffle.ClassName.FILTERED505 ].join(' '));506 $items.css( this.itemCss ).data('point', new Point()).data('scale', DEFAULT_SCALE);507};508/**509 * Updates the filtered item count.510 * @private511 */512Shuffle.prototype._updateItemCount = function() {513 this.visibleItems = this._getFilteredItems().length;514};515/**516 * Sets css transform transition on a an element.517 * @param {Element} element Element to set transition on.518 * @private519 */520Shuffle.prototype._setTransition = function( element ) {521 element.style[ TRANSITION ] = CSS_TRANSFORM + ' ' + this.speed + 'ms ' +522 this.easing + ', opacity ' + this.speed + 'ms ' + this.easing;523};524/**525 * Sets css transform transition on a group of elements.526 * @param {ArrayLike.<Element>} $items Elements to set transitions on.527 * @private528 */529Shuffle.prototype._setTransitions = function( $items ) {530 $items = $items || this.$items;531 each($items, function( el ) {532 this._setTransition( el );533 }, this);534};535/**536 * Sets a transition delay on a collection of elements, making each delay537 * greater than the last.538 * @param {ArrayLike.<Element>} $collection Array to iterate over.539 */540Shuffle.prototype._setSequentialDelay = function( $collection ) {541 if ( !this.supported ) {542 return;543 }544 // $collection can be an array of dom elements or jquery object545 each($collection, function( el, i ) {546 // This works because the transition-property: transform, opacity;547 el.style[ TRANSITION_DELAY ] = '0ms,' + ((i + 1) * this.sequentialFadeDelay) + 'ms';548 }, this);549};550Shuffle.prototype._getItems = function() {551 return this.$el.children( this.itemSelector );552};553Shuffle.prototype._getFilteredItems = function() {554 return this.$items.filter('.' + Shuffle.ClassName.FILTERED);555};556Shuffle.prototype._getConcealedItems = function() {557 return this.$items.filter('.' + Shuffle.ClassName.CONCEALED);558};559/**560 * Returns the column size, based on column width and sizer options.561 * @param {number} containerWidth Size of the parent container.562 * @param {number} gutterSize Size of the gutters.563 * @return {number}564 * @private565 */566Shuffle.prototype._getColumnSize = function( containerWidth, gutterSize ) {567 var size;568 // If the columnWidth property is a function, then the grid is fluid569 if ( $.isFunction( this.columnWidth ) ) {570 size = this.columnWidth(containerWidth);571 // columnWidth option isn't a function, are they using a sizing element?572 } else if ( this.useSizer ) {573 size = Shuffle._getOuterWidth(this.sizer);574 // if not, how about the explicitly set option?575 } else if ( this.columnWidth ) {576 size = this.columnWidth;577 // or use the size of the first item578 } else if ( this.$items.length > 0 ) {579 size = Shuffle._getOuterWidth(this.$items[0], true);580 // if there's no items, use size of container581 } else {582 size = containerWidth;583 }584 // Don't let them set a column width of zero.585 if ( size === 0 ) {586 size = containerWidth;587 }588 return size + gutterSize;589};590/**591 * Returns the gutter size, based on gutter width and sizer options.592 * @param {number} containerWidth Size of the parent container.593 * @return {number}594 * @private595 */596Shuffle.prototype._getGutterSize = function( containerWidth ) {597 var size;598 if ( $.isFunction( this.gutterWidth ) ) {599 size = this.gutterWidth(containerWidth);600 } else if ( this.useSizer ) {601 size = Shuffle._getNumberStyle(this.sizer, 'marginLeft');602 } else {603 size = this.gutterWidth;604 }605 return size;606};607/**608 * Calculate the number of columns to be used. Gets css if using sizer element.609 * @param {number} [theContainerWidth] Optionally specify a container width if it's already available.610 */611Shuffle.prototype._setColumns = function( theContainerWidth ) {612 var containerWidth = theContainerWidth || Shuffle._getOuterWidth( this.element );613 var gutter = this._getGutterSize( containerWidth );614 var columnWidth = this._getColumnSize( containerWidth, gutter );615 var calculatedColumns = (containerWidth + gutter) / columnWidth;616 // Widths given from getComputedStyle are not precise enough...617 if ( Math.abs(Math.round(calculatedColumns) - calculatedColumns) < COLUMN_THRESHOLD ) {618 // e.g. calculatedColumns = 11.998876619 calculatedColumns = Math.round( calculatedColumns );620 }621 this.cols = Math.max( Math.floor(calculatedColumns), 1 );622 this.containerWidth = containerWidth;623 this.colWidth = columnWidth;624};625/**626 * Adjust the height of the grid627 */628Shuffle.prototype._setContainerSize = function() {629 this.$el.css( 'height', this._getContainerSize() );630};631/**632 * Based on the column heights, it returns the biggest one.633 * @return {number}634 * @private635 */636Shuffle.prototype._getContainerSize = function() {637 return arrayMax( this.positions );638};639/**640 * Fire events with .shuffle namespace641 */642Shuffle.prototype._fire = function( name, args ) {643 this.$el.trigger( name + '.' + SHUFFLE, args && args.length ? args : [ this ] );644};645/**646 * Zeros out the y columns array, which is used to determine item placement.647 * @private648 */649Shuffle.prototype._resetCols = function() {650 var i = this.cols;651 this.positions = [];652 while (i--) {653 this.positions.push( 0 );654 }655};656/**657 * Loops through each item that should be shown and calculates the x, y position.658 * @param {Array.<Element>} items Array of items that will be shown/layed out in order in their array.659 * Because jQuery collection are always ordered in DOM order, we can't pass a jq collection.660 * @param {boolean} [isOnlyPosition=false] If true this will position the items with zero opacity.661 */662Shuffle.prototype._layout = function( items, isOnlyPosition ) {663 each(items, function( item ) {664 this._layoutItem( item, !!isOnlyPosition );665 }, this);666 // `_layout` always happens after `_shrink`, so it's safe to process the style667 // queue here with styles from the shrink method.668 this._processStyleQueue();669 // Adjust the height of the container.670 this._setContainerSize();671};672/**673 * Calculates the position of the item and pushes it onto the style queue.674 * @param {Element} item Element which is being positioned.675 * @param {boolean} isOnlyPosition Whether to position the item, but with zero676 * opacity so that it can fade in later.677 * @private678 */679Shuffle.prototype._layoutItem = function( item, isOnlyPosition ) {680 var $item = $(item);681 var itemData = $item.data();682 var currPos = itemData.point;683 var currScale = itemData.scale;684 var itemSize = {685 width: Shuffle._getOuterWidth( item, true ),686 height: Shuffle._getOuterHeight( item, true )687 };688 var pos = this._getItemPosition( itemSize );689 // If the item will not change its position, do not add it to the render690 // queue. Transitions don't fire when setting a property to the same value.691 if ( Point.equals(currPos, pos) && currScale === DEFAULT_SCALE ) {692 return;693 }694 // Save data for shrink695 itemData.point = pos;696 itemData.scale = DEFAULT_SCALE;697 this.styleQueue.push({698 $item: $item,699 point: pos,700 scale: DEFAULT_SCALE,701 opacity: isOnlyPosition ? 0 : 1,702 skipTransition: isOnlyPosition,703 callfront: function() {704 if ( !isOnlyPosition ) {705 $item.css( 'visibility', 'visible' );706 }707 },708 callback: function() {709 if ( isOnlyPosition ) {710 $item.css( 'visibility', 'hidden' );711 }712 }713 });714};715/**716 * Determine the location of the next item, based on its size.717 * @param {{width: number, height: number}} itemSize Object with width and height.718 * @return {Point}719 * @private720 */721Shuffle.prototype._getItemPosition = function( itemSize ) {722 var columnSpan = this._getColumnSpan( itemSize.width, this.colWidth, this.cols );723 var setY = this._getColumnSet( columnSpan, this.cols );724 // Finds the index of the smallest number in the set.725 var shortColumnIndex = this._getShortColumn( setY, this.buffer );726 // Position the item727 var point = new Point(728 Math.round( this.colWidth * shortColumnIndex ),729 Math.round( setY[shortColumnIndex] ));730 // Update the columns array with the new values for each column.731 // e.g. before the update the columns could be [250, 0, 0, 0] for an item732 // which spans 2 columns. After it would be [250, itemHeight, itemHeight, 0].733 var setHeight = setY[shortColumnIndex] + itemSize.height;734 var setSpan = this.cols + 1 - setY.length;735 for ( var i = 0; i < setSpan; i++ ) {736 this.positions[ shortColumnIndex + i ] = setHeight;737 }738 return point;739};740/**741 * Determine the number of columns an items spans.742 * @param {number} itemWidth Width of the item.743 * @param {number} columnWidth Width of the column (includes gutter).744 * @param {number} columns Total number of columns745 * @return {number}746 * @private747 */748Shuffle.prototype._getColumnSpan = function( itemWidth, columnWidth, columns ) {749 var columnSpan = itemWidth / columnWidth;750 // If the difference between the rounded column span number and the751 // calculated column span number is really small, round the number to752 // make it fit.753 if ( Math.abs(Math.round( columnSpan ) - columnSpan ) < COLUMN_THRESHOLD ) {754 // e.g. columnSpan = 4.0089945390298745755 columnSpan = Math.round( columnSpan );756 }757 // Ensure the column span is not more than the amount of columns in the whole layout.758 return Math.min( Math.ceil( columnSpan ), columns );759};760/**761 * Retrieves the column set to use for placement.762 * @param {number} columnSpan The number of columns this current item spans.763 * @param {number} columns The total columns in the grid.764 * @return {Array.<number>} An array of numbers represeting the column set.765 * @private766 */767Shuffle.prototype._getColumnSet = function( columnSpan, columns ) {768 // The item spans only one column.769 if ( columnSpan === 1 ) {770 return this.positions;771 // The item spans more than one column, figure out how many different772 // places it could fit horizontally.773 // The group count is the number of places within the positions this block774 // could fit, ignoring the current positions of items.775 // Imagine a 2 column brick as the second item in a 4 column grid with776 // 10px height each. Find the places it would fit:777 // [10, 0, 0, 0]778 // | | |779 // * * *780 //781 // Then take the places which fit and get the bigger of the two:782 // max([10, 0]), max([0, 0]), max([0, 0]) = [10, 0, 0]783 //784 // Next, find the first smallest number (the short column).785 // [10, 0, 0]786 // |787 // *788 //789 // And that's where it should be placed!790 } else {791 var groupCount = columns + 1 - columnSpan;792 var groupY = [];793 // For how many possible positions for this item there are.794 for ( var i = 0; i < groupCount; i++ ) {795 // Find the bigger value for each place it could fit.796 groupY[i] = arrayMax( this.positions.slice( i, i + columnSpan ) );797 }798 return groupY;799 }800};801/**802 * Find index of short column, the first from the left where this item will go.803 *804 * @param {Array.<number>} positions The array to search for the smallest number.805 * @param {number} buffer Optional buffer which is very useful when the height806 * is a percentage of the width.807 * @return {number} Index of the short column.808 * @private809 */810Shuffle.prototype._getShortColumn = function( positions, buffer ) {811 var minPosition = arrayMin( positions );812 for (var i = 0, len = positions.length; i < len; i++) {813 if ( positions[i] >= minPosition - buffer && positions[i] <= minPosition + buffer ) {814 return i;815 }816 }817 return 0;818};819/**820 * Hides the elements that don't match our filter.821 * @param {jQuery} $collection jQuery collection to shrink.822 * @private823 */824Shuffle.prototype._shrink = function( $collection ) {825 var $concealed = $collection || this._getConcealedItems();826 each($concealed, function( item ) {827 var $item = $(item);828 var itemData = $item.data();829 // Continuing would add a transitionend event listener to the element, but830 // that listener would not execute because the transform and opacity would831 // stay the same.832 if ( itemData.scale === CONCEALED_SCALE ) {833 return;834 }835 itemData.scale = CONCEALED_SCALE;836 this.styleQueue.push({837 $item: $item,838 point: itemData.point,839 scale : CONCEALED_SCALE,840 opacity: 0,841 callback: function() {842 $item.css( 'visibility', 'hidden' );843 }844 });845 }, this);846};847/**848 * Resize handler.849 * @private850 */851Shuffle.prototype._onResize = function() {852 // If shuffle is disabled, destroyed, don't do anything853 if ( !this.enabled || this.destroyed || this.isTransitioning ) {854 return;855 }856 // Will need to check height in the future if it's layed out horizontaly857 var containerWidth = Shuffle._getOuterWidth( this.element );858 // containerWidth hasn't changed, don't do anything859 if ( containerWidth === this.containerWidth ) {860 return;861 }862 this.update();863};864/**865 * Returns styles for either jQuery animate or transition.866 * @param {Object} opts Transition options.867 * @return {!Object} Transforms for transitions, left/top for animate.868 * @private869 */870Shuffle.prototype._getStylesForTransition = function( opts ) {871 var styles = {872 opacity: opts.opacity873 };874 if ( this.supported ) {875 styles[ TRANSFORM ] = Shuffle._getItemTransformString( opts.point, opts.scale );876 } else {877 styles.left = opts.point.x;878 styles.top = opts.point.y;879 }880 return styles;881};882/**883 * Transitions an item in the grid884 *885 * @param {Object} opts options.886 * @param {jQuery} opts.$item jQuery object representing the current item.887 * @param {Point} opts.point A point object with the x and y coordinates.888 * @param {number} opts.scale Amount to scale the item.889 * @param {number} opts.opacity Opacity of the item.890 * @param {Function} opts.callback Complete function for the animation.891 * @param {Function} opts.callfront Function to call before transitioning.892 * @private893 */894Shuffle.prototype._transition = function( opts ) {895 var styles = this._getStylesForTransition( opts );896 this._startItemAnimation( opts.$item, styles, opts.callfront || $.noop, opts.callback || $.noop );897};898Shuffle.prototype._startItemAnimation = function( $item, styles, callfront, callback ) {899 // Transition end handler removes its listener.900 function handleTransitionEnd( evt ) {901 // Make sure this event handler has not bubbled up from a child.902 if ( evt.target === evt.currentTarget ) {903 $( evt.target ).off( TRANSITIONEND, handleTransitionEnd );904 callback();905 }906 }907 callfront();908 // Transitions are not set until shuffle has loaded to avoid the initial transition.909 if ( !this.initialized ) {910 $item.css( styles );911 callback();912 return;913 }914 // Use CSS Transforms if we have them915 if ( this.supported ) {916 $item.css( styles );917 $item.on( TRANSITIONEND, handleTransitionEnd );918 // Use jQuery to animate left/top919 } else {920 // Save the deferred object which jQuery returns.921 var anim = $item.stop( true ).animate( styles, this.speed, 'swing', callback );922 // Push the animation to the list of pending animations.923 this._animations.push( anim.promise() );924 }925};926/**927 * Execute the styles gathered in the style queue. This applies styles to elements,928 * triggering transitions.929 * @param {boolean} noLayout Whether to trigger a layout event.930 * @private931 */932Shuffle.prototype._processStyleQueue = function( noLayout ) {933 var $transitions = $();934 // Iterate over the queue and keep track of ones that use transitions.935 each(this.styleQueue, function( transitionObj ) {936 if ( transitionObj.skipTransition ) {937 this._styleImmediately( transitionObj );938 } else {939 $transitions = $transitions.add( transitionObj.$item );940 this._transition( transitionObj );941 }942 }, this);943 if ( $transitions.length > 0 && this.initialized ) {944 // Set flag that shuffle is currently in motion.945 this.isTransitioning = true;946 if ( this.supported ) {947 this._whenCollectionDone( $transitions, TRANSITIONEND, this._movementFinished );948 // The _transition function appends a promise to the animations array.949 // When they're all complete, do things.950 } else {951 this._whenAnimationsDone( this._movementFinished );952 }953 // A call to layout happened, but none of the newly filtered items will954 // change position. Asynchronously fire the callback here.955 } else if ( !noLayout ) {956 defer( this._layoutEnd, this );957 }958 // Remove everything in the style queue959 this.styleQueue.length = 0;960};961/**962 * Apply styles without a transition.963 * @param {Object} opts Transitions options object.964 * @private965 */966Shuffle.prototype._styleImmediately = function( opts ) {967 Shuffle._skipTransition(opts.$item[0], function() {968 opts.$item.css( this._getStylesForTransition( opts ) );969 }, this);970};971Shuffle.prototype._movementFinished = function() {972 this.isTransitioning = false;973 this._layoutEnd();974};975Shuffle.prototype._layoutEnd = function() {976 this._fire( Shuffle.EventType.LAYOUT );977};978Shuffle.prototype._addItems = function( $newItems, addToEnd, isSequential ) {979 // Add classes and set initial positions.980 this._initItems( $newItems );981 // Add transition to each item.982 this._setTransitions( $newItems );983 // Update the list of984 this.$items = this._getItems();985 // Shrink all items (without transitions).986 this._shrink( $newItems );987 each(this.styleQueue, function( transitionObj ) {988 transitionObj.skipTransition = true;989 });990 // Apply shrink positions, but do not cause a layout event.991 this._processStyleQueue( true );992 if ( addToEnd ) {993 this._addItemsToEnd( $newItems, isSequential );994 } else {995 this.shuffle( this.lastFilter );996 }997};998Shuffle.prototype._addItemsToEnd = function( $newItems, isSequential ) {999 // Get ones that passed the current filter1000 var $passed = this._filter( null, $newItems );1001 var passed = $passed.get();1002 // How many filtered elements?1003 this._updateItemCount();1004 this._layout( passed, true );1005 if ( isSequential && this.supported ) {1006 this._setSequentialDelay( passed );1007 }1008 this._revealAppended( passed );1009};...

Full Screen

Full Screen

swizzle-shuffle.js

Source:swizzle-shuffle.js Github

copy

Full Screen

...259 assertEq(lanes, 16);260 lhs = type(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);261 rhs = type(17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32);262 }263 assertThrowsInstanceOf(() => type.shuffle(lhs) , TypeError);264 assertThrowsInstanceOf(() => type.shuffle(lhs, rhs) , TypeError);265 assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0) , TypeError);266 assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 1, 2) , TypeError);267 assertThrowsInstanceOf(() => type.shuffle(lhs, 0, 1, 2, 7, rhs) , TypeError);268 // Test all possible shuffles.269 var x, y, z, w;270 if (lanes == 2) {271 var x, y;272 for (var i = 0; i < Math.pow(4, 2); i++) {273 [x, y] = [i & 3, (i >> 3) & 3];274 assertEqVec(type.shuffle(lhs, rhs, x, y),275 shuffle2(simdToArray(lhs), simdToArray(rhs), x, y));276 }277 } else if (lanes == 4) {278 var x, y, z, w;279 for (var i = 0; i < Math.pow(8, 4); i++) {280 [x, y, z, w] = [i & 7, (i >> 3) & 7, (i >> 6) & 7, (i >> 9) & 7];281 assertEqVec(type.shuffle(lhs, rhs, x, y, z, w),282 shuffle4(simdToArray(lhs), simdToArray(rhs), x, y, z, w));283 }284 } else if (lanes == 8) {285 var s0, s1, s2, s3, s4, s5, s6, s7;286 var vals = [[15, 8, 15, 8, 15, 8, 15, 8], [9, 7, 9, 7, 9, 7, 9, 7],287 [7, 3, 8, 9, 2, 15, 14, 6], [2, 2, 2, 2, 2, 2, 2, 2],288 [8, 8, 8, 8, 8, 8, 8, 8], [11, 11, 11, 11, 11, 11, 11, 11]];289 for (var t of vals) {290 [s0, s1, s2, s3, s4, s5, s6, s7] = t;291 assertEqVec(type.shuffle(lhs, rhs, s0, s1, s2, s3, s4, s5, s6, s7),292 shuffle8(simdToArray(lhs), simdToArray(rhs), s0, s1, s2, s3, s4, s5, s6, s7));293 }294 } else {295 assertEq(lanes, 16);296 var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15;297 var vals = [[30, 16, 30, 16, 30, 16, 30, 16, 30, 16, 30, 16, 30, 16, 30, 16],298 [19, 17, 19, 17, 19, 17, 19, 17, 19, 17, 19, 17, 19, 17, 19, 17],299 [7, 3, 8, 18, 9, 21, 2, 15, 14, 6, 16, 22, 29, 31, 30, 1],300 [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],301 [16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16],302 [21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21]];303 for (var t of vals) {304 [s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15] = t;305 assertEqVec(type.shuffle(lhs, rhs, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15),306 shuffle16(simdToArray(lhs), simdToArray(rhs), s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15));307 }308 }309 // Test that we throw if an lane argument isn't an int32 or isn't in bounds.310 if (lanes == 2) {311 assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 0.5), RangeError);312 assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, {}), RangeError);313 assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, {valueOf: function(){return 42}}), RangeError);314 assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, "one"), RangeError);315 assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, undefined), RangeError);316 // In bounds is [0, 3]317 assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, -1), RangeError);318 assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 4), RangeError);319 } else if (lanes == 4) {320 assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 0, 0, 0.5), RangeError);321 assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 0, 0, {}), RangeError);322 assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 0, 0, {valueOf: function(){return 42}}), RangeError);323 assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 0, 0, "one"), RangeError);324 assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 0, 0, undefined), RangeError);325 // In bounds is [0, 7]326 assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 0, 0, -1), RangeError);327 assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 0, 0, 8), RangeError);328 } else if (lanes == 8) {329 assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 0, 0, 0, 0, 0, 0, 0.5), RangeError);330 assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 0, 0, 0, 0, 0, 0, {}), RangeError);331 assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 0, 0, 0, 0, 0, 0, {valueOf: function(){return 42}}), RangeError);332 assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 0, 0, 0, 0, 0, 0, "one"), RangeError);333 assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 0, 0, 0, 0, 0, 0, undefined), RangeError);334 // In bounds is [0, 15]335 assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 0, 0, 0, 0, 0, 0, -1), RangeError);336 assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 0, 0, 0, 0, 0, 0, 16), RangeError);337 } else {338 assertEq(lanes, 16);339 assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.5), RangeError);340 assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {}), RangeError);341 assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {valueOf: function(){return 42}}), RangeError);342 assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "one"), RangeError);343 assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, undefined), RangeError);344 // In bounds is [0, 31]345 assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1), RangeError);346 assertThrowsInstanceOf(() => type.shuffle(lhs, rhs, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32), RangeError);347 }348}349function testShuffleInt8x16() {350 var v = Int16x8(1, 2, 3, 4, 5, 6, 7, 8);351 assertThrowsInstanceOf(function() {352 Int8x16.shuffle(v, v, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);353 }, TypeError);354 testShuffleForType(Int8x16);355}356function testShuffleInt16x8() {357 var v = Int8x16(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);358 assertThrowsInstanceOf(function() {359 Int16x8.shuffle(v, v, 0, 0, 0, 0, 0, 0, 0, 0);360 }, TypeError);361 testShuffleForType(Int16x8);362}363function testShuffleInt32x4() {364 var v = Int32x4(1, 2, 3, 4);365 assertThrowsInstanceOf(function() {366 Float32x4.shuffle(v, v, 0, 0, 0, 0);367 }, TypeError);368 testShuffleForType(Int32x4);369}370function testShuffleUint8x16() {371 var v = Uint16x8(1, 2, 3, 4, 5, 6, 7, 8);372 assertThrowsInstanceOf(function() {373 Uint8x16.shuffle(v, v, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);374 }, TypeError);375 testShuffleForType(Uint8x16);376}377function testShuffleUint16x8() {378 var v = Uint8x16(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);379 assertThrowsInstanceOf(function() {380 Uint16x8.shuffle(v, v, 0, 0, 0, 0, 0, 0, 0, 0);381 }, TypeError);382 testShuffleForType(Uint16x8);383}384function testShuffleUint32x4() {385 var v = Uint32x4(1, 2, 3, 4);386 assertThrowsInstanceOf(function() {387 Float32x4.shuffle(v, v, 0, 0, 0, 0);388 }, TypeError);389 testShuffleForType(Uint32x4);390}391function testShuffleFloat32x4() {392 var v = Float32x4(1, 2, 3, 4);393 assertThrowsInstanceOf(function() {394 Int32x4.shuffle(v, v, 0, 0, 0, 0);395 }, TypeError);396 testShuffleForType(Float32x4);397}398function testShuffleFloat64x2() {399 var v = Float64x2(1, 2);400 assertThrowsInstanceOf(function() {401 Float32x4.shuffle(v, v, 0, 0, 0, 0);402 }, TypeError);403 testShuffleForType(Float64x2);404}405testSwizzleInt8x16();406testSwizzleInt16x8();407testSwizzleInt32x4();408testSwizzleUint8x16();409testSwizzleUint16x8();410testSwizzleUint32x4();411testSwizzleFloat32x4();412testSwizzleFloat64x2();413testShuffleInt8x16();414testShuffleInt16x8();415testShuffleInt32x4();...

Full Screen

Full Screen

DBCreatePlaylist.js

Source:DBCreatePlaylist.js Github

copy

Full Screen

1let G_ResultMediaElements = [];2let G_CurrentMediaElementIndex = 0;3let G_ShuffledMediaElementsIndex = [];4let G_ShouldShuffle = false;5let G_CurrentPlayingElement = null;6function DBSite_ContinueMediaQueue(CurrentPlayingElement)7{8 let ElementToPlay = null;9 if(G_ShouldShuffle == false)10 {11 let ElementIndex = 0;12 if(CurrentPlayingElement != null)13 {14 for(let i = 0;i < G_ResultMediaElements.length;i++)15 {16 if(G_ResultMediaElements[i] == CurrentPlayingElement)17 {18 ElementIndex = i+1;19 break;20 }21 }22 }23 if(ElementIndex < G_ResultMediaElements.length)24 {25 ElementToPlay = G_ResultMediaElements[ElementIndex];26 }27 }28 else29 {30 if(G_ShuffledMediaElementsIndex.length > 0)31 {32 let ElementToPlayIndex = G_ShuffledMediaElementsIndex.pop();33 ElementToPlay = G_ResultMediaElements[ElementToPlayIndex];34 }35 }36 G_CurrentPlayingElement = ElementToPlay;37 if(ElementToPlay != null)38 {39 ElementToPlay.currentTime = 0;40 ElementToPlay.play();41 }42}43function DBSite_MediaFinishedCallback(e)44{45 DBSite_ContinueMediaQueue(e.target);46}47function DBSite_PlaybuttonCallback(e)48{49 if(G_CurrentPlayingElement != null)50 {51 if(G_CurrentPlayingElement.paused)52 {53 G_CurrentPlayingElement.play();54 }55 else56 {57 G_CurrentPlayingElement.pause();58 }59 }60}61function DBSite_SkipbuttonCallback(e)62{63 if(G_CurrentPlayingElement != null)64 {65 G_CurrentPlayingElement.pause();66 }67 DBSite_ContinueMediaQueue(G_CurrentPlayingElement);68}69function DBSite_ShuffleCheckboxCallback(e)70{71 console.log("Kommer hit");72 if(e.target.checked)73 {74 G_ShouldShuffle = true;75 }76 else77 {78 G_ShouldShuffle = false;79 }80}81function DBSite_CreateMediaElementsControl()82{83 let ElementsControl = document.createElement("div");84 let ElementControlsWidth = 200;85 let ElementControlsHeight = 50;86 let ElementControlStyleString = "position: fixed; border: 3px solid #00FF00; width: " +ElementControlsWidth.toString()+"px; height: " +ElementControlsHeight.toString()+"px; bottom: 0; right: 50%; background: #000000;";87 ElementsControl.style = ElementControlStyleString;88 console.log(ElementControlStyleString);89 let PlayButton = document.createElement("button");90 PlayButton.classList = "MBButton";91 PlayButton.style.position = "relative";92 PlayButton.style.height = "50%";93 PlayButton.style.marginLeft = "20px";94 PlayButton.style.width = (ElementControlsHeight/2).toString()+"px";95 //PlayButton.style.marginLeft = "-"+(ElementControlsHeight/4).toString()+"px";96 PlayButton.style.top = "50%";97 PlayButton.style.marginTop = "-7.5%";98 PlayButton.innerHTML = "&#x23F8";99 PlayButton.addEventListener("click",DBSite_PlaybuttonCallback);100 let SkipButton = document.createElement("button");101 SkipButton.classList = "MBButton";102 SkipButton.style.position = "relative";103 SkipButton.style.height = "50%";104 SkipButton.style.marginLeft = "20px";105 SkipButton.style.width = (ElementControlsHeight/2).toString()+"px";106 SkipButton.style.top = "50%";107 SkipButton.style.marginTop = "-7.5%";108 SkipButton.innerHTML = "&#x23ED";109 SkipButton.addEventListener("click",DBSite_SkipbuttonCallback);110 let ShuffleDiv = document.createElement("div");111 ShuffleDiv.style.marginLeft = (ElementControlsHeight/2*2+20*3).toString()+"px";112 let ShuffleCheckbox = document.createElement("input");113 ShuffleCheckbox.type = "checkbox";114 ShuffleCheckbox.id = "Shuffle";115 ShuffleCheckbox.addEventListener("change",DBSite_ShuffleCheckboxCallback);116 let ShuffleCheckboxLabel = document.createElement("label");117 ShuffleCheckboxLabel.for = "Shuffle";118 ShuffleCheckboxLabel.innerHTML = "Shuffle";119 ShuffleDiv.appendChild(ShuffleCheckbox);120 ShuffleDiv.appendChild(ShuffleCheckboxLabel);121 ElementsControl.appendChild(PlayButton);122 ElementsControl.appendChild(SkipButton);123 ElementsControl.appendChild(ShuffleDiv);124 //ElementsControl.appendChild(ShuffleCheckbox);125 //ElementsControl.appendChild(ShuffleCheckboxLabel);126 document.body.appendChild(ElementsControl);127}128function DBSite_CreateMediaElementPlaylist()129{130 G_ResultMediaElements = [];131 G_CurrentMediaElementIndex = 0;132 G_ShuffledMediaElementsIndex = [];133 let AllNodes = document.body.getElementsByTagName("*");134 for(let i = 0; i < AllNodes.length; i++)135 {136 if(AllNodes[i] instanceof HTMLMediaElement)137 {138 AllNodes[i].addEventListener('ended',DBSite_MediaFinishedCallback);139 G_ShuffledMediaElementsIndex.push(G_ResultMediaElements.length);140 G_ResultMediaElements.push(AllNodes[i]);141 }142 }143 if(G_ResultMediaElements.length != 0)144 {145 ShuffleArray(G_ShuffledMediaElementsIndex);146 DBSite_CreateMediaElementsControl();147 }148};...

Full Screen

Full Screen

PromoShuffleComponent.jsx

Source:PromoShuffleComponent.jsx Github

copy

Full Screen

...18 const [shuffleStart, setShuffleStart] = useState(false);19 const [shuffleDone, setshuffleDone] = useState(false);20 const [shuffleResult, setShuffleResult] = useState();21 const cards = getCardProps();22 function shuffle() {23 setShuffleStart(true);24 const shuffleSpeed = 250;25 shuffling(2);26 function shuffling(currentShuffle) {27 currentShuffle--;28 for (let i = 1; i <= cards.length; i++) {29 setTimeout(() => {30 setShuffleIndex(i - 1);31 if (i === cards.length && currentShuffle !== 0) {32 setTimeout(shuffling(currentShuffle), shuffleSpeed);33 } else if (i === cards.length && currentShuffle === 0) {34 setTimeout(shufflingDone(), shuffleSpeed);35 }36 }, i * shuffleSpeed);37 }38 }39 function shufflingDone() {40 const result = cards[Math.floor(Math.random() * cards.length)];41 setShuffleResult(result);42 setshuffleDone(true);43 }44 }45 useEffect(() => {46 if (reset) {47 setShuffleStart(false);48 setshuffleDone(false);49 setShuffleResult(null);50 }51 return () => {52 setReset(false);53 };54 }, [reset, setReset]);55 return (56 <Container57 sx={{ height: "calc(100vh - 56px)", position: "relative", top: "56px" }}58 className={styles.imageFadeIn}59 >60 <Toolbar />61 <Grid62 container63 justifyContent="center"64 alignItems="center"65 alignContent={shuffleStart && shuffleDone ? "center" : null}66 sx={{ height: "75%" }}67 >68 <Grid69 item70 xs="auto"71 sm={6}>72 {shuffleDone ? (73 shuffleResult ? (74 <Box75 className={styles.imageFadeIn}76 sx={{ width: "345px" }}>77 <PromoCard78 title={shuffleResult.title}79 description={shuffleResult.description}80 image={shuffleResult.image}81 />82 </Box>83 ) : null84 ) : shuffleStart ? (85 <Box sx={{ overflow: "hidden" }}>86 {cards.map((c, i) => {87 return i === shuffleIndex ? (88 <Box89 key={`box${i}`}90 className={styles.imageSlide}91 sx={{ width: "345px" }}92 >93 <PromoCard94 key={`card${i}`}95 title={c.title}96 description={c.description}97 image={c.image}98 />99 </Box>100 ) : null;101 })}102 </Box>103 ) : (104 <Carousel105 showIndicators={false}106 showStatus={false}107 infiniteLoop={true}108 autoPlay={true}109 showThumbs={false}110 width={345}111 interval={3000}112 >113 {cards.map((c, i) => {114 return (115 <PromoCard116 key={`card${i}`}117 title={c.title}118 description={c.description}119 image={c.image}120 />121 );122 })}123 </Carousel>124 )}125 </Grid>126 <Grid127 textAlign="center"128 item129 xs="auto"130 sm={shuffleStart && shuffleDone ? 0 : 6}131 >132 {shuffleStart ? (133 shuffleDone ? null : (134 <Box sx={{ width: 125, height: 65, margin: "auto" }}>135 <CircularProgress color="secondary" />136 </Box>137 )138 ) : (139 <Box sx={{ width: 125, height: 65, margin: "auto" }}>140 <Button141 sx={{ width: 125, height: 65 }}142 size="large"143 color="secondary"144 variant="contained"145 onClick={() => {146 shuffle();147 }}148 >149 <CardGiftcardIcon />150 </Button>151 </Box>152 )}153 </Grid>154 </Grid>155 </Container>156 );...

Full Screen

Full Screen

script.js

Source:script.js Github

copy

Full Screen

1const fs = require("fs");2// const ndOps = require("ndarray-ops");3const ndarrayPack = require("ndarray-pack");4const ndarrayUnpack = require("ndarray-unpack");5const getPixels = require('get-pixels');6const savePixels = require('save-pixels');7// const pool = require("ndarray-scratch")8const SLICES = [47, 43, 41, 37, 31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2];9// const SLICES = [2,3,5,7];10// const SLICES = [7,5,3,2];11const IN = "./src/defis/kakawouette/succeeded/cryptimagemelange/in.png";12const OUT = "./src/defis/kakawouette/succeeded/cryptimagemelange/out.png";13// const IN = "./src/defis/kakawouette/succeeded/cryptimagemelange/in_sample.png";14// const OUT = "./src/defis/kakawouette/succeeded/cryptimagemelange/out_sample.png";15const DEBUG_OUT = "./src/defis/kakawouette/succeeded/cryptimagemelange/debug";16function computeSens(sens){17 if(sens === 'H'){18 return sens = 'V';19 }else{20 return sens = 'H';21 }22}23function copyImage(dest,source,offsetX,offsetY){24 //Get array shape25 var nx = source.shape[0],26 ny = source.shape[1];27 //Loop over all cells28 for(var x=0; x<nx; ++x) {29 for(var y=0; y<ny; ++y) {30 dest.set(offsetX + x, offsetY + y, 0, source.get(x, y, 0));31 dest.set(offsetX + x, offsetY + y, 1, source.get(x, y, 1));32 dest.set(offsetX + x, offsetY + y, 2, source.get(x, y, 2));33 dest.set(offsetX + x, offsetY + y, 3, 255);34 }35 }36}37function shuffleImage(pixels,horizontal) {38 const width = pixels.shape[0];39 const height = pixels.shape[1];40 let tmp = [];41 let lastSlice = 0;42 SLICES.forEach((slice) => {43 const pixelObj = {44 slice,45 lastSlice: lastSlice,46 pixels:47 ndarrayPack(48 ndarrayUnpack(49 pixels.lo(50 horizontal ? lastSlice : 0,51 !horizontal ? lastSlice : 052 ).hi(53 horizontal ? slice : width,54 !horizontal ? slice : height55 )56 )57 )58 };59 tmp.push(pixelObj);60 lastSlice += slice;61 });62 tmp.forEach((sliceObj) => {63 const offsetX = horizontal ? width - (sliceObj.slice + sliceObj.lastSlice) : 0;64 const offsetY = !horizontal ? height - (sliceObj.slice + sliceObj.lastSlice) : 0;65 copyImage(pixels, sliceObj.pixels, offsetX, offsetY);66 });67}68module.exports = {69 launch : () => {70 let sens = computeSens();71 getPixels(IN, function(err, pixels) {72 shuffleImage(pixels,false);73 shuffleImage(pixels,false);74 shuffleImage(pixels,false);75 shuffleImage(pixels,false);76 shuffleImage(pixels,false);77 shuffleImage(pixels,false);78 shuffleImage(pixels,false);79 shuffleImage(pixels,false);80 shuffleImage(pixels,false);81 shuffleImage(pixels,false);82 shuffleImage(pixels,false);83 shuffleImage(pixels,false);84 shuffleImage(pixels,false);85 shuffleImage(pixels,false);86 shuffleImage(pixels,false);87 shuffleImage(pixels,false);88 shuffleImage(pixels,false);89 //Really close90 shuffleImage(pixels,true);91 shuffleImage(pixels,true);92 shuffleImage(pixels,true);93 shuffleImage(pixels,true);94 shuffleImage(pixels,true);95 shuffleImage(pixels,true);96 shuffleImage(pixels,true);97 shuffleImage(pixels,true);98 shuffleImage(pixels,true);99 shuffleImage(pixels,true);100 shuffleImage(pixels,true);101 shuffleImage(pixels,true);102 shuffleImage(pixels,true);103 shuffleImage(pixels,true);104 shuffleImage(pixels,true);105 shuffleImage(pixels,true);106 shuffleImage(pixels,true);107 const outFile = fs.createWriteStream(OUT);108 savePixels(pixels, "png").pipe(outFile);109 })110 }...

Full Screen

Full Screen

CountdownContainer.js

Source:CountdownContainer.js Github

copy

Full Screen

1import React, { Component } from 'react';2import PropTypes from 'prop-types';3import CountdownUnit from '../presentational/Home/Countdown/CountdownUnit';4import styles from '../presentational/Home/Countdown/Countdown.css';5class CountdownContainer extends Component {6 constructor(props) {7 super(props);8 this.state = {9 ...this.calculateDateDifference(props.weddingDate),10 daysShuffle: true,11 hoursShuffle: true,12 minutesShuffle: true,13 secondsShuffle: true,14 };15 }16 componentDidMount() {17 this.timerID = setInterval(() => this.updateTime(this.props.weddingDate), 50);18 }19 componentWillUnmount() {20 clearInterval(this.timerID);21 }22 // Calculate the difference between now (startDate) and the supplied date (endDate)23 calculateDateDifference(endDate) {24 endDate = new Date(endDate);25 const startDate = Date.now();26 const difference = endDate - startDate;27 const days = parseInt(difference / (24 * 3600 * 1000));28 const hours = parseInt(difference / (3600 * 1000) - (days * 24));29 const minutes = parseInt(difference / (60 * 1000) - (days * 24 * 60) - (hours * 60));30 const seconds = parseInt(difference / (1000) - (minutes * 60) - (days * 24 * 60 * 60) - (hours * 60 * 60));31 return {32 days,33 hours,34 minutes,35 seconds,36 };37 }38 updateTime(endDate) {39 const { days, hours, minutes, seconds } = this.calculateDateDifference(endDate);40 // on days change, update days and shuffle state41 if (days !== this.state.days) {42 const daysShuffle = !this.state.daysShuffle;43 this.setState({44 days,45 daysShuffle,46 });47 }48 // on hour change, update hours and shuffle state49 if (hours !== this.state.hours) {50 const hoursShuffle = !this.state.hoursShuffle;51 this.setState({52 hours,53 hoursShuffle,54 });55 }56 // on minute change, update minutes and shuffle state57 if (minutes !== this.state.minutes) {58 const minutesShuffle = !this.state.minutesShuffle;59 this.setState({60 minutes,61 minutesShuffle,62 });63 }64 // on second change, update seconds and shuffle state65 if (seconds !== this.state.seconds) {66 const secondsShuffle = !this.state.secondsShuffle;67 this.setState({68 seconds,69 secondsShuffle,70 });71 }72 }73 render() {74 // state object destructuring75 const { 76 days,77 hours, 78 minutes, 79 seconds,80 daysShuffle, 81 hoursShuffle, 82 minutesShuffle, 83 secondsShuffle 84 } = this.state;85 return (86 <div className={styles.countdownContainer}>87 <CountdownUnit 88 unit='days'89 digit={days} 90 shuffle={daysShuffle} 91 />92 <CountdownUnit 93 unit='hours'94 digit={hours} 95 shuffle={hoursShuffle} 96 />97 <CountdownUnit 98 unit='minutes'99 digit={minutes} 100 shuffle={minutesShuffle} 101 />102 <CountdownUnit 103 unit='seconds'104 digit={seconds} 105 shuffle={secondsShuffle} 106 />107 </div>108 );109 }110};111CountdownContainer.propTypes = {112 weddingDate: PropTypes.instanceOf(Date),113};...

Full Screen

Full Screen

filter.js

Source:filter.js Github

copy

Full Screen

...4 if(context.location == null){5 $.each(settings.dexp_portfolio, function(filter, view){6 var $grid = $('#'+view,context),$filter = $('#'+filter,context);7 var $newitems = $('#'+view,context).find('.node').not('.shuffle-item');8 $grid.shuffle({9 itemSelector: '.node',10 speed: 50011 });12 $grid.shuffle('appended',$newitems);13 $grid.shuffle('shuffle', 'all');14 });15 }16 $.each(settings.dexp_portfolio, function(filter, view){17 var $grid = $('#'+view,context),$filter = $('#'+filter,context);18 $grid.shuffle({19 itemSelector: '.node',20 speed: 50021 });22 $filter.find('a').click(function(){23 var $this = $(this), filter = $this.data('filter');24 if(filter == '*'){25 $grid.shuffle('shuffle', 'all');26 }else{27 $grid.shuffle('shuffle', function($el, shuffle) {28 // Only search elements in the current group29 if (shuffle.group !== 'all' && $.inArray(shuffle.group, $el.data('groups')) === -1) {30 return false;31 }32 return $el.hasClass(filter);33 });34 }35 $(this).parents('.dexp-portfolio-filter').find('a').removeClass('active');36 $(this).addClass('active');37 return false;38 });39 $grid.shuffle('shuffle', 'all');40 $(window).load(function(){41 $grid.shuffle('shuffle', 'all');42 });43 });44 }45 }46})(jQuery);47/*48jQuery(document).ready(function($){49 var $grid = $('#page-dexp-portfolio');50 $grid.shuffle({51 itemSelector: '.node',52 speed: 50053 });54 $('ul.dexp-portfolio-filter li a').click(function(){55 var $this = $(this), filter = $this.data('filter');56 if(filter == '*'){57 $grid.shuffle('shuffle', 'all');58 }else{59 $grid.shuffle('shuffle', function($el, shuffle) {60 // Only search elements in the current group61 if (shuffle.group !== 'all' && $.inArray(shuffle.group, $el.data('groups')) === -1) {62 return false;63 }64 return $el.hasClass(filter);65 });66 }67 $(this).parents('.dexp-portfolio-filter').find('a').removeClass('active');68 $(this).addClass('active');69 return false;70 });71 $(window).load(function(){72 $grid.shuffle('shuffle', 'all');73 });74})...

Full Screen

Full Screen

shuffle.js

Source:shuffle.js Github

copy

Full Screen

...12 * @param {Array|Object} collection The collection to shuffle.13 * @returns {Array} Returns the new shuffled array.14 * @example15 *16 * _.shuffle([1, 2, 3, 4]);17 * // => [4, 1, 3, 2]18 */19function shuffle(collection) {20 var func = isArray(collection) ? arrayShuffle : baseShuffle;21 return func(collection);22}...

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})();9const {chromium} = require('playwright');10(async () => {11 const browser = await chromium.launch();12 const context = await browser.newContext();13 const page = await context.newPage();14 await page.screenshot({ path: `example.png` });15 await browser.close();16})();17const {chromium} = require('playwright');18(async () => {19 const browser = await chromium.launch();20 const context = await browser.newContext();21 const page = await context.newPage();22 await page.screenshot({ path: `example.png` });23 await browser.close();24})();25const {chromium} = require('playwright');26(async () => {27 const browser = await chromium.launch();28 const context = await browser.newContext();29 const page = await context.newPage();30 await page.screenshot({ path: `example.png` });31 await browser.close();32})();33const {chromium} = require('playwright');34(async () => {35 const browser = await chromium.launch();36 const context = await browser.newContext();37 const page = await context.newPage();38 await page.screenshot({ path: `example.png` });39 await browser.close();40})();41const {chromium} = require('playwright');42(async () => {43 const browser = await chromium.launch();44 const context = await browser.newContext();45 const page = await context.newPage();

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();5 await context.tracing.start({ screenshots: true, snapshots: true });6 const page = await context.newPage();7 await page.screenshot({ path: 'google.png' });8 await page.tracing.stop({ path: 'trace.zip' });9 await browser.close();10})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { shuffle } = require('@playwright/test/lib/utils/shuffle');2const array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];3console.log(shuffle(array));4const { shuffle } = require('@playwright/test/lib/utils/shuffle');5const array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];6console.log(shuffle(array));7const { shuffle } = require('@playwright/test/lib/utils/shuffle');8const array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];9console.log(shuffle(array));

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({5 userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/81.0.4044.0 Safari/537.36'6 });7 const page = await context.newPage();8 await page.close();9 await browser.close();10})();11const {chromium} = require('playwright');12(async () => {13 const browser = await chromium.launch({headless: false});14 const context = await browser.newContext({15 userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/81.0.4044.0 Safari/537.36'16 });17 const page = await context.newPage();18 await page.close();19 await browser.close();20})();21const {chromium} = require('playwright');22(async () => {23 const browser = await chromium.launch({headless: false});24 const context = await browser.newContext({25 userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/81.0.4044.0 Safari/537.36'26 });27 const page = await context.newPage();28 await page.close();29 await browser.close();30})();31const {chromium} = require('playwright');32(async () => {33 const browser = await chromium.launch({headless: false});34 const context = await browser.newContext({35 userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2const { shuffle } = require("playwright/lib/utils/utils");3(async () => {4 const browser = await chromium.launch({ headless: false });5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.screenshot({ path: `example.png` });8 await browser.close();9})();10const { shuffle } = require("playwright/lib/utils/utils");11module.exports = {12};13'use strict';14const shuffle = (array) => {15 for (let i = array.length - 1; i > 0; i--) {16 const j = Math.floor(Math.random() * (i + 1));17 [array[i], array[j]] = [array[j], array[i]];18 }19 return array;20};21module.exports = {22};23'use strict';24const shuffle = (array) => {25 for (let i = array.length - 1; i > 0; i--) {26 const j = Math.floor(Math.random() * (i + 1));27 [array[i], array[j]] = [array[j], array[i]];28 }29 return array;30};31module.exports = {32};33'use strict';34const shuffle = (array) => {35 for (let i = array.length - 1; i > 0; i--) {36 const j = Math.floor(Math.random() * (i + 1));37 [array[i], array[j]] = [array[j], array[i]];38 }39 return array;40};41module.exports = {42};43'use strict';44const shuffle = (array) => {45 for (let i = array.length -

Full Screen

Using AI Code Generation

copy

Full Screen

1const { shuffle } = require('playwright/lib/utils/utils');2console.log(shuffle([1,2,3,4,5]));3const { shuffle } = require('playwright/lib/utils/utils');4console.log(shuffle([1,2,3,4,5]));5const { shuffle } = require('playwright/lib/utils/utils');6console.log(shuffle([1,2,3,4,5]));7const { shuffle } = require('playwright/lib/utils/utils');8console.log(shuffle([1,2,3,4,5]));9const { shuffle } = require('playwright/lib/utils/utils');10console.log(shuffle([1,2,3,4,5]));11const { shuffle } = require('playwright/lib/utils/utils');12console.log(shuffle([1,2,3,4,5]));13const { shuffle } = require('playwright/lib/utils/utils');14console.log(shuffle([1,2,3,4,5]));15const { shuffle } = require('playwright/lib/utils/utils');16console.log(shuffle([1,2,3,4,5]));17const { shuffle } = require('playwright/lib/utils/utils');18console.log(shuffle([1,2,3,4,5]));19const { shuffle } = require('playwright/lib/utils/utils');20console.log(shuffle([1,2,3,4,5]));21const { shuffle } = require('playwright/lib/utils/utils');22console.log(shuffle([1,2,3,4,5]));

Full Screen

Using AI Code Generation

copy

Full Screen

1const { test, expect } = require('@playwright/test');2const { chromium } = require('playwright');3const { shuffle } = require('@playwright/test/lib/utils/shuffle');4const { devices } = require('playwright');5const iPhone = devices['iPhone 11 Pro'];6test.describe('My first test suite', () => {7 let browser, context, page;8 test.beforeAll(async () => {9 browser = await chromium.launch();10 context = await browser.newContext();11 page = await context.newPage();12 });13 test.afterAll(async () => {14 await browser.close();15 });16 test('My first test', async () => {17 const links = await page.$$('text=Learn');18 const shuffledLinks = shuffle(links);19 await Promise.all(shuffledLinks.map(link => link.click()));20 });21});22const { test, expect } = require('@playwright/test');23const { chromium } = require('playwright');24const { shuffle } = require('@playwright/test/lib/utils/shuffle');25const { devices } = require('playwright');26const iPhone = devices['iPhone 11 Pro'];27test.describe('My first test suite', () => {28 let browser, context, page;29 test.beforeAll(async () => {30 browser = await chromium.launch();31 context = await browser.newContext();32 page = await context.newPage();33 });34 test.afterAll(async () => {35 await browser.close();36 });37 test('My first test', async () => {38 const links = await page.$$('text=Learn');39 const shuffledLinks = shuffle(links);40 await Promise.all(shuffledLinks.map(link => link.click()));41 });42});43import { test, expect } from '@playwright/test';44import { chromium } from 'playwright';45import { shuffle } from '@playwright/test/lib/utils/shuffle';46import { devices } from 'playwright';47const iPhone = devices['iPhone 11 Pro'];48test.describe('My first test suite', () => {49 let browser, context, page;50 test.beforeAll(async () => {51 browser = await chromium.launch();52 context = await browser.newContext();53 page = await context.newPage();54 });55 test.afterAll(async () => {

Full Screen

Using AI Code Generation

copy

Full Screen

1const { shuffle } = require('playwright/lib/utils/sequence');2const array = [1, 2, 3, 4, 5];3shuffle(array);4console.log(array);5const { Playwright } = require('playwright/lib/server/playwright');6const playwright = new Playwright();7const browser = playwright._browserType.launch();8const context = browser._defaultContext;9const page = context._newPage('page1');10const frame = page.mainFrame();11const elementHandle = frame._elementHandleForSelector('div');12const elementHandles = frame._elementHandlesForSelectorAll('div');13const element = elementHandle._element;14const frameElement = frame._page._delegate.frameElement();15const frameOwner = frame._page._delegate.frameOwner();16const pageOrError = frame._page._delegate.pageOrError();17const pageOrFrame = frame._page._delegate.pageOrFrame();18const pageOrFrameOrError = frame._page._delegate.pageOrFrameOrError();19const parentFrame = frame._page._delegate.parentFrame();20const sameDocumentNavigation = frame._page._delegate.sameDocumentNavigation();21const url = frame._page._delegate.url();22const viewportSize = frame._page._delegate.viewportSize();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { shuffle } = require('playwright/lib/utils/utils');2const elements = [1, 2, 3, 4, 5];3const shuffled = shuffle(elements);4console.log(shuffled);5const { getAttribute } = require('playwright/lib/utils/utils');6const element = document.querySelector('div');7const attributeValue = getAttribute(element, 'id');8console.log(attributeValue);9const { getOuterHTML } = require('playwright/lib/utils/utils');10const element = document.querySelector('div');11const outerHTML = getOuterHTML(element);12console.log(outerHTML);13const { innerText } = require('playwright/lib/utils/utils');14const element = document.querySelector('div');15const text = innerText(element);16console.log(text);17const { innerText } = require('playwright/lib/utils/utils');18const element = document.querySelector('div');19const text = innerText(element);20console.log(text);21const { innerText } = require('playwright/lib/utils/utils');22const element = document.querySelector('div');23const text = innerText(element);24console.log(text);25const { innerText } = require('playwright/lib/utils/utils');26const element = document.querySelector('div');27const text = innerText(element);28console.log(text);

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