Files
grecia/app/assets/javascripts/managers.js.coffee
Javi Martín 86e704d8a4 Use strict mode in JavaScript
Strict mode is supported by 98% of the browsers, including Internet
Explorer 10, and it helps developers avoid common JavaScript pitfalls.
2019-09-11 03:14:17 +02:00

28 lines
677 B
CoffeeScript

"use strict"
App.Managers =
generatePassword: ->
chars = "aAbcdeEfghiJkmnpqrstuUvwxyz23456789"
pass = ""
x = 0
while x < 12
i = Math.floor(Math.random() * chars.length)
pass += chars.charAt(i)
x++
return pass
togglePassword: (type) ->
$("#user_password").prop "type", type
initialize: ->
$(".generate-random-value").on "click", ->
password = App.Managers.generatePassword()
$("#user_password").val(password)
$(".show-password").on "click", ->
if $("#user_password").is("input[type='password']")
App.Managers.togglePassword("text")
else
App.Managers.togglePassword("password")