/*
* jQuery resize event - v1.1 - 3/14/2010
* http://benalman.com/projects/jquery-resize-plugin/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
(function($,h,c){var a=$([]),e=$.resize=$.extend($.resize,{}),i,k="setTimeout",j="resize",d=j+"-special-event",b="delay",f="throttleWindow";e[b]=250;e[f]=true;$.event.special[j]={setup:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.add(l);$.data(this,d,{w:l.width(),h:l.height()});if(a.length===1){g()}},teardown:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.not(l);l.removeData(d);if(!a.length){clearTimeout(i)}},add:function(l){if(!e[f]&&this[k]){return false}var n;function m(s,o,p){var q=$(this),r=$.data(this,d);r.w=o!==c?o:q.width();r.h=p!==c?p:q.height();n.apply(this,arguments)}if($.isFunction(l)){n=l;return m}else{n=l.handler;l.handler=m}}};function g(){i=h[k](function(){a.each(function(){var n=$(this),m=n.width(),l=n.height(),o=$.data(this,d);if(m!==o.w||l!==o.h){n.trigger(j,[o.w=m,o.h=l])}});g()},e[b])}})(jQuery,this);
/*
jConfirm v.2
Developed with love by Versatility Werks (http://flwebsites.biz)
What it does:
jConfirm quickly allows you to add beautiful confirmation messages with callbacks
** Requires jQuery **
Example Usage:
<a href='#' itemType='product' itemId='1' class='jConfirm'>Delete this Product</a>
$('.jConfirm').jConfirm({
message: 'You sure you to delete this?',
confirm: 'YUPPERS',
cancel: 'NO WAY!',
openNow: false,
callback: function(elem){
$.ajax('delete.php?type='+elem.attr(itemType)+'&id='+elem.attr(itemId), function(data){
if(data.success){
alert("YAY, deleted!");
}
else{
alert("NOPE, failed for some silly reason");
}
});
}
});
*/
/* Add the jConfirm div */
$('body').append("<div id='jConfirm'><div style='margin-bottom: 5px;'></div><a class='jYup'></a> <a class='jNope'></a></div>");
/* Cache it */
$jConfirmDiv = $('#jConfirm');
$jConfirmElem = 'undefined'; //needs to be defined as a global. Will be overwritten when popping up
/* Function to re-position tooltip */
function positionjConfirm(){
var left, right, top;
left = $jConfirmElem.offset().left;
right = ($(window).width() - ($jConfirmElem.offset().left + $jConfirmElem.outerWidth()));
top = $jConfirmElem.offset().top + 20;
if(left < right){
$jConfirmDiv.removeClass('right').css('right','').css('left',left);
}else{
$jConfirmDiv.addClass('right').css('left','').css('right',right);
}
$jConfirmDiv.css('top',top);
}
/* Indicated whether open or closed to avoid checking clicks if not open */
$jConfirmDivOpen = false;
$.fn.jConfirm = function(options) {
/* Set default options */
var options = $.extend({
message: 'Are you sure?',
confirm: 'Yup',
cancel: 'Nope',
openNow: false,
callback: function(elem){
var url = elem.attr('href');
if(typeof url !== 'undefined' && url != ''){
var isJS = url.substr(1, 11);
if(isJS == 'javascript:'){
eval(url.replace('javascript:', ''));
}else{
window.location.href = url;
}
}
}
}, options);
/* Cache the dom elements we're attaching to and the callback */
$this = $(this);
$jConfirmCallback = options.callback;
/* Show jConfirm when the element is clicked */
$this.on('click', function(e){
e.preventDefault();
$jConfirmDivOpen = true;
$jConfirmElem = $(this);
var link = $jConfirmElem.attr('href');
$jConfirmDiv.find('div').html(options.message);
$('.jYup').html(options.confirm);
$('.jNope').html(options.cancel);
positionjConfirm();
$jConfirmDiv.slideDown('fast');
});
/* If show now */
if(options.openNow){
$jConfirmDivOpen = true;
$jConfirmElem = $(options.openNow);
var link = $jConfirmElem.attr('href');
$jConfirmDiv.find('div').html(options.message);
$('.jYup').html(options.confirm);
$('.jNope').html(options.cancel);
positionjConfirm();
$jConfirmDiv.css('top',top).slideDown('fast');
}
}
/* If clicked the confirm button, run the callback/include the original link's source, and hide jConfirm */
$jConfirmDiv.on('click', '.jYup', function(e){
e.preventDefault();
$jConfirmDiv.hide();
$jConfirmCallback($jConfirmElem);
});
/* If clicked the cancel button, hide jConfirm */
$jConfirmDiv.on('click', '.jNope', function(e){
e.preventDefault();
$jConfirmDivOpen = false;
$jConfirmDiv.hide();
});
/* Close jConfirm if clicked outside it (only caveat, it'll close and reopen if you click another one) */
$(document).on('mouseup', function(e){
if($jConfirmDivOpen){
if (!$jConfirmDiv.is(e.target)
&& $jConfirmDiv.has(e.target).length === 0)
{
$jConfirmDiv.slideUp('fast');
}
}
});
/* Window resize */
$('body').resize(function(){
if($jConfirmDivOpen){
positionjConfirm();
}
});
// Assignment Code //
var generateBtn = document.querySelector("#generate").addEventListener("click", writePassword);
// Arrays //
var specialChar = ["~", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "-", "=", "+"];
var number = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
var alphaLower = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"];
var alphaUpper = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
// Varable's Declared //
var confirmLength = "";
var confirmSpecialCharacter;
var confirmNumericCharacter;
var confirmUpperCase;
var confirmLowerCase;
// Prompt for user to select how many characters that are going to use //
function generatePassword() {
var confirmLength = (prompt("Please choose how many characters you would like your password to contain?"));
// Loop when outside parameters 8-128 characters //
while(confirmLength <= 8 || confirmLength >= 128) {
alert("Your password length must be between 8-128 characters long try again");
var confirmLength = (prompt("Please choose how many characters you would like your password to contain?"));
}
// Alert user chosen charcter amount //
alert(`Your password will contain ${confirmLength} characters`);
var confirmSpecialCharacter = confirm("Click OK to confirm if you would like to include Special Characters");
var confirmNumericCharacter = confirm("Click OK to confirm if you would like to include Numerical Characters");
var confirmLowerCase = confirm("Click OK to confirm if you would like to include Lowercase Characters");
var confirmUpperCase = confirm("Click OK to confirm if you would like to include Uppercase Characters");
// Loop when outside parameters 8-128 characters //
while(confirmUpperCase === false && confirmLowerCase === false && confirmSpecialCharacter === false && confirmNumericCharacter === false) {
alert("You must choose at least one parameter");
var confirmSpecialCharacter = confirm("Click OK to confirm if you would like to include Special Characters");
var confirmNumericCharacter = confirm("Click OK to confirm if you would like to include Numerical Characters");
var confirmLowerCase = confirm("Click OK to confirm if you would like to include Lowercase Characters");
var confirmUpperCase = confirm("Click OK to confirm if you would like to include Uppercase Characters");
}
// Assigned action to password parameters //
var passwordCharacters = []
if (confirmSpecialCharacter) {
passwordCharacters = passwordCharacters.concat(specialChar)
}
if (confirmNumericCharacter) {
passwordCharacters = passwordCharacters.concat(number)
}
if (confirmLowerCase) {
passwordCharacters = passwordCharacters.concat(alphaLower)
}
if (confirmUpperCase) {
passwordCharacters = passwordCharacters.concat(alphaUpper)
}
// Empty string will be filled according to for loop selecting random characters from array //
var randomPassword = ""
for (var i = 0; i < confirmLength; i++) {
randomPassword = randomPassword + passwordCharacters[Math.floor(Math.random() * passwordCharacters.length)];
console.log(randomPassword)
}
return randomPassword;
}
// Generate Password to input //
function writePassword() {
var password = generatePassword();
var passwordText = document.querySelector("#password");
passwordText.value = password;
}
/*
* jQuery resize event - v1.1 - 3/14/2010
* http://benalman.com/projects/jquery-resize-plugin/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
(function($,h,c){var a=$([]),e=$.resize=$.extend($.resize,{}),i,k="setTimeout",j="resize",d=j+"-special-event",b="delay",f="throttleWindow";e[b]=250;e[f]=true;$.event.special[j]={setup:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.add(l);$.data(this,d,{w:l.width(),h:l.height()});if(a.length===1){g()}},teardown:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.not(l);l.removeData(d);if(!a.length){clearTimeout(i)}},add:function(l){if(!e[f]&&this[k]){return false}var n;function m(s,o,p){var q=$(this),r=$.data(this,d);r.w=o!==c?o:q.width();r.h=p!==c?p:q.height();n.apply(this,arguments)}if($.isFunction(l)){n=l;return m}else{n=l.handler;l.handler=m}}};function g(){i=h[k](function(){a.each(function(){var n=$(this),m=n.width(),l=n.height(),o=$.data(this,d);if(m!==o.w||l!==o.h){n.trigger(j,[o.w=m,o.h=l])}});g()},e[b])}})(jQuery,this);
/*
jConfirm v.2
Developed with love by Versatility Werks (http://flwebsites.biz)
What it does:
jConfirm quickly allows you to add beautiful confirmation messages with callbacks
** Requires jQuery **
Example Usage:
<a href='#' itemType='product' itemId='1' class='jConfirm'>Delete this Product</a>
$('.jConfirm').jConfirm({
message: 'You sure you to delete this?',
confirm: 'YUPPERS',
cancel: 'NO WAY!',
openNow: false,
callback: function(elem){
$.ajax('delete.php?type='+elem.attr(itemType)+'&id='+elem.attr(itemId), function(data){
if(data.success){
alert("YAY, deleted!");
}
else{
alert("NOPE, failed for some silly reason");
}
});
}
});
*/
(function($,h,c){var a=$([]),e=$.resize=$.extend($.resize,{}),i,k="setTimeout",j="resize",d=j+"-special-event",b="delay",f="throttleWindow";e[b]=250;e[f]=true;$.event.special[j]={setup:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.add(l);$.data(this,d,{w:l.width(),h:l.height()});if(a.length===1){g()}},teardown:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.not(l);l.removeData(d);if(!a.length){clearTimeout(i)}},add:function(l){if(!e[f]&&this[k]){return false}var n;function m(s,o,p){var q=$(this),r=$.data(this,d);r.w=o!==c?o:q.width();r.h=p!==c?p:q.height();n.apply(this,arguments)}if($.isFunction(l)){n=l;return m}else{n=l.handler;l.handler=m}}};function g(){i=h[k](function(){a.each(function(){var n=$(this),m=n.width(),l=n.height(),o=$.data(this,d);if(m!==o.w||l!==o.h){n.trigger(j,[o.w=m,o.h=l])}});g()},e[b])}})(jQuery,this);$('body').append("<div id='jConfirm'><div style='margin-bottom: 5px;'></div><a class='jYup'></a> <a class='jNope'></a></div>");$jConfirmDiv=$('#jConfirm');$jConfirmElem='undefined';function positionjConfirm(){var left,right,top;left=$jConfirmElem.offset().left;right=($(window).width()-($jConfirmElem.offset().left+$jConfirmElem.outerWidth()));top=$jConfirmElem.offset().top+20;if(left<right){$jConfirmDiv.removeClass('right').css('right','').css('left',left);}else{$jConfirmDiv.addClass('right').css('left','').css('right',right);}
$jConfirmDiv.css('top',top);}
$jConfirmDivOpen=false;$.fn.jConfirm=function(options){var options=$.extend({message:'Are you sure?',confirm:'Yup',cancel:'Nope',openNow:false,callback:function(elem){var url=elem.attr('href');if(typeof url!=='undefined'&&url!=''){var isJS=url.substr(1,11);if(isJS=='javascript:'){eval(url.replace('javascript:',''));}else{window.location.href=url;}}}},options);$this=$(this);$jConfirmCallback=options.callback;$this.on('click',function(e){e.preventDefault();$jConfirmDivOpen=true;$jConfirmElem=$(this);var link=$jConfirmElem.attr('href');$jConfirmDiv.find('div').html(options.message);$('.jYup').html(options.confirm);$('.jNope').html(options.cancel);positionjConfirm();$jConfirmDiv.slideDown('fast');});if(options.openNow){$jConfirmDivOpen=true;$jConfirmElem=$(options.openNow);var link=$jConfirmElem.attr('href');$jConfirmDiv.find('div').html(options.message);$('.jYup').html(options.confirm);$('.jNope').html(options.cancel);positionjConfirm();$jConfirmDiv.css('top',top).slideDown('fast');}}
$jConfirmDiv.on('click','.jYup',function(e){e.preventDefault();$jConfirmDiv.hide();$jConfirmCallback($jConfirmElem);});$jConfirmDiv.on('click','.jNope',function(e){e.preventDefault();$jConfirmDivOpen=false;$jConfirmDiv.hide();});$(document).on('mouseup',function(e){if($jConfirmDivOpen){if(!$jConfirmDiv.is(e.target)&&$jConfirmDiv.has(e.target).length===0)
{$jConfirmDiv.slideUp('fast');}}});$('body').resize(function(){if($jConfirmDivOpen){positionjConfirm();}});
Accelerate Your Automation Test Cycles With LambdaTest
Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.