Permalink
Browse files

Rename utilities to utils and use the module pattern

  • Loading branch information...
fhd committed Apr 17, 2012
1 parent fbc4096 commit 0abb7f0eafcd32a08143b410352b9989b86fd1aa
@@ -11,7 +11,7 @@ var boxes = [],
else if (ds instanceof LinkedList)
createLinkedListOperations(ds);
- setInterval(createDrawFunction($("#canvas")[0], draw), 10);
+ setInterval(utils.createDrawFunction($("#canvas")[0], draw), 10);
}
};
@@ -26,7 +26,8 @@ var array = [],
});
});
- setInterval(createDrawFunction($("#canvas")[0], draw), 10);
+ setInterval(utils.createDrawFunction($("#canvas")[0], draw),
+ 10);
}
}
},
View
@@ -1,5 +0,0 @@
-function createDrawFunction(canvas, drawFunction) {
- return function() {
- drawFunction(canvas.getContext("2d"), canvas.width, canvas.height);
- };
-}
View
@@ -0,0 +1,7 @@
+var utils = {
+ createDrawFunction: function(canvas, drawFunction) {
+ return function() {
+ drawFunction(canvas.getContext("2d"), canvas.width, canvas.height);
+ };
+ }
+};
View
@@ -4,7 +4,7 @@
<title>QUnit Tests</title>
<link rel="stylesheet" href="qunit/qunit.css" media="screen"/>
<script src="../js/libs/jquery-1.5.1.min.js"></script>
- <script src="../js/utilities.js"></script>
+ <script src="../js/utils.js"></script>
<script src="../js/sorting/display.js"></script>
<script src="../js/sorting/worker.js"></script>
<script src="../js/sorting/insertionSort.js"></script>
@@ -20,7 +20,7 @@
<script src="qunit/qunit.js"></script>
<script src="sinon-1.3.2.js"></script>
<script src="testUtils.js"></script>
- <script src="tests/utilities.js"></script>
+ <script src="tests/utils.js"></script>
<script src="tests/sorting/display.js"></script>
<script src="tests/sorting/worker.js"></script>
<script src="tests/sorting/sort.js"></script>
@@ -12,16 +12,16 @@ test("init", 2, function() {
currentAlgorithmFile = "";
prettyPrint = sinon.spy();
- sinon.stub(window, "createDrawFunction");
- createDrawFunction.returns(f);
+ sinon.stub(utils, "createDrawFunction");
+ utils.createDrawFunction.returns(f);
sinon.stub(window, "setInterval");
dataStructures.init();
ok(prettyPrint.called, "Google Prettify should be activated.");
ok(setInterval.calledWith(f), "The draw function interval should be set.");
- createDrawFunction.restore();
+ utils.createDrawFunction.restore();
setInterval.restore();
});
@@ -12,15 +12,15 @@ test("init", 2, function() {
currentAlgorithmFile = "";
prettyPrint = sinon.spy();
- sinon.stub(window, "createDrawFunction");
- createDrawFunction.returns(f);
+ sinon.stub(utils, "createDrawFunction");
+ utils.createDrawFunction.returns(f);
sinon.stub(window, "setInterval");
sorting.init();
ok(prettyPrint.called, "Google Prettify should be activated.");
ok(setInterval.calledWith(f), "The draw function interval should be set.");
- createDrawFunction.restore();
+ utils.createDrawFunction.restore();
setInterval.restore();
});
@@ -1,4 +1,4 @@
-module("utilities");
+module("utils");
test("createDrawFunction", 1, function() {
var context = testUtils.uniqueObject(),
@@ -7,7 +7,7 @@ test("createDrawFunction", 1, function() {
},
f = sinon.spy();
- createDrawFunction(canvas, f)();
+ utils.createDrawFunction(canvas, f)();
ok(f.calledWith(context),
"The draw function should use the context of the supplied canvas.");
View
@@ -8,7 +8,7 @@ html
script(src="js/libs/jquery-1.5.1.min.js")
script(src="js/libs/jquery-ui-1.8.11.custom.min.js")
script(src="js/libs/prettify/prettify.js")
- script(src="js/utilities.js")
+ script(src="js/utils.js")
body
header

0 comments on commit 0abb7f0

Please sign in to comment.