Sourcecode in Poll/actions.js:
1: function edit_action() {
2: // pre-process submitted choices
3: var arr = new Array();
4: if (req.data.title_array) {
5: for (var i=0;i<req.data.title_array.length;i++) {
6: var title = req.data.title_array[i].trim();
7: if (title)
8: arr[arr.length] = new Choice(title);
9: }
10: } else if (req.data.title) {
11: var title = req.data.title.trim();
12: if (title)
13: arr[0] = new Choice(title);
14: } else
15: arr = this.list();
16:
17: if (req.data.cancel) {
18: res.redirect(this.href());
19: } else if (req.data.save) {
20: try {
21: res.message = this.evalPoll(req.data.question, arr, session.user);
22: res.redirect(this.site.polls.href());
23: } catch (err) {
24: res.message = err.toString();
25: }
26: } else if (req.data.addchoice)
27: arr.push(new Choice(""));
28:
29: res.push();
30: var max = Math.max(2, arr.length);
31: for (var i=0;i<max;i++) {
32: var c = arr[i] != null ? arr[i] : new Choice("");
33: c.renderSkin("edit", {count: (i+1).toString()});
34: }
35: res.data.choices = res.pop();
36: res.data.action = this.href(req.action);
37: res.data.title = getMessage("Poll.editTitle", {question: this.question});
38: res.data.body = this.renderSkinAsString("edit");
39: this.site.renderSkin("page");
40: return;
41: }
|