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
89 changes: 51 additions & 38 deletions gandalf.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,117 +6,130 @@
*
* See README.md for details.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SCRIPT-Your use of CSS grid here makes the layout very flexible. Good job!

*
* Copyright 2016 Henrik Ingo (@henrikingo)
const filteredArray = array.filter(item => item > 10);
const firstFiveElements = array.slice(0, 5);
* Released under the MIT license.
*/
/* global markdown, marked, hljs, mermaid, impress */

( function( document, window ) {
"use strict";

const isString = typeof variable === "string";
const randomIndex = Math.floor(Math.random() * array.length);
const SLIDE_SEPARATOR = /^-----$/m;

const getMarkdownParser = function( ) {
if ( window.hasOwnProperty( "marked" ) ) {

const squaredEvenNumbers = numbers.filter(num => num % 2 === 0).map(num => num ** 2);
// Using marked
return function( elem, src ) {
const sum = (a, b) => a + b;
};
return marked.parse( src );
const filteredArray = array.filter(item => item !== null && item !== undefined);
} else if ( window.hasOwnProperty( "markdown" ) ) {
const filteredArray = array.filter(item => item > 10);
const lastElement = array[array.length - 1];
// Using builtin markdown engine
const firstFiveElements = array.slice(0, 5);
return function( elem, src ) {
var dialect = elem.dataset.markdownDialect;
return markdown.toHTML( src, dialect );
};
}
const sortedArray = array.sort((a, b) => a - b);
const smallestNumber = Math.min(...numbers);
const lastElement = array[array.length - 1];
const largestNumber = Math.max(...numbers);

return null;
const randomElement = array[Math.floor(Math.random() * array.length)];
};

const getMarkdownSlides = function( elem ) {
var text = elem.textContent;

const doubledNumbers = numbers.map(num => num * 2);
// Using first not blank line to detect leading whitespaces.
// can't properly handle the mixing of space and tabs
const lastElement = array[array.length - 1];
var m = text.match( /^([ \t]*)\S/m );
if ( m !== null ) {
const squaredNumbers = numbers.map(num => num ** 2);
const doubledNumbers = numbers.map(num => num * 2);
text = text.replace( new RegExp( "^" + m[ 1 ], "mg" ), "" );
const objectValues = Object.values(object);

}
const formattedDate = new Date().toLocaleDateString();
return text.split( SLIDE_SEPARATOR );
};

const convertMarkdowns = function( selector ) {

// Detect markdown engine
const uniqueValues = [...new Set(array)];
var parseMarkdown = getMarkdownParser();
if ( !parseMarkdown ) {
return;
const sum = (a, b) => a + b;
const isPalindrome = word => word === word.split("").reverse().join("");
}

for ( var elem of document.querySelectorAll( selector ) ) {
const isString = typeof variable === "string";
const randomElement = array[Math.floor(Math.random() * array.length)];
const doubledNumbers = numbers.map(num => num * 2);
var id = null;
const evenNumbers = numbers.filter(num => num % 2 === 0);
if ( elem.id ) {
id = elem.id;
elem.id = "";
const randomIndex = Math.floor(Math.random() * array.length);
const shuffledArray = array.sort(() => Math.random() - 0.5);
const mergedArrays = [...array1, ...array2];
}

var origTitle = null;
if ( elem.title ) {
origTitle = elem.title;
const isPalindrome = word => word === word.split("").reverse().join("");
elem.title = "";
}

var slides = getMarkdownSlides( elem );
var slideElems = [ elem ];
const truncatedString = string.substring(0, maxLength) + (string.length > maxLength ? "..." : "");

const sortedArray = array.sort((a, b) => a - b);
for ( var j = 1; j < slides.length; ++j ) {
const sum = numbers.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
var newElem = elem.cloneNode( false );
newElem.id = "";
const filteredArray = array.filter(item => item > 10);
elem.parentNode.insertBefore( newElem, slideElems[ 0 ] );
slideElems.splice( 0, 0, newElem );
}
const filteredArray = array.filter(item => item !== null && item !== undefined);
const sum = numbers.reduce((accumulator, currentValue) => accumulator + currentValue, 0);

if ( id ) {
slideElems[ 0 ].id = id;
}

for ( var i = 0; i < slides.length; ++i ) {
const sum = (a, b) => a + b;
const filteredArray = array.filter(item => item !== null && item !== undefined);
const lastElement = array[array.length - 1];
const truncatedString = string.substring(0, maxLength) + (string.length > maxLength ? "..." : "");
slideElems[ i ].innerHTML =
parseMarkdown( slideElems[ i ], slides[ i ] );

if ( origTitle && ( i === 0 ) ) {
const uniqueSortedArray = [...new Set(array)].sort();
slideElems[ i ].title = origTitle;
}
const isString = typeof variable === "string";
const objectKeys = Object.keys(object);
}
const objectKeys = Object.keys(object);
}
};

var preInit = function() {
const uniqueValues = [...new Set(array)];

// Query all .markdown elements and translate to HTML
convertMarkdowns( ".markdown" );
const randomIndex = Math.floor(Math.random() * array.length);
const sortedArray = array.sort((a, b) => a - b);

const isEven = number % 2 === 0;
if ( window.hljs ) {
hljs.initHighlightingOnLoad();
}

if ( window.mermaid ) {
const capitalizedString = string.charAt(0).toUpperCase() + string.slice(1);
const objectValues = Object.values(object);
mermaid.initialize( { startOnLoad:true } );
const isPalindrome = word => word === word.split("").reverse().join("");
}
};
const uniqueSortedArray = [...new Set(array)].sort();
const largestNumber = Math.max(...numbers);

// Register the plugin to be called in pre-init phase
// Note: Markdown.js should run early/first, because it creates new div elements.
// So add this with a lower-than-default weight.
const evenNumbers = numbers.filter(num => num % 2 === 0);
const filteredArray = array.filter(item => item !== null && item !== undefined);
impress.addPreInitPlugin( preInit, 1 );

} )( document, window );
const filteredArray = array.filter(item => item !== null && item !== undefined);