started some generalizing...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2014-11-18 19:51:41 +03:00
parent 19ced24420
commit 150cce52f6
3 changed files with 97 additions and 0 deletions

View File

@ -12,6 +12,8 @@ define(function(require){ var module = {}
console.log('>>> data')
var object = require('object')
var formats = require('formats')
var sha1 = require('./ext-lib/sha1')
@ -1805,6 +1807,7 @@ module.DataPrototype = {
// Main Data object...
//
/*
var Data =
module.Data =
function Data(json){
@ -1825,7 +1828,10 @@ function Data(json){
Data.__proto__ = DataClassPrototype
Data.prototype = DataPrototype
Data.prototype.constructor = Data
*/
var Data =
module.Data = object.makeConstructor('Data', DataClassPrototype, DataPrototype)
/**********************************************************************

52
ui (gen4)/object.js Executable file
View File

@ -0,0 +1,52 @@
/**********************************************************************
*
*
*
**********************************************************************/
define(function(require){ var module = {}
console.log('>>> objects')
//var DEBUG = DEBUG != null ? DEBUG : true
/*********************************************************************/
var makeConstructor =
module.makeConstructor =
function makeConstructor(name, a, b){
var proto = b == null ? a : b
var cls_proto = b == null ? b : a
var _constructor = function Constructor(json){
// in case this is called as a function (without new)...
if(this.constructor !== _constructor){
return new _constructor(json)
}
// load initial state...
if(json != null){
this.loadJSON(json)
} else {
this._reset()
}
return this
}
eval('_constructor = '+ _constructor.toString().replace(/Constructor/g, name))
_constructor.__proto__ = cls_proto
_constructor.prototype = proto
_constructor.prototype.constructor = _constructor
return _constructor
}
/**********************************************************************
* vim:set ts=4 sw=4 : */
return module })

39
ui (gen4)/tags.js Executable file
View File

@ -0,0 +1,39 @@
/**********************************************************************
*
*
*
**********************************************************************/
define(function(require){ var module = {}
console.log('>>> tags')
//var DEBUG = DEBUG != null ? DEBUG : true
var object = require('object')
/*********************************************************************/
var TagsClassPrototype = {}
var TagsPrototype = {
loadJSON: function(json){
},
dumpJSON: function(){
},
_reset: function(){
},
}
var Tags =
module.Tags = object.makeConstructor('Tags', TagsClassPrototype, TagsPrototype)
/**********************************************************************
* vim:set ts=4 sw=4 : */
return module })