Skip to content

Commit

Permalink
Plugin "slideChangeTracker" hinzugefügt & gulp-File angepasst
Browse files Browse the repository at this point in the history
- Plugin slideChangeTracker erstellt & zu Demo-Zwecken mit in Standardpräsentation geladen
- Zeile in gulp-Task 'plugins' auskommentiert; Beim packen des Plugins kommt es ansonsten zu einem Fehler (hakimel/reveal.js#2985)
  • Loading branch information
PSteinweg committed May 2, 2022
1 parent 885bb2e commit a1d4478
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 3 deletions.
3 changes: 2 additions & 1 deletion revealjs/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ gulp.task('plugins', () => {
{ name: 'RevealNotes', input: './plugin/notes/plugin.js', output: './plugin/notes/notes' },
{ name: 'RevealZoom', input: './plugin/zoom/plugin.js', output: './plugin/zoom/zoom' },
{ name: 'RevealMath', input: './plugin/math/plugin.js', output: './plugin/math/math' },
{ name: 'slideChangeTracker', input: './plugin/slideChangeTracker/plugin.js', output: './plugin/slideChangeTracker/slidechangetracker' },
].map( plugin => {
return rollup({
cache: cache[plugin.input],
Expand All @@ -135,7 +136,7 @@ gulp.task('plugins', () => {
commonjs(),
babel({
...babelConfig,
ignore: [/node_modules\/(?!(highlight\.js|marked)\/).*/],
//ignore: [/node_modules\/(?!(highlight\.js|marked)\/).*/], // TODO: Warum klappt gulp plugins, wenn ich diese Zeile auskommentiere?!
}),
terser()
]
Expand Down
8 changes: 6 additions & 2 deletions revealjs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -633,8 +633,9 @@ <h1>THE END</h1>
<script src="plugin/search/search.js"></script>
<script src="plugin/markdown/markdown.js"></script>
<script src="plugin/highlight/highlight.js"></script>
<script src="plugin/slideChangeTracker/slidechangetracker.js"></script>
<script>

//import slideChangeTracker from './plugin/slideChangeTracker/plugin.js'
// Also available as an ES module, see:
// https://revealjs.com/initialization/
Reveal.initialize({
Expand All @@ -644,7 +645,10 @@ <h1>THE END</h1>
hash: true,
slideNumber: "c/t",
// Learn about plugins: https://revealjs.com/plugins/
plugins: [RevealZoom, RevealNotes, RevealSearch, RevealMarkdown, RevealHighlight]
plugins: [RevealZoom, RevealNotes, RevealSearch, RevealMarkdown, RevealHighlight, slideChangeTracker],
slideChangeTracker : {
AWSUrl: "https://hip46fqe3h.execute-api.eu-west-1.amazonaws.com/timestamps",
}
});

</script>
Expand Down
61 changes: 61 additions & 0 deletions revealjs/plugin/slideChangeTracker/plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//import DynamoDBClient from '../../node_modules/@aws-sdk/client-dynamodb/dist-cjs/DynamoDBClient.js';
//import { ddbClient } from "./ddbClient.js";

const Plugin = () => {
function getFlattenedSlidenumber(reveal) {
return reveal.getSlides().indexOf(reveal.getCurrentSlide());
}

function getTotalSlideNumbers(reveal) {
return reveal.getSlides().length;
}

function addButton(reveal) {
const button = document.createElement("button");
button.textContent = "►";
button.style.cssText = "position: absolute;bottom: 0.5em; right: 0.5em;"
button.classList = "button-active";
button.addEventListener("click", function (event) {
button.classList.toggle("button-active");
button.textContent = button.textContent === "►" ? "⏸" : "►";
reveal.getConfig().writeSlideChanges = reveal.getConfig().writeSlideChanges === true ? false : true;
});
document.querySelector(".reveal").parentElement.appendChild(button);

}

function initDynamoDBClient(reveal) {
const client = DynamoDBClient()
console.log(client);
}

return {
id: 'slideChangeTracker',
init: function (reveal) {
//initDynamoDBClient();
const slideChangeEvents = [];
console.log("Config", reveal.getConfig().slideChangeTracker)
console.log("SlideChangeTracker plugin was loaded")
reveal.on("slidechanged", (event) => {
const flattenedSlideNumber = getFlattenedSlidenumber(reveal);
const totalSlideNumbers = getTotalSlideNumbers(reveal);
const dateEvent = {
"timestamp": new Date().toISOString(),
"flattenedSlideNumber": getFlattenedSlidenumber(reveal),
"slideNotation": `${flattenedSlideNumber}/${totalSlideNumbers}`,
}
if (reveal.getConfig().writeSlideChanges) {
// TODO: AWS-Krams einbinden
// TODO: Slide-Change-Event wegschreiben
slideChangeEvents.push(dateEvent);
}
console.log(slideChangeEvents)
})
addButton(reveal);
}
}
}

export default Plugin;


Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a1d4478

Please sign in to comment.