diff options
| author | julian laplace <julescarbon@gmail.com> | 2022-10-26 17:38:08 +0200 |
|---|---|---|
| committer | julian laplace <julescarbon@gmail.com> | 2022-10-26 17:38:08 +0200 |
| commit | 5eec403809726fc2f0e914ef13ad51d15564e9ab (patch) | |
| tree | eb88dd04aeae0eeb418cad48dbf04d1546f7142b /public | |
| parent | 211098a597935494276aa1e43fb92397d549606b (diff) | |
prev/next working :)
Diffstat (limited to 'public')
| -rw-r--r-- | public/assets/js/index.js | 70 | ||||
| -rw-r--r-- | public/assets/js/lib/router.js | 1 | ||||
| -rw-r--r-- | public/assets/js/lib/views/stream/hootstream.js | 3 | ||||
| -rw-r--r-- | public/assets/js/vendor/view/router.js | 10 |
4 files changed, 49 insertions, 35 deletions
diff --git a/public/assets/js/index.js b/public/assets/js/index.js index 51c2226..1c8deb5 100644 --- a/public/assets/js/index.js +++ b/public/assets/js/index.js @@ -1,36 +1,38 @@ -var app = (function(){ - var app = {} - - app.init = function(){ - app.debug = !! window.location.search.match('debug') - app.router = new SiteRouter () - app.view = null +var app = (function () { + var app = {}; - $(window).on("focus", app.focus) - $(window).on("blur", app.blur) - - set_background_color_from_time() - - auth.init(app.ready) - sdk.init() - } - - app.ready = function(){ - app.router.route() - } - - app.focused = true - app.typing = false - - app.focus = function(){ - app.focused = true - } + app.init = function () { + app.debug = !!window.location.search.match("debug"); + app.router = new SiteRouter(); + app.router.initialize(); + app.view = null; - app.blur = function(){ - app.focused = false - } - - document.addEventListener('DOMContentLoaded', app.init) - - return app -})() + $(window).on("focus", app.focus); + $(window).on("blur", app.blur); + + set_background_color_from_time(); + + auth.init(app.ready); + sdk.init(); + }; + + app.ready = function () { + app.router.route(); + }; + + app.focused = true; + app.typing = false; + + app.focus = function () { + app.focused = true; + set_background_color_from_time(); + }; + + app.blur = function () { + app.focused = false; + }; + + document.addEventListener("DOMContentLoaded", app.init); + + return app; +})(); diff --git a/public/assets/js/lib/router.js b/public/assets/js/lib/router.js index b6e29be..f7da22f 100644 --- a/public/assets/js/lib/router.js +++ b/public/assets/js/lib/router.js @@ -37,6 +37,7 @@ var SiteRouter = Router.extend({ }, initialize: function () { + this.__super__.initialize.call(this); $(".logout").click(() => this.logout()); }, diff --git a/public/assets/js/lib/views/stream/hootstream.js b/public/assets/js/lib/views/stream/hootstream.js index dd64aa4..47ed2b9 100644 --- a/public/assets/js/lib/views/stream/hootstream.js +++ b/public/assets/js/lib/views/stream/hootstream.js @@ -29,6 +29,7 @@ var HootStream = View.extend({ case "keywordLink": event.preventDefault(); console.log(">>", url.pathname); + app.router.pushState(url.pathname); app.router.go(url.pathname); break; } @@ -38,7 +39,7 @@ var HootStream = View.extend({ load: function (data) { this.$hootevents.empty(); const { order, threadLookup } = this.agglutinate(data); - console.log(data, threadLookup, order); + // console.log(data, threadLookup, order); const $els = order.map( function (item) { return item.type === "thread" diff --git a/public/assets/js/vendor/view/router.js b/public/assets/js/vendor/view/router.js index 0f977e0..3fc3357 100644 --- a/public/assets/js/vendor/view/router.js +++ b/public/assets/js/vendor/view/router.js @@ -1,6 +1,15 @@ var Router = View.extend({ routeByHash: false, + initialize: function () { + window.addEventListener("popstate", this.onpopstate.bind(this)); + }, + + onpopstate: (event) => { + console.log("POP STATE", document.location.pathname); + app.router.parseRoute(document.location.pathname); + }, + go: function (url) { this.parseRoute(url); }, @@ -9,6 +18,7 @@ var Router = View.extend({ if (this.routeByHash) { window.location.hash = url; } else if (window.history) { + console.log(url); window.history.pushState(null, null, url); } }, |
