view service/arduinoNode/static/output-widgets.html @ 978:e9ed6159b5fa

handle compact/full uris better, but still not always right Ignore-this: 10d98f16a659f899528eb86411473b18 darcs-hash:20150417090015-312f9-dd07384187555a6909b9630c98e09ab5f9865f7c
author drewp <drewp@bigasterisk.com>
date Fri, 17 Apr 2015 02:00:15 -0700
parents 6754aa8aab38
children fc5fdcc3ed4a
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 | 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.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>