-
Notifications
You must be signed in to change notification settings - Fork 21
/
popup.js
61 lines (55 loc) · 2.15 KB
/
popup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
var url;
var config;
function writeModel () {
config.tag = $('#tag').val ();
if (config.tag.startsWith ("compatible:")) {
config.tag = config.tag.substringAfter ("compatible:");
delete config.policy.seed;
} else {
config.policy.seed = config.options.privateSeed;
}
config.policy.length = $('#length').val ();
config.policy.strength = $('#strength').val ();
chrome.extension.getBackgroundPage ().saveConfig (url, config);
if(null == config.policy.seed || config.policy.seed == config.options.privateSeed) {
$("#syncneeded").addClass("hidden");
}
}
function readModel () {
$('#tag').val (config.tag);
$('#tag').autocomplete ({ source: chrome.extension.getBackgroundPage ().loadTags () });
$('#length').val (config.policy.length);
$('#strength').val (config.policy.strength);
if (true == config.options.compatibilityMode) {
$('div#compatmodeheader').html ("<b>Compatibility:</b>");
$('div#compatmode').text ("on");
} else if (null == config.policy.seed) {
$('#tag').val ("compatible:" + config.tag);
}
if (false == config.options.backedUp && false == config.options.compatibilityMode) {
$('div#compatmodeheader').html ("<b>Warning:</b>");
$('div#compatmode').text ("You have not yet indicated that you have backed up your private key. Please do so on the Options page.");
}
if(null != config.policy.seed && config.policy.seed != config.options.privateSeed) {
$("#syncneeded").removeClass("hidden");
}
}
chrome.tabs.getSelected (null, function (tab) {
url = chrome.extension.getBackgroundPage ().grepUrl (tab.url);
config = chrome.extension.getBackgroundPage ().loadConfig (url);
config.fields = toSet (config.fields);
readModel ();
});
$('#bump').click (function () {
$("#tag").val (bump ($("#tag").val ()));
writeModel ();
});
$('#tag').change (writeModel);
$('#length').change (writeModel);
$('#strength').change (writeModel);
$(document).ready(function() {
$('#link-options').click(function() {
chrome.tabs.create({url:'chrome-extension://'+location.hostname+'/options.html'})
});
$('#portablePage').click(function() {chrome.tabs.create({url:'chrome-extension://'+location.hostname+'/passhashplus.html?tag=' + $('#tag').val()})});
})