-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpoll.js
52 lines (49 loc) · 1.19 KB
/
poll.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
$("#title_button").live('click', function()
{
alert('here');
var title = document.getElementById('new_title').value;
var state = wave.getState();
var delta = {};
delta['title'] = title;
state.submitDelta(delta);
});
function addEntry()
{
var state = wave.getState();
var entries = state.get('entries', false);
var entryCount = 0;
if(entries)
{
entryCount = entries.length;
alert(entryCount);
}
var newEntry = document.getElementById('new_entry').value;
var entryName = 'entry' + entryCount;
alert(entries);
alert(entryName);
var delta = {};
delta['entries'] = { entryName : newEntry };
alert(delta['entries']);
state.submitDelta(delta);
};
function render()
{
if(!wave.getState())
{
return;
}
var state = wave.getState();
var title = state.get('title', false);
var entries = state.get('entries', false);
if(title)
{
document.getElementById('strowl_poll').innerHTML = title + "<br /><input id='new_entry' size='30'><button onclick='addEntry()'>Add entry</button><br /><div id='entries'></div>";
if(entries)
{
for(var i = 0; i < entries.length; i++)
{
document.getElementById('entries').innerHTML = i;
}
}
}
};