Skip to content

Commit 7af5875

Browse files
committed
[Time Conductor] #933 Fixed code style errors
1 parent c6eaa3d commit 7af5875

21 files changed

+124
-113
lines changed

platform/commonUI/formats/src/UTCTimeFormat.js

+23-11
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ define([
5656
* the threshold required.
5757
* @private
5858
*/
59-
function getScaledFormat (d) {
59+
function getScaledFormat(d) {
6060
var momentified = moment.utc(d);
6161
/**
6262
* Uses logic from d3 Time-Scales, v3 of the API. See
@@ -65,20 +65,32 @@ define([
6565
* Licensed
6666
*/
6767
return [
68-
[".SSS", function(m) { return m.milliseconds(); }],
69-
[":ss", function(m) { return m.seconds(); }],
70-
["HH:mm", function(m) { return m.minutes(); }],
71-
["HH", function(m) { return m.hours(); }],
72-
["ddd DD", function(m) {
68+
[".SSS", function (m) {
69+
return m.milliseconds();
70+
}],
71+
[":ss", function (m) {
72+
return m.seconds();
73+
}],
74+
["HH:mm", function (m) {
75+
return m.minutes();
76+
}],
77+
["HH", function (m) {
78+
return m.hours();
79+
}],
80+
["ddd DD", function (m) {
7381
return m.days() &&
7482
m.date() !== 1;
7583
}],
76-
["MMM DD", function(m) { return m.date() !== 1; }],
77-
["MMMM", function(m) {
84+
["MMM DD", function (m) {
85+
return m.date() !== 1;
86+
}],
87+
["MMMM", function (m) {
7888
return m.month();
7989
}],
80-
["YYYY", function() { return true; }]
81-
].filter(function (row){
90+
["YYYY", function () {
91+
return true;
92+
}]
93+
].filter(function (row) {
8294
return row[1](momentified);
8395
})[0][0];
8496
}
@@ -91,7 +103,7 @@ define([
91103
* @returns {string} the formatted date
92104
*/
93105
UTCTimeFormat.prototype.format = function (value, scale) {
94-
if (scale !== undefined){
106+
if (scale !== undefined) {
95107
var scaledFormat = getScaledFormat(value, scale);
96108
if (scaledFormat) {
97109
return moment.utc(value).format(scaledFormat);

platform/features/conductor-v2/compatibility/src/ConductorTelemetryDecorator.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ define(
7676
}
7777

7878
conductor.on('bounds', amendRequests);
79-
return function() {
79+
return function () {
8080
unsubscribeFunc();
8181
conductor.off('bounds', amendRequests);
8282
};

platform/features/conductor-v2/conductor/src/TimeConductor.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ define(['EventEmitter'], function (EventEmitter) {
112112
TimeConductor.prototype.bounds = function (newBounds) {
113113
if (arguments.length > 0) {
114114
var validationResult = this.validateBounds(newBounds);
115-
if (validationResult !== true){
115+
if (validationResult !== true) {
116116
throw new Error(validationResult);
117117
}
118118
//Create a copy to avoid direct mutation of conductor bounds

platform/features/conductor-v2/conductor/src/timeSystems/LocalClock.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ define(['./TickSource'], function (TickSource) {
2525
* @implements TickSource
2626
* @constructor
2727
*/
28-
function LocalClock ($timeout, period) {
28+
function LocalClock($timeout, period) {
2929
TickSource.call(this);
3030

3131
this.metadata = {
@@ -56,7 +56,7 @@ define(['./TickSource'], function (TickSource) {
5656

5757
LocalClock.prototype.tick = function () {
5858
var now = Date.now();
59-
this.listeners.forEach(function (listener){
59+
this.listeners.forEach(function (listener) {
6060
listener(now);
6161
});
6262
this.timeoutHandle = this.$timeout(this.tick.bind(this), this.period);
@@ -73,7 +73,7 @@ define(['./TickSource'], function (TickSource) {
7373
var listeners = this.listeners;
7474
listeners.push(listener);
7575

76-
if (listeners.length === 1){
76+
if (listeners.length === 1) {
7777
this.start();
7878
}
7979

platform/features/conductor-v2/conductor/src/timeSystems/TickSource.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ define([], function () {
3030
* @interface
3131
* @constructor
3232
*/
33-
function TickSource () {
33+
function TickSource() {
3434
this.listeners = [];
3535
}
3636

platform/features/conductor-v2/conductor/src/timeSystems/TimeSystem.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ define([], function () {
2525
* @interface
2626
* @constructor
2727
*/
28-
function TimeSystem () {
28+
function TimeSystem() {
2929
/**
3030
* @typedef TimeSystemMetadata
3131
* @property {string} key
@@ -35,7 +35,6 @@ define([], function () {
3535
* @type {TimeSystemMetadata}
3636
*/
3737
this.metadata = undefined;
38-
this._tickSources = [];
3938
}
4039

4140
/**

platform/features/conductor-v2/conductor/src/ui/MctConductorAxis.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ define(
8787
//Define a custom format function
8888
this.xAxis.tickFormat(function (tickValue) {
8989
// Normalize date representations to numbers
90-
if (tickValue instanceof Date){
90+
if (tickValue instanceof Date) {
9191
tickValue = tickValue.getTime();
9292
}
9393
return format.format(tickValue, {
@@ -127,7 +127,7 @@ define(
127127
}
128128
};
129129

130-
return function(conductor, formatService) {
130+
return function (conductor, formatService) {
131131
return new MCTConductorAxis(conductor, formatService);
132132
};
133133
}

platform/features/conductor-v2/conductor/src/ui/MctConductorAxisSpec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ define(['./MctConductorAxis'], function (MctConductorAxis) {
7171
"range"
7272
];
7373
d3 = jasmine.createSpyObj("d3", d3Functions);
74-
d3Functions.forEach(function(func) {
74+
d3Functions.forEach(function (func) {
7575
d3[func].andReturn(d3);
7676
});
7777

@@ -89,7 +89,7 @@ define(['./MctConductorAxis'], function (MctConductorAxis) {
8989
var mockTimeSystem;
9090
var mockFormat;
9191

92-
beforeEach(function() {
92+
beforeEach(function () {
9393
mockTimeSystem = jasmine.createSpyObj("timeSystem", [
9494
"formats",
9595
"isUTCBased"

platform/features/conductor-v2/conductor/src/ui/NumberFormat.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ define([], function () {
3434
}
3535

3636
NumberFormat.prototype.format = function (value) {
37-
if (isNaN(value)){
37+
if (isNaN(value)) {
3838
return '';
3939
} else {
4040
return '' + value;

platform/features/conductor-v2/conductor/src/ui/NumberFormatSpec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ define(['./NumberFormat'], function (NumberFormat) {
3030
it("The format function takes a string and produces a number", function () {
3131
var text = format.format(1);
3232
expect(text).toBe("1");
33-
expect(typeof(text)).toBe("string");
33+
expect(typeof text).toBe("string");
3434
});
3535

3636
it("The parse function takes a string and produces a number", function () {
3737
var number = format.parse("1");
3838
expect(number).toBe(1);
39-
expect(typeof(number)).toBe("number");
39+
expect(typeof number).toBe("number");
4040
});
4141

4242
it("validates that the input is a number", function () {

platform/features/conductor-v2/conductor/src/ui/TimeConductorController.js

+10-9
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ define(
4545
this.validation = new TimeConductorValidation(this.conductor);
4646

4747
// Construct the provided time system definitions
48-
this.timeSystems = timeSystems.map(function (timeSystemConstructor){
48+
this.timeSystems = timeSystems.map(function (timeSystemConstructor) {
4949
return timeSystemConstructor();
5050
});
5151

5252
//Set the initial state of the view based on current time conductor
5353
this.initializeScope();
5454

5555
this.conductor.on('bounds', this.setFormFromBounds);
56-
this.conductor.on('follow', function (follow){
56+
this.conductor.on('follow', function (follow) {
5757
$scope.followMode = follow;
5858
});
5959
this.conductor.on('timeSystem', this.changeTimeSystem);
@@ -67,7 +67,7 @@ define(
6767
/**
6868
* @private
6969
*/
70-
TimeConductorController.prototype.initializeScope = function() {
70+
TimeConductorController.prototype.initializeScope = function () {
7171
//Set time Conductor bounds in the form
7272
this.$scope.boundsModel = this.conductor.bounds();
7373

@@ -126,10 +126,11 @@ define(
126126
TimeConductorController.prototype.setFormFromMode = function (mode) {
127127
this.$scope.modeModel.selectedKey = mode;
128128
//Synchronize scope with time system on mode
129-
this.$scope.timeSystemModel.options = this.conductorViewService.availableTimeSystems()
129+
this.$scope.timeSystemModel.options =
130+
this.conductorViewService.availableTimeSystems()
130131
.map(function (t) {
131132
return t.metadata;
132-
});
133+
});
133134
};
134135

135136
/**
@@ -204,13 +205,13 @@ define(
204205
* @param key
205206
* @see TimeConductorController#setTimeSystem
206207
*/
207-
TimeConductorController.prototype.selectTimeSystemByKey = function(key){
208-
var selected = this.timeSystems.filter(function (timeSystem){
208+
TimeConductorController.prototype.selectTimeSystemByKey = function (key) {
209+
var selected = this.timeSystems.filter(function (timeSystem) {
209210
return timeSystem.metadata.key === key;
210211
})[0];
211212
this.conductor.timeSystem(selected, selected.defaults().bounds);
212213
};
213-
214+
214215
/**
215216
* Handles time system change from time conductor
216217
*
@@ -222,7 +223,7 @@ define(
222223
*/
223224
TimeConductorController.prototype.changeTimeSystem = function (newTimeSystem) {
224225
if (newTimeSystem && (newTimeSystem !== this.$scope.timeSystemModel.selected)) {
225-
if (newTimeSystem.defaults()){
226+
if (newTimeSystem.defaults()) {
226227
var deltas = newTimeSystem.defaults().deltas || {start: 0, end: 0};
227228
var bounds = newTimeSystem.defaults().bounds || {start: 0, end: 0};
228229

platform/features/conductor-v2/conductor/src/ui/TimeConductorControllerSpec.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ define(['./TimeConductorController'], function (TimeConductorController) {
5858
});
5959

6060
function getListener(name) {
61-
return mockTimeConductor.on.calls.filter(function (call){
61+
return mockTimeConductor.on.calls.filter(function (call) {
6262
return call.args[0] === name;
6363
})[0].args[1];
6464
}
6565

66-
describe("", function (){
67-
beforeEach(function() {
66+
describe("", function () {
67+
beforeEach(function () {
6868
controller = new TimeConductorController(
6969
mockScope,
7070
mockWindow,
@@ -183,7 +183,7 @@ define(['./TimeConductorController'], function (TimeConductorController) {
183183
var ts2Metadata;
184184
var ts3Metadata;
185185
var mockTimeSystemConstructors;
186-
186+
187187
beforeEach(function () {
188188
mode = "realtime";
189189
ts1Metadata = {
@@ -304,7 +304,7 @@ define(['./TimeConductorController'], function (TimeConductorController) {
304304
metadata: {
305305
key: 'testTimeSystem'
306306
},
307-
defaults: function() {
307+
defaults: function () {
308308
return {
309309
bounds: defaultBounds
310310
};
@@ -313,7 +313,7 @@ define(['./TimeConductorController'], function (TimeConductorController) {
313313

314314
mockTimeSystems = [
315315
// Wrap as constructor function
316-
function() {
316+
function () {
317317
return timeSystem;
318318
}
319319
];

0 commit comments

Comments
 (0)