forked from GoogleChrome/chrome-extensions-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.js
37 lines (32 loc) · 1.19 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
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
var gmail = "https://mail.google.com/mail/?extsrc=mailto&url=%s";
function toggle(radioButton) {
if (window.localStorage == null) {
alert('Local storage is required for changing providers');
return;
}
if (document.getElementById('gmail').checked) {
window.localStorage.customMailtoUrl = gmail;
} else {
window.localStorage.customMailtoUrl = "";
}
}
function main() {
if (window.localStorage == null) {
alert("LocalStorage must be enabled for changing options.");
document.getElementById('default').disabled = true;
document.getElementById('gmail').disabled = true;
return;
}
// Default handler is checked. If we've chosen another provider, we must
// change the checkmark.
if (window.localStorage.customMailtoUrl == gmail)
document.getElementById('gmail').checked = true;
}
document.addEventListener('DOMContentLoaded', function () {
main();
document.querySelector('#default').addEventListener('click', toggle);
document.querySelector('#gmail').addEventListener('click', toggle);
});