2019-11-24 00:02:31 +00:00
|
|
|
// @ts-check
|
|
|
|
/** Represents a slide */
|
2019-11-22 19:28:19 +00:00
|
|
|
export class Slide {
|
|
|
|
|
2019-11-24 00:02:31 +00:00
|
|
|
/**
|
|
|
|
* @constructor
|
|
|
|
* @param {string} text - The content of the slide
|
|
|
|
*/
|
2019-11-22 19:28:19 +00:00
|
|
|
constructor(text) {
|
2019-11-24 00:02:31 +00:00
|
|
|
/** @property {string} _text - internal text representation */
|
2019-11-22 19:28:19 +00:00
|
|
|
this._text = text;
|
2019-11-24 00:02:31 +00:00
|
|
|
/** @property {HTMLDivElement} _html - host div */
|
2019-11-22 19:28:19 +00:00
|
|
|
this._html = document.createElement('div');
|
|
|
|
this._html.innerHTML = text;
|
2019-11-24 00:02:31 +00:00
|
|
|
/** @property {string} _title - title of the slide */
|
2019-11-22 19:28:19 +00:00
|
|
|
this._title = this._html.querySelectorAll("title")[0].innerText;
|
2019-11-24 00:02:31 +00:00
|
|
|
/** @type{NodeListOf<HTMLElement>} */
|
|
|
|
const transition = (this._html.querySelectorAll("transition"));
|
2019-11-23 20:07:22 +00:00
|
|
|
if (transition.length) {
|
|
|
|
this._transition = transition[0].innerText;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this._transition = null;
|
|
|
|
}
|
2019-11-24 00:02:31 +00:00
|
|
|
/** @type{NodeListOf<HTMLElement>} */
|
2019-11-22 19:28:19 +00:00
|
|
|
const hasNext = this._html.querySelectorAll("nextslide");
|
|
|
|
if (hasNext.length > 0) {
|
|
|
|
this._nextSlideName = hasNext[0].innerText;
|
2019-11-24 00:02:31 +00:00
|
|
|
}
|
2019-11-22 19:28:19 +00:00
|
|
|
else {
|
|
|
|
this._nextSlideName = null;
|
2019-11-24 00:02:31 +00:00
|
|
|
}
|
2019-11-22 19:28:19 +00:00
|
|
|
}
|
|
|
|
|
2019-11-24 00:02:31 +00:00
|
|
|
/**
|
|
|
|
* The slide transition
|
|
|
|
* @return{string} The transition name
|
|
|
|
*/
|
2019-11-23 20:07:22 +00:00
|
|
|
get transition() {
|
|
|
|
return this._transition;
|
|
|
|
}
|
|
|
|
|
2019-11-24 00:02:31 +00:00
|
|
|
/**
|
|
|
|
* The slide title
|
|
|
|
* @return{string} The slide title
|
|
|
|
*/
|
2019-11-22 19:28:19 +00:00
|
|
|
get title() {
|
|
|
|
return this._title;
|
|
|
|
}
|
|
|
|
|
2019-11-24 00:02:31 +00:00
|
|
|
/**
|
|
|
|
* The HTML DOM node for the slide
|
|
|
|
* @return{HTMLDivElement} The HTML content
|
|
|
|
*/
|
2019-11-22 19:28:19 +00:00
|
|
|
get html() {
|
|
|
|
return this._html;
|
|
|
|
}
|
|
|
|
|
2019-11-24 00:02:31 +00:00
|
|
|
/**
|
|
|
|
* The name of the next slide (filename without the .html extension)
|
|
|
|
* @return{string} The name of the next slide
|
|
|
|
*/
|
2019-11-22 19:28:19 +00:00
|
|
|
get nextSlide() {
|
|
|
|
return this._nextSlideName;
|
|
|
|
}
|
|
|
|
}
|