Phi: simplify plugin json and add user plugin support
This commit is contained in:
parent
cee599cd0d
commit
f0588144d1
2 changed files with 28 additions and 27 deletions
|
@ -1,45 +1,33 @@
|
||||||
{
|
{
|
||||||
"plugins": {
|
"plugins": {
|
||||||
"Aircraft": {
|
"Aircraft": {
|
||||||
"component": {
|
"index": 100,
|
||||||
"key": "Aircraft",
|
"component": "topics/Aircraft"
|
||||||
"lib": "topics/Aircraft"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
"Environment": {
|
"Environment": {
|
||||||
"component": {
|
"index": 200,
|
||||||
"key": "Environment",
|
"component": "topics/Environment"
|
||||||
"lib": "topics/Environment"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
"Map": {
|
"Map": {
|
||||||
"component": {
|
"index": 300,
|
||||||
"key": "Map",
|
"component": "topics/Map"
|
||||||
"lib": "topics/Map"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
"Tools": {
|
"Tools": {
|
||||||
"component": {
|
"index": 400,
|
||||||
"key": "Tools",
|
"component": "topics/Tools"
|
||||||
"lib": "topics/Tools"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
"Simulator": {
|
"Simulator": {
|
||||||
"component": {
|
"index": 500,
|
||||||
"key": "Simulator",
|
"component": "topics/Simulator"
|
||||||
"lib": "topics/Simulator"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
"Help": {
|
"Help": {
|
||||||
"component": {
|
"index": 600,
|
||||||
"key": "Help",
|
"component": "topics/Help"
|
||||||
"lib": "topics/Help"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
19
Phi/main.js
19
Phi/main.js
|
@ -203,20 +203,33 @@ require([
|
||||||
|
|
||||||
jquery.get('/config.json', null, function(config) {
|
jquery.get('/config.json', null, function(config) {
|
||||||
|
|
||||||
|
// merge user config into global config
|
||||||
|
jquery.get('/fg-home/Phi/config.json', null, function(userConfig) {
|
||||||
|
for ( var p in userConfig.plugins ) {
|
||||||
|
config.plugins[p] = userConfig.plugins[p];
|
||||||
|
}
|
||||||
|
|
||||||
var topics = [];
|
var topics = [];
|
||||||
if (config && config.plugins ) {
|
if (config && config.plugins ) {
|
||||||
for ( var p in config.plugins ) {
|
for ( var p in config.plugins ) {
|
||||||
var plugin = config.plugins[p];
|
var plugin = config.plugins[p];
|
||||||
if (plugin.component && plugin.component.key && plugin.component.lib) {
|
if (plugin.component) {
|
||||||
if (false == ko.components.isRegistered(plugin.component.key)) {
|
if (false == ko.components.isRegistered(p)) {
|
||||||
ko.components.register(plugin.component.key, { require: plugin.component.lib });
|
ko.components.register(p, { require: plugin.component });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
topics.push(p);
|
topics.push(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
topics.sort(function(a,b) {
|
||||||
|
indexa = config.plugins[a].index || 0;
|
||||||
|
indexb = config.plugins[b].index || 0;
|
||||||
|
return indexa - indexb;
|
||||||
|
});
|
||||||
ko.applyBindings(new PhiViewModel(topics), document.getElementById('wrapper'));
|
ko.applyBindings(new PhiViewModel(topics), document.getElementById('wrapper'));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue