Commit 6a3a5f02 authored by Josef Hoppe's avatar Josef Hoppe
Browse files

done

parent f794cb64
......@@ -3,7 +3,9 @@
"description": "password generator",
"main": "index.html",
"dependencies": {
"polymer": "Polymer/polymer#^1.4.0"
"polymer": "Polymer/polymer#^1.4.0",
"paper-input": "PolymerElements/paper-input#^1.1.18",
"paper-material": "PolymerElements/paper-material#^1.0.6"
},
"devDependencies": {
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
......
<!doctype html>
<html>
<head>
<title>random-passwords</title>
<title>Password Generator</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="manifest" href="/manifest.json">
<script src="/bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="/src/random-passwords-app/random-passwords-app.html">
<script src="bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="src/random-passwords-app/random-passwords-app.html">
</head>
<body>
<random-passwords-app></random-passwords-app>
</body>
</html>
<link rel="import" href="../../bower_components/polymer/polymer.html">
<link rel="import" href="../../bower_components/paper-input/paper-input.html">
<link rel="import" href="../../bower_components/paper-button/paper-button.html">
<link rel="import" href="../../bower_components/paper-material/paper-material.html">
<dom-module id="random-passwords-app">
<template>
......@@ -6,8 +9,23 @@
:host {
display: block;
}
#main {
max-width: 400px;
margin-left: auto;
margin-right: auto;
padding: 10px;
}
</style>
<h2>Hello [[prop1]]</h2>
<paper-material id="main">
<paper-input label="Anzahl Passwörter" value="{{count}}" type="number"></paper-input>
<paper-input label="Passwortlänge" value="{{length}}" type="number"></paper-input>
<paper-input label="Zeichensatz" value="{{charset}}"></paper-input>
<paper-button on-tap="_generate">Generieren</paper-button>
<div id="pwDiv">
</div>
</paper-material>
</template>
<script>
......@@ -16,12 +34,61 @@
is: 'random-passwords-app',
properties: {
prop1: {
type: String,
value: 'random-passwords-app',
count: {
type: Number,
value: 5
},
passwords: {
type: Array,
value: []
},
length: {
type: Number,
value: 8
},
charset: {
type: String,
value: "abcdefghijklmnopqrstuvwxyzöäüABCDEFGHIJKLMNOPQRSTUVWXYZÖÄÜ0123456789!§$%&/()=?{[]}\\,.-;:_<>"
}
},
_generate: function() {
var passwords = [];
for (var i = 0; i < this.count; i++) {
passwords.push("<p>" + this._escapeHtml(this._generatePassword()) + "</p>");
}
this.$.pwDiv.innerHTML = passwords.join("");
},
_escapeHtml: function(string) {
var entityMap = {
"&": "&amp;",
"<": "&lt;",
">": "&gt;",
'"': '&quot;',
"'": '&#39;',
"/": '&#x2F;'
};
return String(string).replace(/[&<>"'\/]/g, function(s) {
return entityMap[s];
});
},
_getValue: function(item) {
console.log(item);
return JSON.stringify(item);
},
_generatePassword: function() {
var retVal = "";
for (var i = 0, n = this.charset.length; i < this.length; ++i) {
retVal += this.charset.charAt(Math.floor(Math.random() * n));
}
return retVal;
}
});
</script>
</dom-module>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment