-
Notifications
You must be signed in to change notification settings - Fork 1
/
js.js
56 lines (56 loc) · 1.54 KB
/
js.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
$(document).ready(function(){
$("#gen_pass").click(function () {
if($("#char").prop("checked"))
$("#new_pass").empty().text(rand_str_c(parseInt($("#num_c").val())));
else
$("#new_pass").empty().append(rand_str(parseInt($("#num_c").val())));
});
$("#ins_to_input").change(function () {
if($("#ins_to_input").prop("checked")) {
chrome.storage.sync.set({'ins_to_input': "true"});
}else{
chrome.storage.sync.set({'ins_to_input': "false"});
}
});
$("#on").change(function () {
if($("#on").prop("checked")) {
chrome.storage.sync.set({'on': "true"});
}else{
chrome.storage.sync.set({'on': "false"});
}
});
});
chrome.storage.sync.get("ins_to_input", function (obj) {
if (obj.ins_to_input!==null) {
if (obj.ins_to_input == "true") {
$("#ins_to_input").attr("checked","checked");
}else{
$("#ins_to_input").removeAttr("checked");
}
}
});
chrome.storage.sync.get("on", function (obj) {
if (obj.on!==null) {
if (obj.on == "true") {
$("#on").attr("checked","checked");
}else{
$("#on").removeAttr("checked");
}
}
});
function rand_str(n){
var s ='';
while(s.length < n)
s += Math.random().toString(36).slice(2, 12);
return s.substr(0, n);
}
function rand_str_c(n) {
var result = '';
var words = '0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM!@"#№$;%^:&?*()[]{}\'|/.,<>+=-_`~';
var max_position = words.length - 1;
for( i = 0; i < n; ++i ) {
position = Math.floor ( Math.random() * max_position );
result = result + words.substring(position, position + 1);
}
return result;
}