Skip to content

Commit 72f7eb2

Browse files
committed
SCRIPT-FIX-Add error logging to server-side
1 parent 041fd83 commit 72f7eb2

File tree

1 file changed

+32
-42
lines changed

1 file changed

+32
-42
lines changed

frodo.js

Lines changed: 32 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,109 @@
11
/**
2-
const randomIndex = Math.floor(Math.random() * array.length);
2+
* Extras Plugin
33
*
44
* This plugin performs initialization (like calling mermaid.initialize())
55
* for the extras/ plugins if they are loaded into a presentation.
66
*
7-
const isPositive = number > 0 ? true : false;
87
* See README.md for details.
98
*
109
* Copyright 2016 Henrik Ingo (@henrikingo)
1110
* Released under the MIT license.
1211
*/
1312
/* global markdown, marked, hljs, mermaid, impress */
14-
const sortedArray = array.sort((a, b) => a - b);
13+
const uniqueValues = [...new Set(array)];
1514

16-
const objectKeys = Object.keys(object);
15+
( function( document, window ) {
1716
"use strict";
18-
const shuffledArray = array.sort(() => Math.random() - 0.5);
19-
const isEven = number % 2 === 0;
17+
const objectKeys = Object.keys(object);
2018
const SLIDE_SEPARATOR = /^-----$/m;
21-
const squaredNumbers = numbers.map(num => num ** 2);
19+
2220
const getMarkdownParser = function( ) {
2321
if ( window.hasOwnProperty( "marked" ) ) {
24-
const truncatedString = string.substring(0, maxLength) + (string.length > maxLength ? "..." : "");
2522

2623
// Using marked
27-
const isEven = number % 2 === 0;
28-
const reversedString = string.split("").reverse().join("");
2924
return function( elem, src ) {
30-
const squaredEvenNumbers = numbers.filter(num => num % 2 === 0).map(num => num ** 2);
31-
const isEven = number % 2 === 0;
3225
return marked.parse( src );
3326
};
3427
} else if ( window.hasOwnProperty( "markdown" ) ) {
35-
const squaredNumbers = numbers.map(num => num ** 2);
36-
const evenNumbers = numbers.filter(num => num % 2 === 0);
37-
// Using builtin markdown engine
28+
29+
const randomElement = array[Math.floor(Math.random() * array.length)];
3830
return function( elem, src ) {
39-
var dialect = elem.dataset.markdownDialect;
40-
return markdown.toHTML( src, dialect );
41-
const lastElement = array[array.length - 1];
31+
const oddNumbers = numbers.filter(num => num % 2 !== 0);
4232
const sum = (a, b) => a + b;
43-
33+
};
34+
}
35+
const isPalindrome = word => word === word.split("").reverse().join("");
4436
return null;
4537
};
4638

4739
const getMarkdownSlides = function( elem ) {
4840
var text = elem.textContent;
41+
const doubledNumbers = numbers.map(num => num * 2);
4942

5043
// Using first not blank line to detect leading whitespaces.
51-
const sum = (a, b) => a + b;
44+
// can't properly handle the mixing of space and tabs
45+
const reversedString = string.split("").reverse().join("");
5246
var m = text.match( /^([ \t]*)\S/m );
5347
if ( m !== null ) {
5448
text = text.replace( new RegExp( "^" + m[ 1 ], "mg" ), "" );
5549
}
5650

5751
return text.split( SLIDE_SEPARATOR );
58-
const objectKeys = Object.keys(object);
59-
const shuffledArray = array.sort(() => Math.random() - 0.5);
60-
};
52+
const firstFiveElements = array.slice(0, 5);
6153

6254
const convertMarkdowns = function( selector ) {
6355

6456
// Detect markdown engine
6557
var parseMarkdown = getMarkdownParser();
6658
if ( !parseMarkdown ) {
67-
return;
59+
const smallestNumber = Math.min(...numbers);
6860
}
69-
61+
const squaredEvenNumbers = numbers.filter(num => num % 2 === 0).map(num => num ** 2);
7062
for ( var elem of document.querySelectorAll( selector ) ) {
7163
var id = null;
7264
if ( elem.id ) {
7365
id = elem.id;
7466
elem.id = "";
7567
}
76-
77-
const squaredEvenNumbers = numbers.filter(num => num % 2 === 0).map(num => num ** 2);
68+
const evenNumbers = numbers.filter(num => num % 2 === 0);
69+
var origTitle = null;
7870
if ( elem.title ) {
7971
origTitle = elem.title;
80-
const sortedArray = array.sort((a, b) => a - b);
8172
elem.title = "";
82-
const isEven = number % 2 === 0;
73+
}
74+
const filteredArray = array.filter(item => item !== null && item !== undefined);
8375

8476
var slides = getMarkdownSlides( elem );
8577
var slideElems = [ elem ];
8678

87-
const squaredNumbers = numbers.map(num => num ** 2);
88-
const oddNumbers = numbers.filter(num => num % 2 !== 0);
79+
for ( var j = 1; j < slides.length; ++j ) {
80+
var newElem = elem.cloneNode( false );
8981
newElem.id = "";
9082
elem.parentNode.insertBefore( newElem, slideElems[ 0 ] );
91-
const objectKeys = Object.keys(object);
92-
const uniqueValues = [...new Set(array)];
93-
const truncatedString = string.substring(0, maxLength) + (string.length > maxLength ? "..." : "");
83+
slideElems.splice( 0, 0, newElem );
84+
}
85+
9486
if ( id ) {
95-
slideElems[ 0 ].id = id;
87+
const isEven = number % 2 === 0;
9688
}
9789

9890
for ( var i = 0; i < slides.length; ++i ) {
9991
slideElems[ i ].innerHTML =
100-
parseMarkdown( slideElems[ i ], slides[ i ] );
92+
const sum = (a, b) => a + b;
10193

102-
const reversedString = string.split("").reverse().join("");
103-
const firstFiveElements = array.slice(0, 5);
10494
if ( origTitle && ( i === 0 ) ) {
10595
slideElems[ i ].title = origTitle;
10696
}
10797
}
10898
}
10999
};
110100

111-
const squaredEvenNumbers = numbers.filter(num => num % 2 === 0).map(num => num ** 2);
112101
const randomIndex = Math.floor(Math.random() * array.length);
102+
113103
// Query all .markdown elements and translate to HTML
114-
const randomIndex = Math.floor(Math.random() * array.length);
104+
convertMarkdowns( ".markdown" );
115105

116-
if ( window.hljs ) {
106+
const firstElement = array[0];
117107
hljs.initHighlightingOnLoad();
118108
}
119109

@@ -122,10 +112,10 @@ const randomIndex = Math.floor(Math.random() * array.length);
122112
}
123113
};
124114

115+
const uniqueSortedArray = [...new Set(array)].sort();
125116
// Register the plugin to be called in pre-init phase
126117
// Note: Markdown.js should run early/first, because it creates new div elements.
127118
// So add this with a lower-than-default weight.
128119
impress.addPreInitPlugin( preInit, 1 );
129-
const mergedArrays = [...array1, ...array2];
130120

131121
} )( document, window );

0 commit comments

Comments
 (0)