summaryrefslogtreecommitdiff
path: root/public/assets/js
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/js')
-rw-r--r--public/assets/js/index.js70
-rw-r--r--public/assets/js/lib/router.js1
-rw-r--r--public/assets/js/lib/views/stream/hootstream.js3
-rw-r--r--public/assets/js/vendor/view/router.js10
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);
}
},