new password bb object

This commit is contained in:
martind2000 2017-04-20 13:42:55 +01:00
parent 413347117e
commit 9f53aa6cba
9 changed files with 130 additions and 96 deletions

View File

@ -1,46 +1,5 @@
(function() {
let formatPassword = function(data) {
let dest$ = $('#passwordOut');
let html = new EJS({url: '/template/password.ejs'}).render(data);
dest$.empty();
dest$.append(html);
dest$.show();
};
let generatePassword = function(from, to) {
let url = '/generate';
$.ajax({
type: 'GET',
url: url,
data: '',
dataType: 'json',
timeout: 10000,
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'PUT, GET, POST, DELETE, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type'
},
success: function(data) {
formatPassword(data);
},
error: function(xhr, type) {
console.log('ajax error');
console.log(xhr);
console.log(type);
}
});
};
$('#newPassword').on('click', function() {
generatePassword();
});
document.title = 'Slack';
document.title = 'Slack';
})();
let popitout = function(url) {

View File

@ -0,0 +1,72 @@
/**
* Created by mdonnel on 20/04/2017.
*/
Array.prototype.random = function () {
return this[Math.floor((Math.random() * this.length))];
};
let PasswordView = Backbone.View.extend({
el: $('#passwords'),
initialize: function () {
this.alpha = ['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', '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', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
this.whitespace = ['.', '~', '#', '!', '$', '+', '-', '+'];
this.numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
this.left = ['Alabama',
'Alaska',
'Arizona',
'Maryland',
'Nevada',
'Mexico',
'Texas',
'Utah',
'Glasgow',
'Inverness',
'Edinburgh',
'Dumbarton',
'Balloch',
'Renton',
'Cardross',
'Dundee',
'Paisley',
'Hamilton',
'Greenock',
'Falkirk',
'Irvine',
'Renfrew',
'Erskine',
'London',
'Hammersmith',
'Islington',
'Silver', 'Black', 'Yellow', 'Purple', 'White', 'Pink', 'Red', 'Orange', 'Brown', 'Green', 'Blue', 'Amber', 'Aqua', 'Azure', 'Bronze', 'Coral', 'Copper', 'Crimson', 'Cyan', 'Ginger', 'Gold', 'Indigo', 'Jade'
];
this.right = ['Aganju', 'Cygni', 'Akeron', 'Antares', 'Aragoth', 'Ardus', 'Carpenter', 'Cooper', 'Dahin', 'Capella', 'Endriago', 'Gallina', 'Fenris', 'Freya', 'Glenn', 'Grissom', 'Jotunheim', 'Kailaasa', 'Lagarto', 'Muspelheim', 'Nifleheim', 'Primus', 'Vega', 'Ragnarok', 'Shepard', 'Slayton', 'Tarsis', 'Mercury', 'Venus', 'Mars', 'Earth', 'Terra', 'Jupiter', 'Saturn', 'Uranus', 'Neptune', 'Pluto', 'Europa', 'Ganymede', 'Callisto', 'Titan', 'Juno', 'Eridanus', 'Scorpius', 'Crux', 'Cancer', 'Taurus', 'Lyra', 'Andromeda', 'Virgo', 'Aquarius', 'Cygnus', 'Corvus', 'Taurus', 'Draco', 'Perseus', 'Pegasus', 'Gemini', 'Columbia', 'Bootes', 'Orion', 'Deneb', 'Merope', 'Agate', 'Amber', 'Beryl', 'Calcite', 'Citrine', 'Coral', 'Diamond', 'Emerald', 'Garnet', 'Jade', 'Lapis', 'Moonstone', 'Obsidian', 'Onyx', 'Opal', 'Pearl', 'Quartz', 'Ruby', 'Sapphire', 'Topaz', 'Iron', 'Lead', 'Nickel', 'Copper', 'Zinc', 'Tin', 'Manes', 'Argon', 'Neon', 'Alpha', 'Bravo', 'Charlie', 'Delta', 'Echo', 'Foxtrot', 'Golf', 'Hotel', 'India', 'Juliett', 'Kilo', 'Lima', 'Mike', 'November', 'Oscar', 'Papa', 'Quebec', 'Romeo', 'Sierra', 'Tango', 'Uniform', 'Victor', 'Whisky', 'Xray', 'Yankee', 'Zulu'];
_.bindAll(this, 'newClick');
},
events: {
'click #newPassword': 'newClick'
},
numberCluster: function () {
return this.numbers.random() + this.numbers.random() + this.numbers.random();
},
randomAmount: function (i) {
let str = '';
for (let t = 0; t < i; t++) {
str = str + this.alpha.random();
}
return str;
},
newClick: function () {
let $passwordOut = $('#passwordOut');
let long = (this.left.random() + ' ' + this.right.random() + ' ' + this.numberCluster()).split(' ').join(this.whitespace.random());
let short = (this.randomAmount(5) + ' ' + this.randomAmount(5)).split(' ').join(this.whitespace.random());
let template = `<div>Long: ${long}</div><div>Short: ${short}</div>`;
$passwordOut.empty().append(template).removeClass('mui--hide');
}
});

File diff suppressed because one or more lines are too long

View File

@ -23,7 +23,7 @@ let dest = 'app/live';
let fontOptions = { };
gulp.task('appJS', function() {
return gulp.src(['app/js/modules/events.js', 'app/js/modules/bitcoin.js', 'app/js/modules/fx.js', 'app/js/modules/train.js','app/js/modules/weather.js', 'app/app.js'])
return gulp.src(['app/js/modules/events.js', 'app/js/modules/bitcoin.js', 'app/js/modules/fx.js', 'app/js/modules/train.js','app/js/modules/weather.js','app/js/modules/password.js', 'app/app.js'])
.pipe(stripDebug())
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('default'))

File diff suppressed because one or more lines are too long

View File

@ -1,68 +1,68 @@
var http = require('http');
Array.prototype.random = function () {
return this[Math.floor((Math.random() * this.length))];
return this[Math.floor((Math.random() * this.length))];
};
var alpha = ['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', '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', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
var whitespace = ['.', '~', '#', '!', '$', '+', '-', '+'];
var numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
var left = ["Alabama",
"Alaska",
"Arizona",
"Maryland",
"Nevada",
"Mexico",
"Texas",
"Utah",
"Glasgow",
"Inverness",
"Edinburgh",
"Dumbarton",
"Balloch",
"Renton",
"Cardross",
"Dundee",
"Paisley",
"Hamilton",
"Greenock",
"Falkirk",
"Irvine",
"Renfrew",
"Erskine",
"London",
"Hammersmith",
"Islington",
"Silver", "Black", "Yellow", "Purple", 'White', 'Pink', 'Red', 'Orange','Brown','Green','Blue','Amber','Aqua','Azure','Bronze','Coral','Copper','Crimson','Cyan','Ginger','Gold','Indigo','Jade'
var left = ['Alabama',
'Alaska',
'Arizona',
'Maryland',
'Nevada',
'Mexico',
'Texas',
'Utah',
'Glasgow',
'Inverness',
'Edinburgh',
'Dumbarton',
'Balloch',
'Renton',
'Cardross',
'Dundee',
'Paisley',
'Hamilton',
'Greenock',
'Falkirk',
'Irvine',
'Renfrew',
'Erskine',
'London',
'Hammersmith',
'Islington',
'Silver', 'Black', 'Yellow', 'Purple', 'White', 'Pink', 'Red', 'Orange', 'Brown', 'Green', 'Blue', 'Amber', 'Aqua', 'Azure', 'Bronze', 'Coral', 'Copper', 'Crimson', 'Cyan', 'Ginger', 'Gold', 'Indigo', 'Jade'
];
var right = ['Aganju', 'Cygni', 'Akeron', 'Antares', 'Aragoth', 'Ardus', 'Carpenter', 'Cooper', 'Dahin', 'Capella', 'Endriago', 'Gallina', 'Fenris', 'Freya', 'Glenn', 'Grissom', 'Jotunheim', 'Kailaasa', 'Lagarto', 'Muspelheim', 'Nifleheim', 'Primus', 'Vega', 'Ragnarok', 'Shepard', 'Slayton', 'Tarsis', 'Mercury', 'Venus', 'Mars', 'Earth', 'Terra', 'Jupiter', 'Saturn', 'Uranus', 'Neptune', 'Pluto', 'Europa', 'Ganymede', 'Callisto', 'Titan', 'Juno', 'Eridanus', 'Scorpius', 'Crux', 'Cancer', 'Taurus', 'Lyra', 'Andromeda', 'Virgo', 'Aquarius', 'Cygnus', 'Corvus', 'Taurus', 'Draco', 'Perseus', 'Pegasus', 'Gemini', 'Columbia', 'Bootes', 'Orion', 'Deneb', 'Merope', 'Agate','Amber','Beryl','Calcite','Citrine','Coral','Diamond','Emerald','Garnet','Jade','Lapis','Moonstone','Obsidian','Onyx','Opal','Pearl','Quartz','Ruby','Sapphire','Topaz','Iron','Lead','Nickel','Copper','Zinc','Tin','Manes','Argon','Neon','Alpha','Bravo','Charlie','Delta','Echo','Foxtrot','Golf','Hotel','India','Juliett','Kilo','Lima','Mike','November','Oscar','Papa','Quebec','Romeo','Sierra','Tango','Uniform','Victor','Whisky','Xray','Yankee','Zulu'];
var right = ['Aganju', 'Cygni', 'Akeron', 'Antares', 'Aragoth', 'Ardus', 'Carpenter', 'Cooper', 'Dahin', 'Capella', 'Endriago', 'Gallina', 'Fenris', 'Freya', 'Glenn', 'Grissom', 'Jotunheim', 'Kailaasa', 'Lagarto', 'Muspelheim', 'Nifleheim', 'Primus', 'Vega', 'Ragnarok', 'Shepard', 'Slayton', 'Tarsis', 'Mercury', 'Venus', 'Mars', 'Earth', 'Terra', 'Jupiter', 'Saturn', 'Uranus', 'Neptune', 'Pluto', 'Europa', 'Ganymede', 'Callisto', 'Titan', 'Juno', 'Eridanus', 'Scorpius', 'Crux', 'Cancer', 'Taurus', 'Lyra', 'Andromeda', 'Virgo', 'Aquarius', 'Cygnus', 'Corvus', 'Taurus', 'Draco', 'Perseus', 'Pegasus', 'Gemini', 'Columbia', 'Bootes', 'Orion', 'Deneb', 'Merope', 'Agate', 'Amber', 'Beryl', 'Calcite', 'Citrine', 'Coral', 'Diamond', 'Emerald', 'Garnet', 'Jade', 'Lapis', 'Moonstone', 'Obsidian', 'Onyx', 'Opal', 'Pearl', 'Quartz', 'Ruby', 'Sapphire', 'Topaz', 'Iron', 'Lead', 'Nickel', 'Copper', 'Zinc', 'Tin', 'Manes', 'Argon', 'Neon', 'Alpha', 'Bravo', 'Charlie', 'Delta', 'Echo', 'Foxtrot', 'Golf', 'Hotel', 'India', 'Juliett', 'Kilo', 'Lima', 'Mike', 'November', 'Oscar', 'Papa', 'Quebec', 'Romeo', 'Sierra', 'Tango', 'Uniform', 'Victor', 'Whisky', 'Xray', 'Yankee', 'Zulu'];
var numberCluster = function () {
return numbers.random() + numbers.random() + numbers.random();
return numbers.random() + numbers.random() + numbers.random();
};
var randomAmount = function (i) {
var str = '';
var str = '';
for (var t = 0; t < i; t++) {
str = str + alpha.random();
}
for (var t = 0; t < i; t++) {
str = str + alpha.random();
}
return str;
return str;
};
module.exports = {
generate: function (req, res) {
var reply = {
long: (left.random() + ' ' + right.random() + ' ' + numberCluster() + ' ' + numberCluster()).split(' ').join(whitespace.random()),
short: randomAmount(10)
};
generate: function (req, res) {
var reply = {
long: (left.random() + ' ' + right.random() + ' ' + numberCluster() + ' ' + numberCluster()).split(' ').join(whitespace.random()),
short: randomAmount(10)
};
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(reply));
}
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(reply));
}
};

View File

@ -70,10 +70,11 @@
<li><a href="https://httpbin.org/">AJAX Endpoints</a></li>
<li><a href="https://tools.bartlweb.net/webssh/">WebSSH</a></li>
<li><a href="http://jade-lang.com/demo/">Jade Tester</a></li>
<li><button class="mui-btn mui-btn--flat" id='newPassword'>Generate Password</button></li>
</ul>
<div id='passwordOut' class='password' style='display:none;'></div>
<div id="passwords">
<button class="mui-btn mui-btn--flat" id='newPassword'>Generate Password</button>
<div id='passwordOut' class='password mui--hide' >Something</div>
</div>
</div>
<div class="mui-col-md-4">
<div class="mui--text-title mui-text-black">Bitcoin <span id="btc"></span></div>
@ -381,6 +382,7 @@
w.glqhymView = new TrainView({model: new TrainModel({from: 'glq', to: 'hym'})});
w.hymglqView = new TrainView({model: new TrainModel({from: 'hym', to: 'glq'})});
w.passwords = new PasswordView();
})(window);
</script>

View File

@ -71,11 +71,11 @@
<li><a href="https://tools.bartlweb.net/webssh/">WebSSH</a></li>
<li><a href="http://jade-lang.com/demo/">Jade Tester</a></li>
<li>
<button class="mui-btn mui-btn--flat" id='newPassword'>Generate Password</button>
</li>
</ul>
<div id='passwordOut' class='password' style='display:none;'></div>
<div id="passwords">
<button class="mui-btn mui-btn--flat" id='newPassword'>Generate Password</button>
<div id='passwordOut' class='password mui--hide' >Something</div>
</div>
</div>
<div class="mui-col-md-4">
<div class="mui--text-title mui-text-black">Bitcoin <span id="btc"></span></div>
@ -382,6 +382,7 @@
<script src="js/modules/fx.js"></script>
<script src="js/modules/train.js"></script>
<script src="js/modules/weather.js"></script>
<script src="js/modules/password.js"></script>
<script src="app.js"></script>
<script>
@ -397,7 +398,7 @@
w.glqhymView = new TrainView({model: new TrainModel({from: 'glq', to: 'hym'})});
w.hymglqView = new TrainView({model: new TrainModel({from: 'hym', to: 'glq'})});
w.passwords = new PasswordView();
})(window);