1234567891011121314151617181920 |
- /// <reference path="../Say.ts" />
- class SayProtip extends Say {
- private static tipCounter = {};
- public async getPureElements () : Promise<Array<Element | Text>> {
- let paragraphs = await this.getParagraphs();
- let elements = paragraphs.length == 1 ? paragraphs[0] : Array.prototype.concat.apply([], paragraphs);
- let span = document.createElement("span");
- span.classList.add("protip");
- elements.forEach((element) => {
- span.appendChild(element);
- });
- SayProtip.tipCounter[span.innerText] = SayProtip.tipCounter[span.innerText] == undefined ? 1 : SayProtip.tipCounter[span.innerText] + 1;
- if (SayProtip.tipCounter[span.innerText] <= 5) {
- return [span];
- } else {
- return [];
- }
- }
- }
|