annotate web/views/set.tpl @ 183:177f616893e6

param editor roughly working
author Matt Johnston <matt@ucc.asn.au>
date Tue, 04 Feb 2014 23:39:06 +0800
parents e731c0d30b09
children cbe14244a372
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
182
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3 <head>
183
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
5 <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=8,minimum-scale=0.1">
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
6 <script src="jquery-2.1.0.min.js"></script>
182
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7 <script>
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8 %include riot.min.js
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
9 </script>
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
10
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
11 <style type="text/css">
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
12 span.no_selection {
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
13 -webkit-user-select: none; // webkit (safari, chrome) browsers
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
14 -moz-user-select: none; // mozilla browsers
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
15 -khtml-user-select: none; // webkit (konqueror) browsers
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
16 }
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
17
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
18 body {
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
19 font-family: "sans-serif";
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
20 }
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
21
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
22 input {
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
23 border: 2px solid transparent;
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
24 border-radius: 4px;
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
25 background-color: white;
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
26 border-color: black;
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
27 padding: 0;
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
28 font-size: 80%;
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
29 }
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
30
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
31 input[type="button"] {
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
32 width: 4em;
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
33 height: 4em;
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
34 margin-left: 0.5em;
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
35 }
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
36
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
37 input[type="submit"] {
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
38 width: 10em;
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
39 height: 4em;
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
40 margin-top: 1em;
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
41 align: center;
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
42 }
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
43
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
44 input[type="text"] {
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
45 height: 4em;
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
46 text-align: center;
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
47 }
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
48
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
49 .onbutton {
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
50 background-color: #cdf;
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
51 }
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
52
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
53 .existing {
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
54 margin-top: 1em;
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
55 font-size: 70%;
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
56 }
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
57
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
58 </style>
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
59 <title>Set templog</title>
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
60 </head>
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
61
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
62 <body>
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
63
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
64 <section id="paramlist">
183
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
65 </section>
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
66
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
67 <div id="jsontest">
182
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
68 </div>
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
69
183
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
70 <input type="button" id="savebutton" value="Save"/>
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
71
182
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
72 </body>
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
73
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
74 <script type="html/num_input">
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
75 <div id="{id}">
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
76 <span class="existing">{title} <span id="existing_{name}">{oldvalue}</span>{unit}</span>
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
77 <br/>
183
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
78 <input type="text" class="input" name="input_{name}" />
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
79 <input type="button" class="button_down" value="-"/>
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
80 <input type="button" class="button_up" value="+"/>
182
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
81 </div>
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
82 </script>
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
83
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
84 <script type="html/yesno_button">
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
85 <div id="{id}">
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
86 <span class="existing">{title} <span id="existing_{name}">{oldvalue}</span></span>
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
87 <br/>
183
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
88 <input type="button" class="button_no" value="No"/>
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
89 <input type="button" class="button_yes" value="Yes"/>
182
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
90 </div>
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
91 </script>
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
92
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
93 <script>
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
94
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
95 function Setter(params) {
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
96 var self = $.observable(this);
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
97
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
98 self.params = params;
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
99
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
100 $.each(self.params, function(idx, param) {
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
101 param.id = "param_id_" + idx;
183
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
102 param.oldvalue = param.value;
182
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
103 });
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
104
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
105 self.edit = function(param) {
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
106 params[param.name] = param;
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
107 self.trigger("edit", param);
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
108 }
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
109
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
110 self.adjust = function(param, updown) {
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
111 // XXX increment
183
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
112 param.value += (param.amount*updown);
182
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
113 self.trigger("edit", param);
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
114 }
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
115
183
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
116 self.save = function() {
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
117 var j = JSON.stringify(self.params);
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
118 self.trigger("saved", j)
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
119 }
182
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
120 }
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
121
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
122 (function() { 'use strict';
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
123
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
124 var params = {{!inline_data}};
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
125 window.setter = new Setter(params);
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
126
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
127 var root = $("#paramlist");
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
128
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
129 var number_template = $("[type='html/num_input']").html();
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
130 var button_template = $("[type='html/yesno_button']").html();
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
131
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
132 setter.on("add", add);
183
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
133
182
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
134 setter.on("edit", function(param)
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
135 {
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
136 var el = $("#" + param.id);
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
137 if (param.kind === "number")
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
138 {
183
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
139 set_text_state(el, param.value);
182
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
140 }
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
141 else if (param.kind === "yesno")
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
142 {
183
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
143 set_button_state(el, param.value);
182
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
144 }
183
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
145 });
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
146
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
147 setter.on("saved", function(j) {
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
148 $("#jsontest").text(j);
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
149 });
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
150
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
151
182
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
152
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
153 $.route(function(hash) {
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
154
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
155 // clear list and add new ones
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
156 root.empty() && $.each(setter.params, function (idx, p) {
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
157 add(p);
183
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
158
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
159 $("#savebutton").click(function() {
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
160 setter.save();
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
161 })
182
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
162 })
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
163 })
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
164
183
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
165 function set_text_state(el, value)
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
166 {
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
167 var input = $(".input", el);
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
168 input.text(value).val(value)
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
169 }
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
170
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
171 function set_button_state(el, value)
182
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
172 {
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
173 var button_yes = $(".button_yes", el);
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
174 var button_no = $(".button_no", el);
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
175 if (value)
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
176 {
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
177 button_yes.addClass("onbutton");
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
178 button_no.removeClass("onbutton");
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
179 }
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
180 else
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
181 {
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
182 button_no.addClass("onbutton");
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
183 button_yes.removeClass("onbutton");
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
184 }
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
185 }
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
186
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
187 function add(param)
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
188 {
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
189 if (param.kind === "number")
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
190 {
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
191 var el = $($.render(number_template, param)).appendTo(root);
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
192 var input = $(".input", el);
183
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
193
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
194 input.keyup(function(e) {
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
195 if (e.which == 13)
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
196 {
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
197 param.value = Number(this.value);
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
198 setter.edit(param);
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
199 }
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
200 });
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
201
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
202 $(".button_up", el).click(function() {
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
203 setter.adjust(param, 1);
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
204 });
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
205 $(".button_down", el).click(function() {
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
206 setter.adjust(param, -1);
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
207 });
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
208
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
209 set_text_state(el, param.value);
182
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
210 }
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
211 else if (param.kind === "yesno")
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
212 {
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
213 var el = $($.render(button_template, param)).appendTo(root);
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
214 var button_yes = $(".button_yes", el);
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
215 var button_no = $(".button_no", el);
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
216
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
217 button_yes.click(function() {
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
218 param.value = true;
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
219 setter.edit(param);
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
220 })
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
221
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
222 button_no.click(function() {
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
223 param.value = false;
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
224 setter.edit(param);
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
225 })
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
226
183
177f616893e6 param editor roughly working
Matt Johnston <matt@ucc.asn.au>
parents: 182
diff changeset
227 set_button_state(el, param.value);
182
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
228 }
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
229 }
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
230
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
231 })()
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
232
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
233 </script>
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
234
e731c0d30b09 set nearly working
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
235 </html>