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

66 lines
2.1 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([]);
self.description = ko.observable('');
self.longDescription = ko.observable('');
jquery.get('/json/sim/description', null, function(data) {
self.description(data.value);
});
jquery.get('/json/sim/long-description', null, function(data) {
self.longDescription(data.value);
});
2015-02-06 10:36:53 +00:00
2015-02-23 20:37:58 +00:00
jquery.get('/json/sim/help?d=2', null, function(data) {
2015-02-06 10:36:53 +00:00
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
self.helpContent(helpContent);
2015-02-06 10:36:53 +00:00
});
}
// ViewModel.prototype.dispose = function() {
// }
// Return component definition
return {
viewModel : ViewModel,
template : htmlString
};
});