2011-07-29 18:37:11 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
2011-05-25 19:42:45 +00:00
|
|
|
pandora.UI = (function() {
|
|
|
|
return {
|
2011-08-07 18:30:14 +00:00
|
|
|
set: function(/*{key: val} or key, val*/) {
|
|
|
|
var obj = Ox.makeObject(arguments);
|
2011-08-25 02:51:58 +00:00
|
|
|
Ox.forEach(obj, function(val, key) {
|
2011-05-25 19:42:45 +00:00
|
|
|
Ox.print('key', key, 'val', val);
|
|
|
|
var i = 0,
|
|
|
|
keys = key.split('|'),
|
2011-08-25 02:51:58 +00:00
|
|
|
ui = pandora.user.ui;
|
2011-05-25 19:42:45 +00:00
|
|
|
while (i < keys.length - 1) {
|
2011-08-25 02:51:58 +00:00
|
|
|
ui = ui[keys[i]];
|
2011-05-25 19:42:45 +00:00
|
|
|
i++;
|
|
|
|
}
|
2011-08-25 02:51:58 +00:00
|
|
|
if (ui[keys[i]] !== val) {
|
|
|
|
if (val === null) {
|
|
|
|
delete ui[keys[i]]
|
|
|
|
} else {
|
|
|
|
ui[keys[i]] = val;
|
|
|
|
}
|
2011-05-25 19:42:45 +00:00
|
|
|
} else {
|
|
|
|
delete obj[key];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Ox.len(obj) && pandora.api.setUI(obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}());
|
|
|
|
|