Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
c248a97
Link to Open Fixture Library
FloEdelmann Oct 13, 2017
8610528
Merge branch 'master' into patch-1
peternewman Oct 14, 2017
065aabd
add links to each OFL mode
FloEdelmann Oct 15, 2017
44672a2
update Closure build tools and compile app.js
FloEdelmann Oct 17, 2017
9fb1d19
Merge branch 'master' into patch-1
peternewman Oct 27, 2017
c9c2bd7
Merge branch 'master' into patch-1
peternewman Oct 27, 2017
123d415
exclude rdm.js from BUILD
FloEdelmann Nov 26, 2017
2495fff
call closure compiler from Gruntfile
FloEdelmann Nov 26, 2017
70685f0
fix lint and add linter option
FloEdelmann Nov 26, 2017
5d67555
Merge branch 'master' into patch-1
FloEdelmann Nov 26, 2017
ab59937
Merge branch 'master' into patch-1
FloEdelmann Nov 29, 2017
c9a3e28
Merge branch 'master' into patch-1
FloEdelmann Dec 22, 2017
5d6108e
Merge branch 'master' into patch-1
FloEdelmann Dec 29, 2017
6691d41
Merge branch 'master' into patch-1
FloEdelmann Jan 3, 2018
06006ff
Remove double-whitespace
FloEdelmann Jan 3, 2018
436e8a0
Merge branch 'master' into patch-1
FloEdelmann Jan 25, 2018
f40c907
Merge branch 'master' into patch-1
peternewman Jan 27, 2018
61a3515
Add closure-compiler to Travis
peternewman Jan 27, 2018
6872b28
Add closure-compiler to .travis-ci.sh
peternewman Jan 27, 2018
9cb9b2f
fix a lot of Closure compiler warnings
FloEdelmann Jan 27, 2018
b6d625f
source out app.displayCommand to pid_utils.js
FloEdelmann Jan 27, 2018
60a8664
Merge branch 'master' into patch-1
peternewman Jan 27, 2018
051d284
fix requested JSDoc change; set OFL base URL only once
FloEdelmann Jan 27, 2018
8ca247e
Merge branch 'patch-1' of github.com:FloEdelmann/rdm-app into patch-1
FloEdelmann Jan 27, 2018
dbf8743
Ooops, remove debug console.log()
FloEdelmann Jan 27, 2018
b38bd14
construct the URL in Python
FloEdelmann Jan 27, 2018
a5f5897
Merge branch 'master' into patch-1
peternewman Jan 31, 2018
49840d9
Merge branch 'master' into patch-1
FloEdelmann Feb 6, 2018
a089d43
move "fieldset exists?" checks out
FloEdelmann Feb 6, 2018
af0e3de
Merge branch 'master' into patch-1
FloEdelmann Feb 28, 2018
5f76a1d
update JSDoc comment types
FloEdelmann Mar 5, 2018
387be32
Add myself to contributors
FloEdelmann Mar 6, 2018
42dc9f2
Merge branch 'master' into patch-1
peternewman Mar 9, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#!/bin/sh

trunk/closure/bin/build/closurebuilder.py --root=trunk/ --root=js_src \
--namespace="app.setup" --output_mode=compiled --compiler_jar=compiler.jar \
--compiler_flags="--compilation_level=ADVANCED_OPTIMIZATIONS" \
> static/js/app.js
java \
-jar node_modules/google-closure-compiler/compiler.jar \
--js 'js_src/**.js' \
--js 'node_modules/google-closure-library/closure/**.js' \
--js 'node_modules/google-closure-library/third_party/**.js' \
--js '!**_test.js' \
--entry_point 'app.setup' \
--js_output_file static/js/app.js \
--dependency_mode STRICT \
--compilation_level ADVANCED_OPTIMIZATIONS
24 changes: 18 additions & 6 deletions js_src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ goog.require('goog.dom');
goog.require('goog.events');
goog.require('goog.ui.Component');
goog.require('goog.ui.TableSorter');
goog.require('app.MessageStructure');
goog.require('app.pid');

goog.provide('app.setup');

var app = app || {}
Copy link
Member

Choose a reason for hiding this comment

The 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:
https://groups.google.com/d/msg/open-lighting/4bgqRxhg6XQ/d2pCA7RFAgAJ

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regardless where I put var app = {};, it complains about app already being defined in js_src/pid_display.js, where goog.provide('app.pid'); is called. And it does indeed work without explicitly including it, so I wouldn't put too much effort into this.


// Empty list, this is populated in the page
app.SOFTWARE_VERSIONS = []
// These are populated in the page
app.MANUFACTURER_ID = null;
app.MODEL_ID = null;
app.SOFTWARE_VERSIONS = [];

/**
* Sort hex values
Expand Down Expand Up @@ -112,6 +112,15 @@ app.makeModelTable = function(table_id) {
goog.exportSymbol('app.makeModelTable', app.makeModelTable);


/**
* Set manufacturer and model ID
*/
app.setIds = function(manufacturer_id, model_id) {
app.MANUFACTURER_ID = manufacturer_id;
app.MODEL_ID = model_id;
};
goog.exportSymbol('app.setIds', app.setIds);

/**
* Set the software versions
*/
Expand Down Expand Up @@ -143,6 +152,8 @@ app.changeSoftwareVersion = function(element) {
goog.dom.removeChildren(tbody);
for (var i = 0; i < personalities.length; ++i) {
var personality = personalities[i];
var oflLink = 'https://open-fixture-library.herokuapp.com/rdm?manufacturerId=' + app.MANUFACTURER_ID + '&amp;modelId=' + app.MODEL_ID + '&amp;personalityIndex=' + personality['index'] + '&amp;source=olp';

var tr = goog.dom.createDom('tr');
// add the cells
goog.dom.appendChild(tr, app.newTD(personality['index']));
Expand All @@ -152,6 +163,7 @@ app.changeSoftwareVersion = function(element) {
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);
}
app.showBlock(personality_fieldset);
Expand Down Expand Up @@ -257,7 +269,7 @@ goog.exportSymbol('app.makePIDTable', app.makePIDTable);
* Display a pid command
*/
app.displayCommand = function(json, element_id) {
var msg_structure = new app.MessageStructure();
var msg_structure = new app.pid.MessageStructure();
msg_structure.decorate(goog.dom.$(element_id));
msg_structure.update(json['items']);
};
Expand Down
55 changes: 29 additions & 26 deletions js_src/pid_display.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,36 +22,37 @@ goog.require('goog.ui.Component');
goog.require('goog.ui.Tooltip');


goog.provide('app.MessageStructure');
goog.provide('app.pid');


/**
* A message field, this represents a field within a RDM message.
* @constructor
* @extends goog.ui.Component
*/
app.MessageField = function(field_info, opt_domHelper) {
app.pid.MessageField = function(field_info, opt_domHelper) {
goog.ui.Component.call(this, opt_domHelper);
this._field_info = field_info;
};
goog.inherits(app.MessageField, goog.ui.Component);
goog.inherits(app.pid.MessageField, goog.ui.Component);


/**
* Return the underlying field info
*/
app.MessageField.prototype.pid = function() { return this._pid; };
app.pid.MessageField.prototype.pid = function() { return this._pid; };


/**
* This component can't be used to decorate
*/
app.MessageField.prototype.canDecorate = function() { return false; };
app.pid.MessageField.prototype.canDecorate = function() { return false; };


/**
* Create the dom for this component
*/
app.MessageField.prototype.createDom = function() {
app.pid.MessageField.prototype.createDom = function() {
var class_names = this._field_info['type'] + '_field message_field';
var field_name = this._field_info['name'];
if (this._field_info['type'] == 'string') {
Expand Down Expand Up @@ -81,8 +82,8 @@ app.MessageField.prototype.createDom = function() {
/**
* Attach the event handler
*/
app.MessageField.prototype.enterDocument = function() {
app.MessageField.superClass_.enterDocument.call(this);
app.pid.MessageField.prototype.enterDocument = function() {
app.pid.MessageField.superClass_.enterDocument.call(this);

var tt = (
'Type: ' + this._field_info['type'] + '<br>' +
Expand Down Expand Up @@ -122,61 +123,63 @@ app.MessageField.prototype.enterDocument = function() {
/**
* Remove the tooltip
*/
app.MessageField.prototype.exitDocument = function() {
app.MessageField.superClass_.exitDocument.call(this);
app.pid.MessageField.prototype.exitDocument = function() {
app.pid.MessageField.superClass_.exitDocument.call(this);
this.tt.detach(this.getElement());
};


/**
* Create a RDM message structure object.
* @param {goog.dom.DomHelper=} opt_domHelper Optional DOM helper.
* @constructor
* @extends goog.ui.Component
*/
app.MessageStructure = function(opt_domHelper) {
app.pid.MessageStructure = function(opt_domHelper) {
goog.ui.Component.call(this, opt_domHelper);
};
goog.inherits(app.MessageStructure, goog.ui.Component);
goog.inherits(app.pid.MessageStructure, goog.ui.Component);


/**
* Create the dom for the TableContainer
*/
app.MessageStructure.prototype.createDom = function(container) {
app.pid.MessageStructure.prototype.createDom = function(container) {
this.decorateInternal(this.dom_.createElement('div'));
};


/**
* Decorate an existing element
*/
app.MessageStructure.prototype.decorateInternal = function(element) {
app.MessageStructure.superClass_.decorateInternal.call(this, element);
app.pid.MessageStructure.prototype.decorateInternal = function(element) {
app.pid.MessageStructure.superClass_.decorateInternal.call(this, element);
};


/**
* Check if we can decorate an element.
* @param {Element} element the dom element to check.
*/
app.MessageStructure.prototype.canDecorate = function(element) {
app.pid.MessageStructure.prototype.canDecorate = function(element) {
return element.tagName == 'DIV';
};


app.MessageStructure.prototype.update = function(fields) {
app.pid.MessageStructure.prototype.update = function(fields) {
this.removeChildren(true);

for (var i = 0; i < fields.length; ++i) {
var field = fields[i];

var new_div = null;
if (field['type'] == 'group') {
new_div = new app.MessageGroup();
new_div = new app.pid.MessageGroup();
new_div.update(field['items']);
this.addChild(new_div, true);
new_div.attachTooltip(field);
} else {
new_div = new app.MessageField(field);
new_div = new app.pid.MessageField(field);
this.addChild(new_div, true);
}
}
Expand All @@ -188,17 +191,17 @@ app.MessageStructure.prototype.update = function(fields) {
* message.
* @constructor
*/
app.MessageGroup = function(opt_domHelper) {
app.pid.MessageGroup = function(opt_domHelper) {
goog.ui.Component.call(this, opt_domHelper);
this.tt = null;
};
goog.inherits(app.MessageGroup, app.MessageStructure);
goog.inherits(app.pid.MessageGroup, app.pid.MessageStructure);


/**
* Attach the tooltip for this group
*/
app.MessageGroup.prototype.attachTooltip = function(field) {
app.pid.MessageGroup.prototype.attachTooltip = function(field) {
this.tt = new goog.ui.Tooltip(this.getElement());
var tt = 'A repeated group of fields. ';
var min = field['min_size'];
Expand All @@ -222,17 +225,17 @@ app.MessageGroup.prototype.attachTooltip = function(field) {
/**
* Decorate an existing element
*/
app.MessageGroup.prototype.decorateInternal = function(element) {
app.MessageStructure.superClass_.decorateInternal.call(this, element);
app.pid.MessageGroup.prototype.decorateInternal = function(element) {
app.pid.MessageStructure.superClass_.decorateInternal.call(this, element);
element.className = 'message_group';
};


/**
* Remove the tooltip
*/
app.MessageField.prototype.exitDocument = function() {
app.MessageField.superClass_.exitDocument.call(this);
app.pid.MessageField.prototype.exitDocument = function() {
app.pid.MessageField.superClass_.exitDocument.call(this);
if (this.tt) {
this.tt.detach(this.getElement());
}
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"Sean Sill"
],
"devDependencies": {
"google-closure-compiler": "^20170910.0.0",
"google-closure-library": "^20170910.0.0",
"grunt": "^1.0.0",
"grunt-bower-task": "~0.4.0",
"grunt-contrib-clean": "~0.6.0",
Expand Down
Loading