diff service/arduinoNode/static/output-widgets.html @ 187:fc5fdcc3ed4a

board control ui: output-rgb, fix ajax protocol, display output uris Ignore-this: f3d3e6739851232d2177eacdd833c16
author drewp@bigasterisk.com
date Wed, 08 Jul 2015 01:22:37 -0700
parents 0daa8cbbd8f6
children 960b3b4cdd29
line wrap: on
line diff
--- a/service/arduinoNode/static/output-widgets.html	Wed Jul 08 01:21:02 2015 -0700
+++ b/service/arduinoNode/static/output-widgets.html	Wed Jul 08 01:22:37 2015 -0700
@@ -2,24 +2,38 @@
 
 <polymer-element name="output-widget" attributes="subj pred">
   <template>
-    <core-ajax id="output" url="../output" method="POST"></core-ajax>
-    Set this device's {{pred | compactUri}} to
+    <core-ajax id="output" url="../output" method="PUT"></core-ajax>
+    Set <a href="{{subj}}">{{subj | compactUri}}</a>'s {{pred | compactUri}} 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.headers = {'content-type': ...}
+	// broken in polymer 0.5 this.$.output.params = {s: this.subj, p: this.pred};
+       this.$.output.url = "output?s="+encodeURIComponent(this.subj)+"&p="+encodeURIComponent(this.pred);
+       this.$.output.body = this.value;
        this.$.output.go();
      }
    });
   </script>
 </polymer-element>
 
+<polymer-element name="output-rgb" extends="output-widget">
+  <template>
+    <color-picker id="pick" width="200" height="100" color="{{value}}"></color-picker>
+    color pick {{value}}
+  </template>
+  <script>
+    Polymer({
+      domReady: function() {
+        this.$.pick.addEventListener('colorselected', function(ev) {
+          this.value = ev.detail.hex;
+        }.bind(this));
+      }
+    });
+  </script>
+</polymer-element>
+
 <polymer-element name="output-slider" extends="output-widget"
                  attributes="min max step"
                  noscript>