diff options
author | Noah Loomans <noahloomans@gmail.com> | 2017-01-30 18:27:20 +0100 |
---|---|---|
committer | Noah Loomans <noahloomans@gmail.com> | 2017-01-30 18:27:20 +0100 |
commit | 6edf8919a7ea9718405d3ccd0fed2e93ce1e54cc (patch) | |
tree | c23422c676ce5d7f8017a4691c56e3467ca3adb6 /public/javascripts/url.js | |
parent | 344504782ac628b15229cafada34a9f32d595624 (diff) |
Refactor item to user
While item is technically more correct, I still prefer user as i think
it makes the code easier to understand.
Diffstat (limited to 'public/javascripts/url.js')
-rw-r--r-- | public/javascripts/url.js | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/public/javascripts/url.js b/public/javascripts/url.js index b856285..63e6081 100644 --- a/public/javascripts/url.js +++ b/public/javascripts/url.js @@ -4,39 +4,39 @@ const EventEmitter = require('events') const self = new EventEmitter() -self._getPageTitle = function (selectedItem) { - if (selectedItem == null) { +self._getPageTitle = function (selectedUser) { + if (selectedUser == null) { return `Metis Rooster` } else { - return `Metis Rooster - ${selectedItem.value}` + return `Metis Rooster - ${selectedUser.value}` } } -self._getPageURL = function (selectedItem) { - return `/${selectedItem.type}/${selectedItem.value}` +self._getPageURL = function (selectedUser) { + return `/${selectedUser.type}/${selectedUser.value}` } -self.push = function (selectedItem, push) { +self.push = function (selectedUser, push) { if (push == null) push = true - const pageTitle = self._getPageTitle(selectedItem) - const pageURL = self._getPageURL(selectedItem) + const pageTitle = self._getPageTitle(selectedUser) + const pageURL = self._getPageURL(selectedUser) if (push) { - window.history.pushState(selectedItem, pageTitle, pageURL) + window.history.pushState(selectedUser, pageTitle, pageURL) } else { - window.history.replaceState(selectedItem, pageTitle, pageURL) + window.history.replaceState(selectedUser, pageTitle, pageURL) } } -self.update = function (selectedItem) { - document.title = self._getPageTitle(selectedItem) +self.update = function (selectedUser) { + document.title = self._getPageTitle(selectedUser) } -self.hasSelectedItem = function () { +self.hasSelectedUser = function () { const pageUrl = window.location.pathname return /^\/s\/|^\/t\/|^\/r\/|^\/c\//.test(pageUrl) } -self.getSelectedItem = function () { +self.getSelectedUser = function () { const pageUrl = window.location.pathname const pageUrlData = pageUrl.split('/') const type = pageUrlData[1] |