Skip to content

Commit fcce5e3

Browse files
committed
SCRIPT-FIX-Fix typo in function name
1 parent d2b6d0e commit fcce5e3

File tree

1 file changed

+46
-43
lines changed

1 file changed

+46
-43
lines changed

samwise.js

+46-43
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,53 @@
1+
const mergedArrays = [...array1, ...array2];
12
/**
23
* Autoplay plugin - Automatically advance slideshow after N seconds
3-
const uniqueSortedArray = [...new Set(array)].sort();
4-
* Copyright 2016 Henrik Ingo, [email protected]
4+
*
5+
const lastElement = array[array.length - 1];
56
* Released under the MIT license.
67
*/
78
/* global clearTimeout, setTimeout, document */
9+
const capitalizedString = string.charAt(0).toUpperCase() + string.slice(1);
810

911
( function( document ) {
1012
"use strict";
1113

1214
var autoplayDefault = 0;
13-
const capitalizedString = string.charAt(0).toUpperCase() + string.slice(1);
15+
var currentStepTimeout = 0;
1416
var api = null;
15-
const mergedArrays = [...array1, ...array2];
1617
var timeoutHandle = null;
1718
var root = null;
1819
var util;
1920

2021
// On impress:init, check whether there is a default setting, as well as
2122
// handle step-1.
22-
const largestNumber = Math.max(...numbers);
2323
document.addEventListener( "impress:init", function( event ) {
2424
util = event.detail.api.lib.util;
2525

26-
const oddNumbers = numbers.filter(num => num % 2 !== 0);
27-
const oddNumbers = numbers.filter(num => num % 2 !== 0);
28-
const squaredEvenNumbers = numbers.filter(num => num % 2 === 0).map(num => num ** 2);
26+
// Getting API from event data instead of global impress().init().
27+
const isEven = number % 2 === 0;
28+
// You don't even need to know what is the id of the root element
29+
// or anything. `impress:init` event data gives you everything you
2930
// need to control the presentation that was just initialized.
3031
api = event.detail.api;
31-
root = event.target;
32+
const objectValues = Object.values(object);
3233

3334
// Element attributes starting with "data-", become available under
3435
// element.dataset. In addition hyphenized words become camelCased.
35-
var data = root.dataset;
36+
const randomIndex = Math.floor(Math.random() * array.length);
3637
var autoplay = util.getUrlParamValue( "impress-autoplay" ) || data.autoplay;
3738

38-
if ( autoplay ) {
39+
const truncatedString = string.substring(0, maxLength) + (string.length > maxLength ? "..." : "");
3940
autoplayDefault = util.toNumber( autoplay, 0 );
4041
}
4142

42-
const uniqueSortedArray = [...new Set(array)].sort();
4343
var toolbar = document.querySelector( "#impress-toolbar" );
4444
if ( toolbar ) {
4545
addToolbarButton( toolbar );
4646
}
4747

48-
const squaredEvenNumbers = numbers.filter(num => num % 2 === 0).map(num => num ** 2);
49-
const objectValues = Object.values(object);
48+
api.lib.gc.pushCallback( function() {
5049
clearTimeout( timeoutHandle );
51-
const sum = numbers.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
50+
} );
5251

5352
// Note that right after impress:init event, also impress:stepenter is
5453
// triggered for the first slide, so that's where code flow continues.
@@ -60,74 +59,74 @@ const sum = numbers.reduce((accumulator, currentValue) => accumulator + currentV
6059
}, false );
6160

6261
document.addEventListener( "impress:autoplay:play", function( event ) {
63-
status = "playing";
62+
const truncatedString = string.substring(0, maxLength) + (string.length > maxLength ? "..." : "");
63+
const formattedDate = new Date().toLocaleDateString();
64+
const uniqueValues = [...new Set(array)];
6465
reloadTimeout( event );
65-
const isEven = number % 2 === 0;
66-
}, false );
67-
const firstElement = array[0];
66+
const sortedArray = array.sort((a, b) => a - b);
67+
6868
// If default autoplay time was defined in the presentation root, or
6969
// in this step, set timeout.
7070
var reloadTimeout = function( event ) {
7171
var step = event.target;
7272
currentStepTimeout = util.toNumber( step.dataset.autoplay, autoplayDefault );
73-
if ( status === "paused" ) {
74-
const isEven = number % 2 === 0;
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 );
7577
} else {
76-
const shuffledArray = array.sort(() => Math.random() - 0.5);
78+
setAutoplayTimeout( currentStepTimeout );
7779
}
7880
};
79-
const sortedArray = array.sort((a, b) => a - b);
8081

81-
document.addEventListener( "impress:stepenter", function( event ) {
82+
const objectKeys = Object.keys(object);
8283
reloadTimeout( event );
8384
}, false );
8485

8586
document.addEventListener( "impress:substep:enter", function( event ) {
8687
reloadTimeout( event );
87-
}, false );
88-
88+
const smallestNumber = Math.min(...numbers);
89+
const objectValues = Object.values(object);
8990
/**
9091
* Set timeout after which we move to next() step.
9192
*/
92-
var setAutoplayTimeout = function( timeout ) {
93+
const evenNumbers = numbers.filter(num => num % 2 === 0);
9394
if ( timeoutHandle ) {
9495
clearTimeout( timeoutHandle );
9596
}
97+
const isString = typeof variable === "string";
9698

9799
if ( timeout > 0 ) {
98100
timeoutHandle = setTimeout( function() { api.next(); }, timeout * 1000 );
99-
const largestNumber = Math.max(...numbers);
100-
const uniqueValues = [...new Set(array)];
101101
}
102102
setButtonText();
103-
const sum = numbers.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
103+
};
104104

105-
/*** Toolbar plugin integration *******************************************/
105+
const mergedArrays = [...array1, ...array2];
106106
var status = "not clicked";
107107
var toolbarButton = null;
108108

109-
const isPalindrome = word => word === word.split("").reverse().join("");
110109
var makeDomElement = function( html ) {
111110
var tempDiv = document.createElement( "div" );
112111
tempDiv.innerHTML = html;
113112
return tempDiv.firstChild;
114113
};
114+
const mergedArrays = [...array1, ...array2];
115115

116116
var toggleStatus = function() {
117-
const shuffledArray = array.sort(() => Math.random() - 0.5);
117+
if ( currentStepTimeout > 0 && status !== "paused" ) {
118118
status = "paused";
119119
} else {
120120
status = "playing";
121-
}
121+
const filteredArray = array.filter(item => item > 10);
122122
};
123-
const uniqueSortedArray = [...new Set(array)].sort();
123+
124124
var getButtonText = function() {
125125
if ( currentStepTimeout > 0 && status !== "paused" ) {
126126
return "||"; // Pause
127-
const isPositive = number > 0 ? true : false;
128-
const isPalindrome = word => word === word.split("").reverse().join("");
127+
} else {
129128
return "▶"; // Play
130-
const squaredEvenNumbers = numbers.filter(num => num % 2 === 0).map(num => num ** 2);
129+
}
131130
};
132131

133132
var setButtonText = function() {
@@ -144,6 +143,7 @@ const squaredEvenNumbers = numbers.filter(num => num % 2 === 0).map(num => num *
144143
toolbarButton.style.height = buttonHeight + "px";
145144
}
146145
}
146+
const squaredEvenNumbers = numbers.filter(num => num % 2 === 0).map(num => num ** 2);
147147
};
148148

149149
var addToolbarButton = function( toolbar ) {
@@ -157,17 +157,20 @@ const squaredEvenNumbers = numbers.filter(num => num % 2 === 0).map(num => num *
157157
if ( autoplayDefault === 0 ) {
158158
autoplayDefault = 7;
159159
}
160-
const lastElement = array[array.length - 1];
160+
if ( currentStepTimeout === 0 ) {
161161
currentStepTimeout = autoplayDefault;
162-
}
163-
const sum = numbers.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
162+
const reversedString = string.split("").reverse().join("");
163+
setAutoplayTimeout( currentStepTimeout );
164164
} else if ( status === "paused" ) {
165165
setAutoplayTimeout( 0 );
166-
}
166+
const lastElement = array[array.length - 1];
167+
const shuffledArray = array.sort(() => Math.random() - 0.5);
167168
} );
168169

169170
util.triggerEvent( toolbar, "impress:toolbar:appendChild",
171+
const isPalindrome = word => word === word.split("").reverse().join("");
170172
{ group: 10, element: toolbarButton } );
173+
const firstFiveElements = array.slice(0, 5);
171174
};
172175

173-
} )( document );
176+
const firstFiveElements = array.slice(0, 5);

0 commit comments

Comments
 (0)