diff options
Diffstat (limited to 'public/assets/js/nav.js')
| -rw-r--r-- | public/assets/js/nav.js | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/public/assets/js/nav.js b/public/assets/js/nav.js index ca231fe..bfddc2c 100644 --- a/public/assets/js/nav.js +++ b/public/assets/js/nav.js @@ -11,18 +11,18 @@ var NavView = View.extend({ "click .refresh": "refresh", "click .random": "random", }, - + initialize: function(){ this.id = -1 this.$pip = this.$("#pip") this.$pip_img = this.$("#pip img") this.$image = this.$("#luckyimage") - + $(window).on("keydown", this.keydown.bind(this)) $(document).ajaxError(function(){ this.fetching = false }.bind(this)) - + window.onpopstate = function(event) { this.display(event.state) }.bind(this) @@ -34,7 +34,7 @@ var NavView = View.extend({ else { this.latest() } - + $(".prev").on("touchstart", function(){ console.log("<<<<<PREV") }) @@ -42,7 +42,7 @@ var NavView = View.extend({ console.log("<<<<<CLICKPREV") }) }, - + keydown: function(e){ if (e.shiftKey || e.metaKey || e.ctrlKey || e.altKey) { return } switch (e.keyCode) { @@ -60,34 +60,34 @@ var NavView = View.extend({ break } }, - + latest: function(){ if (this.fetching) return this.fetch("latest") this.onLatest = true }, - + prev: function(){ if (this.fetching) return if (this.id - 1 < 1) { return } this.fetch(this.id-1) }, - + next: function(){ if (this.fetching) return if (this.onLatest || this.id < 1) { return } this.fetch(this.id+1) }, - + random: function(){ if (this.fetching) return this.fetch("random") }, - + fetch: function(id){ this.fetching = true this.onLatest = false - $.get("/get/" + id, function(data){ + $.get("/p/get/" + id, function(data){ this.fetching = false this.display(data) history.pushState(data, document.title, "/p/" + data.id) @@ -108,7 +108,7 @@ var NavView = View.extend({ } this.$image.css("background-image", "url(" + data.url + ")") }, - + link: function(){ window.open(this.data.url, "_blank") }, |
