190e8449ce
- rename the directory from webgui to Phi - let the webserver's root point to Phi instead of Docs - redirect old /gui/ url to the new location (/)
34 lines
972 B
JavaScript
34 lines
972 B
JavaScript
(function(factory) {
|
|
if (typeof define === "function" && define.amd) {
|
|
// AMD. Register as an anonymous module.
|
|
define(['knockout'], factory);
|
|
} else {
|
|
// Browser globals
|
|
factory(ko);
|
|
}
|
|
}(function(ko) {
|
|
|
|
function SubtopicViewModel(topics, prefix, params) {
|
|
var self = this;
|
|
|
|
self.topics = ko.observableArray(topics);
|
|
|
|
self.selectedTopic = ko.observable();
|
|
|
|
self.selectedComponent = ko.pureComputed(function() {
|
|
return prefix + "/" + self.selectedTopic();
|
|
});
|
|
|
|
self.selectTopic = function(topic) {
|
|
location.hash = prefix + "/" + topic;
|
|
self.selectedTopic(topic);
|
|
}
|
|
|
|
var topic = (params && params.topic) ? ko.unwrap(params.topic) : self.topics()[0];
|
|
if( self.topics.indexOf(topic) == -1 )
|
|
topic = self.topics()[0];
|
|
self.selectTopic(topic);
|
|
}
|
|
|
|
return SubtopicViewModel;
|
|
}));
|