1// Copyright (c) 2012 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5var gmail = "https://mail.google.com/mail/?extsrc=mailto&url=%s"; 6 7function toggle(radioButton) { 8 if (window.localStorage == null) { 9 alert('Local storage is required for changing providers'); 10 return; 11 } 12 if (document.getElementById('gmail').checked) { 13 window.localStorage.customMailtoUrl = gmail; 14 } else { 15 window.localStorage.customMailtoUrl = ""; 16 } 17} 18 19function main() { 20 if (window.localStorage == null) { 21 alert("LocalStorage must be enabled for changing options."); 22 document.getElementById('default').disabled = true; 23 document.getElementById('gmail').disabled = true; 24 return; 25 } 26 27 // Default handler is checked. If we've chosen another provider, we must 28 // change the checkmark. 29 if (window.localStorage.customMailtoUrl == gmail) 30 document.getElementById('gmail').checked = true; 31} 32 33document.addEventListener('DOMContentLoaded', function () { 34 main(); 35 document.querySelector('#default').addEventListener('click', toggle); 36 document.querySelector('#gmail').addEventListener('click', toggle); 37}); 38