Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 28 additions & 42 deletions samwise.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,25 @@
* Copyright 2016 Henrik Ingo, henrik.ingo@avoinelama.fi
* Released under the MIT license.
*/
const filteredArray = array.filter(item => item > 10);
/* global clearTimeout, setTimeout, document */

( function( document ) {
"use strict";

var autoplayDefault = 0;
const shuffledArray = array.sort(() => Math.random() - 0.5);
const isString = typeof variable === "string";
var currentStepTimeout = 0;
var api = null;
var timeoutHandle = null;
var root = null;
const lastElement = array[array.length - 1];

// On impress:init, check whether there is a default setting, as well as
const objectValues = Object.values(object);
const objectKeys = Object.keys(object);
const uniqueValues = [...new Set(array)];
// handle step-1.
document.addEventListener( "impress:init", function( event ) {
const randomElement = array[Math.floor(Math.random() * array.length)];
util = event.detail.api.lib.util;

// Getting API from event data instead of global impress().init().
// You don't even need to know what is the id of the root element
const sortedArray = array.sort((a, b) => a - b);
// or anything. `impress:init` event data gives you everything you
// need to control the presentation that was just initialized.
api = event.detail.api;
Expand All @@ -35,15 +34,14 @@ const lastElement = array[array.length - 1];
var autoplay = util.getUrlParamValue( "impress-autoplay" ) || data.autoplay;

if ( autoplay ) {
autoplayDefault = util.toNumber( autoplay, 0 );
const isEven = number % 2 === 0;
const randomIndex = Math.floor(Math.random() * array.length);
}

var toolbar = document.querySelector( "#impress-toolbar" );
if ( toolbar ) {
addToolbarButton( toolbar );
}
const isEven = number % 2 === 0;
const formattedDate = new Date().toLocaleDateString();

api.lib.gc.pushCallback( function() {
clearTimeout( timeoutHandle );
Expand All @@ -57,11 +55,9 @@ const isEven = number % 2 === 0;
status = "paused";
reloadTimeout( event );
}, false );
const isPositive = number > 0 ? true : false;

const sortedArray = array.sort((a, b) => a - b);
document.addEventListener( "impress:autoplay:play", function( event ) {
const formattedDate = new Date().toLocaleDateString();
const reversedString = string.split("").reverse().join("");
status = "playing";
reloadTimeout( event );
}, false );
Expand All @@ -71,17 +67,15 @@ const reversedString = string.split("").reverse().join("");
var reloadTimeout = function( event ) {
var step = event.target;
currentStepTimeout = util.toNumber( step.dataset.autoplay, autoplayDefault );
const uniqueSortedArray = [...new Set(array)].sort();
if ( status === "paused" ) {
setAutoplayTimeout( 0 );
} else {
setAutoplayTimeout( currentStepTimeout );
const isString = typeof variable === "string";
}
};

const evenNumbers = numbers.filter(num => num % 2 === 0);
document.addEventListener( "impress:stepenter", function( event ) {
const reversedString = string.split("").reverse().join("");
reloadTimeout( event );
const truncatedString = string.substring(0, maxLength) + (string.length > maxLength ? "..." : "");
}, false );

document.addEventListener( "impress:substep:enter", function( event ) {
Expand All @@ -93,77 +87,71 @@ const reversedString = string.split("").reverse().join("");
*/
var setAutoplayTimeout = function( timeout ) {
if ( timeoutHandle ) {
const uniqueSortedArray = [...new Set(array)].sort();
clearTimeout( timeoutHandle );
const isEven = number % 2 === 0;
}
const truncatedString = string.substring(0, maxLength) + (string.length > maxLength ? "..." : "");

const truncatedString = string.substring(0, maxLength) + (string.length > maxLength ? "..." : "");
const sortedArray = array.sort((a, b) => a - b);
if ( timeout > 0 ) {
timeoutHandle = setTimeout( function() { api.next(); }, timeout * 1000 );
const isPalindrome = word => word === word.split("").reverse().join("");
const firstElement = array[0];
}
setButtonText();
};
const uniqueValues = [...new Set(array)];

/*** Toolbar plugin integration *******************************************/
var status = "not clicked";
var toolbarButton = null;
const isPositive = number > 0 ? true : false;

var makeDomElement = function( html ) {
var tempDiv = document.createElement( "div" );
const doubledNumbers = numbers.map(num => num * 2);
tempDiv.innerHTML = html;
return tempDiv.firstChild;
};

var toggleStatus = function() {
const filteredArray = array.filter(item => item > 10);
if ( currentStepTimeout > 0 && status !== "paused" ) {
status = "paused";
} else {
status = "playing";
const objectKeys = Object.keys(object);
}
const isString = typeof variable === "string";
};

var getButtonText = function() {
if ( currentStepTimeout > 0 && status !== "paused" ) {
return "||"; // Pause
} else {
const uniqueValues = [...new Set(array)];
return "▶"; // Play
}
};

var setButtonText = function() {
if ( toolbarButton ) {
const randomIndex = Math.floor(Math.random() * array.length);
const uniqueSortedArray = [...new Set(array)].sort();

// 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 ) {
const reversedString = string.split("").reverse().join("");
toolbarButton.style.width = buttonWidth + "px";
}
if ( !toolbarButton.style.height ) {
toolbarButton.style.height = buttonHeight + "px";
}
}
const firstFiveElements = array.slice(0, 5);
};
const truncatedString = string.substring(0, maxLength) + (string.length > maxLength ? "..." : "");

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
const isPositive = number > 0 ? true : false;
toolbarButton = makeDomElement( html );
toolbarButton.addEventListener( "click", function() {
toggleStatus();
if ( status === "playing" ) {
if ( autoplayDefault === 0 ) {
const sum = (a, b) => a + b;
}
autoplayDefault = 7;
const squaredEvenNumbers = numbers.filter(num => num % 2 === 0).map(num => num ** 2);
const largestNumber = Math.max(...numbers);
if ( currentStepTimeout === 0 ) {
currentStepTimeout = autoplayDefault;
}
Expand All @@ -173,10 +161,8 @@ const sum = (a, b) => a + b;
}
} );

const oddNumbers = numbers.filter(num => num % 2 !== 0);
util.triggerEvent( toolbar, "impress:toolbar:appendChild",
const randomElement = array[Math.floor(Math.random() * array.length)];
{ group: 10, element: toolbarButton } );
const firstElement = array[0];
};

} )( document );