Mercurial > code > home > repos > homeauto
view service/arduinoNode/static/output-widgets.html @ 171:4d2df276baae
clean up rdf-observe demo ui
Ignore-this: 8795333fe63ccd47e8c3e9584efaa43d
author | drewp@bigasterisk.com |
---|---|
date | Tue, 14 Apr 2015 02:01:51 -0700 |
parents | 376599552a4c |
children | 0daa8cbbd8f6 |
line wrap: on
line source
<link rel="import" href="/lib/polymer/0.5.2/core-ajax/core-ajax.html"> <polymer-element name="output-widget" attributes="subj pred"> <template> <core-ajax id="output" url="../output" method="POST"></core-ajax> Set this device's {{pred}} to </template> <script> function ntriple(s, p, o) { // incomplete o = o.replace('\n', '\\n'); return '<'+s+'> <'+p+'> "'+o+'".'; } Polymer({ valueChanged: function() { this.$.output.body = ntriple(this.subj, this.pred, this.value); this.$.output.go(); } }); </script> </polymer-element> <polymer-element name="output-slider" extends="output-widget" attributes="min max step" noscript> <template> <shadow></shadow> <input type="range" min="{{min}}" max="{{max}}" step="{{step}}" value="{{value}}"> {{value}} </template> </polymer-element> <polymer-element name="output-fixed-text" extends="output-widget" attributes="rows cols" noscript> <template> <textarea rows="{{rows}}" cols="{{cols}}" value="{{value}}"></textarea> </template> </polymer-element> <polymer-element name="output-switch" extends="output-widget"> <template> <shadow></shadow> <input type="checkbox" checked="{{check}}"> {{value}} </template> <script> Polymer({ check: false, checkChanged: function() { this.value = this.check ? "high" : "low"; } }); </script> </polymer-element> <polymer-element name="output-widget-any" attributes="desc"> <template></template> <script> Polymer({ domReady: function() { var elem = document.createElement(this.desc.element); this.shadowRoot.appendChild(elem); for (var k of Object.keys(this.desc)) { elem.setAttribute(k, this.desc[k]); } } }); </script> </polymer-element>