new password bb object
This commit is contained in:
parent
413347117e
commit
9f53aa6cba
43
app/app.js
43
app/app.js
@ -1,46 +1,5 @@
|
|||||||
(function() {
|
(function() {
|
||||||
|
document.title = 'Slack';
|
||||||
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';
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
let popitout = function(url) {
|
let popitout = function(url) {
|
||||||
|
72
app/js/modules/password.js
Normal file
72
app/js/modules/password.js
Normal 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');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
Binary file not shown.
File diff suppressed because one or more lines are too long
@ -23,7 +23,7 @@ let dest = 'app/live';
|
|||||||
let fontOptions = { };
|
let fontOptions = { };
|
||||||
|
|
||||||
gulp.task('appJS', function() {
|
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(stripDebug())
|
||||||
.pipe(jshint('.jshintrc'))
|
.pipe(jshint('.jshintrc'))
|
||||||
.pipe(jshint.reporter('default'))
|
.pipe(jshint.reporter('default'))
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1,68 +1,68 @@
|
|||||||
var http = require('http');
|
var http = require('http');
|
||||||
|
|
||||||
Array.prototype.random = function () {
|
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 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 whitespace = ['.', '~', '#', '!', '$', '+', '-', '+'];
|
||||||
var numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
|
var numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
|
||||||
var left = ["Alabama",
|
var left = ['Alabama',
|
||||||
"Alaska",
|
'Alaska',
|
||||||
"Arizona",
|
'Arizona',
|
||||||
"Maryland",
|
'Maryland',
|
||||||
"Nevada",
|
'Nevada',
|
||||||
"Mexico",
|
'Mexico',
|
||||||
"Texas",
|
'Texas',
|
||||||
"Utah",
|
'Utah',
|
||||||
"Glasgow",
|
'Glasgow',
|
||||||
"Inverness",
|
'Inverness',
|
||||||
"Edinburgh",
|
'Edinburgh',
|
||||||
"Dumbarton",
|
'Dumbarton',
|
||||||
"Balloch",
|
'Balloch',
|
||||||
"Renton",
|
'Renton',
|
||||||
"Cardross",
|
'Cardross',
|
||||||
"Dundee",
|
'Dundee',
|
||||||
"Paisley",
|
'Paisley',
|
||||||
"Hamilton",
|
'Hamilton',
|
||||||
"Greenock",
|
'Greenock',
|
||||||
"Falkirk",
|
'Falkirk',
|
||||||
"Irvine",
|
'Irvine',
|
||||||
"Renfrew",
|
'Renfrew',
|
||||||
"Erskine",
|
'Erskine',
|
||||||
"London",
|
'London',
|
||||||
"Hammersmith",
|
'Hammersmith',
|
||||||
"Islington",
|
'Islington',
|
||||||
"Silver", "Black", "Yellow", "Purple", 'White', 'Pink', 'Red', 'Orange','Brown','Green','Blue','Amber','Aqua','Azure','Bronze','Coral','Copper','Crimson','Cyan','Ginger','Gold','Indigo','Jade'
|
'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 () {
|
var numberCluster = function () {
|
||||||
return numbers.random() + numbers.random() + numbers.random();
|
return numbers.random() + numbers.random() + numbers.random();
|
||||||
};
|
};
|
||||||
|
|
||||||
var randomAmount = function (i) {
|
var randomAmount = function (i) {
|
||||||
var str = '';
|
var str = '';
|
||||||
|
|
||||||
for (var t = 0; t < i; t++) {
|
for (var t = 0; t < i; t++) {
|
||||||
str = str + alpha.random();
|
str = str + alpha.random();
|
||||||
}
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
||||||
generate: function (req, res) {
|
generate: function (req, res) {
|
||||||
var reply = {
|
var reply = {
|
||||||
long: (left.random() + ' ' + right.random() + ' ' + numberCluster() + ' ' + numberCluster()).split(' ').join(whitespace.random()),
|
long: (left.random() + ' ' + right.random() + ' ' + numberCluster() + ' ' + numberCluster()).split(' ').join(whitespace.random()),
|
||||||
short: randomAmount(10)
|
short: randomAmount(10)
|
||||||
};
|
};
|
||||||
|
|
||||||
res.setHeader('Content-Type', 'application/json');
|
res.setHeader('Content-Type', 'application/json');
|
||||||
res.end(JSON.stringify(reply));
|
res.end(JSON.stringify(reply));
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -70,10 +70,11 @@
|
|||||||
<li><a href="https://httpbin.org/">AJAX Endpoints</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://tools.bartlweb.net/webssh/">WebSSH</a></li>
|
||||||
<li><a href="http://jade-lang.com/demo/">Jade Tester</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>
|
</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>
|
||||||
<div class="mui-col-md-4">
|
<div class="mui-col-md-4">
|
||||||
<div class="mui--text-title mui-text-black">Bitcoin <span id="btc"></span></div>
|
<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.glqhymView = new TrainView({model: new TrainModel({from: 'glq', to: 'hym'})});
|
||||||
w.hymglqView = new TrainView({model: new TrainModel({from: 'hym', to: 'glq'})});
|
w.hymglqView = new TrainView({model: new TrainModel({from: 'hym', to: 'glq'})});
|
||||||
|
|
||||||
|
w.passwords = new PasswordView();
|
||||||
})(window);
|
})(window);
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -71,11 +71,11 @@
|
|||||||
<li><a href="https://tools.bartlweb.net/webssh/">WebSSH</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><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>
|
</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>
|
||||||
<div class="mui-col-md-4">
|
<div class="mui-col-md-4">
|
||||||
<div class="mui--text-title mui-text-black">Bitcoin <span id="btc"></span></div>
|
<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/fx.js"></script>
|
||||||
<script src="js/modules/train.js"></script>
|
<script src="js/modules/train.js"></script>
|
||||||
<script src="js/modules/weather.js"></script>
|
<script src="js/modules/weather.js"></script>
|
||||||
|
<script src="js/modules/password.js"></script>
|
||||||
<script src="app.js"></script>
|
<script src="app.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
@ -397,7 +398,7 @@
|
|||||||
w.glqhymView = new TrainView({model: new TrainModel({from: 'glq', to: 'hym'})});
|
w.glqhymView = new TrainView({model: new TrainModel({from: 'glq', to: 'hym'})});
|
||||||
w.hymglqView = new TrainView({model: new TrainModel({from: 'hym', to: 'glq'})});
|
w.hymglqView = new TrainView({model: new TrainModel({from: 'hym', to: 'glq'})});
|
||||||
|
|
||||||
|
w.passwords = new PasswordView();
|
||||||
|
|
||||||
})(window);
|
})(window);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user