1
0
Fork 0
fgdata/webgui/topics/Aircraft/Help.js

57 lines
1.8 KiB
JavaScript
Raw Normal View History

2015-02-06 10:36:53 +00:00
define([
'jquery', 'knockout', 'text!./Help.html'
], function(jquery, ko, htmlString) {
function ViewModel(params) {
var self = this;
self.helpTitle = ko.observable("");
2015-02-06 11:04:17 +00:00
self.helpContent = ko.observableArray([]);
2015-02-06 10:36:53 +00:00
jquery.get('/json/sim/help', null, function(data) {
2015-02-06 11:04:17 +00:00
var helpContent = [];
2015-02-06 10:36:53 +00:00
data.children.forEach(function(prop) {
if (prop.name === 'title') {
self.helpTitle(prop.value);
2015-02-06 11:04:17 +00:00
} else if (prop.name == 'line' ) {
helpContent.push({
type: 'line',
text: prop.value,
});
} else if (prop.name == 'text') {
helpContent.push({
type: 'text',
text: prop.value,
});
} else if (prop.name == 'key') {
var content = {
type: 'key',
name: 'noname',
desc: 'nothing',
}
helpContent.push(content);
prop.children.forEach(function(prop) {
if (prop.name === 'name') {
content.name = prop.value;
} else if( prop.name == 'desc' ) {
content.desc = prop.value;
}
});
2015-02-06 10:36:53 +00:00
}
});
2015-02-06 11:04:17 +00:00
console.log(helpContent);
self.helpContent(helpContent);
2015-02-06 10:36:53 +00:00
});
}
// ViewModel.prototype.dispose = function() {
// }
// Return component definition
return {
viewModel : ViewModel,
template : htmlString
};
});