Permalink
Browse files

Allow profiles to activate automatically for specific sites, via a "u…

…se with sites" list in profile options.

This is useful when sites implement a "change password every N days" policy.  Or, when sites have different password requirements like "no punctuation".

Simply add those sites to a different profile and forget about them.

Automatic activation is not persistent, to not interfere with normal usage.
  • Loading branch information...
wadetb committed Jul 27, 2011
1 parent 970a4a4 commit 129089915cababdf01f919dcca656f16ce8655e4
Showing with 49 additions and 7 deletions.
  1. +7 −0 html/options.html
  2. +2 −0 javascript/options.js
  3. +38 −7 javascript/popup.js
  4. +2 −0 javascript/profile.js
View
@@ -47,6 +47,13 @@ <h2>Profiles</h2>
<input class="standard" id="profileNameTB"/>
</div>
<div class="row">
<div class="subrow">
<label for="siteList">Use with sites:</label>
<input class="standard" id="siteList"/>
</div>
</div>
<div class="row">
<div class="url_example">
<span id="exprotocol">http://</span><span id="exsubdomain">my.</span><span id="exdomain">example.com</span><span id="expath">/my/path?q=search#top</span>
View
@@ -64,6 +64,7 @@ function removeProfile() {
function setCurrentProfile(profile) {
currentProfile = profile;
$("#profileNameTB").val(profile.title);
$("#siteList").val(profile.siteList);
$("#protocolCB").attr('checked', profile.url_protocol);
$("#subdomainCB").attr('checked', profile.url_subdomain);
$("#domainCB").attr('checked', profile.url_domain);
@@ -157,6 +158,7 @@ function highlightProfile(){
function saveProfile() {
currentProfile.title = $("#profileNameTB").val();
currentProfile.siteList = $("#siteList").val();
currentProfile.url_protocol = $("#protocolCB").attr('checked');
currentProfile.url_subdomain = $("#subdomainCB").attr('checked');
currentProfile.url_domain = $("#domainCB").attr('checked');
View
@@ -9,15 +9,36 @@ function setPasswordColors(foreground, background) {
$("#confirmation").css("color", foreground);
}
function getAutoProfileIdForUrl(url) {
var profiles = Settings.getProfiles();
for (var i in profiles) {
var profile = profiles[i];
if (profile.siteList) {
var profileUrl = profile.getUrl(url);
var sites = profile.siteList.split(' ');
if (sites.indexOf(profileUrl) != -1) {
return profile.id;
}
}
}
return null;
}
function updateFields(e) {
var password = $("#password").val();
var confirmation = $("#confirmation").val();
var usedtext = $("#usedtext").val();
var profileId = $("#profile").val();
if (profileId == "auto") {
profileId = getAutoProfileIdForUrl(usedtext);
} else {
Settings.setActiveProfileId(profileId);
}
var profile = Settings.getProfile(profileId);
Settings.setStoreLocation($("#store_location").val());
Settings.setPassword(password);
Settings.setActiveProfileId(profileId);
if (password == "") {
$("#generatedForClipboard").val("");
@@ -66,7 +87,11 @@ function matchesHash(password) {
}
function updateUsedText(url) {
var profile = Settings.getProfile($("#profile").val());
var profileId = $("#profile").val();
if (profileId == "auto") {
profileId = getAutoProfileIdForUrl(url);
}
var profile = Settings.getProfile(profileId);
$("#usedtext").val(profile.getUrl(url));
}
@@ -87,19 +112,25 @@ function showCopy() {
}
function init(url) {
var profiles = Settings.getProfiles();
Settings.getPassword(function(password) {
$("#password").val(password);
$("#confirmation").val(password);
var activeProfileId = Settings.getActiveProfileId();
var autoProfileId = getAutoProfileIdForUrl(url);
var options = "";
var profiles = Settings.getProfiles();
for (var i in profiles) {
var profile = profiles[i];
options += "<option value='"+profile.id+"'";
if (profile.id == Settings.getActiveProfileId()){
options += " selected='true' ";
if (autoProfileId && profile.id == autoProfileId) {
options += "<option value='auto' selected='true'";
} else if (!autoProfileId && profile.id == activeProfileId) {
options += "<option value='"+profile.id+"' selected='true'";
} else {
options += "<option value='"+profile.id+"'";
}
options += "'>"+profile.title+"</option>";
options += ">"+profile.title+"</option>";
}
$("#profile").empty().append(options);
View
@@ -2,6 +2,8 @@ function Profile() {
this.id = 1;
this.title = "Default";
this.siteList = "";
// Settings for the URL generation
this.url_protocol = false;
this.url_subdomain = false;

0 comments on commit 1290899

Please sign in to comment.