Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: Xalior/djsex
base: 36da7c8220
...
head fork: Xalior/djsex
compare: d8b2658b15
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 60 additions and 50 deletions.
  1. +57 −49 Core.js
  2. +3 −1 Math.js
View
106 Core.js
@@ -1,64 +1,72 @@
/* Simple 'Class' style JavaScript Inheritance
* Based upon (MIT Licensed) code by John Resig http://ejohn.org/
*/
+var djsex = {
+ init: function(){
+ var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;
-var djsex = function(){};
+ // Create a new Class that inherits from this class
+ djsex.Class.extend = function(prop) {
+ var _super = this.prototype;
-(function(){
- var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;
- // The base Class implementation (does nothing)
- djsex.Class = function(){};
-
- // Create a new Class that inherits from this class
- djsex.Class.extend = function(prop) {
- var _super = this.prototype;
+ // Instantiate a base class (but only create the instance,
+ // don't run the init constructor)
+ initializing = true;
+ var prototype = new this();
+ initializing = false;
- // Instantiate a base class (but only create the instance,
- // don't run the init constructor)
- initializing = true;
- var prototype = new this();
- initializing = false;
+ // Copy the properties over onto the new prototype
+ for (var name in prop) {
+ // Check if we're overwriting an existing function
+ prototype[name] = typeof prop[name] == "function" &&
+ typeof _super[name] == "function" && fnTest.test(prop[name]) ?
+ (function(name, fn){
+ return function() {
+ var tmp = this._super;
+
+ // Add a new ._super() method that is the same method
+ // but on the super-class
+ this._super = _super[name];
+
+ // The method only need to be bound temporarily, so we
+ // remove it when we're done executing
+ var ret = fn.apply(this, arguments);
+ this._super = tmp;
- // Copy the properties over onto the new prototype
- for (var name in prop) {
- // Check if we're overwriting an existing function
- prototype[name] = typeof prop[name] == "function" &&
- typeof _super[name] == "function" && fnTest.test(prop[name]) ?
- (function(name, fn){
- return function() {
- var tmp = this._super;
+ return ret;
+ };
+ })(name, prop[name]) :
+ prop[name];
+ }
- // Add a new ._super() method that is the same method
- // but on the super-class
- this._super = _super[name];
+ // The dummy class constructor
+ djsex.Class = function() {
+ // All construction is actually done in the init method
+ if ( !initializing && this.init )
+ this.init.apply(this, arguments);
+ }
- // The method only need to be bound temporarily, so we
- // remove it when we're done executing
- var ret = fn.apply(this, arguments);
- this._super = tmp;
+ // Populate our constructed prototype object
+ djsex.Class.prototype = prototype;
- return ret;
- };
- })(name, prop[name]) :
- prop[name];
- }
+ // Enforce the constructor to be what we expect
+ djsex.Class.prototype.constructor = djsex.Class;
- // The dummy class constructor
- djsex.Class = function() {
- // All construction is actually done in the init method
- if ( !initializing && this.init )
- this.init.apply(this, arguments);
- }
+ // And make this class extendable
+ djsex.Class.extend = arguments.callee;
- // Populate our constructed prototype object
- djsex.Class.prototype = prototype;
+ return djsex.Class;
+ };
+ },
+
+ debug: function(msg){
+ console.debug(msg);
+ },
- // Enforce the constructor to be what we expect
- djsex.Class.prototype.constructor = djsex.Class;
- // And make this class extendable
- djsex.Class.extend = arguments.callee;
+ // The base Class implementation (does nothing)
+ Class: function(){
+ },
+};
- return djsex.Class;
- };
-})();
+djsex.init();
View
4 Math.js
@@ -9,7 +9,9 @@
djsex.math = {
randomint: function(floor, ceil) {
- return Math.floor((Math.random()*ceil)+floor);
+ var min = floor === ceil ? ceil : floor; // min is value that is not max
+ var d = ceil - floor + 1; // distribution range
+ return Math.floor(Math.random() * d + floor);
},
decimalToHex: function(d, padding) {

No commit comments for this range

Something went wrong with that request. Please try again.