Skip to content

Commit 02d9f1e

Browse files
committed
Adding some additional eslint flags, and adding base 10 to all parseFloat calls
1 parent 107fa6a commit 02d9f1e

File tree

7 files changed

+32
-27
lines changed

7 files changed

+32
-27
lines changed

src/timeline/js/controllers.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ App.controller("TimelineCtrl", function ($scope) {
742742
y += scrolling_tracks.scrollTop();
743743

744744
// Return number of track
745-
return parseInt($scope.GetTrackAtY(y - scrolling_tracks_offset_top).number);
745+
return parseInt($scope.GetTrackAtY(y - scrolling_tracks_offset_top).number, 10);
746746
};
747747

748748
// Get JSON of most recent item (used by Qt)
@@ -1363,7 +1363,7 @@ App.controller("TimelineCtrl", function ($scope) {
13631363
$scope.addClips = function (numClips) {
13641364
var startNum = $scope.project.clips.length + 1;
13651365
var positionNum = 0;
1366-
for (var x = 0; x < parseInt(numClips); x++) {
1366+
for (var x = 0; x < parseInt(numClips, 10); x++) {
13671367
$scope.project.clips.push({
13681368
id: x.toString(),
13691369
layer: 0,
@@ -1407,7 +1407,7 @@ App.controller("TimelineCtrl", function ($scope) {
14071407
// Debug method to add a marker to the $scope
14081408
$scope.addMarker = function (markLoc) {
14091409
$scope.project.markers.push({
1410-
position: parseInt(markLoc),
1410+
position: parseInt(markLoc, 10),
14111411
icon: "blue.png"
14121412
});
14131413
$scope.markLoc = "";

src/timeline/js/directives/clip.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var track_container_height = -1;
4141
// 3: class change when hovered over
4242
var dragLoc = null;
4343

44-
/*global App, timeline*/
44+
/*global App, timeline, moveBoundingBox*/
4545
App.directive("tlClip", function ($timeout) {
4646
return {
4747
scope: "@",
@@ -72,8 +72,8 @@ App.directive("tlClip", function ($timeout) {
7272

7373
// Does this bounding box overlap a locked track?
7474
var vert_scroll_offset = $("#scrolling_tracks").scrollTop();
75-
var track_top = (parseInt(element.position().top) + parseInt(vert_scroll_offset));
76-
var track_bottom = (parseInt(element.position().top) + parseInt(element.height()) + parseInt(vert_scroll_offset));
75+
var track_top = (parseInt(element.position().top, 10) + parseInt(vert_scroll_offset, 10));
76+
var track_bottom = (parseInt(element.position().top, 10) + parseInt(element.height(), 10) + parseInt(vert_scroll_offset, 10));
7777
if (hasLockedTrack(scope, track_top, track_bottom)) {
7878
resize_disabled = true;
7979
}

src/timeline/js/directives/playhead.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ App.directive("tlPlayhead", function () {
3838
playhead_y_max = element.position().top;
3939

4040
// get the size of the playhead and line so we can determine the offset
41-
var playhead_top_w = parseInt($(".playhead-top").css("width"));
41+
var playhead_top_w = parseInt($(".playhead-top").css("width"), 10);
4242
scope.playheadOffset = 0.0 - (playhead_top_w / 2.0);
4343

4444
// Move playhead to new position (if it's not currently being animated)

src/timeline/js/directives/ruler.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var scroll_left_pixels = 0;
3838

3939
// This container allows for tracks to be scrolled (with synced ruler)
4040
// and allows for panning of the timeline with the middle mouse button
41-
/*global App*/
41+
/*global App, secondsToTime*/
4242
App.directive("tlScrollableTracks", function () {
4343
return {
4444
restrict: "A",

src/timeline/js/directives/track.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
// Treats element as a track
3131
// 1: allows clips, transitions, and effects to be dropped
32-
/*global App, timeline*/
32+
/*global App, timeline, findTrackAtLocation*/
3333
App.directive("tlTrack", function ($timeout) {
3434
return {
3535
// A = attribute, E = Element, C = Class and M = HTML Comment
@@ -118,7 +118,7 @@ App.directive("tlTrack", function ($timeout) {
118118
}
119119

120120
// get track the item was dropped on
121-
var drop_track_num = findTrackAtLocation(scope, parseInt(item_middle));
121+
var drop_track_num = findTrackAtLocation(scope, parseInt(item_middle, 10));
122122

123123
// if the droptrack was found, update the json
124124
if (drop_track_num != -1) {

src/timeline/js/directives/transition.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var track_container_height = -1;
4141
// 3: class change when hovered over
4242
var dragLoc = null;
4343

44-
/*global App, timeline*/
44+
/*global App, timeline, hasLockedTrack, moveBoundingBox*/
4545
App.directive("tlTransition", function () {
4646
return {
4747
scope: "@",
@@ -66,14 +66,14 @@ App.directive("tlTransition", function () {
6666

6767
// Does this bounding box overlap a locked track?
6868
var vert_scroll_offset = $("#scrolling_tracks").scrollTop();
69-
var track_top = (parseInt(element.position().top) + parseInt(vert_scroll_offset));
70-
var track_bottom = (parseInt(element.position().top) + parseInt(element.height()) + parseInt(vert_scroll_offset));
69+
var track_top = (parseInt(element.position().top, 10) + parseInt(vert_scroll_offset, 10));
70+
var track_bottom = (parseInt(element.position().top, 10) + parseInt(element.height(), 10) + parseInt(vert_scroll_offset, 10));
7171
if (hasLockedTrack(scope, track_top, track_bottom)) {
7272
resize_disabled = true;
7373
}
7474

7575
// Hide keyframe points
76-
element.find(".point_icon").hide()
76+
element.find(".point_icon").hide();
7777

7878
},
7979
stop: function (e, ui) {
@@ -263,7 +263,7 @@ App.directive("tlTransition", function () {
263263
drag: function (e, ui) {
264264
var previous_x = ui.originalPosition.left;
265265
var previous_y = ui.originalPosition.top;
266-
if (previous_drag_position != null) {
266+
if (previous_drag_position !== null) {
267267
// if available, override with previous drag position
268268
previous_x = previous_drag_position.left;
269269
previous_y = previous_drag_position.top;

src/timeline/js/functions.js

+17-12
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@
3030
// Find a JSON element / object with a particular value in the json data
3131
function findElement(arr, propName, propValue) {
3232
// Loop through array looking for a matching element
33-
for (var i = 0; i < arr.length; i++)
34-
if (arr[i][propName] === propValue)
33+
for (var i = 0; i < arr.length; i++) {
34+
if (arr[i][propName] === propValue) {
3535
return arr[i];
36+
}
37+
}
3638

3739
}
3840

@@ -41,9 +43,11 @@ function getTrackContainerHeight() {
4143

4244
var track_margin = 0;
4345
var track_object = $(".track");
44-
if (track_object.length)
45-
if (track_object.css("margin-bottom"))
46-
track_margin = parseInt(track_object.css("margin-bottom").replace("px", ""));
46+
if (track_object.length) {
47+
if (track_object.css("margin-bottom")) {
48+
track_margin = parseInt(track_object.css("margin-bottom").replace("px", ""), 10);
49+
}
50+
}
4751

4852
return $("#track-container").height() - track_margin;
4953
}
@@ -173,12 +177,13 @@ function findTrackAtLocation(scope, top) {
173177
var layer = scope.project.layers[layer_index];
174178

175179
// Compare position of track to Y param (of unlocked tracks)
176-
if (!layer.lock)
180+
if (!layer.lock) {
177181
if ((top < layer.y && top > track_position) || track_position === 0) {
178182
// return first matching layer
179183
track_position = layer.y;
180184
track_number = layer.number;
181185
}
186+
}
182187
}
183188

184189
return track_number;
@@ -223,16 +228,16 @@ function setBoundingBox(scope, item) {
223228
bounding_box.width = item.width();
224229
} else {
225230
//compare and change if item is a better fit for bounding box edges
226-
if (item_top < bounding_box.top) bounding_box.top = item_top;
227-
if (item_left < bounding_box.left) bounding_box.left = item_left;
228-
if (item_bottom > bounding_box.bottom) bounding_box.bottom = item_bottom;
229-
if (item_right > bounding_box.right) bounding_box.right = item_right;
231+
if (item_top < bounding_box.top) { bounding_box.top = item_top };
232+
if (item_left < bounding_box.left) { bounding_box.left = item_left };
233+
if (item_bottom > bounding_box.bottom) { bounding_box.bottom = item_bottom };
234+
if (item_right > bounding_box.right) { bounding_box.right = item_right };
230235

231236
// compare height and width of bounding box (take the largest number)
232237
var height = bounding_box.bottom - bounding_box.top;
233238
var width = bounding_box.right - bounding_box.left;
234-
if (height > bounding_box.height) bounding_box.height = height;
235-
if (width > bounding_box.width) bounding_box.width = width;
239+
if (height > bounding_box.height) { bounding_box.height = height };
240+
if (width > bounding_box.width) { bounding_box.width = width };
236241
}
237242

238243
// Get list of current selected ids (so we can ignore their snapping x coordinates)

0 commit comments

Comments
 (0)