From b3d6fee2ed8e23dfbe835d91b50b9922657030bd Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Wed, 19 Mar 2014 20:07:40 +0400 Subject: [PATCH] made the Data constructor more generic + started migration process... Signed-off-by: Alex A. Naanou --- ui/data4.js | 29 +++++++++++++++++++++-------- ui/index.html | 1 + 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/ui/data4.js b/ui/data4.js index fcf1ed7c..f2a240c0 100755 --- a/ui/data4.js +++ b/ui/data4.js @@ -9,7 +9,7 @@ /*********************************************************************/ -var DataClassProto = { +var DataClassPrototype = { // NOTE: we consider the list sorted... fromList: function(list){ var res = new Data() @@ -754,14 +754,27 @@ var DataPrototype = { } -var Data = function(){ - this.base = null - this.current = null - this.order = [] - this.ribbon_order = [] - this.ribbons = {} +function Data(json){ + if(this.constructor.name != 'Data'){ + obj = new Data + } else { + obj = this + } - this._gid_cache = [] + obj.base = null + obj.current = null + obj.order = [] + obj.ribbon_order = [] + obj.ribbons = {} + + obj._gid_cache = [] + + // load initial state... + if(json != null){ + obj.loadJSON(json) + } + + return obj } Data.__proto__ = DataClassPrototype Data.prototype = DataPrototype diff --git a/ui/index.html b/ui/index.html index c73e302c..424c859f 100755 --- a/ui/index.html +++ b/ui/index.html @@ -31,6 +31,7 @@ +