Poll voter token
This commit is contained in:
@@ -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(){
|
||||
|
||||
21
app/assets/javascripts/polls.js.coffee
Normal file
21
app/assets/javascripts/polls.js.coffee
Normal 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
|
||||
Reference in New Issue
Block a user