Created
September 1, 2014 05:22
-
-
Save cheesinglee/1a84c5d97253c0660353 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Saves options to chrome.storage | |
function save_options() { | |
var username = document.getElementById('username').value; | |
var apikey = document.getElementById('apikey').value; | |
chrome.storage.sync.set({ | |
username: username, | |
apikey: apikey | |
}, function() { | |
// Update status to let user know options were saved. | |
chrome.runtime.sendMessage({greeting:"fetchmodel"}) ; | |
var status = document.getElementById('status'); | |
status.textContent = 'Options saved.'; | |
setTimeout(function() { | |
status.textContent = ''; | |
}, 750); | |
}); | |
} | |
// Restores select box and checkbox state using the preferences | |
// stored in chrome.storage. | |
function restore_options() { | |
// Use default value color = 'red' and likesColor = true. | |
chrome.storage.sync.get({ | |
username: 'BigML Username', | |
apikey: 'BigML API Key' | |
}, function(items) { | |
document.getElementById('username').value = items.username; | |
document.getElementById('apikey').value = items.apikey; | |
}); | |
} | |
document.addEventListener('DOMContentLoaded', restore_options); | |
document.getElementById('save').addEventListener('click', | |
save_options); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment