-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathActionStopSpeech.js
63 lines (51 loc) · 1.32 KB
/
ActionStopSpeech.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*\
title: $:/plugins/OokTech/TiddlyTalking/action-stopspeech.js
type: application/javascript
module-type: widget
Action widget to stop any speech started by action-readtiddler
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
var Widget = require("$:/core/modules/widgets/widget.js").widget;
var StopSpeech = function(parseTreeNode,options) {
this.initialise(parseTreeNode,options);
};
/*
Inherit from the base widget class
*/
StopSpeech.prototype = new Widget();
/*
Render this widget into the DOM
*/
StopSpeech.prototype.render = function(parent,nextSibling) {
this.computeAttributes();
this.execute();
};
/*
Compute the internal state of the widget
*/
StopSpeech.prototype.execute = function() {
$tw.speechSynthesis = window.speechSynthesis;
};
/*
Refresh the widget by ensuring our attributes are up to date
*/
StopSpeech.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes();
if(changedAttributes["tiddler"]) {
this.refreshSelf();
return true;
}
return this.refreshChildren(changedTiddlers);
};
/*
Invoke the action associated with this widget
*/
StopSpeech.prototype.invokeAction = function(triggeringWidget,event) {
$tw.speechSynthesis.cancel();
return true; // Action was invoked
};
exports["action-stopspeech"] = StopSpeech;
})();