diff --git a/src/git.js b/src/git.js index e7a11f1a..c66193dc 100644 --- a/src/git.js +++ b/src/git.js @@ -7,13 +7,13 @@ var uniqueId = (function() { }; })(); -function GitEngine() { +function GitEngine(options) { this.rootCommit = null; this.refs = {}; this.HEAD = null; this.id_gen = 0; this.branches = []; - this.collection = commitCollection; + this.collection = options.collection; // global variable to keep track of the options given // along with the command call. @@ -28,7 +28,7 @@ function GitEngine() { GitEngine.prototype.init = function() { // make an initial commit and a master branch this.rootCommit = new Commit({rootCommit: true}); - commitCollection.add(this.rootCommit); + this.collection.add(this.rootCommit); this.refs[this.rootCommit.get('id')] = this.rootCommit; diff --git a/src/mine.js b/src/mine.js index 99585289..df35f48b 100644 --- a/src/mine.js +++ b/src/mine.js @@ -34,8 +34,12 @@ $(document).ready(function(){ collection: commandCollection }); - gitEngine = new GitEngine(); - gitVisuals = new GitVisuals(); + gitEngine = new GitEngine({ + collection: commitCollection + }); + gitVisuals = new GitVisuals({ + collection: commitCollection + }); $('#commandTextField').focus(); }); diff --git a/src/visuals.js b/src/visuals.js index 5ea8c122..726822f6 100644 --- a/src/visuals.js +++ b/src/visuals.js @@ -1,5 +1,5 @@ -function GitVisuals() { - this.collection = commitCollection; +function GitVisuals(options) { + this.collection = options.collection; this.collection.on('change', _.bind(this.collectionChanged, this)); events.on('drawGitVisuals', _.bind(this.drawVisuals, this));