Updated pGenerator jQuery Plugin to v1.0.5

This commit is contained in:
Wes Hulette 2018-09-28 12:50:11 -04:00
parent e80dfc886e
commit 991a00b38f
13 changed files with 181 additions and 147 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,32 +1,13 @@
{
<<<<<<< develop
"/js/build/vue.js": "/js/build/vue.js?id=f89ed45026610831d45d",
"/css/build/AdminLTE.css": "/css/build/AdminLTE.css?id=5002486f605469c322ed",
"/css/build/app.css": "/css/build/app.css?id=0c4d55f9abe9a4efe526",
"/js/build/vue.js.map": "/js/build/vue.js.map?id=3aae6e8f609e5cd2842a",
"/css/build/AdminLTE.css.map": "/css/build/AdminLTE.css.map?id=fa40c591a5b361cb0761",
"/css/build/app.css.map": "/css/build/app.css.map?id=5a1bc8c3be0d3da37d0a",
"/css/all.css": "/css/all.css?id=d4da88a066c39e0ef7d0",
"/css/skins/skin-green-dark.min.css": "/css/skins/skin-green-dark.min.css?id=1039ae0e198a7f3d8da7",
"/css/skins/skin-orange-dark.min.css": "/css/skins/skin-orange-dark.min.css?id=9a461970f7ab07f40847",
"/css/skins/skin-red-dark.min.css": "/css/skins/skin-red-dark.min.css?id=99f90bbd653d7db10795",
"/css/signature-pad.css": "/css/signature-pad.css?id=6a89d3cd901305e66ced",
"/css/signature-pad.min.css": "/css/signature-pad.min.css?id=6a89d3cd901305e66ced",
"/css/blue.png": "/css/blue.png?id=e83a6c29e04fe851f212",
"/css/blue@2x.png": "/css/blue@2x.png?id=51135dd4d24f88f5de0b",
"/js/dist/all.js": "/js/dist/all.js?id=95ade195248bad430b49",
"/js/build/all.js": "/js/build/all.js?id=95ade195248bad430b49",
=======
"/js/app.js": "/js/app.js?id=f72ed3705ed56421deed",
"/css/AdminLTE.css": "/css/AdminLTE.css?id=3f11a229453c98bd7d9d",
"/css/app.css": "/css/app.css?id=6c077c0864a66fa68f27",
"/css/overrides.css": "/css/overrides.css?id=6b828d7767ff152a582b",
"/css/dist/all.css": "/css/dist/all.css?id=52eeb0ac804d01ab930e",
"/css/build/all.css": "/css/build/all.css?id=52eeb0ac804d01ab930e",
"/js/vendor.js": "/js/vendor.js?id=0b5b63ceb817e544cab2",
"/js/app.js": "/js/app.js?id=cb3b214bf844383831d7",
"/css/AdminLTE.css": "/css/AdminLTE.css?id=a501321b732a1aca5cc9",
"/css/app.css": "/css/app.css?id=c3b4e5ea2063d7f76241",
"/css/overrides.css": "/css/overrides.css?id=3f6a7848656e6755847e",
"/css/dist/all.css": "/css/dist/all.css?id=c78a60594ab97ac02719",
"/css/build/all.css": "/css/build/all.css?id=c78a60594ab97ac02719",
"/js/vendor.js": "/js/vendor.js?id=534ce0a6cfd17eec12d1",
"/js/html5shiv.min.js": "/js/html5shiv.min.js?id=ba846cb704dbfbc5f1b3",
"/js/respond.min.js": "/js/respond.min.js?id=afc1984a3d17110449dc",
>>>>>>> Cleaned up JS
"/js/dist/bootstrap-table.js": "/js/dist/bootstrap-table.js?id=7223478ba9bf2c6dfb4f",
"/js/dist/bootstrap-table-simple-view.js": "/js/dist/bootstrap-table-simple-view.js?id=3926b8f4aaad6ca20d31",
"/css/dist/bootstrap-table.css": "/css/dist/bootstrap-table.css?id=8340c60bfbc12c34d2e6"

View file

@ -1,146 +1,199 @@
/*!
* pGenerator jQuery Plugin v1.0.0
* http://accountspassword.com/password-generator-jquery-plugin
*
* Created by AccountsPassword.com
* Released under the GPL General Public License (Feel free to copy, modify or redistribute this plugin.)
* pGenerator jQuery Plugin v1.0.5
* https://github.com/M1Sh0u/pGenerator
*
* Created by Mihai MATEI <mihai.matei@outlook.com>
* Released under the MIT License (Feel free to copy, modify or redistribute this plugin.)
*/
(function($){
var numbers_array = new Array(),
upper_letters_array = new Array(),
lower_letters_array = new Array(),
special_chars_array = new Array(),
$pGeneratorElement = null;
var methods = {
init : function( options, callbacks) {
var settings = $.extend({
'bind': 'click',
'passwordElement': null,
'displayElement': null,
'passwordLength': 16,
'uppercase': true,
'lowercase': true,
'numbers': true,
'specialChars': true,
'onPasswordGenerated': function(generatedPassword) { }
}, options);
var numbers_array = [],
upper_letters_array = [],
lower_letters_array = [],
special_chars_array = [],
$pGeneratorElement = null;
for(var i = 48; i < 58; i++)
numbers_array.push(i);
for(i = 65; i < 91; i++)
upper_letters_array.push(i);
for(i = 97; i < 123; i++)
lower_letters_array.push(i);
special_chars_array = [33,35,64,36,38,42,91,93,123,125,92,47,63,58,59,95,45,53];
/**
* Plugin methods.
*
* @type {{init: init, generatePassword: generatePassword}}
*/
var methods = {
return this.each(function(){
/**
* Initialize the object.
*
* @param options
* @param callbacks
*
* @returns {*}
*/
init: function(options, callbacks)
{
var settings = $.extend({
'bind': 'click',
'passwordElement': null,
'displayElement': null,
'passwordLength': 16,
'uppercase': true,
'lowercase': true,
'numbers': true,
'specialChars': true,
'additionalSpecialChars': [],
'onPasswordGenerated': function(generatedPassword) { }
}, options);
$pGeneratorElement = $(this);
for(var i = 48; i < 58; i++) {
numbers_array.push(i);
}
$pGeneratorElement.bind(settings.bind, function(e){
e.preventDefault();
methods.generatePassword(settings);
});
for(i = 65; i < 91; i++) {
upper_letters_array.push(i);
}
});
},
generatePassword: function(settings) {
for(i = 97; i < 123; i++) {
lower_letters_array.push(i);
}
special_chars_array = [33, 35, 64, 36, 38, 42, 91, 93, 123, 125, 92, 47, 63, 58, 59, 95, 45].concat(settings.additionalSpecialChars);
var password = new Array(),
selOptions = settings.uppercase + settings.lowercase + settings.numbers + settings.specialChars,
selected = 0,
no_lower_letters = new Array();
return this.each(function(){
var optionLength = Math.floor(settings.passwordLength / selOptions);
$pGeneratorElement = $(this);
if(settings.uppercase) {
// uppercase letters
for(var i = 0; i < optionLength; i++) {
password.push(String.fromCharCode(upper_letters_array[randomFromInterval(0, upper_letters_array.length - 1)]));
}
$pGeneratorElement.bind(settings.bind, function(e){
e.preventDefault();
methods.generatePassword(settings);
});
no_lower_letters = no_lower_letters.concat(upper_letters_array);
});
},
selected++;
}
/**
* Generate the password.
*
* @param {object} settings
*/
generatePassword: function(settings)
{
var password = new Array(),
selOptions = settings.uppercase + settings.lowercase + settings.numbers + settings.specialChars,
selected = 0,
no_lower_letters = new Array();
if(settings.numbers) {
// numbers letters
for(var i = 0; i < optionLength; i++) {
password.push(String.fromCharCode(numbers_array[randomFromInterval(0, numbers_array.length - 1)]));
}
var optionLength = Math.floor(settings.passwordLength / selOptions);
no_lower_letters = no_lower_letters.concat(numbers_array);
selected++;
}
if(settings.specialChars) {
// numbers letters
for(var i = 0; i < optionLength; i++) {
password.push(String.fromCharCode(special_chars_array[randomFromInterval(0, special_chars_array.length - 1)]));
}
no_lower_letters = no_lower_letters.concat(special_chars_array);
selected++;
}
var remained = settings.passwordLength - (selected * optionLength);
if(settings.lowercase) {
for(var i = 0; i < remained; i++) {
password.push(String.fromCharCode(lower_letters_array[randomFromInterval(0, lower_letters_array.length - 1)]));
}
} else {
for(var i = 0; i < remained; i++) {
password.push(String.fromCharCode(no_lower_letters[randomFromInterval(0, no_lower_letters.length - 1)]));
}
}
password = shuffle(password);
passwordString = password.join('');
if(settings.passwordElement !== null) {
$(settings.passwordElement).val(passwordString);
}
if(settings.displayElement !== null) {
if($(settings.displayElement).is("input")) {
$(settings.displayElement).val(passwordString);
} else {
$(settings.displayElement).text(passwordString);
if(settings.uppercase) {
// uppercase letters
for(var i = 0; i < optionLength; i++) {
password.push(String.fromCharCode(upper_letters_array[randomFromInterval(0, upper_letters_array.length - 1)]));
}
}
settings.onPasswordGenerated(passwordString);
no_lower_letters = no_lower_letters.concat(upper_letters_array);
}
};
selected++;
}
function shuffle(o){ //v1.0
for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
return o;
};
if(settings.numbers) {
// numbers letters
for(var i = 0; i < optionLength; i++) {
password.push(String.fromCharCode(numbers_array[randomFromInterval(0, numbers_array.length - 1)]));
}
function randomFromInterval(from, to)
{
return Math.floor(Math.random()*(to-from+1)+from);
};
no_lower_letters = no_lower_letters.concat(numbers_array);
$.fn.pGenerator = function(method) {
if ( methods[method] ) {
return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
} else if ( typeof method === 'object' || ! method ) {
return methods.init.apply( this, arguments );
} else {
$.error( 'Method ' + method + ' does not exist on jQuery.pGenerator' );
}
};
selected++;
}
})(jQuery);
if(settings.specialChars) {
// numbers letters
for(var i = 0; i < optionLength; i++) {
password.push(String.fromCharCode(special_chars_array[randomFromInterval(0, special_chars_array.length - 1)]));
}
no_lower_letters = no_lower_letters.concat(special_chars_array);
selected++;
}
var remained = settings.passwordLength - (selected * optionLength);
if(settings.lowercase) {
for(var i = 0; i < remained; i++) {
password.push(String.fromCharCode(lower_letters_array[randomFromInterval(0, lower_letters_array.length - 1)]));
}
} else {
for(var i = 0; i < remained; i++) {
password.push(String.fromCharCode(no_lower_letters[randomFromInterval(0, no_lower_letters.length - 1)]));
}
}
password = shuffle(password).join('');
if(settings.passwordElement !== null) {
$(settings.passwordElement).val(password);
}
if(settings.displayElement !== null) {
if($(settings.displayElement).is("input")) {
$(settings.displayElement).val(password);
} else {
$(settings.displayElement).text(password);
}
}
settings.onPasswordGenerated(password);
}
};
/**
* Shuffle the password.
*
* @param {Array} o
*
* @returns {Array}
*/
function shuffle(o)
{
for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
return o;
}
/**
* Get a random number in the given interval.
*
* @param {number} from
* @param {number} to
*
* @returns {number}
*/
function randomFromInterval(from, to)
{
return Math.floor(Math.random()*(to-from+1)+from);
}
/**
* Define the pGenerator jQuery plugin.
*
* @param method
* @returns {*}
*/
$.fn.pGenerator = function(method)
{
if (methods[method]) {
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
}
else if (typeof method === 'object' || !method) {
return methods.init.apply(this, arguments);
}
else {
$.error( 'Method ' + method + ' does not exist on jQuery.pGenerator' );
}
};
})(jQuery);