|
|
@@ -56,41 +56,71 @@
|
|
|
var oldNav = this.nav;
|
|
|
this.nav = this.parsePath();
|
|
|
console.log(this.nav, oldNav);
|
|
|
- if(this.nav.repo === oldNav.repo && this.nav.example === oldNav.example) {
|
|
|
- console.log('nav: nop');
|
|
|
- }
|
|
|
- // else if(this.nav.repo !== oldNav.repo && this.nav.example !== oldNav.example) {
|
|
|
- // console.log('nav: repo&example');
|
|
|
- // }
|
|
|
- else if(this.nav.repo === oldNav.repo) {
|
|
|
- if(this.nav.example === '') {
|
|
|
- console.log('nav: example empty');
|
|
|
- console.log(_ws.events);
|
|
|
- _ws.events.emit('navToRepoRoot');
|
|
|
- }
|
|
|
- else {
|
|
|
- console.log('nav: example changed');
|
|
|
- _ws.events.emit('navToExample', this.nav.repo);
|
|
|
- }
|
|
|
+
|
|
|
+ if(this.nav.repo !== oldNav.repo) {
|
|
|
+ console.log('nav: repo changed');
|
|
|
+ _ws.events.emit('navToRepo', this.nav.repo);
|
|
|
+ rp.get('/parts/' + this.nav.repo, 'json')
|
|
|
+ .then(function(parts) {
|
|
|
+ renderMenuExample(parts.menuExample);
|
|
|
+ });
|
|
|
}
|
|
|
- else if(this.nav.example === oldNav.example) {
|
|
|
- if(this.nav.repo === '') {
|
|
|
- console.log('nav: repo empty');
|
|
|
- _ws.events.emit('navToRoot');
|
|
|
- }
|
|
|
- else {
|
|
|
- console.log('nav: repo changed');
|
|
|
- _ws.events.emit('navToRepo', this.nav.repo);
|
|
|
- rp.get('/parts/' + this.nav.repo, 'json')
|
|
|
- .then(function(parts) {
|
|
|
- renderMenuExample(parts.menuExample);
|
|
|
- });
|
|
|
- }
|
|
|
+ else if(this.nav.example !== oldNav.example) {
|
|
|
+ console.log('nav: example changed');
|
|
|
+ _ws.events.emit('navToExample', this.nav.example);
|
|
|
+ rp.get('/parts/' + this.nav.repo + '/' + this.nav.example, 'json')
|
|
|
+ .then(function(parts) {
|
|
|
+ console.log(parts);
|
|
|
+ renderExample(parts);
|
|
|
+
|
|
|
+
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ // if(this.nav.repo === oldNav.repo && this.nav.example === oldNav.example) {
|
|
|
+ // console.log('nav: nop');
|
|
|
+ // }
|
|
|
+ // // else if(this.nav.repo !== oldNav.repo && this.nav.example !== oldNav.example) {
|
|
|
+ // // console.log('nav: repo&example');
|
|
|
+ // // }
|
|
|
+ // else if(this.nav.repo === oldNav.repo) {
|
|
|
+ // if(this.nav.example === '') {
|
|
|
+ // console.log('nav: example empty');
|
|
|
+ // console.log(_ws.events);
|
|
|
+ // _ws.events.emit('navToRepoRoot');
|
|
|
+ // }
|
|
|
+ // else {
|
|
|
+ // console.log('nav: example changed');
|
|
|
+ // _ws.events.emit('navToExample', this.nav.repo);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // else if(this.nav.example === oldNav.example) {
|
|
|
+ // if(this.nav.repo === '') {
|
|
|
+ // console.log('nav: repo empty');
|
|
|
+ // _ws.events.emit('navToRoot');
|
|
|
+ // }
|
|
|
+ // else {
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
};
|
|
|
|
|
|
+ function renderInto(id, parts) {
|
|
|
+ var tmpl = $('#' + id + '-tmpl').html();
|
|
|
+ console.log(tmpl);
|
|
|
+ $('#' + id).html( Mustache.render( tmpl, parts ) );
|
|
|
+ }
|
|
|
+
|
|
|
+ function renderTabs() {
|
|
|
+ renderInto('tabs', parts);
|
|
|
+ }
|
|
|
|
|
|
+ function renderExample(parts) {
|
|
|
+ var tmpl = $('#details-example-tmpl').html();
|
|
|
+ console.log(tmpl);
|
|
|
+ $('#details-example').html( Mustache.render( tmpl, parts ) );
|
|
|
+ }
|
|
|
function renderMenuExample(menuExample) {
|
|
|
var tmpl = $('#menu-example-tmpl').html();
|
|
|
console.log(tmpl);
|