From db6cfaa8fb7b787489dfab4bc5775e63756bbfc0 Mon Sep 17 00:00:00 2001 From: Diego Cepeda Date: Wed, 27 Jun 2018 12:03:08 -0700 Subject: [PATCH] descriptive page titles (#173) * 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 --- src/oncall/ui/static/js/oncall.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/oncall/ui/static/js/oncall.js b/src/oncall/ui/static/js/oncall.js index 5e128025..7e720f34 100644 --- a/src/oncall/ui/static/js/oncall.js +++ b/src/oncall/ui/static/js/oncall.js @@ -205,6 +205,15 @@ 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({ @@ -212,66 +221,78 @@ var oncall = { 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(); },