Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

moved weatherKey and coordinates to local storage #141

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,34 @@
// │ │ ││││├┤ ││ ┬│ │├┬┘├─┤ │ ││ ││││
// └─┘└─┘┘└┘└ ┴└─┘└─┘┴└─┴ ┴ ┴ ┴└─┘┘└┘

// credit to @Lainfall for the original apikey function https://github.com/Lainfall/SP/blob/master/assets/js/weather.js
function getWeatherKey() {
const currentKey = localStorage.getItem("WEATHER_KEY");
if (currentKey) return currentKey;

const newKey = window.prompt("What's your Weather API key?");
localStorage.setItem("WEATHER_KEY", newKey);
return newKey;
}

function getLat() {
const currentLat = localStorage.getItem("LAT");
if (currentLat) return currentLat;

const newLat = window.prompt("Whats your Latitude");
localStorage.setItem("LAT", newLat);
return newLat;
}

function getLong(){
const currentLong = localStorage.getItem("LONG");
if (currentLong) return currentLong;

const newLong = window.prompt("Whats your Longitude");
localStorage.setItem("LONG", newLong);
return newLong;
}

const CONFIG = {
// ┌┐ ┌─┐┌─┐┬┌─┐┌─┐
// ├┴┐├─┤└─┐││ └─┐
Expand All @@ -26,14 +54,14 @@ const CONFIG = {
bentoLayout: 'bento', // 'bento', 'lists', 'buttons'

// Weather
weatherKey: 'InsertYourAPIKeyHere123456', // Write here your API Key
weatherKey: getWeatherKey(), // Write here your API Key
weatherIcons: 'OneDark', // 'Onedark', 'Nord', 'Dark', 'White'
weatherUnit: 'C', // 'F', 'C'
language: 'en', // More languages in https://openweathermap.org/current#multi

trackLocation: true, // If false or an error occurs, the app will use the lat/lon below
defaultLatitude: '37.775',
defaultLongitude: '-122.419',
defaultLatitude: getLat(),
defaultLongitude: getLong(),

// Autochange
autoChangeTheme: true,
Expand Down