comparison web/views/set.tpl @ 188:ae5efca89001

working OK
author Matt Johnston <matt@ucc.asn.au>
date Fri, 07 Feb 2014 23:32:08 +0800
parents adbf70d1449f
children 101c66da848d
comparison
equal deleted inserted replaced
187:be1fde83630d 188:ae5efca89001
2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> 2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
3 <head> 3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5 <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=8,minimum-scale=0.1"> 5 <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=8,minimum-scale=0.1">
6 <script src="jquery-2.1.0.min.js"></script> 6 <script src="jquery-2.1.0.min.js"></script>
7 <script src="jquery.mobile.custom.min.js"></script>
7 <script> 8 <script>
8 %include riot.min.js 9 %include riot.min.js
9 </script> 10 </script>
10 11
11 <style type="text/css"> 12 <style type="text/css">
39 height: 4em; 40 height: 4em;
40 margin-top: 1em; 41 margin-top: 1em;
41 align: center; 42 align: center;
42 } 43 }
43 44
44 input[type="text"] { 45 input[type="text"], input[type="number"] {
45 height: 4em; 46 height: 4em;
46 text-align: center; 47 text-align: center;
47 } 48 }
48 49
49 #savebox { 50 #savebox {
72 73
73 <script type="html/num_input"> 74 <script type="html/num_input">
74 <div id="{id}"> 75 <div id="{id}">
75 <span class="existing">{title} <span id="oldvalue">{oldvaluetext}{unit}</span></span> 76 <span class="existing">{title} <span id="oldvalue">{oldvaluetext}{unit}</span></span>
76 <br/> 77 <br/>
77 <input type="text" class="input" name="input_{name}" /> 78 <input type="number" class="input" name="input_{name}" />
78 <input type="button" class="button_down" value="-"/> 79 <input type="button" class="button_down" value="-"/>
79 <input type="button" class="button_up" value="+"/> 80 <input type="button" class="button_up" value="+"/>
80 </div> 81 </div>
81 </script> 82 </script>
82 83
136 }); 137 });
137 138
138 var post_data = {data: JSON.stringify(post_json)}; 139 var post_data = {data: JSON.stringify(post_json)};
139 140
140 var req = $.ajax({type: "POST", 141 var req = $.ajax({type: "POST",
141 url: "setparams", 142 url: "set/update",
142 data: post_data}); 143 data: post_data});
143 144
144 req.done(function(data, status, hdr) { 145 req.done(function(data, status, hdr) {
145 self.trigger("status", "Saved") 146 self.trigger("status", "Saved")
146 }); 147 });
205 }) 206 })
206 207
207 $("#savebutton").click(function() { 208 $("#savebutton").click(function() {
208 setter.save(); 209 setter.save();
209 }) 210 })
211
212 var gofn = function() {
213 var r = '#';
214 r += (5+Math.floor(Math.random() * 5));
215 r += (5+Math.floor(Math.random() * 5));
216 r += (5+Math.floor(Math.random() * 5));
217 document.body.style.background = r;
218 this.value = r;
219 }
220 //$("#go").addEventListener("touchstart", gofn, false)
221 //$("#go").addEventListener("click", gofn, false)
222 $("#go").on("vmousedown", gofn);
210 } 223 }
211 224
212 function set_text_state(el, param) 225 function set_text_state(el, param)
213 { 226 {
214 var input = $(".input", el); 227 var input = $(".input", el);
238 251
239 input.blur(function(e) { 252 input.blur(function(e) {
240 setter.edit(param, Number(this.value)); 253 setter.edit(param, Number(this.value));
241 }); 254 });
242 255
243 $(".button_up", el).click(function() { 256 $(".button_up", el).on("vmousedown", function() {
244 setter.adjust(param, 1); 257 setter.adjust(param, 1);
245 this.blur() 258 this.blur()
246 }); 259 });
247 $(".button_down", el).click(function() { 260 $(".button_down", el).on("vmousedown", function() {
248 setter.adjust(param, -1); 261 setter.adjust(param, -1);
249 this.blur() 262 this.blur()
250 }); 263 });
251 264
252 set_text_state(el, param); 265 set_text_state(el, param);
255 { 268 {
256 var el = $($.render(button_template, param)).appendTo(root); 269 var el = $($.render(button_template, param)).appendTo(root);
257 var button_yes = $(".button_yes", el); 270 var button_yes = $(".button_yes", el);
258 var button_no = $(".button_no", el); 271 var button_no = $(".button_no", el);
259 272
260 button_yes.click(function() { 273 button_yes.on("vmousedown", function() {
261 setter.edit(param, true); 274 setter.edit(param, true);
262 this.blur() 275 this.blur()
263 }) 276 })
264 277
265 button_no.click(function() { 278 button_no.on("vmousedown", function() {
266 setter.edit(param, false); 279 setter.edit(param, false);
267 this.blur() 280 this.blur()
268 }) 281 })
269 282
270 set_button_state(el, param.value); 283 set_button_state(el, param.value);
271 } 284 }
272 } 285 }
273 286
274 })() 287 })()
275 288
289
290
276 </script> 291 </script>
277 292
278 <body> 293 <body>
294 <input type="button" id="go" value="go"/>
295
279 296
280 <section id="paramlist"> 297 <section id="paramlist">
281 </section> 298 </section>
282 299
283 <div id="savebox"> 300 <div id="savebox">