Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- console.clear();
- var cl = function(text){ console.log(text); }
- Sandbox.modules = {};
- Sandbox.modules.dam = function(box){
- box.getElement1 = function(){};
- box.getElement2 = function(){};
- box.getElement3 = function(){};
- box.showDamEvent = function(){
- console.log('inside dam');
- }
- };
- Sandbox.modules.event = function(box){
- box.constructor.prototype.m = 'mmm';
- box.attachEvent = function(){};
- box.dettachEvent = function(){};
- box.showEvent = function(){ console.log('amfa techno');};
- }
- function Sandbox(){
- var args = Array.prototype.slice.call(arguments),
- callback = args.pop(),
- i,
- modules = (args[0] && typeof args[0] === 'string') ? args: args[0];
- if (!(this instanceof Sandbox)){
- return new Sandbox(modules, callback);
- }
- this.a = 1;
- this.b = 2;
- if (!modules || modules === '*'){
- modules = [];
- for(i in Sandbox.modules) {
- if (Sandbox.modules.hasOwnProperty(i)){
- modules.push(i);
- }
- }
- }
- for (i = 0; i < modules.length; i += 1){
- Sandbox.modules[modules[i]](this);
- }
- callback(this);
- }
- Sandbox.prototype = {
- name: "moja apka",
- version: '1.0'
- };
- Sandbox(
- ['dam','event'],
- function(box){
- box.showEvent();
- box.showDamEvent();
- }
- );
Advertisement
Add Comment
Please, Sign In to add comment