|
|
@ -67,14 +67,14 @@ const displayCarbonUsage = async (apiKey, region) => {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// set up api key and region
|
|
|
|
// set up api key and region
|
|
|
|
const setUpUser = async (apiKey, regionName) => {
|
|
|
|
const setUpUser = async (apiKey, region) => {
|
|
|
|
localStorage.setItem('apiKey', apiKey);
|
|
|
|
localStorage.setItem('apiKey', apiKey);
|
|
|
|
localStorage.setItem('regionName', regionName);
|
|
|
|
localStorage.setItem('region', region);
|
|
|
|
loading.style.display = 'block';
|
|
|
|
loading.style.display = 'block';
|
|
|
|
errors.textContent = '';
|
|
|
|
errors.textContent = '';
|
|
|
|
clearBtn.style.display = 'block';
|
|
|
|
clearBtn.style.display = 'block';
|
|
|
|
//make initial call
|
|
|
|
//make initial call
|
|
|
|
displayCarbonUsage(apiKey, regionName);
|
|
|
|
displayCarbonUsage(apiKey, region);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// handle form submission
|
|
|
|
// handle form submission
|
|
|
@ -87,7 +87,7 @@ const handleSubmit = async (e) => {
|
|
|
|
const init = async () => {
|
|
|
|
const init = async () => {
|
|
|
|
//if anything is in localStorage, pick it up
|
|
|
|
//if anything is in localStorage, pick it up
|
|
|
|
const storedApiKey = localStorage.getItem('apiKey');
|
|
|
|
const storedApiKey = localStorage.getItem('apiKey');
|
|
|
|
const storedRegion = localStorage.getItem('regionName');
|
|
|
|
const storedRegion = localStorage.getItem('region');
|
|
|
|
|
|
|
|
|
|
|
|
//set icon to be generic green
|
|
|
|
//set icon to be generic green
|
|
|
|
chrome.runtime.sendMessage({
|
|
|
|
chrome.runtime.sendMessage({
|
|
|
@ -116,7 +116,7 @@ const init = async () => {
|
|
|
|
const reset = async (e) => {
|
|
|
|
const reset = async (e) => {
|
|
|
|
e.preventDefault();
|
|
|
|
e.preventDefault();
|
|
|
|
//clear local storage for region only
|
|
|
|
//clear local storage for region only
|
|
|
|
localStorage.removeItem('regionName');
|
|
|
|
localStorage.removeItem('region');
|
|
|
|
init();
|
|
|
|
init();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|