User
$(document).ready(function()........
// super this.super = function (name) { return cls.super(this, name); }
var Class = function(){}; Class.create = function(prop, cls_super){ if (!cls_super){ cls_super = Class; } var init = false; // new class var cls = function (){ if (init) { // extend this this.extend = function (prop) { for (name in prop) { this[name] = prop[name]; } return this; } if (this.init) { this.init.apply(this, arguments); } } }; cls.prototype = new cls_super(); init = true; // extend class for (name in prop) { cls.prototype[name] = prop[name]; } cls.prototype.constructor = cls; // super cls.super = function(instance, name){ var property = cls_super.prototype[name]; if (property instanceof Function){ return function () {return property.apply(instance, arguments)}; } else { return property; } } // extend cls.extend = function(prop){ init = false; var _cls = Class.create(prop, cls); init = true; return _cls; } return cls; }
var C1 = Class.create({ init: function() { alert("C1"); } }); var C2 = C1.extend({ init: function() { alert("C2"); // debugger; C2.super(this, 'init')(); } }); var C3 = C2.extend({ }); var C4 = C3.extend({ init: function() { alert("C4"); C4.super(this, 'init')(); } }); var obj = new C4();
var Class = function(){}; Class.create = function(prop, cls_super){ if (!cls_super){ cls_super = Class; } var init = false; // new class var cls = function (){ if (init) { // super this.super = function (name) { return this.constructor.super(this, name); } // extend this this.extend = function (prop) { for (name in prop) { this[name] = prop[name]; } return this; } if (this.init) { this.init.apply(this, arguments); } } }; cls.prototype = new cls_super(); init = true; // extend class for (name in prop) { cls.prototype[name] = prop[name]; } cls.prototype.constructor = cls; // super cls.super = function(instance, name){ var property = cls_super.prototype[name]; if (property instanceof Function){ return function () {property.apply(instance, arguments)}; } else { return property; } } // extend cls.extend = function(prop){ init = false; var _cls = Class.create(prop, cls); init = true; return _cls; } return cls; } // // end //
var Animal = Class.create({init: function(kind){this.kind = kind;}}) var Dog = Animal.extend({ init: function(name, kind) { this.super('init')(kind); this.name = name; } }); var doggy = new Dog('Rex', 'wolf');
my_list = [1,2,3,4,1,2,6,9,2,3,8,4,5,76,2,5,6,7] unique_list = list(set(my_list)) # [1, 2, 3, 4, 5, 6, 7, 8, 9, 76]
$(document).ready(function()........
это лишнее, т.к. GreaseMonkey запускает скрипт как только поступит событие DOMContentLoaded
wiki.greasespot.net/DOMContentLoaded
выслал кому смог, ждите приглашение от гугла.
пишите своё мыло.
rerвсё нормально отработало
через железобетон не пройдёт
идёт рекурсивный вызов, придётся убрать this.super и заменить на class.super
профиксил:
ваш код тогда будет выглядеть так:
вот думаю как сделать:
1) class.super(объект, имя_метода)
или
2) class.super(имя_метода, объект)
сейчас используется 1 вариант
вот пример использования:
самый простой пример:
my_list = [1,2,3,4,1,2,6,9,2,3,8,4,5,76,2,5,6,7]
unique_list = list(set(my_list))
# [1, 2, 3, 4, 5, 6, 7, 8, 9, 76]