Skip to content

Commit

Permalink
implemented part of the javascript needed to handle upvotes and downv…
Browse files Browse the repository at this point in the history
…otes
  • Loading branch information
antirez committed Oct 17, 2011
1 parent a218312 commit 3ba707c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 0 additions & 1 deletion app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@ def create_user(username,password)
# Side effect: the auth token is modified.
def update_auth_token(user_id)
user = get_user_by_id(user_id)
puts user.inspect
return nil if !user
$r.del("auth:#{user['auth']}")
new_auth_token = get_rand
Expand Down
1 change: 1 addition & 0 deletions public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ news h2 a:visited {

news uparrow, news downarrow {
font-size: 16px;
cursor: pointer;
}

news uparrow {
Expand Down
15 changes: 15 additions & 0 deletions public/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,18 @@ function submit() {
});
return false;
}

// Install the onclick event in all news arrows the user did not voted already.
$(document).ready(function() {
$('news').each(function(i,news) {
var news_id = news.id;
var up_class = news.children[0].getAttribute("class");
if (!up_class) {
news.onclick=function() {alert("x");}
}
var down_class = news.children[3].getAttribute("class");
if (!down_class) {
news.onclick=function() {alert("y");}
}
});
});

0 comments on commit 3ba707c

Please sign in to comment.