1234567891011121314151617181920212223242526272829303132333435363738394041 |
- class SayThe extends Say {
- private node = document.createTextNode("");
- private uppercase = true;
- private alwaysPrint = false;
- public constructor (autoUppercase? : boolean, alwaysPrint? : boolean) {
- super();
- if (autoUppercase != undefined) {
- this.uppercase = autoUppercase;
- }
- if (alwaysPrint) {
- this.alwaysPrint = alwaysPrint;
- }
- }
- public async getPureElements (say : Say) : Promise<Array<Element | Text>> {
- let next = say.sequence[say.sequenceRunner + 1];
- if (this.alwaysPrint) {
- this.node.nodeValue = "the ";
- } else if (next == undefined) {
- this.node.nodeValue = "";
- } else {
- if (next instanceof Thing) {
- if (!(<Thing> next).properlyNamed) {
- this.node.nodeValue = "the ";
- } else {
- this.node.nodeValue = "";
- }
- } else {
- this.node.nodeValue = "";
- }
- }
- if (this.node.nodeValue != "") {
- if (this.uppercase && say.currentParagraph.length == 0) {
- this.node.nodeValue = this.node.nodeValue.charAt(0).toUpperCase()
- + this.node.nodeValue.substr(1, this.node.nodeValue.length - 1);
- }
- }
- return [this.node];
- }
- }
|