Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add password generation in the popup window #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@
"message": "Password type",
"description": ""
},

"master_key_tag": {
"message": "Master Key",
"description": ""
},

"add_profile": {
"message": "Add profile",
Expand Down
5 changes: 5 additions & 0 deletions _locales/es/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@
"message": "Tipo de contraseña",
"description": ""
},

"master_key_tag": {
"message": "Contraseña maestra",
"description": ""
},

"add_profile": {
"message": "Añadir perfil",
Expand Down
5 changes: 5 additions & 0 deletions _locales/it/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@
"message": "Tipo password",
"description": ""
},

"master_key_tag": {
"message": "Master password",
"description": ""
},

"add_profile": {
"message": "Aggiungi profilo",
Expand Down
11 changes: 11 additions & 0 deletions popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
<script type="text/javascript" src="constants.js"></script>
<script type="text/javascript" src="util.js"></script>
<script type="text/javascript" src="popup.js"></script>
<script type="text/javascript" src="lib/PasswordHasher.js"></script>
<script type="text/javascript" src="lib/sha1.js"></script>
<link href='http://fonts.googleapis.com/css?family=Roboto+Condensed' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="css/theme.css"/>
Expand Down Expand Up @@ -71,6 +73,15 @@ <h2>twik</h2>
<select name="password_type" id="password_type"></select>
</div>
</div> <!-- row -->
<div class="twik-row">
<div class="twik-cell">
<label i18n="master_key_tag"></label>
</div>
<div class="twik-cell">
<input type="password" name="master_key" id="master_key" size="20" />
<input type="input" name="password" id="password" size="20" />
</div>
</div> <!-- row -->
</div> <!-- table -->
<br/>
<a id="link-options" href="#" i18n="options"></a>
Expand Down
26 changes: 25 additions & 1 deletion popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,30 @@ var url;

bgPage = chrome.extension.getBackgroundPage();


function updatePassword() {
if ($('#master_key').val() != '') {
var settings = bgPage.getSiteSettings(url)
var passwordHasher = new PasswordHasher();
var sitePassword = passwordHasher.hashPassword(
$('#tag').val(),
$('#master_key').val(),
settings.private_key,
$('#password_length').val(),
$('#password_type').val()
);
$('#password').val(sitePassword);
}
else {
$('#password').val('');
}
}

window.onload = function() {
localizePage();
populateProfiles();
populatePasswordLength();
populatePasswordType();

// Select the profile and fill the settings
chrome.tabs.getSelected(null, function(tab) {
url = tab.url;
Expand All @@ -35,6 +53,11 @@ window.onload = function() {
updateValues();
setListeners();
});
$('#tag').bind('input', updatePassword)
$('#password_length').bind('input', updatePassword)
$('#password_type').bind('input', updatePassword)
$('#master_key').bind('input', updatePassword)
$('#master_key').focus()
}

function updateValues() {
Expand Down Expand Up @@ -67,3 +90,4 @@ function updateSiteSettings() {
};
bgPage.updateSiteSettings(url, settings, true);
}