aboutsummaryrefslogtreecommitdiff
path: root/src/client/javascript/url.js
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2017-09-13 21:29:15 +0200
committerNoah Loomans <noahloomans@gmail.com>2017-09-13 21:29:15 +0200
commite87bf34e06f8bec3c6622102528c2d685b3cbb5b (patch)
treeeadfe43844faf52293f293ab37d9d621b6821329 /src/client/javascript/url.js
parent3fb86482404e11942cd83c3500a297a3991db0e4 (diff)
Add some basic elm
Diffstat (limited to 'src/client/javascript/url.js')
-rw-r--r--src/client/javascript/url.js67
1 files changed, 0 insertions, 67 deletions
diff --git a/src/client/javascript/url.js b/src/client/javascript/url.js
deleted file mode 100644
index 17ab7c8..0000000
--- a/src/client/javascript/url.js
+++ /dev/null
@@ -1,67 +0,0 @@
-/* global USERS FLAGS */
-
-const EventEmitter = require('events')
-
-const self = new EventEmitter()
-
-self._getPageTitle = function (selectedUser) {
- let ret
-
- if (selectedUser == null) {
- ret = `Metis Rooster`
- } else {
- ret = `Metis Rooster - ${selectedUser.value}`
- }
-
- if (FLAGS.indexOf('BETA') !== -1) {
- ret = `BETA ${ret}`
- }
-
- return ret
-}
-
-self._getPageURL = function (selectedUser) {
- return `/${selectedUser.type}/${selectedUser.value}`
-}
-
-self.push = function (selectedUser, push) {
- if (push == null) push = true
- const pageTitle = self._getPageTitle(selectedUser)
- const pageURL = self._getPageURL(selectedUser)
- if (push) {
- window.history.pushState(selectedUser, pageTitle, pageURL)
- } else {
- window.history.replaceState(selectedUser, pageTitle, pageURL)
- }
-}
-
-self.update = function (selectedUser) {
- document.title = self._getPageTitle(selectedUser)
-}
-
-self.hasSelectedUser = function () {
- const pageUrl = window.location.pathname
- return /^\/s\/|^\/t\/|^\/r\/|^\/c\//.test(pageUrl)
-}
-
-self.getSelectedUser = function () {
- const pageUrl = window.location.pathname
- const pageUrlData = pageUrl.split('/')
- const type = pageUrlData[1]
- const value = pageUrlData[2]
-
- const user = USERS.filter(function (user) {
- return user.type === type &&
- user.value === value
- })[0]
-
- return user
-}
-
-self._handleUpdate = function (event) {
- self.emit('update', event.state)
-}
-
-window.addEventListener('popstate', self._handleUpdate)
-
-module.exports = self