Skip to content

Commit 5945970

Browse files
author
Matt Swanson
committed
fix issue with opening wrong story URL.
1 parent fc98beb commit 5945970

1 file changed

Lines changed: 17 additions & 15 deletions

File tree

‎app/public/js/app.js‎

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ $(document).ready(function() {
3535
$(".story-lead", this).fadeOut(1000);
3636
$(".story-body-container", this).stop().show();
3737

38-
var story_id = $this.data("id");
38+
var storyId = $this.data("id");
3939

40-
if (story_id > 0) {
41-
$.post("/mark_as_read", { story_id: story_id })
40+
if (storyId > 0) {
41+
$.post("/mark_as_read", { story_id: storyId })
4242
.fail(function() { alert("something broke!"); });
4343
}
4444
});
@@ -64,10 +64,10 @@ $(document).ready(function() {
6464
e.preventDefault();
6565
var $this = $(this);
6666

67-
var feed_id = $this.parents("li").data("id");
67+
var feedId = $this.parents("li").data("id");
6868

69-
if (feed_id > 0) {
70-
$.post("/delete_feed", { feed_id: feed_id })
69+
if (feedId > 0) {
70+
$.post("/delete_feed", { feed_id: feedId })
7171
.success(function() {
7272
$this.parents("li").fadeOut(500, function () {
7373
$(this).remove();
@@ -81,31 +81,31 @@ $(document).ready(function() {
8181
$("#shortcuts").modal('toggle');
8282
});
8383

84-
var cursor_position = -1;
84+
var cursorPosition = -1;
8585
var MAX_POSITION = $("li.story").size();
8686

8787
Mousetrap.bind("k", function() {
88-
if (cursor_position < MAX_POSITION - 1) {
89-
cursor_position++;
88+
if (cursorPosition < MAX_POSITION - 1) {
89+
cursorPosition++;
9090

9191
$("li.story").removeClass("cursor");
92-
$("li.story").eq(cursor_position).addClass("cursor");
92+
$("li.story").eq(cursorPosition).addClass("cursor");
9393
}
9494
});
9595

9696
Mousetrap.bind("j", function() {
9797
$("li.story").removeClass("cursor");
9898

99-
if (cursor_position > 0) {
100-
cursor_position--;
101-
$("li.story").eq(cursor_position).addClass("cursor");
99+
if (cursorPosition > 0) {
100+
cursorPosition--;
101+
$("li.story").eq(cursorPosition).addClass("cursor");
102102
} else {
103103
$("li.story").eq(0).addClass("cursor");
104104
}
105105
});
106106

107107
Mousetrap.bind(["o", "enter"], function() {
108-
$("li.story").eq(cursor_position).trigger("toggleStory");
108+
$("li.story").eq(cursorPosition).trigger("toggleStory");
109109
});
110110

111111
Mousetrap.bind("r", function() {
@@ -118,7 +118,9 @@ $(document).ready(function() {
118118
});
119119

120120
Mousetrap.bind("v", function() {
121-
var permalink = $("li.story.open a#story-permalink")[0];
121+
var currentStory = $("li.story").eq(cursorPosition);
122+
123+
var permalink = currentStory.find("a#story-permalink")[0];
122124
if (permalink) permalink.click();
123125
});
124126
});

0 commit comments

Comments
 (0)