mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-24 15:08:37 +02:00
Use 'Array.prototype.forEach' instead of '_.each' and '_.forEach'
This commit is contained in:
parent
d87fd095c0
commit
bd8009386d
19 changed files with 74 additions and 82 deletions
|
@ -1551,11 +1551,9 @@ GitEngine.prototype.fakeTeamwork = function(numToMake, branch) {
|
||||||
var deferred = Q.defer();
|
var deferred = Q.defer();
|
||||||
var chain = deferred.promise;
|
var chain = deferred.promise;
|
||||||
|
|
||||||
_.each(_.range(numToMake), function(i) {
|
for(var i = 0; i < numToMake; i++) {
|
||||||
chain = chain.then(function() {
|
chain = chain.then(chainStep);
|
||||||
return chainStep();
|
}
|
||||||
});
|
|
||||||
});
|
|
||||||
this.animationQueue.thenFinish(chain, deferred);
|
this.animationQueue.thenFinish(chain, deferred);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2074,7 +2072,7 @@ GitEngine.prototype.hgRebase = function(destination, base) {
|
||||||
|
|
||||||
var masterSet = {};
|
var masterSet = {};
|
||||||
masterSet[baseCommit.get('id')] = true;
|
masterSet[baseCommit.get('id')] = true;
|
||||||
_.each([upstream, downstream].concat(moreSets), function(set) {
|
[upstream, downstream].concat(moreSets).forEach(function(set) {
|
||||||
_.each(set, function(val, id) {
|
_.each(set, function(val, id) {
|
||||||
masterSet[id] = true;
|
masterSet[id] = true;
|
||||||
});
|
});
|
||||||
|
@ -2085,7 +2083,7 @@ GitEngine.prototype.hgRebase = function(destination, base) {
|
||||||
var upstreamSet = this.getUpstreamBranchSet();
|
var upstreamSet = this.getUpstreamBranchSet();
|
||||||
_.each(masterSet, function(val, commitID) {
|
_.each(masterSet, function(val, commitID) {
|
||||||
// now loop over that commits branches
|
// now loop over that commits branches
|
||||||
_.each(upstreamSet[commitID], function(branchJSON) {
|
upstreamSet[commitID].forEach(function(branchJSON) {
|
||||||
branchMap[branchJSON.id] = true;
|
branchMap[branchJSON.id] = true;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -85,7 +85,7 @@ var Graph = {
|
||||||
var commitJSON = tree.commits[objID];
|
var commitJSON = tree.commits[objID];
|
||||||
|
|
||||||
var parentObjs = [];
|
var parentObjs = [];
|
||||||
_.each(commitJSON.parents, function(parentID) {
|
commitJSON.parents.forEach(function(parentID) {
|
||||||
parentObjs.push(this.getOrMakeRecursive(tree, createdSoFar, parentID));
|
parentObjs.push(this.getOrMakeRecursive(tree, createdSoFar, parentID));
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ var Graph = {
|
||||||
var here = queue.pop();
|
var here = queue.pop();
|
||||||
var rents = here.get('parents');
|
var rents = here.get('parents');
|
||||||
|
|
||||||
_.each(rents, addToExplored);
|
(rents || []).forEach(addToExplored);
|
||||||
}
|
}
|
||||||
return exploredSet;
|
return exploredSet;
|
||||||
},
|
},
|
||||||
|
@ -151,7 +151,7 @@ var Graph = {
|
||||||
getUniqueObjects: function(objects) {
|
getUniqueObjects: function(objects) {
|
||||||
var unique = {};
|
var unique = {};
|
||||||
var result = [];
|
var result = [];
|
||||||
_.forEach(objects, function(object) {
|
objects.forEach(function(object) {
|
||||||
if (unique[object.id]) {
|
if (unique[object.id]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,7 @@ TreeCompare.compareAllTagsWithinTrees = function(treeA, treeB) {
|
||||||
|
|
||||||
TreeCompare.compareBranchesWithinTrees = function(treeA, treeB, branches) {
|
TreeCompare.compareBranchesWithinTrees = function(treeA, treeB, branches) {
|
||||||
var result = true;
|
var result = true;
|
||||||
_.each(branches, function(branchName) {
|
branches.forEach(function(branchName) {
|
||||||
result = result && this.compareBranchWithinTrees(treeA, treeB, branchName);
|
result = result && this.compareBranchWithinTrees(treeA, treeB, branchName);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ TreeCompare.compareBranchesWithinTreesHashAgnostic = function(treeA, treeB, bran
|
||||||
var recurseCompare = this.getRecurseCompareHashAgnostic(treeA, treeB);
|
var recurseCompare = this.getRecurseCompareHashAgnostic(treeA, treeB);
|
||||||
|
|
||||||
var result = true;
|
var result = true;
|
||||||
_.each(branches, function(branchName) {
|
branches.forEach(function(branchName) {
|
||||||
var branchA = treeA.branches[branchName];
|
var branchA = treeA.branches[branchName];
|
||||||
var branchB = treeB.branches[branchName];
|
var branchB = treeB.branches[branchName];
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ TreeCompare.evalAssertsOnBranch = function(tree, branchName, asserts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = true;
|
var result = true;
|
||||||
_.each(asserts, function(assert) {
|
asserts.forEach(function(assert) {
|
||||||
try {
|
try {
|
||||||
result = result && assert(data);
|
result = result && assert(data);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -305,7 +305,7 @@ TreeCompare.getRecurseCompare = function(treeA, treeB, options) {
|
||||||
// so the index lookup is valid. for merge commits this will duplicate some of the
|
// so the index lookup is valid. for merge commits this will duplicate some of the
|
||||||
// checking (because we aren't doing graph search) but it's not a huge deal
|
// checking (because we aren't doing graph search) but it's not a huge deal
|
||||||
var maxNumParents = Math.max(commitA.parents.length, commitB.parents.length);
|
var maxNumParents = Math.max(commitA.parents.length, commitB.parents.length);
|
||||||
_.each(_.range(maxNumParents), function(index) {
|
for (var index = 0; index < maxNumParents; index++) {
|
||||||
var pAid = commitA.parents[index];
|
var pAid = commitA.parents[index];
|
||||||
var pBid = commitB.parents[index];
|
var pBid = commitB.parents[index];
|
||||||
|
|
||||||
|
@ -315,7 +315,7 @@ TreeCompare.getRecurseCompare = function(treeA, treeB, options) {
|
||||||
var childB = treeB.commits[pBid];
|
var childB = treeB.commits[pBid];
|
||||||
|
|
||||||
result = result && recurseCompare(childA, childB);
|
result = result && recurseCompare(childA, childB);
|
||||||
}, this);
|
}
|
||||||
// if each of our children recursively are equal, we are good
|
// if each of our children recursively are equal, we are good
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
@ -377,7 +377,7 @@ TreeCompare.reduceTreeFields = function(trees) {
|
||||||
tags: {}
|
tags: {}
|
||||||
};
|
};
|
||||||
|
|
||||||
_.each(trees, function(tree) {
|
trees.forEach(function(tree) {
|
||||||
_.each(treeDefaults, function(val, key) {
|
_.each(treeDefaults, function(val, key) {
|
||||||
if (tree[key] === undefined) {
|
if (tree[key] === undefined) {
|
||||||
tree[key] = val;
|
tree[key] = val;
|
||||||
|
@ -391,7 +391,7 @@ TreeCompare.reduceTreeFields = function(trees) {
|
||||||
_.each(objects, function(obj, objKey) {
|
_.each(objects, function(obj, objKey) {
|
||||||
// our blank slate to copy over
|
// our blank slate to copy over
|
||||||
var blank = {};
|
var blank = {};
|
||||||
_.each(saveFields, function(field) {
|
saveFields.forEach(function(field) {
|
||||||
if (obj[field] !== undefined) {
|
if (obj[field] !== undefined) {
|
||||||
blank[field] = obj[field];
|
blank[field] = obj[field];
|
||||||
} else if (defaults[field] !== undefined) {
|
} else if (defaults[field] !== undefined) {
|
||||||
|
@ -410,7 +410,7 @@ TreeCompare.reduceTreeFields = function(trees) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
_.each(trees, function(tree) {
|
trees.forEach(function(tree) {
|
||||||
saveOnly(tree, 'commits', commitSaveFields, commitSortFields);
|
saveOnly(tree, 'commits', commitSaveFields, commitSortFields);
|
||||||
saveOnly(tree, 'branches', branchSaveFields);
|
saveOnly(tree, 'branches', branchSaveFields);
|
||||||
saveOnly(tree, 'tags', tagSaveFields);
|
saveOnly(tree, 'tags', tagSaveFields);
|
||||||
|
|
|
@ -68,7 +68,7 @@ ParseWaterfall.prototype.addLast = function(which, value) {
|
||||||
};
|
};
|
||||||
|
|
||||||
ParseWaterfall.prototype.expandAllShortcuts = function(commandStr) {
|
ParseWaterfall.prototype.expandAllShortcuts = function(commandStr) {
|
||||||
_.each(this.shortcutWaterfall, function(shortcutMap) {
|
this.shortcutWaterfall.forEach(function(shortcutMap) {
|
||||||
commandStr = this.expandShortcut(commandStr, shortcutMap);
|
commandStr = this.expandShortcut(commandStr, shortcutMap);
|
||||||
}, this);
|
}, this);
|
||||||
return commandStr;
|
return commandStr;
|
||||||
|
@ -87,13 +87,13 @@ ParseWaterfall.prototype.expandShortcut = function(commandStr, shortcutMap) {
|
||||||
};
|
};
|
||||||
|
|
||||||
ParseWaterfall.prototype.processAllInstants = function(commandStr) {
|
ParseWaterfall.prototype.processAllInstants = function(commandStr) {
|
||||||
_.each(this.instantWaterfall, function(instantCommands) {
|
this.instantWaterfall.forEach(function(instantCommands) {
|
||||||
this.processInstant(commandStr, instantCommands);
|
this.processInstant(commandStr, instantCommands);
|
||||||
}, this);
|
}, this);
|
||||||
};
|
};
|
||||||
|
|
||||||
ParseWaterfall.prototype.processInstant = function(commandStr, instantCommands) {
|
ParseWaterfall.prototype.processInstant = function(commandStr, instantCommands) {
|
||||||
_.each(instantCommands, function(tuple) {
|
instantCommands.forEach(function(tuple) {
|
||||||
var regex = tuple[0];
|
var regex = tuple[0];
|
||||||
var results = regex.exec(commandStr);
|
var results = regex.exec(commandStr);
|
||||||
if (results) {
|
if (results) {
|
||||||
|
@ -109,7 +109,7 @@ ParseWaterfall.prototype.parseAll = function(commandStr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var toReturn = false;
|
var toReturn = false;
|
||||||
_.each(this.parseWaterfall, function(parseFunc) {
|
this.parseWaterfall.forEach(function(parseFunc) {
|
||||||
var results = parseFunc(commandStr);
|
var results = parseFunc(commandStr);
|
||||||
if (results) {
|
if (results) {
|
||||||
toReturn = results;
|
toReturn = results;
|
||||||
|
@ -120,4 +120,3 @@ ParseWaterfall.prototype.parseAll = function(commandStr) {
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.ParseWaterfall = ParseWaterfall;
|
exports.ParseWaterfall = ParseWaterfall;
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ var Command = Backbone.Model.extend({
|
||||||
|
|
||||||
deleteOptions: function(options) {
|
deleteOptions: function(options) {
|
||||||
var map = this.getOptionsMap();
|
var map = this.getOptionsMap();
|
||||||
_.each(options, function(option) {
|
options.forEach(function(option) {
|
||||||
delete map[option];
|
delete map[option];
|
||||||
}, this);
|
}, this);
|
||||||
this.setOptionsMap(map);
|
this.setOptionsMap(map);
|
||||||
|
|
|
@ -98,7 +98,7 @@ var instantCommands = [
|
||||||
intl.str('show-all-commands'),
|
intl.str('show-all-commands'),
|
||||||
'<br/>'
|
'<br/>'
|
||||||
];
|
];
|
||||||
_.each(allCommands, function(regex, command) {
|
allCommands.forEach(function(regex, command) {
|
||||||
lines.push(command);
|
lines.push(command);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ var getAllCommands = function() {
|
||||||
allCommands[vcs + ' ' + method] = regex;
|
allCommands[vcs + ' ' + method] = regex;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
_.each(toDelete, function(key) {
|
toDelete.forEach(function(key) {
|
||||||
delete allCommands[key];
|
delete allCommands[key];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ var validateLevel = function(level) {
|
||||||
'solutionCommand'
|
'solutionCommand'
|
||||||
];
|
];
|
||||||
|
|
||||||
_.each(requiredFields, function(field) {
|
requiredFields.forEach(function(field) {
|
||||||
if (level[field] === undefined) {
|
if (level[field] === undefined) {
|
||||||
console.log(level);
|
console.log(level);
|
||||||
throw new Error('I need this field for a level: ' + field);
|
throw new Error('I need this field for a level: ' + field);
|
||||||
|
@ -59,7 +59,7 @@ _.each(levelSequences, function(levels, levelSequenceName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// for this particular sequence...
|
// for this particular sequence...
|
||||||
_.each(levels, function(level, index) {
|
levels.forEach(function(level, index) {
|
||||||
validateLevel(level);
|
validateLevel(level);
|
||||||
|
|
||||||
var id = levelSequenceName + String(index + 1);
|
var id = levelSequenceName + String(index + 1);
|
||||||
|
|
|
@ -173,7 +173,7 @@ var CommandPromptView = Backbone.View.extend({
|
||||||
which.reverse();
|
which.reverse();
|
||||||
|
|
||||||
var str = '';
|
var str = '';
|
||||||
_.each(which, function(text) {
|
which.forEach(function(text) {
|
||||||
str += text + ';';
|
str += text + ';';
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
|
@ -202,4 +202,3 @@ var CommandPromptView = Backbone.View.extend({
|
||||||
});
|
});
|
||||||
|
|
||||||
exports.CommandPromptView = CommandPromptView;
|
exports.CommandPromptView = CommandPromptView;
|
||||||
|
|
||||||
|
|
|
@ -168,7 +168,7 @@ var GitDemonstrationView = ContainedBase.extend({
|
||||||
var chainDeferred = Q.defer();
|
var chainDeferred = Q.defer();
|
||||||
var chainPromise = chainDeferred.promise;
|
var chainPromise = chainDeferred.promise;
|
||||||
|
|
||||||
_.each(commands, function(command, index) {
|
commands.forEach(function(command, index) {
|
||||||
chainPromise = chainPromise.then(function() {
|
chainPromise = chainPromise.then(function() {
|
||||||
var myDefer = Q.defer();
|
var myDefer = Q.defer();
|
||||||
this.mainVis.gitEngine.dispatch(command, myDefer);
|
this.mainVis.gitEngine.dispatch(command, myDefer);
|
||||||
|
|
|
@ -292,7 +292,7 @@ var LevelDropdownView = ContainedBase.extend({
|
||||||
$(selector).toggleClass('selected', value);
|
$(selector).toggleClass('selected', value);
|
||||||
|
|
||||||
// also go find the series and update the about
|
// also go find the series and update the about
|
||||||
_.each(this.seriesViews, function(view) {
|
this.seriesViews.forEach(function(view) {
|
||||||
if (view.levelIDs.indexOf(id) === -1) {
|
if (view.levelIDs.indexOf(id) === -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -343,14 +343,14 @@ var LevelDropdownView = ContainedBase.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
updateSolvedStatus: function() {
|
updateSolvedStatus: function() {
|
||||||
_.each(this.seriesViews, function(view) {
|
this.seriesViews.forEach(function(view) {
|
||||||
view.updateSolvedStatus();
|
view.updateSolvedStatus();
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
buildSequences: function() {
|
buildSequences: function() {
|
||||||
this.seriesViews = [];
|
this.seriesViews = [];
|
||||||
_.each(this.getSequencesOnTab(), function(sequenceName) {
|
this.getSequencesOnTab().forEach(function(sequenceName) {
|
||||||
this.seriesViews.push(new SeriesView({
|
this.seriesViews.push(new SeriesView({
|
||||||
destination: this.$el,
|
destination: this.$el,
|
||||||
name: sequenceName,
|
name: sequenceName,
|
||||||
|
@ -377,7 +377,7 @@ var SeriesView = BaseView.extend({
|
||||||
|
|
||||||
this.levelIDs = [];
|
this.levelIDs = [];
|
||||||
var firstLevelInfo = null;
|
var firstLevelInfo = null;
|
||||||
_.each(this.levels, function(level) {
|
this.levels.forEach(function(level) {
|
||||||
if (firstLevelInfo === null) {
|
if (firstLevelInfo === null) {
|
||||||
firstLevelInfo = this.formatLevelAbout(level.id);
|
firstLevelInfo = this.formatLevelAbout(level.id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,7 +142,7 @@ var MultiView = Backbone.View.extend({
|
||||||
// other views will take if they need to
|
// other views will take if they need to
|
||||||
this.keyboardListener.mute();
|
this.keyboardListener.mute();
|
||||||
|
|
||||||
_.each(this.childViews, function(childView) {
|
this.childViews.forEach(function(childView) {
|
||||||
childView.die();
|
childView.die();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ var MultiView = Backbone.View.extend({
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
// go through each and render... show the first
|
// go through each and render... show the first
|
||||||
_.each(this.childViewJSONs, function(childViewJSON, index) {
|
this.childViewJSONs.forEach(function(childViewJSON, index) {
|
||||||
var childView = this.createChildView(childViewJSON);
|
var childView = this.createChildView(childViewJSON);
|
||||||
this.childViews.push(childView);
|
this.childViews.push(childView);
|
||||||
this.addNavToView(childView, index);
|
this.addNavToView(childView, index);
|
||||||
|
|
|
@ -19,7 +19,7 @@ var InteractiveRebaseView = ContainedBase.extend({
|
||||||
|
|
||||||
this.rebaseEntries = new RebaseEntryCollection();
|
this.rebaseEntries = new RebaseEntryCollection();
|
||||||
options.toRebase.reverse();
|
options.toRebase.reverse();
|
||||||
_.each(options.toRebase, function(commit) {
|
options.toRebase.forEach(function(commit) {
|
||||||
var id = commit.get('id');
|
var id = commit.get('id');
|
||||||
this.rebaseMap[id] = commit;
|
this.rebaseMap[id] = commit;
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ var InteractiveRebaseView = ContainedBase.extend({
|
||||||
|
|
||||||
// now get the real array
|
// now get the real array
|
||||||
var toRebase = [];
|
var toRebase = [];
|
||||||
_.each(uiOrder, function(id) {
|
uiOrder.forEach(function(id) {
|
||||||
// the model pick check
|
// the model pick check
|
||||||
if (this.entryObjMap[id].get('pick')) {
|
if (this.entryObjMap[id].get('pick')) {
|
||||||
toRebase.unshift(this.rebaseMap[id]);
|
toRebase.unshift(this.rebaseMap[id]);
|
||||||
|
|
|
@ -58,7 +58,7 @@ GitVisuals.prototype.defer = function(action) {
|
||||||
};
|
};
|
||||||
|
|
||||||
GitVisuals.prototype.deferFlush = function() {
|
GitVisuals.prototype.deferFlush = function() {
|
||||||
_.each(this.deferred, function(action) {
|
this.deferred.forEach(function(action) {
|
||||||
action();
|
action();
|
||||||
}, this);
|
}, this);
|
||||||
this.deferred = [];
|
this.deferred = [];
|
||||||
|
@ -68,17 +68,17 @@ GitVisuals.prototype.resetAll = function() {
|
||||||
// make sure to copy these collections because we remove
|
// make sure to copy these collections because we remove
|
||||||
// items in place and underscore is too dumb to detect length change
|
// items in place and underscore is too dumb to detect length change
|
||||||
var edges = this.visEdgeCollection.toArray();
|
var edges = this.visEdgeCollection.toArray();
|
||||||
_.each(edges, function(visEdge) {
|
edges.forEach(function(visEdge) {
|
||||||
visEdge.remove();
|
visEdge.remove();
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
var branches = this.visBranchCollection.toArray();
|
var branches = this.visBranchCollection.toArray();
|
||||||
_.each(branches, function(visBranch) {
|
branches.forEach(function(visBranch) {
|
||||||
visBranch.remove();
|
visBranch.remove();
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
var tags = this.visTagCollection.toArray();
|
var tags = this.visTagCollection.toArray();
|
||||||
_.each(tags, function(visTag) {
|
tags.forEach(function(visTag) {
|
||||||
visTag.remove();
|
visTag.remove();
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
|
@ -332,7 +332,7 @@ GitVisuals.prototype.explodeNodes = function(speed) {
|
||||||
// are called unnecessarily when they have almost
|
// are called unnecessarily when they have almost
|
||||||
// zero speed. would be interesting to see performance differences
|
// zero speed. would be interesting to see performance differences
|
||||||
var keepGoing = [];
|
var keepGoing = [];
|
||||||
_.each(funcs, function(func) {
|
funcs.forEach(function(func) {
|
||||||
if (func()) {
|
if (func()) {
|
||||||
keepGoing.push(func);
|
keepGoing.push(func);
|
||||||
}
|
}
|
||||||
|
@ -485,7 +485,7 @@ GitVisuals.prototype.getBlendedHuesForCommit = function(commit) {
|
||||||
|
|
||||||
GitVisuals.prototype.blendHuesFromBranchStack = function(branchStackArray) {
|
GitVisuals.prototype.blendHuesFromBranchStack = function(branchStackArray) {
|
||||||
var hueStrings = [];
|
var hueStrings = [];
|
||||||
_.each(branchStackArray, function(branchWrapper) {
|
branchStackArray.forEach(function(branchWrapper) {
|
||||||
var fill = branchWrapper.obj.get('visBranch').get('fill');
|
var fill = branchWrapper.obj.get('visBranch').get('fill');
|
||||||
|
|
||||||
if (fill.slice(0,3) !== 'hsb') {
|
if (fill.slice(0,3) !== 'hsb') {
|
||||||
|
@ -525,7 +525,7 @@ GitVisuals.prototype.getCommitUpstreamStatus = function(commit) {
|
||||||
GitVisuals.prototype.calcTagStacks = function() {
|
GitVisuals.prototype.calcTagStacks = function() {
|
||||||
var tags = this.gitEngine.getTags();
|
var tags = this.gitEngine.getTags();
|
||||||
var map = {};
|
var map = {};
|
||||||
_.each(tags, function(tag) {
|
tags.forEach(function(tag) {
|
||||||
var thisId = tag.target.get('id');
|
var thisId = tag.target.get('id');
|
||||||
|
|
||||||
map[thisId] = map[thisId] || [];
|
map[thisId] = map[thisId] || [];
|
||||||
|
@ -542,7 +542,7 @@ GitVisuals.prototype.calcTagStacks = function() {
|
||||||
GitVisuals.prototype.calcBranchStacks = function() {
|
GitVisuals.prototype.calcBranchStacks = function() {
|
||||||
var branches = this.gitEngine.getBranches();
|
var branches = this.gitEngine.getBranches();
|
||||||
var map = {};
|
var map = {};
|
||||||
_.each(branches, function(branch) {
|
branches.forEach(function(branch) {
|
||||||
var thisId = branch.target.get('id');
|
var thisId = branch.target.get('id');
|
||||||
|
|
||||||
map[thisId] = map[thisId] || [];
|
map[thisId] = map[thisId] || [];
|
||||||
|
@ -572,7 +572,7 @@ GitVisuals.prototype.calcWidth = function() {
|
||||||
|
|
||||||
GitVisuals.prototype.maxWidthRecursive = function(commit) {
|
GitVisuals.prototype.maxWidthRecursive = function(commit) {
|
||||||
var childrenTotalWidth = 0;
|
var childrenTotalWidth = 0;
|
||||||
_.each(commit.get('children'), function(child) {
|
commit.get('children').forEach(function(child) {
|
||||||
// only include this if we are the "main" parent of
|
// only include this if we are the "main" parent of
|
||||||
// this child
|
// this child
|
||||||
if (child.isMainParent(commit)) {
|
if (child.isMainParent(commit)) {
|
||||||
|
@ -601,14 +601,14 @@ GitVisuals.prototype.assignBoundsRecursive = function(commit, min, max) {
|
||||||
// basic box-flex model
|
// basic box-flex model
|
||||||
var totalFlex = 0;
|
var totalFlex = 0;
|
||||||
var children = commit.get('children');
|
var children = commit.get('children');
|
||||||
_.each(children, function(child) {
|
children.forEach(function(child) {
|
||||||
if (child.isMainParent(commit)) {
|
if (child.isMainParent(commit)) {
|
||||||
totalFlex += child.get('visNode').getMaxWidthScaled();
|
totalFlex += child.get('visNode').getMaxWidthScaled();
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
var prevBound = min;
|
var prevBound = min;
|
||||||
_.each(children, function(child, index) {
|
children.forEach(function(child, index) {
|
||||||
if (!child.isMainParent(commit)) {
|
if (!child.isMainParent(commit)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -777,7 +777,7 @@ GitVisuals.prototype.calcDepthRecursive = function(commit, depth) {
|
||||||
|
|
||||||
var children = commit.get('children');
|
var children = commit.get('children');
|
||||||
var maxDepth = depth;
|
var maxDepth = depth;
|
||||||
_.each(children, function(child) {
|
children.forEach(function(child) {
|
||||||
var d = this.calcDepthRecursive(child, depth + 1);
|
var d = this.calcDepthRecursive(child, depth + 1);
|
||||||
maxDepth = Math.max(d, maxDepth);
|
maxDepth = Math.max(d, maxDepth);
|
||||||
}, this);
|
}, this);
|
||||||
|
@ -924,7 +924,7 @@ function blendHueStrings(hueStrings) {
|
||||||
var totalBright = 0;
|
var totalBright = 0;
|
||||||
var length = hueStrings.length;
|
var length = hueStrings.length;
|
||||||
|
|
||||||
_.each(hueStrings, function(hueString) {
|
hueStrings.forEach(function(hueString) {
|
||||||
var exploded = hueString.split('(')[1];
|
var exploded = hueString.split('(')[1];
|
||||||
exploded = exploded.split(')')[0];
|
exploded = exploded.split(')')[0];
|
||||||
exploded = exploded.split(',');
|
exploded = exploded.split(',');
|
||||||
|
|
|
@ -3,7 +3,7 @@ var Backbone = require('backbone');
|
||||||
|
|
||||||
var VisBase = Backbone.Model.extend({
|
var VisBase = Backbone.Model.extend({
|
||||||
removeKeys: function(keys) {
|
removeKeys: function(keys) {
|
||||||
_.each(keys, function(key) {
|
keys.forEach(function(key) {
|
||||||
if (this.get(key)) {
|
if (this.get(key)) {
|
||||||
this.get(key).remove();
|
this.get(key).remove();
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ var VisBase = Backbone.Model.extend({
|
||||||
var attr = this.getAttributes();
|
var attr = this.getAttributes();
|
||||||
|
|
||||||
// safely insert this attribute into all the keys we want
|
// safely insert this attribute into all the keys we want
|
||||||
_.each(keys.include, function(key) {
|
keys.include.forEach(function(key) {
|
||||||
attr[key] = Object.assign(
|
attr[key] = Object.assign(
|
||||||
{},
|
{},
|
||||||
attr[key],
|
attr[key],
|
||||||
|
@ -33,7 +33,7 @@ var VisBase = Backbone.Model.extend({
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
_.each(keys.exclude, function(key) {
|
keys.exclude.forEach(function(key) {
|
||||||
delete attr[key];
|
delete attr[key];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -42,4 +42,3 @@ var VisBase = Backbone.Model.extend({
|
||||||
});
|
});
|
||||||
|
|
||||||
exports.VisBase = VisBase;
|
exports.VisBase = VisBase;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ var Backbone = require('backbone');
|
||||||
|
|
||||||
var VisBase = Backbone.Model.extend({
|
var VisBase = Backbone.Model.extend({
|
||||||
removeKeys: function(keys) {
|
removeKeys: function(keys) {
|
||||||
_.each(keys, function(key) {
|
keys.forEach(function(key) {
|
||||||
if (this.get(key)) {
|
if (this.get(key)) {
|
||||||
this.get(key).remove();
|
this.get(key).remove();
|
||||||
}
|
}
|
||||||
|
@ -35,14 +35,14 @@ var VisBase = Backbone.Model.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
setAttrBase: function(keys, attr, instant, speed, easing) {
|
setAttrBase: function(keys, attr, instant, speed, easing) {
|
||||||
_.each(keys, function(key) {
|
keys.forEach(function(key) {
|
||||||
if (instant) {
|
if (instant) {
|
||||||
this.get(key).attr(attr[key]);
|
this.get(key).attr(attr[key]);
|
||||||
} else {
|
} else {
|
||||||
this.get(key).stop();
|
this.get(key).stop();
|
||||||
this.get(key).animate(attr[key], speed, easing);
|
this.get(key).animate(attr[key], speed, easing);
|
||||||
// some keys don't support animating too, so set those instantly here
|
// some keys don't support animating too, so set those instantly here
|
||||||
_.forEach(this.getNonAnimateKeys(), function(nonAnimateKey) {
|
this.getNonAnimateKeys().forEach(function(nonAnimateKey) {
|
||||||
if (attr[key] && attr[key][nonAnimateKey] !== undefined) {
|
if (attr[key] && attr[key][nonAnimateKey] !== undefined) {
|
||||||
this.get(key).attr(nonAnimateKey, attr[key][nonAnimateKey]);
|
this.get(key).attr(nonAnimateKey, attr[key][nonAnimateKey]);
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ var VisBase = Backbone.Model.extend({
|
||||||
var attr = this.getAttributes();
|
var attr = this.getAttributes();
|
||||||
|
|
||||||
// safely insert this attribute into all the keys we want
|
// safely insert this attribute into all the keys we want
|
||||||
_.each(keys.include, function(key) {
|
keys.include.forEach(function(key) {
|
||||||
attr[key] = Object.assign(
|
attr[key] = Object.assign(
|
||||||
{},
|
{},
|
||||||
attr[key],
|
attr[key],
|
||||||
|
@ -78,7 +78,7 @@ var VisBase = Backbone.Model.extend({
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
_.each(keys.exclude, function(key) {
|
keys.exclude.forEach(function(key) {
|
||||||
delete attr[key];
|
delete attr[key];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -87,4 +87,3 @@ var VisBase = Backbone.Model.extend({
|
||||||
});
|
});
|
||||||
|
|
||||||
exports.VisBase = VisBase;
|
exports.VisBase = VisBase;
|
||||||
|
|
||||||
|
|
|
@ -167,7 +167,7 @@ var VisBranch = VisBase.extend({
|
||||||
|
|
||||||
var myArray = this.getBranchStackArray();
|
var myArray = this.getBranchStackArray();
|
||||||
var index = -1;
|
var index = -1;
|
||||||
_.each(myArray, function(branch, i) {
|
myArray.forEach(function(branch, i) {
|
||||||
if (branch.obj == this.get('branch')) {
|
if (branch.obj == this.get('branch')) {
|
||||||
index = i;
|
index = i;
|
||||||
}
|
}
|
||||||
|
@ -279,7 +279,7 @@ var VisBranch = VisBase.extend({
|
||||||
arrowInnerLow,
|
arrowInnerLow,
|
||||||
arrowStartLow
|
arrowStartLow
|
||||||
];
|
];
|
||||||
_.each(coords, function(pos) {
|
coords.forEach(function(pos) {
|
||||||
pathStr += 'L' + toStringCoords(pos) + ' ';
|
pathStr += 'L' + toStringCoords(pos) + ' ';
|
||||||
}, this);
|
}, this);
|
||||||
pathStr += 'z';
|
pathStr += 'z';
|
||||||
|
@ -309,7 +309,7 @@ var VisBranch = VisBase.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
var maxWidth = 0;
|
var maxWidth = 0;
|
||||||
_.each(this.getBranchStackArray(), function(branch) {
|
this.getBranchStackArray().forEach(function(branch) {
|
||||||
maxWidth = Math.max(maxWidth, getTextWidth(
|
maxWidth = Math.max(maxWidth, getTextWidth(
|
||||||
branch.obj.get('visBranch')
|
branch.obj.get('visBranch')
|
||||||
));
|
));
|
||||||
|
@ -432,7 +432,7 @@ var VisBranch = VisBase.extend({
|
||||||
|
|
||||||
// set CSS
|
// set CSS
|
||||||
var keys = ['text', 'rect', 'arrow'];
|
var keys = ['text', 'rect', 'arrow'];
|
||||||
_.each(keys, function(key) {
|
keys.forEach(function(key) {
|
||||||
$(this.get(key).node).css(attr.css);
|
$(this.get(key).node).css(attr.css);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
|
@ -451,7 +451,7 @@ var VisBranch = VisBase.extend({
|
||||||
this.get('arrow')
|
this.get('arrow')
|
||||||
];
|
];
|
||||||
|
|
||||||
_.each(objs, function(rObj) {
|
objs.forEach(function(rObj) {
|
||||||
rObj.click(this.onClick.bind(this));
|
rObj.click(this.onClick.bind(this));
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
|
@ -577,4 +577,3 @@ var VisBranchCollection = Backbone.Collection.extend({
|
||||||
exports.VisBranchCollection = VisBranchCollection;
|
exports.VisBranchCollection = VisBranchCollection;
|
||||||
exports.VisBranch = VisBranch;
|
exports.VisBranch = VisBranch;
|
||||||
exports.randomHueString = randomHueString;
|
exports.randomHueString = randomHueString;
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ var VisEdge = VisBase.extend({
|
||||||
|
|
||||||
validateAtInit: function() {
|
validateAtInit: function() {
|
||||||
var required = ['tail', 'head'];
|
var required = ['tail', 'head'];
|
||||||
_.each(required, function(key) {
|
required.forEach(function(key) {
|
||||||
if (!this.get(key)) {
|
if (!this.get(key)) {
|
||||||
throw new Error(key + ' is required!');
|
throw new Error(key + ' is required!');
|
||||||
}
|
}
|
||||||
|
|
|
@ -261,33 +261,33 @@ var VisNode = VisBase.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
setOutgoingEdgesOpacity: function(opacity) {
|
setOutgoingEdgesOpacity: function(opacity) {
|
||||||
_.each(this.get('outgoingEdges'), function(edge) {
|
this.get('outgoingEdges').forEach(function(edge) {
|
||||||
edge.setOpacity(opacity);
|
edge.setOpacity(opacity);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
animateOutgoingEdgesToAttr: function(snapShot, speed, easing) {
|
animateOutgoingEdgesToAttr: function(snapShot, speed, easing) {
|
||||||
_.each(this.get('outgoingEdges'), function(edge) {
|
this.get('outgoingEdges').forEach(function(edge) {
|
||||||
var attr = snapShot[edge.getID()];
|
var attr = snapShot[edge.getID()];
|
||||||
edge.animateToAttr(attr);
|
edge.animateToAttr(attr);
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
animateOutgoingEdges: function(speed, easing) {
|
animateOutgoingEdges: function(speed, easing) {
|
||||||
_.each(this.get('outgoingEdges'), function(edge) {
|
this.get('outgoingEdges').forEach(function(edge) {
|
||||||
edge.animateUpdatedPath(speed, easing);
|
edge.animateUpdatedPath(speed, easing);
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
animateOutgoingEdgesFromSnapshot: function(snapshot, speed, easing) {
|
animateOutgoingEdgesFromSnapshot: function(snapshot, speed, easing) {
|
||||||
_.each(this.get('outgoingEdges'), function(edge) {
|
this.get('outgoingEdges').forEach(function(edge) {
|
||||||
var attr = snapshot[edge.getID()];
|
var attr = snapshot[edge.getID()];
|
||||||
edge.animateToAttr(attr, speed, easing);
|
edge.animateToAttr(attr, speed, easing);
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
setOutgoingEdgesBirthPosition: function(parentCoords) {
|
setOutgoingEdgesBirthPosition: function(parentCoords) {
|
||||||
_.each(this.get('outgoingEdges'), function(edge) {
|
this.get('outgoingEdges').forEach(function(edge) {
|
||||||
var headPos = edge.get('head').getScreenCoords();
|
var headPos = edge.get('head').getScreenCoords();
|
||||||
var path = edge.genSmoothBezierPathStringFromCoords(parentCoords, headPos);
|
var path = edge.genSmoothBezierPathStringFromCoords(parentCoords, headPos);
|
||||||
edge.get('path').stop();
|
edge.get('path').stop();
|
||||||
|
@ -334,7 +334,7 @@ var VisNode = VisBase.extend({
|
||||||
}
|
}
|
||||||
var commandStr = 'git checkout ' + this.get('commit').get('id');
|
var commandStr = 'git checkout ' + this.get('commit').get('id');
|
||||||
var Main = require('../app');
|
var Main = require('../app');
|
||||||
_.each([this.get('circle'), this.get('text')], function(rObj) {
|
[this.get('circle'), this.get('text')].forEach(function(rObj) {
|
||||||
rObj.click(function() {
|
rObj.click(function() {
|
||||||
Main.getEventBaton().trigger('commandSubmitted', commandStr);
|
Main.getEventBaton().trigger('commandSubmitted', commandStr);
|
||||||
});
|
});
|
||||||
|
@ -347,7 +347,7 @@ var VisNode = VisBase.extend({
|
||||||
|
|
||||||
// set the opacity on my stuff
|
// set the opacity on my stuff
|
||||||
var keys = ['circle', 'text'];
|
var keys = ['circle', 'text'];
|
||||||
_.each(keys, function(key) {
|
keys.forEach(function(key) {
|
||||||
this.get(key).attr({
|
this.get(key).attr({
|
||||||
opacity: opacity
|
opacity: opacity
|
||||||
});
|
});
|
||||||
|
@ -371,7 +371,7 @@ var VisNode = VisBase.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
removeAllEdges: function() {
|
removeAllEdges: function() {
|
||||||
_.each(this.get('outgoingEdges'), function(edge) {
|
this.get('outgoingEdges').forEach(function(edge) {
|
||||||
edge.remove();
|
edge.remove();
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
|
|
|
@ -95,7 +95,7 @@ var VisTag = VisBase.extend({
|
||||||
|
|
||||||
var myArray = this.getTagStackArray();
|
var myArray = this.getTagStackArray();
|
||||||
var index = -1;
|
var index = -1;
|
||||||
_.each(myArray, function(Tag, i) {
|
myArray.forEach(function(Tag, i) {
|
||||||
if (Tag.obj == this.get('tag')) {
|
if (Tag.obj == this.get('tag')) {
|
||||||
index = i;
|
index = i;
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ var VisTag = VisBase.extend({
|
||||||
var textNode = this.get('text').node;
|
var textNode = this.get('text').node;
|
||||||
|
|
||||||
var maxWidth = 0;
|
var maxWidth = 0;
|
||||||
_.each(this.getTagStackArray(), function(Tag) {
|
this.getTagStackArray().forEach(function(Tag) {
|
||||||
maxWidth = Math.max(maxWidth, getTextWidth(
|
maxWidth = Math.max(maxWidth, getTextWidth(
|
||||||
Tag.obj.get('visTag')
|
Tag.obj.get('visTag')
|
||||||
));
|
));
|
||||||
|
@ -271,7 +271,7 @@ var VisTag = VisBase.extend({
|
||||||
|
|
||||||
// set CSS
|
// set CSS
|
||||||
var keys = ['text', 'rect'];
|
var keys = ['text', 'rect'];
|
||||||
_.each(keys, function(key) {
|
keys.forEach(function(key) {
|
||||||
$(this.get(key).node).css(attr.css);
|
$(this.get(key).node).css(attr.css);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
|
@ -289,7 +289,7 @@ var VisTag = VisBase.extend({
|
||||||
this.get('text')
|
this.get('text')
|
||||||
];
|
];
|
||||||
|
|
||||||
_.each(objs, function(rObj) {
|
objs.forEach(function(rObj) {
|
||||||
rObj.click(this.onClick.bind(this));
|
rObj.click(this.onClick.bind(this));
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
|
@ -405,4 +405,3 @@ var VisTagCollection = Backbone.Collection.extend({
|
||||||
exports.VisTagCollection = VisTagCollection;
|
exports.VisTagCollection = VisTagCollection;
|
||||||
exports.VisTag = VisTag;
|
exports.VisTag = VisTag;
|
||||||
exports.randomHueString = randomHueString;
|
exports.randomHueString = randomHueString;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue