Poll voter token

This commit is contained in:
María Checa
2017-10-06 20:44:47 +02:00
parent 165509b525
commit bcfd1a844a
9 changed files with 35 additions and 8 deletions

View File

@@ -70,6 +70,7 @@
//= require polls_admin
//= require leaflet
//= require map
//= require polls
var initialize_modules = function() {
App.Comments.initialize();
@@ -108,6 +109,7 @@ var initialize_modules = function() {
App.TagAutocomplete.initialize();
App.PollsAdmin.initialize();
App.Map.initialize();
App.Polls.initialize();
};
$(function(){

View File

@@ -0,0 +1,21 @@
App.Polls =
generateToken: ->
rand = Math.random().toString(36).substr(2) # remove `0.`
token = rand + rand # to make it longer
return token
replaceToken: ->
for link in $('.js-question-answer')
token_param = link.search.slice(-6)
if token_param == "token="
link.href = link.href + @token
initialize: ->
@token = App.Polls.generateToken()
App.Polls.replaceToken()
$(".js-question-answer").on "click", (@token) ->
token_message = $(".js-token-message")
token_message.html(token_message.html() + "<br><strong>" + @token + "</strong>");
token_message.show()
false