Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update client side js

  • Loading branch information...
commit 85bb692de45a62b576f7e5eccfe66cae0e3d0735 1 parent 6e38490
@pfleidi pfleidi authored
Showing with 27 additions and 1 deletion.
  1. +27 −1 public/js/laser.js
View
28 public/js/laser.js
@@ -1,3 +1,5 @@
+var curUser = 0;
+
(function ($, window, undefined) {
$('.typeahead').typeahead({
@@ -13,7 +15,8 @@
getUserRecommendations = function(userId) {
$('#links').empty();
-
+ $('.active').removeClass('active');
+ $('#showRecomendationsBtn').parent().addClass('active');
$.getJSON('/api/users/' + userId, function (data) {
$.each(data['recommendations'], function (itemId) {
$.getJSON('/api/urls/' + data['recommendations'][itemId]['item'], function (data_mapped) {
@@ -27,9 +30,32 @@
});
};
+ getUserLinks = function(userId) {
+ $('#links').empty();
+ $.getJSON('/api/users/' + userId, function(data) {
+ $.each(data['links'], function(itemId) {
+ $.getJSON('/api/urls/' + data['links'][itemId], function (data_mapped) {
+ $('#links').append('<tr><td><a href=\"' + data_mapped['url']+ '\">'+ data_mapped['title'] + '</a> </td><td></td></tr>');
+ });
+ });
+ });
+ };
+
$('#recommend').click(function (event) {
getUserRecommendations($('#username').val());
+ curUser = $("#username").val();
});
+ $('#showRecomendationsBtn').click(function (event) {
+ getUserRecommendations(curUser);
+ $('.active').removeClass('active');
+ $('#showRecomendationsBtn').parent().addClass('active');
+ });
+
+ $('#userLinksBtn').click(function (event) {
+ getUserLinks(curUser);
+ $('.active').removeClass('active');
+ $('#userLinksBtn').parent().addClass('active');
+ });
}(jQuery, window));
Please sign in to comment.
Something went wrong with that request. Please try again.