summaryrefslogtreecommitdiff
path: root/js/utility.js
diff options
context:
space:
mode:
authorLi Zhineng <[email protected]>2013-06-10 16:40:34 +0800
committerLi Zhineng <[email protected]>2013-06-10 16:40:34 +0800
commita92f6af5807669013aa40771690e0472d7f5da9d (patch)
tree9423367249ab2032ad1d0d7b0007144759bea247 /js/utility.js
parent006b98dfd0ae1fbc34ef4c135e4ab07a7b82b152 (diff)
downloadword-search-game-a92f6af5807669013aa40771690e0472d7f5da9d.tar.gz
word-search-game-a92f6af5807669013aa40771690e0472d7f5da9d.zip
Code refactoring
Diffstat (limited to 'js/utility.js')
-rw-r--r--js/utility.js30
1 files changed, 24 insertions, 6 deletions
diff --git a/js/utility.js b/js/utility.js
index a59841f..fe1d0f1 100644
--- a/js/utility.js
+++ b/js/utility.js
@@ -5,10 +5,28 @@
* @param {Number} max
* @return {Number}
*/
-Math.rangeInt = function(min, max){
- if (max == undefined) {
- max = min;
- min = 0;
- }
- return Math.floor(Math.random() * (max - min + 1)) + min;
+if (typeof Math.rangeInt != 'function') {
+ Math.rangeInt = function(min, max){
+ if (max == undefined) {
+ max = min;
+ min = 0;
+ }
+ return Math.floor(Math.random() * (max - min + 1)) + min;
+ }
+}
+
+/**
+ * Mege two objects
+ *
+ * @param {Object} o1 Object 1
+ * @param {Object} o2 Object 2
+ * @return {Object}
+ */
+if (typeof Object.merge != 'function') {
+ Object.merge = function(o1, o2) {
+ for (var i in o1) {
+ o2[i] = o1[i];
+ }
+ return o2;
+ }
}