-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathoptions.js
58 lines (53 loc) · 1.66 KB
/
options.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
function msg(title, message){
chrome.notifications.create(
'name-for-notification', {
type: 'basic',
iconUrl: 'icon48.png',
title: title,
message: message
},
function() {}
);
}
var demoSettings = {
"Deep Auto Fill Chrome Demo" : {
"randomLocale" : "de",
"fields" : [
{
"selector" : "#textbox2",
"random": "A bunch of random values: {{name.lastName}}, {{name.firstName}} {{name.suffix}}"
},
{
"selector" : "input[name=textbox1]",
"random": "A bunch of another random values: {{internet.email}}, {{helpers.createCard}} {{address.secondaryAddress}}",
"static" : "A static value"
},
{
"selector" : "#textbox4",
"static" : "A static value"
}
]
}
}
jQuery(function($){
var text = localStorage.settings ? localStorage.settings : JSON.stringify(demoSettings, null, '\t');
var editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai");
editor.getSession().setMode("ace/mode/javascript");
editor.getSession().setValue(text);
editor.commands.addCommand({
name: 'save_settings',
bindKey: {win: "Ctrl-S", "mac": "Cmd-S"},
exec: function(editor) {
try {
var data = editor.session.getValue();
var parsedData = JSON.parse(data); // try it to see if setting are valid
localStorage.settings = data;
chrome.runtime.reload();
msg("Settings saved successfully", "☑️"); // error in the above string (in this case, yes)!
} catch(e) {
msg("⚠️ Error", e); // error in the above string (in this case, yes)!
}
}
})
});