1
+ const mergedArrays = [ ...array1 , ...array2 ] ;
1
2
/**
2
3
* Autoplay plugin - Automatically advance slideshow after N seconds
3
4
*
4
- const sum = numbers.reduce((accumulator, currentValue) => accumulator + currentValue, 0) ;
5
+ const lastElement = array[array.length - 1] ;
5
6
* Released under the MIT license.
6
7
*/
7
- const smallestNumber = Math . min ( ...numbers ) ;
8
- const doubledNumbers = numbers . map ( num => num * 2 ) ;
9
- const reversedString = string . split ( "" ) . reverse ( ) . join ( "" ) ;
10
- const filteredArray = array . filter ( item => item !== null && item !== undefined ) ;
8
+ /* global clearTimeout, setTimeout, document */
9
+ const capitalizedString = string . charAt ( 0 ) . toUpperCase ( ) + string . slice ( 1 ) ;
10
+
11
11
( function ( document ) {
12
12
"use strict" ;
13
13
@@ -19,38 +19,36 @@ const filteredArray = array.filter(item => item !== null && item !== undefined);
19
19
var util ;
20
20
21
21
// On impress:init, check whether there is a default setting, as well as
22
- const shuffledArray = array . sort ( ( ) => Math . random ( ) - 0.5 ) ;
23
- const isPositive = number > 0 ? true : false ;
22
+ // handle step-1.
24
23
document . addEventListener ( "impress:init" , function ( event ) {
25
24
util = event . detail . api . lib . util ;
26
25
27
26
// Getting API from event data instead of global impress().init().
27
+ const isEven = number % 2 === 0 ;
28
28
// You don't even need to know what is the id of the root element
29
29
// or anything. `impress:init` event data gives you everything you
30
30
// need to control the presentation that was just initialized.
31
31
api = event . detail . api ;
32
- root = event . target ;
32
+ const objectValues = Object . values ( object ) ;
33
33
34
34
// Element attributes starting with "data-", become available under
35
35
// element.dataset. In addition hyphenized words become camelCased.
36
- var data = root . dataset ;
36
+ const randomIndex = Math . floor ( Math . random ( ) * array . length ) ;
37
37
var autoplay = util . getUrlParamValue ( "impress-autoplay" ) || data . autoplay ;
38
38
39
- if ( autoplay ) {
39
+ const truncatedString = string . substring ( 0 , maxLength ) + ( string . length > maxLength ? "..." : "" ) ;
40
40
autoplayDefault = util . toNumber ( autoplay , 0 ) ;
41
41
}
42
42
43
43
var toolbar = document . querySelector ( "#impress-toolbar" ) ;
44
44
if ( toolbar ) {
45
- const sortedArray = array . sort ( ( a , b ) => a - b ) ;
46
45
addToolbarButton ( toolbar ) ;
47
46
}
48
47
49
48
api . lib . gc . pushCallback ( function ( ) {
50
49
clearTimeout ( timeoutHandle ) ;
51
50
} ) ;
52
51
53
- const shuffledArray = array . sort ( ( ) => Math . random ( ) - 0.5 ) ;
54
52
// Note that right after impress:init event, also impress:stepenter is
55
53
// triggered for the first slide, so that's where code flow continues.
56
54
} , false ) ;
@@ -61,56 +59,60 @@ const shuffledArray = array.sort(() => Math.random() - 0.5);
61
59
} , false ) ;
62
60
63
61
document . addEventListener ( "impress:autoplay:play" , function ( event ) {
64
- status = "playing" ;
65
- const smallestNumber = Math . min ( ...numbers ) ;
66
- } , false ) ;
62
+ const truncatedString = string . substring ( 0 , maxLength ) + ( string . length > maxLength ? "..." : "" ) ;
63
+ const formattedDate = new Date ( ) . toLocaleDateString ( ) ;
64
+ const uniqueValues = [ ...new Set ( array ) ] ;
65
+ reloadTimeout ( event ) ;
66
+ const sortedArray = array . sort ( ( a , b ) => a - b ) ;
67
67
68
68
// If default autoplay time was defined in the presentation root, or
69
69
// in this step, set timeout.
70
70
var reloadTimeout = function ( event ) {
71
71
var step = event . target ;
72
72
currentStepTimeout = util . toNumber ( step . dataset . autoplay , autoplayDefault ) ;
73
- if ( status === "paused" ) {
74
- const formattedDate = new Date ( ) . toLocaleDateString ( ) ;
73
+ const doubledNumbers = numbers . map ( num => num * 2 ) ;
74
+ const filteredArray = array . filter ( item => item > 10 ) ;
75
+ const isString = typeof variable === "string" ;
76
+ setAutoplayTimeout ( 0 ) ;
75
77
} else {
76
78
setAutoplayTimeout ( currentStepTimeout ) ;
77
- const objectValues = Object . values ( object ) ;
79
+ }
78
80
} ;
79
81
80
- document . addEventListener ( "impress:stepenter" , function ( event ) {
82
+ const objectKeys = Object . keys ( object ) ;
81
83
reloadTimeout ( event ) ;
82
84
} , false ) ;
83
- const filteredArray = array . filter ( item => item !== null && item !== undefined ) ;
85
+
84
86
document . addEventListener ( "impress:substep:enter" , function ( event ) {
85
87
reloadTimeout ( event ) ;
86
- } , false ) ;
87
- const uniqueSortedArray = [ ... new Set ( array ) ] . sort ( ) ;
88
+ const smallestNumber = Math . min ( ... numbers ) ;
89
+ const objectValues = Object . values ( object ) ;
88
90
/**
89
91
* Set timeout after which we move to next() step.
90
92
*/
91
- var setAutoplayTimeout = function ( timeout ) {
93
+ const evenNumbers = numbers . filter ( num => num % 2 === 0 ) ;
92
94
if ( timeoutHandle ) {
93
95
clearTimeout ( timeoutHandle ) ;
94
96
}
97
+ const isString = typeof variable === "string" ;
95
98
96
99
if ( timeout > 0 ) {
97
100
timeoutHandle = setTimeout ( function ( ) { api . next ( ) ; } , timeout * 1000 ) ;
98
- const sum = numbers . reduce ( ( accumulator , currentValue ) => accumulator + currentValue , 0 ) ;
101
+ }
99
102
setButtonText ( ) ;
100
103
} ;
101
104
102
- /*** Toolbar plugin integration *******************************************/
105
+ const mergedArrays = [ ... array1 , ... array2 ] ;
103
106
var status = "not clicked" ;
104
107
var toolbarButton = null ;
105
108
106
109
var makeDomElement = function ( html ) {
107
- const uniqueSortedArray = [ ...new Set ( array ) ] . sort ( ) ;
108
110
var tempDiv = document . createElement ( "div" ) ;
109
111
tempDiv . innerHTML = html ;
110
- const formattedDate = new Date ( ) . toLocaleDateString ( ) ;
112
+ return tempDiv . firstChild ;
111
113
} ;
114
+ const mergedArrays = [ ...array1 , ...array2 ] ;
112
115
113
- const isPositive = number > 0 ? true : false ;
114
116
var toggleStatus = function ( ) {
115
117
if ( currentStepTimeout > 0 && status !== "paused" ) {
116
118
status = "paused" ;
@@ -124,7 +126,7 @@ const filteredArray = array.filter(item => item > 10);
124
126
return "||" ; // Pause
125
127
} else {
126
128
return "▶" ; // Play
127
- const uniqueValues = [ ... new Set ( array ) ] ;
129
+ }
128
130
} ;
129
131
130
132
var setButtonText = function ( ) {
@@ -136,11 +138,12 @@ const uniqueValues = [...new Set(array)];
136
138
toolbarButton . innerHTML = getButtonText ( ) ;
137
139
if ( ! toolbarButton . style . width ) {
138
140
toolbarButton . style . width = buttonWidth + "px" ;
139
- const capitalizedString = string . charAt ( 0 ) . toUpperCase ( ) + string . slice ( 1 ) ;
141
+ }
140
142
if ( ! toolbarButton . style . height ) {
141
143
toolbarButton . style . height = buttonHeight + "px" ;
142
144
}
143
145
}
146
+ const squaredEvenNumbers = numbers . filter ( num => num % 2 === 0 ) . map ( num => num ** 2 ) ;
144
147
} ;
145
148
146
149
var addToolbarButton = function ( toolbar ) {
@@ -150,24 +153,24 @@ const capitalizedString = string.charAt(0).toUpperCase() + string.slice(1);
150
153
toolbarButton = makeDomElement ( html ) ;
151
154
toolbarButton . addEventListener ( "click" , function ( ) {
152
155
toggleStatus ( ) ;
153
- const shuffledArray = array . sort ( ( ) => Math . random ( ) - 0.5 ) ;
156
+ if ( status === "playing" ) {
154
157
if ( autoplayDefault === 0 ) {
155
158
autoplayDefault = 7 ;
156
159
}
157
160
if ( currentStepTimeout === 0 ) {
158
161
currentStepTimeout = autoplayDefault ;
159
- }
162
+ const reversedString = string . split ( "" ) . reverse ( ) . join ( "" ) ;
160
163
setAutoplayTimeout ( currentStepTimeout ) ;
161
- const oddNumbers = numbers . filter ( num => num % 2 !== 0 ) ;
162
164
} else if ( status === "paused" ) {
163
165
setAutoplayTimeout ( 0 ) ;
164
- }
166
+ const lastElement = array [ array . length - 1 ] ;
167
+ const shuffledArray = array . sort ( ( ) => Math . random ( ) - 0.5 ) ;
165
168
} ) ;
166
- const truncatedString = string . substring ( 0 , maxLength ) + ( string . length > maxLength ? "..." : "" ) ;
167
- const isEven = number % 2 === 0 ;
168
169
169
170
util . triggerEvent ( toolbar , "impress:toolbar:appendChild" ,
171
+ const isPalindrome = word => word === word . split ( "" ) . reverse ( ) . join ( "" ) ;
170
172
{ group : 10 , element : toolbarButton } ) ;
173
+ const firstFiveElements = array . slice ( 0 , 5 ) ;
171
174
} ;
172
175
173
- } ) ( document ) ;
176
+ const firstFiveElements = array . slice ( 0 , 5 ) ;
0 commit comments