-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-gadget.xml
44 lines (38 loc) · 1.22 KB
/
test-gadget.xml
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
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="State Example" height="120">
<Require feature="wave" />
</ModulePrefs>
<Content type="html">
<![CDATA[
<div id="content_div" style="height: 50px;"></div>
<script type="text/javascript">
var div = document.getElementById('content_div');
function buttonClicked() {
var value = parseInt(wave.getState().get('count', '0'));
wave.getState().submitDelta({'count': value + 1});
}
function stateUpdated() {
if(!wave.getState().get('count')) {
div.innerHTML = "The count is 0."
}
else {
div.innerHTML = "The count is " + wave.getState().get('count');
}
}
function init() {
if (wave && wave.isInWaveContainer()) {
wave.setStateCallback(stateUpdated);
}
}
gadgets.util.registerOnLoadHandler(init);
// Reset value of "count" to 0
function resetCounter(){
wave.getState().submitDelta({'count': '0'});
}
</script>
<input type=button value="Click Me!" id="butCount" onClick="buttonClicked()">
<input type=button value="Reset" id="butReset" onClick="resetCounter()">
]]>
</Content>
</Module>