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