Front end password generator

This commit is contained in:
Martin Donnelly 2015-08-19 11:53:32 +01:00
parent a75ea76571
commit f2c628784f
3 changed files with 63 additions and 2 deletions

View File

@ -338,6 +338,50 @@
});
};
var formatPassword = function (data) {
var dest$ = $('#passwordOut');
var html = new EJS({url: '/template/password.ejs'}).render(data);
console.log(html);
dest$.empty();
dest$.append(html);
dest$.show();
};
var generatePassword = function(from, to) {
var url = '/generate';
$.ajax({
type: 'GET',
url: url,
data: '',
dataType: 'json',
timeout: 10000,
//contentType: ('application/json'),
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'PUT, GET, POST, DELETE, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type'
},
success: function (data) {
console.log(data);
formatPassword(data);
},
error: function (xhr, type) {
console.log("ajax error");
console.log(xhr);
console.log(type);
}
});
};
tick();
@ -369,6 +413,10 @@
getTrains('glq','dbe');
});
$('#newPassword').on('click', function() {
generatePassword();
});
})();
var popitout = function (url) {

View File

@ -42,6 +42,14 @@
.nochange {
color: #000000;
}
.password {
border: 1px solid #cccccc;
background-color: #efefef;
font-family: monospace;
white-space: pre;
}
</style>
<script src="//cdnjs.cloudflare.com/ajax/libs/zepto/1.1.4/zepto.min.js"></script>
</head>
@ -106,9 +114,12 @@
<li><a href="https://howsecureismypassword.net/">Password Checker</a></li>
<li><a href="https://archive.today">Archive Today</a></li>
<li><a href="http://staticmapmaker.com/google/">Static Map Generator</a></li>
<li><a href="https://httpbin.org/">AJAX Endpoints</a></li>
<li><a href="https://tools.bartlweb.net/webssh/">WebSSH</a></li>
<li><a href="https://httpbin.org/">AJAX Endpoints</a></li>
<li><a href="https://tools.bartlweb.net/webssh/">WebSSH</a></li>
<li><span id='newPassword'>Generate Password</span></li>
</ul>
<div id='passwordOut' class='password' style='display:none;'></div>
</div>
<div class="mui-col-md-4">
<div class="mui-text-title mui-text-black">Bitcoin <span id="btc"></span></div>

View File

@ -0,0 +1,2 @@
<div>Long: <%=long%></div>
<div>Short: <%=short%></div>