Skip to content

Commit

Permalink
descriptive page titles (linkedin#173)
Browse files Browse the repository at this point in the history
* Page title now changes to reflect the page the user is currently on.

* added more descriptive page titles

* fixed typo tittle -> title

* Remeved redundant part in updateTitleTag function
  • Loading branch information
diegocepedaw authored and dwang159 committed Jun 27, 2018
1 parent 4e1917a commit db6cfaa
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/oncall/ui/static/js/oncall.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,73 +205,94 @@ var oncall = {
this.data.$loginForm.on('submit', this.login.bind(this));
this.data.$logoutBtn.on('click', this.logout.bind(this));
},
updateTitleTag: function(newTitle){
if(newTitle == ""){
document.title = "Oncall";
}
else{
document.title = unescape(newTitle) + " - Oncall";
}

},
defineRoutes: function(){
var self = this;
router.on({
'teams/all': function(){
oncall.callbacks.onLogin = $.noop;
oncall.callbacks.onLogout = $.noop;
self.browse.init();
self.updateTitleTag("All teams");
},
'team/:name/info': function(params){
oncall.callbacks.onLogin = $.noop;
oncall.callbacks.onLogout = $.noop;
self.team.init(params.name, 'info');
self.team.info.init(params.name);
self.updateTitleTag(params.name + " team info");
},
'team/:name/schedules': function(params){
oncall.callbacks.onLogin = $.noop;
oncall.callbacks.onLogout = $.noop;
self.team.init(params.name, 'schedules');
self.team.schedules.init(params.name);
self.updateTitleTag(params.name + " schedules");
},
'team/:name/subscriptions': function(params){
oncall.callbacks.onLogin = $.noop;
oncall.callbacks.onLogout = $.noop;
self.team.init(params.name, 'subscriptions');
self.team.subscriptions.init(params.name);
self.updateTitleTag(params.name + " subscriptions");
},
'team/:name/audit': function(params){
oncall.callbacks.onLogin = $.noop;
oncall.callbacks.onLogout = $.noop;
self.team.init(params.name, 'audit');
self.team.audit.init(params.name);
self.updateTitleTag(params.name + " audit");
},
'team/:name': function(params){
oncall.callbacks.onLogin = $.noop;
oncall.callbacks.onLogout = $.noop;
self.team.init(params.name, 'calendar');
self.team.calendar.init(params.name);
self.updateTitleTag(params.name + " calendar");
},
'dashboard/:name': function(params){
oncall.callbacks.onLogin = $.noop;
oncall.callbacks.onLogout = $.noop;
self.dashboard.init(params.name);
self.updateTitleTag(params.name + " dasboard");
},
'user/:user/': function(){
oncall.callbacks.onLogin = $.noop;
oncall.callbacks.onLogout = $.noop;
self.settings.init();
self.updateTitleTag("");
},
'user/:user/notifications': function(){
oncall.callbacks.onLogin = $.noop;
oncall.callbacks.onLogout = $.noop;
self.settings.notifications.init();
self.updateTitleTag("Notifications");
},
'query/:query/:fields': function(params){
oncall.callbacks.onLogin = $.noop;
oncall.callbacks.onLogout = $.noop;
self.data.$page.off(); //reset events on page init
self.search.init(params);
self.updateTitleTag("");
},
'*': function(){
oncall.callbacks.onLogin = $.noop;
oncall.callbacks.onLogout = $.noop;
window.history.replaceState({},'home', '/');
self.search.init();
self.updateTitleTag("");
}
}).notFound(function(){
router.navigate('/');
self.updateTitleTag("");
});
router.resolve();
},
Expand Down

0 comments on commit db6cfaa

Please sign in to comment.