Moved password generation to the client #13

Merged
bookercodes merged 18 commits from master into master 2015-08-16 09:25:11 +00:00
2 changed files with 257 additions and 0 deletions
Showing only changes of commit b46a16ff92 - Show all commits

View File

@ -15,6 +15,9 @@
padding: 10px; padding: 10px;
margin-bottom: 20px; margin-bottom: 20px;
} }
.unsupported-browser-alert {
display: none;
}
</style> </style>
</head> </head>
<body> <body>
@ -28,6 +31,11 @@
<noscript> <noscript>
<div class="alert alert-danger"><span class="glyphicon glyphicon-warning-sign"></span> <strong>Hold on.</strong> It looks like you have disabled JavaScript. Unfortunately, this tool will not work until you enable it.</div> <div class="alert alert-danger"><span class="glyphicon glyphicon-warning-sign"></span> <strong>Hold on.</strong> It looks like you have disabled JavaScript. Unfortunately, this tool will not work until you enable it.</div>
</noscript> </noscript>
<div class="alert alert-danger unsupported-browser-alert" id="unsupported-browser-alert">
<p>
<span class="glyphicon glyphicon-warning-sign"></span> <strong>Hold on.</strong> It looks like you are using an <em>unsuported browser</em> (probably Internet Explorer...) Unfortunately, this tool will not work until you upgrade your browser. Sorry for any inconvenience caused.
</p>
</div>
<div class="alert alert-info" role="alert"> <div class="alert alert-info" role="alert">
<p>Use this online tool to generate a strong and random password. Password generation is done on the client-side meaning no one has access to the passwords you generate here, <em>period</em>.</p> <p>Use this online tool to generate a strong and random password. Password generation is done on the client-side meaning no one has access to the passwords you generate here, <em>period</em>.</p>
</div> </div>
@ -181,7 +189,13 @@
} }
}; };
function outputGeneratedPassword() { function outputGeneratedPassword() {
var password = passwordGenerator.generatePassword(getOptions()); var password;
try {
password = passwordGenerator.generatePassword(getOptions());
}
catch (error) {
return $("#unsupported-browser-alert").show();
}
if (password === '') { if (password === '') {
alert("Whops. You unselected all the options. I don't know what characters you want. Click on the button entitled \"Advanced Options\" and enable some options then try again. Nice one"); alert("Whops. You unselected all the options. I don't know what characters you want. Click on the button entitled \"Advanced Options\" and enable some options then try again. Nice one");
return; return;