For now we're only adding rules related to spacing and double quotes, following the same rules we use in Ruby, which are the same rules CoffeeScript followed when compiling these files. We're also using the recommended ESLint rules, which will warn us about many JavaScript common pitfalls, the `strict` rule which enforces using strict mode, and the `no-console` rule, which will prevent us from shipping code meant for debugging. Although it's arguably more common to use the JSON format to define these rules, I've chosen YAML because it's the format we use in all our linters.
33 lines
953 B
JavaScript
33 lines
953 B
JavaScript
(function() {
|
|
"use strict";
|
|
App.Managers = {
|
|
generatePassword: function() {
|
|
var chars, possible_chars;
|
|
possible_chars = "aAbcdeEfghiJkmnpqrstuUvwxyz23456789";
|
|
chars = Array.apply(null, {
|
|
length: 12
|
|
}).map(function() {
|
|
var i;
|
|
i = Math.floor(Math.random() * possible_chars.length);
|
|
return possible_chars.charAt(i);
|
|
});
|
|
return chars.join("");
|
|
},
|
|
togglePassword: function(type) {
|
|
$("#user_password").prop("type", type);
|
|
},
|
|
initialize: function() {
|
|
$(".generate-random-value").on("click", function() {
|
|
$("#user_password").val(App.Managers.generatePassword());
|
|
});
|
|
$(".show-password").on("click", function() {
|
|
if ($("#user_password").is("input[type='password']")) {
|
|
App.Managers.togglePassword("text");
|
|
} else {
|
|
App.Managers.togglePassword("password");
|
|
}
|
|
});
|
|
}
|
|
};
|
|
}).call(this);
|