annotate service/arduinoNode/static/output-widgets.html @ 218:f8ffb9d8d982

multi-boards on one service, new devices, devices return their current Ignore-this: e214852bca67519e79f9ddb3644576e1 values in the graph, jsonld support, multiple temp sensors on OW bus
author drewp@bigasterisk.com
date Sun, 03 Jan 2016 02:29:14 -0800
parents 960b3b4cdd29
children 4ebb5cc30002
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
193
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
1 <link rel="import" href="/lib/polymer/1.0.9/iron-ajax/iron-ajax.html">
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
2 <link rel="import" href="/lib/polymer/1.0.9/polymer/polymer.html">
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
3 <link rel="import" href="/lib/polymer/1.0.9/color-picker-element/dist/color-picker.html">
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
4 <link rel="import" href="/room/ari/static/rdf-uri.html">
170
376599552a4c polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
diff changeset
5
193
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
6 <dom-module id="output-sender">
170
376599552a4c polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
diff changeset
7 <template>
218
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
8 <iron-ajax id="graphGet" url="../graph" method="GET" headers='{"Accept": "application/ld+json"}'></iron-ajax>
193
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
9 <iron-ajax id="output" url="../output" method="PUT"></iron-ajax>
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
10 Set <a href$="{{subj}}">{{compactUri(subj)}}</a>'s
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
11 <span>{{compactUri(pred)}}</span> to
170
376599552a4c polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
diff changeset
12 </template>
376599552a4c polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
diff changeset
13 <script>
376599552a4c polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
diff changeset
14 Polymer({
193
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
15 is: 'output-sender',
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
16 behaviors: [BigastUri],
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
17 properties: {
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
18 subj: { notify: true },
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
19 pred: { notify: true },
218
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
20 value: { notify: true, observer: 'valueChanged' }
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
21 },
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
22 ready: function() {
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
23 this.waitOnChangeMs = 100;
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
24 this.smallestRequestPeriodMs = 200;
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
25 this.synced = false;
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
26
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
27 this.newRequestNeedsSending = false;
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
28 this.lastSendMs = 0;
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
29 this.$.output.addEventListener('response', this.onResponse.bind(this));
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
30
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
31 this.loadInitialValue();
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
32 },
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
33 loadInitialValue: function() {
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
34 this.$.graphGet.addEventListener('response', function(ev) {
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
35 ev.target.removeEventListener(ev.type, arguments.callee);
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
36
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
37 ev.detail.response.forEach(function(row) {
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
38 var subj = row['@id'];
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
39 if (subj == this.subj) {
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
40 Object.keys(row).forEach(function(pred) {
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
41 if (pred == this.pred) {
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
42 row[pred].forEach(function(obj) {
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
43 this.value = obj['@value'];
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
44 this.synced = true;
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
45 }.bind(this));
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
46 }
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
47 }.bind(this));
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
48 }
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
49 }.bind(this));
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
50
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
51 }.bind(this));
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
52 this.$.graphGet.generateRequest();
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
53 },
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
54 onResponse: function() {
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
55 if (!this.newRequestNeedsSending) {
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
56 return;
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
57 }
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
58 if (this.$.output.activeRequests.length > 0) {
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
59 return; // 'response' event will call us back
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
60 }
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
61
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
62 var now = Date.now(), dt = now - this.lastSendMs;
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
63 if (dt < this.smallestRequestPeriodMs) {
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
64 setTimeout(this.onResponse.bind(this),
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
65 this.smallestRequestPeriodMs - dt);
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
66 return;
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
67 }
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
68 this.newRequestNeedsSending = false;
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
69 this.lastSendMs = now;
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
70 this.$.output.generateRequest();
193
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
71 },
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
72 valueChanged: function () {
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
73 if (!this.subj || !this.pred) {
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
74 return;
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
75 }
187
fc5fdcc3ed4a board control ui: output-rgb, fix ajax protocol, display output uris
drewp@bigasterisk.com
parents: 173
diff changeset
76 //this.$.output.headers = {'content-type': ...}
193
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
77 this.$.output.params = {s: this.subj, p: this.pred};
187
fc5fdcc3ed4a board control ui: output-rgb, fix ajax protocol, display output uris
drewp@bigasterisk.com
parents: 173
diff changeset
78 this.$.output.body = this.value;
218
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
79 this.newRequestNeedsSending = true;
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
80 setTimeout(this.onResponse.bind(this), this.waitOnChangeMs);
170
376599552a4c polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
diff changeset
81 }
376599552a4c polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
diff changeset
82 });
376599552a4c polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
diff changeset
83 </script>
193
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
84 </dom-module>
170
376599552a4c polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
diff changeset
85
193
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
86 <dom-module id="output-rgb">
187
fc5fdcc3ed4a board control ui: output-rgb, fix ajax protocol, display output uris
drewp@bigasterisk.com
parents: 173
diff changeset
87 <template>
218
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
88 <div style="display: flex">
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
89 <div>
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
90 <output-sender subj="{{subj}}" pred="{{pred}}" value="{{value}}"></output-sender>
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
91 <div>color pick <span>{{value}}</span>
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
92 <button on-click="black">Black</button>
193
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
93 <button on-click="white">White</button>
218
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
94 </div>
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
95 </div>
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
96 <div>
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
97 <color-picker id="pick" width="200" height="100" color="{{value}}"></color-picker>
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
98 </div>
f8ffb9d8d982 multi-boards on one service, new devices, devices return their current
drewp@bigasterisk.com
parents: 193
diff changeset
99 </div>
193
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
100 </template>
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
101 <script>
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
102 Polymer({
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
103 is: 'output-rgb',
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
104 properties: {
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
105 value: { notify: true },
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
106 },
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
107 ready: function () {
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
108 this.$.pick.addEventListener('colorselected', function (ev) {
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
109 this.value = ev.detail.hex;
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
110 }.bind(this));
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
111 },
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
112 black: function() {this.value = "#000000";},
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
113 white: function() {this.value = "#ffffff";}
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
114 });
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
115 </script>
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
116 </dom-module>
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
117
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
118 <dom-module id="output-slider">
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
119 <template>
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
120 <output-sender subj="{{subj}}" pred="{{pred}}" value="{{value}}"></output-sender>
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
121 <input type="range" min="{{min}}" max="{{max}}" step="{{step}}" value="{{value::input}}"> <span>{{value}}</span>
187
fc5fdcc3ed4a board control ui: output-rgb, fix ajax protocol, display output uris
drewp@bigasterisk.com
parents: 173
diff changeset
122 </template>
fc5fdcc3ed4a board control ui: output-rgb, fix ajax protocol, display output uris
drewp@bigasterisk.com
parents: 173
diff changeset
123 <script>
fc5fdcc3ed4a board control ui: output-rgb, fix ajax protocol, display output uris
drewp@bigasterisk.com
parents: 173
diff changeset
124 Polymer({
193
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
125 is: 'output-slider',
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
126 properties: {
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
127 max: { notify: true },
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
128 min: { notify: true },
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
129 step: { notify: true }
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
130 },
187
fc5fdcc3ed4a board control ui: output-rgb, fix ajax protocol, display output uris
drewp@bigasterisk.com
parents: 173
diff changeset
131 });
fc5fdcc3ed4a board control ui: output-rgb, fix ajax protocol, display output uris
drewp@bigasterisk.com
parents: 173
diff changeset
132 </script>
193
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
133 </dom-module>
170
376599552a4c polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
diff changeset
134
193
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
135 <!--
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
136 TODO(polyup): Inheriting from other custom elements is not yet supported.
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
137 See: https://www.polymer-project.org/1.0/docs/migration.html#inheritance
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
138 -->
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
139 <dom-module id="output-fixed-text">
170
376599552a4c polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
diff changeset
140 <template>
193
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
141 <output-sender subj="{{subj}}" pred="{{pred}}" value="{{value}}"></output-sender>
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
142 <textarea rows="{{rows}}" cols="{{cols}}" value="{{value::input}}"></textarea>
170
376599552a4c polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
diff changeset
143 </template>
193
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
144 <script>
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
145 Polymer({
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
146 is: 'output-fixed-text',
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
147 properties: {
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
148 cols: { notify: true },
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
149 rows: { notify: true }
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
150 },
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
151 });
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
152 </script>
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
153 </dom-module>
170
376599552a4c polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
diff changeset
154
193
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
155 <dom-module id="output-switch">
170
376599552a4c polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
diff changeset
156 <template>
193
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
157 <output-sender subj="{{subj}}" pred="{{pred}}" value="{{value}}"></output-sender>
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
158 <input type="checkbox" checked="{{check::change}}"> <span>{{value}}</span>
170
376599552a4c polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
diff changeset
159 </template>
376599552a4c polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
diff changeset
160 <script>
376599552a4c polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
diff changeset
161 Polymer({
193
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
162 is: 'output-switch',
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
163 properties: {
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
164 check: {
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
165 type: Boolean,
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
166 value: false,
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
167 observer: 'checkChanged'
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
168 },
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
169 value: { notify: true }
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
170 },
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
171 checkChanged: function () {
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
172 this.value = this.check ? 'high' : 'low';
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
173 },
170
376599552a4c polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
diff changeset
174 });
376599552a4c polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
diff changeset
175 </script>
193
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
176 </dom-module>
170
376599552a4c polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
diff changeset
177
193
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
178 <dom-module id="output-widget-any">
170
376599552a4c polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
diff changeset
179 <template></template>
376599552a4c polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
diff changeset
180 <script>
376599552a4c polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
diff changeset
181 Polymer({
193
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
182 is: 'output-widget-any',
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
183 properties: {
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
184 desc: { type: Object, notify: true }
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
185 },
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
186 ready: function () {
170
376599552a4c polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
diff changeset
187 var elem = document.createElement(this.desc.element);
193
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
188 this.appendChild(elem);
170
376599552a4c polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
diff changeset
189 for (var k of Object.keys(this.desc)) {
376599552a4c polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
diff changeset
190 elem.setAttribute(k, this.desc[k]);
376599552a4c polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
diff changeset
191 }
376599552a4c polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
diff changeset
192 }
376599552a4c polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
diff changeset
193 });
376599552a4c polymer board debug page with working output widgets
drewp@bigasterisk.com
parents:
diff changeset
194 </script>
193
960b3b4cdd29 rewrite to polymer 1
drewp@bigasterisk.com
parents: 187
diff changeset
195 </dom-module>