function notify(ov, nv) { for (var i = observers.length - 1; i >= 0; --i) { observers[i].onMessage({ type: ‘attributeChange’, attribute: attr, oldValue: ov, newValue: nv }); } } var attr = { name: name, type: type, get: function() { return value; }, set: function(v) { var oldValue = value; value = v; notify(oldValue, value); }, addObserver: function(b) { observers.push(b); }, removeObserver: function(b) { observers.splice(observers.indexOf(b), 1); }, }; return attr; } Saturday, 1 June 13