Commit 9076194b91ae9ff560675f70dffcb7ee0cf4a85a
1 parent
caabb1a5
Exists in
master
and in
10 other branches
Resolve pequenos 'warnings' do jshint/jslint.
Showing
1 changed file
with
40 additions
and
45 deletions
Show diff stats
js/main.js
1 | +/* global Handlebars, $ */ | |
1 | 2 | // The template code |
2 | 3 | var templateSource = document.getElementById('proposal-template').innerHTML; |
3 | 4 | |
... | ... | @@ -10,8 +11,6 @@ var resultsTemplate = Handlebars.compile(document.getElementById('results').inne |
10 | 11 | // The div/container that we are going to display the results in |
11 | 12 | var resultsPlaceholder = document.getElementById('proposal-result'); |
12 | 13 | |
13 | -var topics; | |
14 | - | |
15 | 14 | var logged_in = false; |
16 | 15 | |
17 | 16 | var loginButton; |
... | ... | @@ -48,8 +47,8 @@ $.getJSON(noosferoAPI) |
48 | 47 | navigateTo(window.location.hash); |
49 | 48 | |
50 | 49 | //Actions for links |
51 | - $( '#nav-proposal-categories a' ).on('click touchstart', function(event){ | |
52 | - event.preventDefault(); | |
50 | + $( '#nav-proposal-categories a' ).on('click touchstart', function(e){ | |
51 | + e.preventDefault(); | |
53 | 52 | |
54 | 53 | var $link = $(this); |
55 | 54 | |
... | ... | @@ -57,8 +56,8 @@ $.getJSON(noosferoAPI) |
57 | 56 | updateHash($link.attr('href')); |
58 | 57 | }); |
59 | 58 | |
60 | - $( '#nav-proposal-group a' ).on('click touchstart', function(event){ | |
61 | - event.preventDefault(); | |
59 | + $( '#nav-proposal-group a' ).on('click touchstart', function(e){ | |
60 | + e.preventDefault(); | |
62 | 61 | |
63 | 62 | var $link = $(this); |
64 | 63 | |
... | ... | @@ -66,26 +65,26 @@ $.getJSON(noosferoAPI) |
66 | 65 | updateHash($link.attr('href')); |
67 | 66 | }); |
68 | 67 | |
69 | - $( '.proposal-item a' ).on('click touchstart', function(event){ | |
68 | + $( '.proposal-item a' ).on('click touchstart', function(e){ | |
69 | + e.preventDefault(); | |
70 | + | |
70 | 71 | var $link = $(this); |
71 | - var item = $link.data('target'); | |
72 | 72 | |
73 | 73 | // Update URL and Navigate |
74 | 74 | updateHash($link.attr('href')); |
75 | 75 | }); |
76 | 76 | |
77 | - $( '.proposal-category a' ).on('click touchstart', function(event){ | |
78 | - event.preventDefault(); | |
77 | + $( '.proposal-category a' ).on('click touchstart', function(e){ | |
78 | + e.preventDefault(); | |
79 | 79 | |
80 | 80 | var $link = $(this); |
81 | - var item = $link.data('target'); | |
82 | 81 | |
83 | 82 | // Update URL and Navigate |
84 | 83 | updateHash($link.attr('href')); |
85 | 84 | }); |
86 | 85 | |
87 | - $( '.proposal-category .go-back' ).on('click touchstart', function(event){ | |
88 | - event.preventDefault(); | |
86 | + $( '.proposal-category .go-back' ).on('click touchstart', function(e){ | |
87 | + e.preventDefault(); | |
89 | 88 | |
90 | 89 | var oldHash = window.location.hash; |
91 | 90 | var regexSubpages = /sobre-o-programa$/; |
... | ... | @@ -121,7 +120,6 @@ $.getJSON(noosferoAPI) |
121 | 120 | e.preventDefault(); |
122 | 121 | |
123 | 122 | var $link = $(this); |
124 | - var item = $link.data('target'); | |
125 | 123 | |
126 | 124 | // Update URL and Navigate |
127 | 125 | updateHash($link.attr('href')); |
... | ... | @@ -131,7 +129,6 @@ $.getJSON(noosferoAPI) |
131 | 129 | e.preventDefault(); |
132 | 130 | |
133 | 131 | var $link = $(this); |
134 | - var item = $link.data('target'); | |
135 | 132 | |
136 | 133 | // Update URL and Navigate |
137 | 134 | updateHash($link.attr('href')); |
... | ... | @@ -176,7 +173,7 @@ $.getJSON(noosferoAPI) |
176 | 173 | url: host + '/api/v1/articles/' + proposal_id + '/children', |
177 | 174 | data: $('#'+this.id).serialize() + '&private_token=' + private_token + '&fields=id&article[name]=article_' + guid() |
178 | 175 | }) |
179 | - .done(function( data ) { | |
176 | + .done(function( /*data*/ ) { | |
180 | 177 | form.reset(); |
181 | 178 | $form.hide(); |
182 | 179 | $form.siblings('.success-sent').show(); |
... | ... | @@ -231,7 +228,7 @@ function loadRandomProposal(topic_id, private_token) { |
231 | 228 | value: $(this).data('vote-value'), |
232 | 229 | private_token: private_token |
233 | 230 | } |
234 | - }).done(function( data ) { | |
231 | + }).done(function( /*data*/ ) { | |
235 | 232 | loadRandomProposal(topic_id, private_token); |
236 | 233 | }); |
237 | 234 | e.preventDefault(); |
... | ... | @@ -267,45 +264,21 @@ function loadRandomProposal(topic_id, private_token) { |
267 | 264 | $('.experience-proposal-container').show(); |
268 | 265 | $('.talk-proposal-container').show(); |
269 | 266 | } |
270 | - | |
267 | + | |
271 | 268 | e.preventDefault(); |
272 | 269 | }); |
273 | 270 | }); |
274 | 271 | } |
275 | 272 | |
276 | -jQuery(document).ready(function($) { | |
273 | +$(document).ready(function($) { | |
277 | 274 | if($.cookie('_dialoga_session')) { |
278 | 275 | var url = host + '/api/v1/users/me?private_token=' + $.cookie('_dialoga_session'); |
279 | - $.getJSON(url).done(function( data ) { | |
276 | + $.getJSON(url).done(function( /*data*/ ) { | |
280 | 277 | logged_in = true; |
281 | 278 | private_token = $.cookie('_dialoga_session'); |
282 | 279 | }); |
283 | 280 | } |
284 | -}); | |
285 | 281 | |
286 | -function loginCallback(loggedIn, token) { | |
287 | - logged_in = loggedIn; | |
288 | - $('.login .message').text(''); | |
289 | - | |
290 | - if(logged_in) { | |
291 | - if(token){ | |
292 | - private_token = token; | |
293 | - } | |
294 | - loginButton.siblings('.save-article-form').show(); | |
295 | - loginButton.siblings('.save-article-form .message').show(); | |
296 | - loginButton.siblings('.login-container').hide(); | |
297 | - $.cookie('_dialoga_session', private_token); | |
298 | - } else { | |
299 | - loginButton.siblings('.save-article-form').hide(); | |
300 | - loginButton.siblings('.login-container').show(); | |
301 | - } | |
302 | -} | |
303 | - | |
304 | -function oauthPluginHandleLoginResult(loggedIn, token) { | |
305 | - loginCallback(loggedIn, token); | |
306 | -} | |
307 | - | |
308 | -jQuery(document).ready(function($) { | |
309 | 282 | $(document).on('click', '.login-action', function(e) { |
310 | 283 | var message = $('.login .message'); |
311 | 284 | message.hide(); |
... | ... | @@ -319,7 +292,7 @@ jQuery(document).ready(function($) { |
319 | 292 | } |
320 | 293 | }).done(function(data) { |
321 | 294 | loginCallback(true, data.private_token); |
322 | - }).fail(function(data) { | |
295 | + }).fail(function( /*data*/ ) { | |
323 | 296 | message.show(); |
324 | 297 | message.text('Não foi possível logar'); |
325 | 298 | }); |
... | ... | @@ -327,6 +300,28 @@ jQuery(document).ready(function($) { |
327 | 300 | }); |
328 | 301 | }); |
329 | 302 | |
303 | +function loginCallback(loggedIn, token) { | |
304 | + logged_in = loggedIn; | |
305 | + $('.login .message').text(''); | |
306 | + | |
307 | + if(logged_in) { | |
308 | + if(token){ | |
309 | + private_token = token; | |
310 | + } | |
311 | + loginButton.siblings('.save-article-form').show(); | |
312 | + loginButton.siblings('.save-article-form .message').show(); | |
313 | + loginButton.siblings('.login-container').hide(); | |
314 | + $.cookie('_dialoga_session', private_token); | |
315 | + } else { | |
316 | + loginButton.siblings('.save-article-form').hide(); | |
317 | + loginButton.siblings('.login-container').show(); | |
318 | + } | |
319 | +} | |
320 | + | |
321 | +// function oauthPluginHandleLoginResult(loggedIn, token) { | |
322 | +// loginCallback(loggedIn, token); | |
323 | +// } | |
324 | + | |
330 | 325 | function guid() { |
331 | 326 | function s4() { |
332 | 327 | return Math.floor((1 + Math.random()) * 0x10000) | ... | ... |