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/app.js": "/js/app.js?id=cb3b214bf844383831d7",
"/js/build/vue.js": "/js/build/vue.js?id=f89ed45026610831d45d", "/css/AdminLTE.css": "/css/AdminLTE.css?id=a501321b732a1aca5cc9",
"/css/build/AdminLTE.css": "/css/build/AdminLTE.css?id=5002486f605469c322ed", "/css/app.css": "/css/app.css?id=c3b4e5ea2063d7f76241",
"/css/build/app.css": "/css/build/app.css?id=0c4d55f9abe9a4efe526", "/css/overrides.css": "/css/overrides.css?id=3f6a7848656e6755847e",
"/js/build/vue.js.map": "/js/build/vue.js.map?id=3aae6e8f609e5cd2842a", "/css/dist/all.css": "/css/dist/all.css?id=c78a60594ab97ac02719",
"/css/build/AdminLTE.css.map": "/css/build/AdminLTE.css.map?id=fa40c591a5b361cb0761", "/css/build/all.css": "/css/build/all.css?id=c78a60594ab97ac02719",
"/css/build/app.css.map": "/css/build/app.css.map?id=5a1bc8c3be0d3da37d0a", "/js/vendor.js": "/js/vendor.js?id=534ce0a6cfd17eec12d1",
"/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/html5shiv.min.js": "/js/html5shiv.min.js?id=ba846cb704dbfbc5f1b3", "/js/html5shiv.min.js": "/js/html5shiv.min.js?id=ba846cb704dbfbc5f1b3",
"/js/respond.min.js": "/js/respond.min.js?id=afc1984a3d17110449dc", "/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.js": "/js/dist/bootstrap-table.js?id=7223478ba9bf2c6dfb4f",
"/js/dist/bootstrap-table-simple-view.js": "/js/dist/bootstrap-table-simple-view.js?id=3926b8f4aaad6ca20d31", "/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" "/css/dist/bootstrap-table.css": "/css/dist/bootstrap-table.css?id=8340c60bfbc12c34d2e6"

View file

@ -1,146 +1,199 @@
/*! /*!
* pGenerator jQuery Plugin v1.0.0 * pGenerator jQuery Plugin v1.0.5
* http://accountspassword.com/password-generator-jquery-plugin * https://github.com/M1Sh0u/pGenerator
*
* Created by AccountsPassword.com
* Released under the GPL General Public License (Feel free to copy, modify or redistribute this plugin.)
* *
* Created by Mihai MATEI <mihai.matei@outlook.com>
* Released under the MIT License (Feel free to copy, modify or redistribute this plugin.)
*/ */
(function($){ (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({ var numbers_array = [],
'bind': 'click', upper_letters_array = [],
'passwordElement': null, lower_letters_array = [],
'displayElement': null, special_chars_array = [],
'passwordLength': 16, $pGeneratorElement = null;
'uppercase': true,
'lowercase': true,
'numbers': true,
'specialChars': true,
'onPasswordGenerated': function(generatedPassword) { }
}, options);
for(var i = 48; i < 58; i++) /**
numbers_array.push(i); * Plugin methods.
for(i = 65; i < 91; i++) *
upper_letters_array.push(i); * @type {{init: init, generatePassword: generatePassword}}
for(i = 97; i < 123; i++) */
lower_letters_array.push(i); var methods = {
special_chars_array = [33,35,64,36,38,42,91,93,123,125,92,47,63,58,59,95,45,53];
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){ for(i = 65; i < 91; i++) {
e.preventDefault(); upper_letters_array.push(i);
methods.generatePassword(settings); }
});
}); for(i = 97; i < 123; i++) {
}, lower_letters_array.push(i);
generatePassword: function(settings) { }
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(), return this.each(function(){
selOptions = settings.uppercase + settings.lowercase + settings.numbers + settings.specialChars,
selected = 0,
no_lower_letters = new Array();
var optionLength = Math.floor(settings.passwordLength / selOptions); $pGeneratorElement = $(this);
if(settings.uppercase) { $pGeneratorElement.bind(settings.bind, function(e){
// uppercase letters e.preventDefault();
for(var i = 0; i < optionLength; i++) { methods.generatePassword(settings);
password.push(String.fromCharCode(upper_letters_array[randomFromInterval(0, upper_letters_array.length - 1)])); });
}
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) { var optionLength = Math.floor(settings.passwordLength / selOptions);
// numbers letters
for(var i = 0; i < optionLength; i++) {
password.push(String.fromCharCode(numbers_array[randomFromInterval(0, numbers_array.length - 1)]));
}
no_lower_letters = no_lower_letters.concat(numbers_array); if(settings.uppercase) {
// uppercase letters
selected++; for(var i = 0; i < optionLength; i++) {
} password.push(String.fromCharCode(upper_letters_array[randomFromInterval(0, upper_letters_array.length - 1)]));
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);
} }
}
settings.onPasswordGenerated(passwordString); no_lower_letters = no_lower_letters.concat(upper_letters_array);
} selected++;
}; }
function shuffle(o){ //v1.0 if(settings.numbers) {
for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x); // numbers letters
return o; for(var i = 0; i < optionLength; i++) {
}; password.push(String.fromCharCode(numbers_array[randomFromInterval(0, numbers_array.length - 1)]));
}
function randomFromInterval(from, to) no_lower_letters = no_lower_letters.concat(numbers_array);
{
return Math.floor(Math.random()*(to-from+1)+from);
};
$.fn.pGenerator = function(method) { selected++;
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); 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);