c5c832d598
- Rename some map overlays - add multiplayer config
51 lines
1.3 KiB
JavaScript
51 lines
1.3 KiB
JavaScript
/**
|
|
* Wraps json properties into something like SGPropertyNodes
|
|
*/
|
|
(function(factory) {
|
|
if (typeof define === "function" && define.amd)// AMD. Register as an anonymous module.
|
|
define([
|
|
], factory); else // Browser globals
|
|
factory();
|
|
}(function() {
|
|
|
|
var SGPropertyNode = function(json) {
|
|
this.json = json;
|
|
};
|
|
|
|
SGPropertyNode.prototype.getValue = function() {
|
|
return this.json.value;
|
|
}
|
|
|
|
SGPropertyNode.prototype.getName = function() {
|
|
return this.json.name;
|
|
}
|
|
|
|
SGPropertyNode.prototype.getPath = function() {
|
|
return this.json.path;
|
|
}
|
|
|
|
SGPropertyNode.prototype.getIndex = function() {
|
|
return this.json.index;
|
|
}
|
|
|
|
SGPropertyNode.prototype.getChildren = function(name) {
|
|
var reply = [];
|
|
this.json.children.forEach(function(child) {
|
|
if (name && child.name == name)
|
|
reply.push(new SGPropertyNode(child));
|
|
});
|
|
return reply;
|
|
}
|
|
|
|
SGPropertyNode.prototype.getNode = function(name, index) {
|
|
if (!index)
|
|
index = 0;
|
|
for (var i = 0; i < this.json.children.length; i++) {
|
|
var child = this.json.children[i];
|
|
if (child.name == name && child.index == index)
|
|
return new SGPropertyNode(child);
|
|
}
|
|
}
|
|
|
|
return SGPropertyNode;
|
|
}));
|