Skip to content

Commit 1c0bd25

Browse files
committed
Revert many JS loop syntax changes from #3022. Those changes broke all HTML rendering on my local dev version.
1 parent b380279 commit 1c0bd25

File tree

5 files changed

+114
-90
lines changed

5 files changed

+114
-90
lines changed

src/timeline/app.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,12 @@ var App = angular.module('openshot-timeline', ['ui.bootstrap','ngAnimate']);
6666

6767
// Bind to keydown event (to detect SHIFT)
6868
$( "body" ).keydown(function(event) {
69-
if (event.which === 16)
69+
if (event.which==16)
7070
$('body').scope().shift_pressed = true;
7171
});
7272
$( "body" ).keyup(function(event) {
7373
if ($('body').scope().shift_pressed)
7474
$('body').scope().shift_pressed = false;
7575
});
7676
});
77+

src/timeline/js/controllers.js

+90-70
Original file line numberDiff line numberDiff line change
@@ -331,18 +331,20 @@ App.controller('TimelineCtrl',function($scope) {
331331
}
332332
// Determine if this property is a Keyframe
333333
if (typeof object[child] == "object" && "Points" in object[child]) {
334-
for (const point of object[child].Points) {
335-
if (point.co.X >= clip_start_x && point.co.X <= clip_end_x)
334+
for (var point = 0; point < object[child].Points.length; point++) {
335+
var co = object[child].Points[point].co;
336+
if (co.X >= clip_start_x && co.X <= clip_end_x)
336337
// Only add keyframe coordinates that are within the bounds of the clip
337-
keyframes[point.co.X] = point.co.Y;
338+
keyframes[co.X] = co.Y;
338339
}
339340
}
340341
// Determine if this property is a Color Keyframe
341342
if (typeof object[child] == "object" && "red" in object[child]) {
342-
for (const point of object[child]["red"].Points) {
343-
if (point.co.X >= clip_start_x && point.co.X <= clip_end_x)
343+
for (var point = 0; point < object[child]["red"].Points.length; point++) {
344+
var co = object[child]["red"].Points[point].co;
345+
if (co.X >= clip_start_x && co.X <= clip_end_x)
344346
// Only add keyframe coordinates that are within the bounds of the clip
345-
keyframes[point.co.X] = point.co.Y;
347+
keyframes[co.X] = co.Y;
346348
}
347349
}
348350
}
@@ -357,18 +359,20 @@ App.controller('TimelineCtrl',function($scope) {
357359
}
358360
// Determine if this property is a Keyframe
359361
if (typeof object["effects"][effect][child] == "object" && "Points" in object["effects"][effect][child]) {
360-
for (const point of object["effects"][effect][child].Points) {
361-
if (point.co.X >= clip_start_x && point.co.X <= clip_end_x)
362+
for (var point = 0; point < object["effects"][effect][child].Points.length; point++) {
363+
var co = object["effects"][effect][child].Points[point].co;
364+
if (co.X >= clip_start_x && co.X <= clip_end_x)
362365
// Only add keyframe coordinates that are within the bounds of the clip
363-
keyframes[point.co.X] = point.co.Y;
366+
keyframes[co.X] = co.Y;
364367
}
365368
}
366369
// Determine if this property is a Color Keyframe
367370
if (typeof object["effects"][effect][child] == "object" && "red" in object["effects"][effect][child]) {
368-
for (const point of object["effects"][effect][child]["red"].Points) {
369-
if (point.co.X >= clip_start_x && point.co.X <= clip_end_x)
371+
for (var point = 0; point < object["effects"][effect][child]["red"].Points.length; point++) {
372+
var co = object["effects"][effect][child]["red"].Points[point].co;
373+
if (co.X >= clip_start_x && co.X <= clip_end_x)
370374
// Only add keyframe coordinates that are within the bounds of the clip
371-
keyframes[point.co.X] = point.co.Y;
375+
keyframes[co.X] = co.Y;
372376
}
373377
}
374378
}
@@ -470,12 +474,12 @@ App.controller('TimelineCtrl',function($scope) {
470474
// Set the audio data for a clip
471475
$scope.setAudioData = function(clip_id, audio_data) {
472476
// Find matching clip
473-
for (const clip of $scope.project.clips) {
474-
if (clip.id == clip_id) {
477+
for (var clip_index = 0; clip_index < $scope.project.clips.length; clip_index++) {
478+
if ($scope.project.clips[clip_index].id == clip_id) {
475479
// Set audio data
476480
$scope.$apply(function(){
477-
clip.audio_data = audio_data;
478-
clip.show_audio = true;
481+
$scope.project.clips[clip_index].audio_data = audio_data;
482+
$scope.project.clips[clip_index].show_audio = true;
479483
});
480484
timeline.qt_log("Audio data successful set on clip JSON");
481485
break;
@@ -489,12 +493,12 @@ App.controller('TimelineCtrl',function($scope) {
489493
// Hide the audio waveform for a clip
490494
$scope.hideAudioData = function(clip_id, audio_data) {
491495
// Find matching clip
492-
for (const clip of $scope.project.clips) {
493-
if (clip.id == clip_id) {
496+
for (var clip_index = 0; clip_index < $scope.project.clips.length; clip_index++) {
497+
if ($scope.project.clips[clip_index].id == clip_id) {
494498
// Set audio data
495499
$scope.$apply(function(){
496-
clip.show_audio = false;
497-
clip.audio_data = [];
500+
$scope.project.clips[clip_index].show_audio = false;
501+
$scope.project.clips[clip_index].audio_data = [];
498502
});
499503
break;
500504
}
@@ -504,19 +508,19 @@ App.controller('TimelineCtrl',function($scope) {
504508
// Redraw all audio waveforms on the timeline (if any)
505509
$scope.reDrawAllAudioData = function() {
506510
// Find matching clip
507-
for (const clip of $scope.project.clips) {
508-
if ("audio_data" in clip && clip.audio_data.length > 0) {
511+
for (var clip_index = 0; clip_index < $scope.project.clips.length; clip_index++) {
512+
if ("audio_data" in $scope.project.clips[clip_index] && $scope.project.clips[clip_index].audio_data.length > 0) {
509513
// Redraw audio data (since it has audio data)
510-
drawAudio($scope, clip.id);
514+
drawAudio($scope, $scope.project.clips[clip_index].id);
511515
}
512516
}
513517
};
514518

515519
// Does clip have audio_data?
516520
$scope.hasAudioData = function(clip_id) {
517521
// Find matching clip
518-
for (const clip of $scope.project.clips) {
519-
if (clip.id == clip_id && "audio_data" in clip && clip.audio_data.length > 0) {
522+
for (var clip_index = 0; clip_index < $scope.project.clips.length; clip_index++) {
523+
if ($scope.project.clips[clip_index].id == clip_id && "audio_data" in $scope.project.clips[clip_index] && $scope.project.clips[clip_index].audio_data.length > 0) {
520524
return true;
521525
break;
522526
}
@@ -633,11 +637,11 @@ App.controller('TimelineCtrl',function($scope) {
633637

634638
// Update scope
635639
$scope.$apply(function() {
636-
for (const clip of $scope.project.clips) {
637-
clip.selected = false;
640+
for (var clip_index = 0; clip_index < $scope.project.clips.length; clip_index++) {
641+
$scope.project.clips[clip_index].selected = false;
638642
}
639-
for (const effect of $scope.project.effects) {
640-
effect.selected = false;
643+
for (var effect_index = 0; effect_index < $scope.project.effects.length; effect_index++) {
644+
$scope.project.effects[effect_index].selected = false;
641645
}
642646
});
643647
};
@@ -646,14 +650,14 @@ App.controller('TimelineCtrl',function($scope) {
646650
$scope.SelectAll = function() {
647651
$scope.$apply(function() {
648652
// Select all clips
649-
for (const clip of $scope.project.clips) {
650-
clip.selected = true;
651-
timeline.addSelection(clip.id, "clip", false);
653+
for (var clip_index = 0; clip_index < $scope.project.clips.length; clip_index++) {
654+
$scope.project.clips[clip_index].selected = true;
655+
timeline.addSelection($scope.project.clips[clip_index].id, "clip", false);
652656
}
653657
// Select all transitions
654-
for (const effect of $scope.project.effects) {
655-
effect.selected = true;
656-
timeline.addSelection(effect.id, "transition", false);
658+
for (var effect_index = 0; effect_index < $scope.project.effects.length; effect_index++) {
659+
$scope.project.effects[effect_index].selected = true;
660+
timeline.addSelection($scope.project.effects[effect_index].id, "transition", false);
657661
}
658662
});
659663
};
@@ -684,17 +688,17 @@ App.controller('TimelineCtrl',function($scope) {
684688
}
685689

686690
// Unselect all clips
687-
for (const clip of $scope.project.clips) {
688-
if (clip.id == id) {
689-
clip.selected = true;
691+
for (var clip_index = 0; clip_index < $scope.project.clips.length; clip_index++) {
692+
if ($scope.project.clips[clip_index].id == id) {
693+
$scope.project.clips[clip_index].selected = true;
690694
if ($scope.Qt) {
691695
timeline.addSelection(id, "clip", clear_selections);
692696
}
693697
}
694698
else if (clear_selections && !is_ctrl) {
695-
clip.selected = false;
699+
$scope.project.clips[clip_index].selected = false;
696700
if ($scope.Qt) {
697-
timeline.removeSelection(clip.id, "clip");
701+
timeline.removeSelection($scope.project.clips[clip_index].id, "clip");
698702
}
699703
}
700704
}
@@ -727,16 +731,16 @@ App.controller('TimelineCtrl',function($scope) {
727731
}
728732

729733
// Unselect all transitions
730-
for (const tran of $scope.project.effects) {
731-
if (tran.id == id) {
732-
tran.selected = true;
734+
for (var tran_index = 0; tran_index < $scope.project.effects.length; tran_index++) {
735+
if ($scope.project.effects[tran_index].id == id) {
736+
$scope.project.effects[tran_index].selected = true;
733737
if ($scope.Qt)
734738
timeline.addSelection(id, "transition", clear_selections);
735739
}
736740
else if (clear_selections && !is_ctrl) {
737-
tran.selected = false;
741+
$scope.project.effects[tran_index].selected = false;
738742
if ($scope.Qt)
739-
timeline.removeSelection(tran.id, "transition");
743+
timeline.removeSelection($scope.project.effects[tran_index].id, "transition");
740744
}
741745
}
742746
};
@@ -758,7 +762,8 @@ App.controller('TimelineCtrl',function($scope) {
758762
$scope.ResizeTimeline = function() {
759763
// Unselect all clips
760764
var furthest_right_edge = 0;
761-
for (const clip of $scope.project.clips) {
765+
for (var clip_index = 0; clip_index < $scope.project.clips.length; clip_index++) {
766+
var clip = $scope.project.clips[clip_index];
762767
var right_edge = clip.position + (clip.end - clip.start);
763768
if (right_edge > furthest_right_edge)
764769
furthest_right_edge = right_edge;
@@ -948,20 +953,20 @@ $scope.SetTrackLabel = function (label) {
948953
// Select new clip object (and unselect others)
949954
// This needs to be done inline due to async issues with the
950955
// above calls to SelectClip/SelectTransition
951-
for (const clip of $scope.project.clips) {
952-
if (clip.id == item_id) {
953-
clip.selected = true;
956+
for (var clip_index = 0; clip_index < $scope.project.clips.length; clip_index++) {
957+
if ($scope.project.clips[clip_index].id == item_id) {
958+
$scope.project.clips[clip_index].selected = true;
954959
} else {
955-
clip.selected = false;
960+
$scope.project.clips[clip_index].selected = false;
956961
}
957962
}
958963

959964
// Select new transition object (and unselect others)
960-
for (const tran of $scope.project.effects) {
961-
if (tran.id == item_id) {
962-
tran.selected = true;
965+
for (var tran_index = 0; tran_index < $scope.project.effects.length; tran_index++) {
966+
if ($scope.project.effects[tran_index].id == item_id) {
967+
$scope.project.effects[tran_index].selected = true;
963968
} else {
964-
tran.selected = false;
969+
$scope.project.effects[tran_index].selected = false;
965970
}
966971
}
967972

@@ -1019,7 +1024,9 @@ $scope.SetTrackLabel = function (label) {
10191024
}
10201025
// Loop through each layer (looking for the closest track based on Y coordinate)
10211026
bounding_box.track_position = 0;
1022-
for (const layer of $scope.project.layers) {
1027+
for (var layer_index = $scope.project.layers.length - 1; layer_index >= 0 ; layer_index--) {
1028+
var layer = $scope.project.layers[layer_index];
1029+
10231030
// Compare position of track to Y param (for unlocked tracks)
10241031
if (!layer.lock) {
10251032
if ((top < layer.y && top > bounding_box.track_position) || bounding_box.track_position === 0) {
@@ -1049,7 +1056,9 @@ $scope.SetTrackLabel = function (label) {
10491056

10501057
$scope.$apply(function() {
10511058
// Loop through each layer
1052-
for (const layer of $scope.project.layers) {
1059+
for (var layer_index = 0; layer_index < $scope.project.layers.length; layer_index++) {
1060+
var layer = $scope.project.layers[layer_index];
1061+
10531062
// Find element on screen (bound to this layer)
10541063
var layer_elem = $("#track_" + layer.number);
10551064
if (layer_elem) {
@@ -1118,7 +1127,9 @@ $scope.SetTrackLabel = function (label) {
11181127
var original_right = original_clip.position + (original_clip.end - original_clip.start);
11191128

11201129
// Search through all other clips on this track, and look for overlapping ones
1121-
for (const clip of $scope.project.clips) {
1130+
for (var index = 0; index < $scope.project.clips.length; index++) {
1131+
var clip = $scope.project.clips[index];
1132+
11221133
// skip clips that are not on the same layer
11231134
if (original_clip.layer != clip.layer) {
11241135
continue;
@@ -1146,7 +1157,9 @@ $scope.SetTrackLabel = function (label) {
11461157
}
11471158
// Search through all existing transitions, and don't overlap an existing one
11481159
if (transition_size != null) {
1149-
for (const tran of $scope.project.effects) {
1160+
for (var tran_index = 0; tran_index < $scope.project.effects.length; tran_index++) {
1161+
var tran = $scope.project.effects[tran_index];
1162+
11501163
// skip transitions that are not on the same layer
11511164
if (tran.layer != transition_size.layer) {
11521165
continue;
@@ -1179,9 +1192,12 @@ $scope.SetTrackLabel = function (label) {
11791192
var diffs = [];
11801193

11811194
// Loop through each pixel position (supports multiple positions: i.e. left and right side of bounding box)
1182-
for (const position of pixel_positions) {
1195+
for (var pos_index = 0; pos_index < pixel_positions.length; pos_index++) {
1196+
var position = pixel_positions[pos_index];
1197+
11831198
// Add clip positions to array
1184-
for (const clip of $scope.project.clips) {
1199+
for (var index = 0; index < $scope.project.clips.length; index++) {
1200+
var clip = $scope.project.clips[index];
11851201
var clip_left_position = clip.position * $scope.pixelsPerSecond;
11861202
var clip_right_position = (clip.position + (clip.end - clip.start)) * $scope.pixelsPerSecond;
11871203

@@ -1195,7 +1211,8 @@ $scope.SetTrackLabel = function (label) {
11951211
}
11961212

11971213
// Add transition positions to array
1198-
for (const transition of $scope.project.effects) {
1214+
for (var index = 0; index < $scope.project.effects.length; index++) {
1215+
var transition = $scope.project.effects[index];
11991216
var tran_left_position = transition.position * $scope.pixelsPerSecond;
12001217
var tran_right_position = (transition.position + (transition.end - transition.start)) * $scope.pixelsPerSecond;
12011218

@@ -1204,13 +1221,14 @@ $scope.SetTrackLabel = function (label) {
12041221
if (ignore_ids.hasOwnProperty(transition.id)) {
12051222
continue;
12061223
}
1207-
1224+
12081225
diffs.push({'diff' : position - tran_left_position, 'position' : tran_left_position}, // left side of transition
12091226
{'diff' : position - tran_right_position, 'position' : tran_right_position}); // right side of transition
12101227
}
12111228

12121229
// Add marker positions to array
1213-
for (const marker of $scope.project.markers) {
1230+
for (var index = 0; index < $scope.project.markers.length; index++) {
1231+
var marker = $scope.project.markers[index];
12141232
var marker_position = marker.position * $scope.pixelsPerSecond;
12151233

12161234
diffs.push({'diff' : position - marker_position, 'position' : marker_position}, // left side of marker
@@ -1221,19 +1239,19 @@ $scope.SetTrackLabel = function (label) {
12211239
var playhead_pixel_position = $scope.project.playhead_position * $scope.pixelsPerSecond;
12221240
var playhead_diff = position - playhead_pixel_position;
12231241
diffs.push({'diff' : playhead_diff, 'position' : playhead_pixel_position });
1224-
1242+
12251243
// Loop through diffs (and find the smallest one)
1226-
for (const each_diff of diffs) {
1227-
var diff = each_diff.diff;
1228-
var diff_position = each_diff.position;
1244+
for (var diff_index = 0; diff_index < diffs.length; diff_index++) {
1245+
var diff = diffs[diff_index].diff;
1246+
var position = diffs[diff_index].position;
12291247
var abs_diff = Math.abs(diff);
1230-
1248+
12311249
// Check if this clip is nearby
12321250
if (abs_diff < smallest_abs_diff && abs_diff <= threshold) {
12331251
// This one is smaller
12341252
smallest_diff = diff;
12351253
smallest_abs_diff = abs_diff;
1236-
snapping_position = diff_position;
1254+
snapping_position = position;
12371255
}
12381256
}
12391257
}
@@ -1328,7 +1346,9 @@ $scope.SetTrackLabel = function (label) {
13281346
$scope.ApplyJsonDiff = function(jsonDiff) {
13291347

13301348
// Loop through each UpdateAction
1331-
for (const action of jsonDiff) {
1349+
for (var action_index = 0; action_index < jsonDiff.length; action_index++) {
1350+
var action = jsonDiff[action_index];
1351+
13321352
// Iterate through the key levels (looking for a matching element in the $scope.project)
13331353
var previous_object = null;
13341354
var current_object = $scope.project;

src/timeline/js/directives/ruler.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ App.directive('tlRulertime', function () {
219219

220220
// Move playhead to new position (if it's not currently being animated)
221221
element.on('mousemove', function(e){
222-
if (e.which === 1 && !scope.playhead_animating) { // left button
222+
if (e.which == 1 && !scope.playhead_animating) { // left button
223223
var playhead_seconds = 0.0;
224224
// Update playhead
225225
scope.MovePlayhead(playhead_seconds);

0 commit comments

Comments
 (0)