-
Notifications
You must be signed in to change notification settings - Fork 11
Link to Open Fixture Library #128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 30 commits
c248a97
8610528
065aabd
44672a2
9fb1d19
c9c2bd7
123d415
2495fff
70685f0
5d67555
ab59937
c9a3e28
5d6108e
6691d41
06006ff
436e8a0
f40c907
61a3515
6872b28
9cb9b2f
b6d625f
60a8664
051d284
8ca247e
dbf8743
b38bd14
a5f5897
49840d9
a089d43
af0e3de
5f76a1d
387be32
42dc9f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,18 +17,18 @@ | |
| * Copyright (C) 2011 Simon Newton | ||
| */ | ||
|
|
||
| goog.provide('app.setup'); | ||
|
|
||
| goog.require('app.displayCommand'); | ||
| goog.require('goog.dom'); | ||
| goog.require('goog.events'); | ||
| goog.require('goog.ui.Component'); | ||
| goog.require('goog.ui.TableSorter'); | ||
| goog.require('app.MessageStructure'); | ||
|
|
||
| goog.provide('app.setup'); | ||
|
|
||
| var app = app || {} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't look like app is being defined anywhere now. Although I understand why you've gone down this route. See my suggestion here about pulling some stuff out into another file to avoid the circular dependencies:
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Regardless where I put |
||
|
|
||
| // Empty list, this is populated in the page | ||
| app.SOFTWARE_VERSIONS = [] | ||
| // These are populated in the page | ||
| app.SOFTWARE_VERSIONS = []; | ||
| app.OPEN_FIXTURE_LIBRARY_MODEL_URL = null; | ||
|
|
||
| /** | ||
| * Sort hex values | ||
|
|
@@ -37,7 +37,7 @@ app.SOFTWARE_VERSIONS = [] | |
| * @return {number} Negative if a < b, 0 if a = b, and positive if a > b. | ||
| */ | ||
| app.hexSort = function(a, b) { | ||
| return parseInt(a) - parseInt(b); | ||
| return parseInt(a, 16) - parseInt(b, 16); | ||
| }; | ||
|
|
||
|
|
||
|
|
@@ -61,45 +61,52 @@ app.toHex = function(n, padding) { | |
|
|
||
| /** | ||
| * Hide a node. | ||
| * @param {!Element} node The HTML element to hide. | ||
| */ | ||
| app.hideNode = function(node) { | ||
| node.style.display = 'none'; | ||
| } | ||
| }; | ||
|
|
||
| /** | ||
| * Show a block node | ||
| * @param {!Element} node The HTML element to show as a block. | ||
| */ | ||
| app.showBlock = function(node) { | ||
| node.style.display = 'block'; | ||
| } | ||
| }; | ||
|
|
||
| /** | ||
| * Show a inline node | ||
| * @param {!Element} node The HTML element to show inline. | ||
| */ | ||
| app.showInline = function(node) { | ||
| node.style.display = 'inline'; | ||
| } | ||
| }; | ||
|
|
||
| /** | ||
| * Show a table row | ||
| * @param {!Element} row The HTML element to show as a table row. | ||
| */ | ||
| app.showRow = function(row) { | ||
| row.style.display = 'table-row'; | ||
| } | ||
| }; | ||
|
|
||
|
|
||
| /** | ||
| * Create a TD node and set the innerHTML property | ||
| * @param {!string} text Inner HTML for the new table cell. | ||
| * @return {!Element} The created TD element. | ||
| */ | ||
| app.newTD = function(text) { | ||
| var td = goog.dom.createDom('td'); | ||
| td.innerHTML = text; | ||
| return td; | ||
| } | ||
| }; | ||
|
|
||
|
|
||
| /** | ||
| * Make the model table sortable | ||
| * @param {!string} table_id | ||
| */ | ||
| app.makeModelTable = function(table_id) { | ||
| var table = new goog.ui.TableSorter(); | ||
|
|
@@ -114,15 +121,28 @@ goog.exportSymbol('app.makeModelTable', app.makeModelTable); | |
|
|
||
| /** | ||
| * Set the software versions | ||
| * @param {!string} version_info The software versions. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at https://github.com/google/closure-compiler/wiki/Types-in-the-Closure-Type-System shouldn't this be
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
| */ | ||
| app.setSoftwareVersions = function(version_info) { | ||
| app.SOFTWARE_VERSIONS = version_info; | ||
| }; | ||
| goog.exportSymbol('app.setSoftwareVersions', app.setSoftwareVersions); | ||
|
|
||
|
|
||
| /** | ||
| * Set the URL of the RDM lookup page in the Open Fixture library with the RDM IDs | ||
| * of this model so we can use it to link every personality. | ||
| * @param {!string} url The URL with query parameters for RDM manufacturer ID and RDM model ID. | ||
| */ | ||
| app.setOpenFixtureLibraryModelUrl = function(url) { | ||
| app.OPEN_FIXTURE_LIBRARY_MODEL_URL = url; | ||
| }; | ||
| goog.exportSymbol('app.setOpenFixtureLibraryModelUrl', app.setOpenFixtureLibraryModelUrl); | ||
|
|
||
|
|
||
| /** | ||
| * Display info for the currently selected software version | ||
| * @param {?Element=} element | ||
| */ | ||
| app.changeSoftwareVersion = function(element) { | ||
| // default to displaying the first version | ||
|
|
@@ -138,87 +158,97 @@ app.changeSoftwareVersion = function(element) { | |
| // DMX Personalities | ||
| var personalities = software_version['personalities']; | ||
| var personality_fieldset = goog.dom.$('model_personality_fieldset'); | ||
| if (personalities && personalities.length) { | ||
| var tbody = goog.dom.$('model_personality_tbody'); | ||
| goog.dom.removeChildren(tbody); | ||
| for (var i = 0; i < personalities.length; ++i) { | ||
| var personality = personalities[i]; | ||
| var tr = goog.dom.createDom('tr'); | ||
| // add the cells | ||
| goog.dom.appendChild(tr, app.newTD(personality['index'])); | ||
| if ('slot_count' in personality) { | ||
| goog.dom.appendChild(tr, app.newTD(personality['slot_count'])); | ||
| } else { | ||
| goog.dom.appendChild(tr, app.newTD('Unknown')); | ||
| if (personality_fieldset) { | ||
| if (personalities && personalities.length) { | ||
| var tbody = goog.dom.$('model_personality_tbody'); | ||
| goog.dom.removeChildren(tbody); | ||
| for (var i = 0; i < personalities.length; ++i) { | ||
| var personality = personalities[i]; | ||
| var oflLink = app.OPEN_FIXTURE_LIBRARY_MODEL_URL + '&personalityIndex=' + personality['index']; | ||
|
|
||
| var tr = goog.dom.createDom('tr'); | ||
| // add the cells | ||
| goog.dom.appendChild(tr, app.newTD(personality['index'])); | ||
| if ('slot_count' in personality) { | ||
| goog.dom.appendChild(tr, app.newTD(personality['slot_count'])); | ||
| } else { | ||
| goog.dom.appendChild(tr, app.newTD('Unknown')); | ||
| } | ||
| goog.dom.appendChild(tr, app.newTD(personality['description'])); | ||
| goog.dom.appendChild(tr, app.newTD('<a href="' + oflLink + '">View in Open Fixture Library</a>')); | ||
| goog.dom.appendChild(tbody, tr); | ||
| } | ||
| goog.dom.appendChild(tr, app.newTD(personality['description'])); | ||
| goog.dom.appendChild(tbody, tr); | ||
| app.showBlock(personality_fieldset); | ||
| } else { | ||
| app.hideNode(personality_fieldset); | ||
| } | ||
| app.showBlock(personality_fieldset); | ||
| } else { | ||
| app.hideNode(personality_fieldset); | ||
| } | ||
|
|
||
| // Sensors | ||
| var sensors = software_version['sensors']; | ||
| var sensor_fieldset = goog.dom.$('model_sensor_fieldset'); | ||
| if (sensors && sensors.length) { | ||
| var tbody = goog.dom.$('model_sensor_tbody'); | ||
| goog.dom.removeChildren(tbody); | ||
| for (var i = 0; i < sensors.length; ++i) { | ||
| var sensor = sensors[i]; | ||
| var tr = goog.dom.createDom('tr'); | ||
| // add the cells | ||
| goog.dom.appendChild(tr, app.newTD(sensor['index'])); | ||
| goog.dom.appendChild(tr, app.newTD(sensor['description'])); | ||
| var type_str = sensor['type_str']; | ||
| var sensor_type = ''; | ||
| if (type_str) { | ||
| sensor_type = type_str + ' (0x' + app.toHex(sensor['type'], 2) + ')'; | ||
| } else { | ||
| sensor_type = app.toHex(sensor['type'], 2) | ||
| if (sensor_fieldset) { | ||
| if (sensors && sensors.length) { | ||
| var tbody = goog.dom.$('model_sensor_tbody'); | ||
| goog.dom.removeChildren(tbody); | ||
| for (var i = 0; i < sensors.length; ++i) { | ||
| var sensor = sensors[i]; | ||
| var tr = goog.dom.createDom('tr'); | ||
| // add the cells | ||
| goog.dom.appendChild(tr, app.newTD(sensor['index'])); | ||
| goog.dom.appendChild(tr, app.newTD(sensor['description'])); | ||
| var type_str = sensor['type_str']; | ||
| var sensor_type = ''; | ||
| if (type_str) { | ||
| sensor_type = type_str + ' (0x' + app.toHex(sensor['type'], 2) + ')'; | ||
| } else { | ||
| sensor_type = app.toHex(sensor['type'], 2); | ||
| } | ||
| goog.dom.appendChild(tr, app.newTD(sensor_type)); | ||
| goog.dom.appendChild(tr, app.newTD(sensor['supports_recording'])); | ||
| goog.dom.appendChild(tr, app.newTD(sensor['supports_min_max'])); | ||
| goog.dom.appendChild(tbody, tr); | ||
| } | ||
| goog.dom.appendChild(tr, app.newTD(sensor_type)); | ||
| goog.dom.appendChild(tr, app.newTD(sensor['supports_recording'])); | ||
| goog.dom.appendChild(tr, app.newTD(sensor['supports_min_max'])); | ||
| goog.dom.appendChild(tbody, tr); | ||
| app.showBlock(sensor_fieldset); | ||
| } else { | ||
| app.hideNode(sensor_fieldset); | ||
| } | ||
| app.showBlock(sensor_fieldset); | ||
| } else { | ||
| app.hideNode(sensor_fieldset); | ||
| } | ||
|
|
||
| // supported params | ||
| var supported_params = software_version['supported_parameters']; | ||
| var supported_params_fieldset = goog.dom.$('model_params_fieldset'); | ||
| if (supported_params && supported_params.length) { | ||
| var supported_params_list = goog.dom.$('model_params_list'); | ||
| goog.dom.removeChildren(supported_params_list); | ||
| for (var i = 0; i < supported_params.length; ++i) { | ||
| var param = supported_params[i]; | ||
| var param_name = param['name']; | ||
| var li = goog.dom.createDom('li'); | ||
| if (param_name) { | ||
| var a = goog.dom.createDom('a'); | ||
| a.innerHTML = param_name + ' (0x' + app.toHex(param['id'], 4) + ')'; | ||
| a.href = ('/pid/display?manufacturer=' + param['manufacturer_id'] + | ||
| '&pid=' + param['id']); | ||
| goog.dom.appendChild(li, a) | ||
| } else { | ||
| li.innerHTML = '0x' + app.toHex(param['id'], 4); | ||
| if (supported_params_fieldset) { | ||
| if (supported_params && supported_params.length) { | ||
| var supported_params_list = goog.dom.$('model_params_list'); | ||
| goog.dom.removeChildren(supported_params_list); | ||
| for (var i = 0; i < supported_params.length; ++i) { | ||
| var param = supported_params[i]; | ||
| var param_name = param['name']; | ||
| var li = goog.dom.createDom('li'); | ||
| if (param_name) { | ||
| var a = goog.dom.createDom('a'); | ||
| a.innerHTML = param_name + ' (0x' + app.toHex(param['id'], 4) + ')'; | ||
| a.href = ('/pid/display?manufacturer=' + param['manufacturer_id'] + | ||
| '&pid=' + param['id']); | ||
| goog.dom.appendChild(li, a); | ||
| } else { | ||
| li.innerHTML = '0x' + app.toHex(param['id'], 4); | ||
| } | ||
| goog.dom.appendChild(supported_params_list, li); | ||
| } | ||
| goog.dom.appendChild(supported_params_list, li); | ||
| app.showBlock(supported_params_fieldset); | ||
| } else { | ||
| app.hideNode(supported_params_fieldset); | ||
| } | ||
| app.showBlock(supported_params_fieldset); | ||
| } else { | ||
| app.hideNode(supported_params_fieldset); | ||
| } | ||
| }; | ||
| goog.exportSymbol('app.changeSoftwareVersion', app.changeSoftwareVersion); | ||
|
|
||
|
|
||
| /** | ||
| * Display the latest version for the element. | ||
| * @param {!Element} element | ||
| */ | ||
| app.setLatestVersion = function(element) { | ||
| var index = 0; | ||
|
|
@@ -232,12 +262,13 @@ app.setLatestVersion = function(element) { | |
| } | ||
| element.selectedIndex = index; | ||
| app.changeSoftwareVersion(element); | ||
| } | ||
| }; | ||
| goog.exportSymbol('app.setLatestVersion', app.setLatestVersion); | ||
|
|
||
|
|
||
| /** | ||
| * Make the pid table sortable | ||
| * @param {!string} table_id | ||
| */ | ||
| app.makePIDTable = function(table_id) { | ||
| var table = new goog.ui.TableSorter(); | ||
|
|
@@ -251,14 +282,3 @@ app.makePIDTable = function(table_id) { | |
| table.setSortFunction(5, goog.ui.TableSorter.alphaSort); | ||
| }; | ||
| goog.exportSymbol('app.makePIDTable', app.makePIDTable); | ||
|
|
||
|
|
||
| /** | ||
| * Display a pid command | ||
| */ | ||
| app.displayCommand = function(json, element_id) { | ||
| var msg_structure = new app.MessageStructure(); | ||
| msg_structure.decorate(goog.dom.$(element_id)); | ||
| msg_structure.update(json['items']); | ||
| }; | ||
| goog.exportSymbol('app.displayCommand', app.displayCommand); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to say you don't need this, but I'm guessing it optimises it out if it's not in there otherwise?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's not in there, I get a
TypeError: app.displayCommand is not a functionin the browser console on PID pages. However, I just noticed another error:TypeError: this.l.ya is not a function😕There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, then you have to look at the minification to make sense of it! Or perhaps try the non-advanced optimisation may be enough to tell, while giving it a real function name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, it's actually one of those warnings that were not produced by my changes:
this.tt.setHtml is not a functionUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ping @FloEdelmann . I've been doing some testing with deploy in #206 and I'm currently getting that "TypeError: this.l.ya is not a function" error and no tooltips e.g. on http://peter-ola-rdm-app.appspot.com/pid/display?manufacturer=0&pid=1 . It does work with what's on live though... http://rdm.openlighting.org/pid/display?manufacturer=0&pid=1
Prior to your changes it hadn't been touched since 2015, which is most likely what live is running.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this is why, and I suspect your bumping of closure-compiler and/or recompiling means we now need to update various bits such as: gmalartre/closure-library@8932858#diff-b655ee9f9748151f90992f5878791bf6L142
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, I didn't notice a consequence of that error when testing in this PR; seems like it does matter though (it even stops showing the upper_uid box).
Have you already tried just replacing
this.tt.setHtmlwiththis.tt.setSafeHtmlhere? https://github.com/OpenLightingProject/rdm-app/blob/master/js_src/pid_display.js#L122In the second occurrence in that file (line 234),
setTextshould be enough.Both should be available (in contrast to the old
setHtml), according to the Closure API.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in #209