31 lines
No EOL
806 B
JavaScript
31 lines
No EOL
806 B
JavaScript
const setTheme = (theme) => {
|
|
document.documentElement.className = theme;
|
|
localStorage.setItem('theme', theme);
|
|
}
|
|
|
|
const hasCodeRun = localStorage.getItem('hasCodeRun');
|
|
|
|
if (!hasCodeRun) {
|
|
const defaultTheme = "{{ config.extra.default_theme }}";
|
|
setTheme(defaultTheme);
|
|
localStorage.setItem('hasCodeRun', 'true');
|
|
}
|
|
|
|
const getTheme = () => {
|
|
const theme = localStorage.getItem('theme');
|
|
if (theme) {
|
|
setTheme(theme);
|
|
}
|
|
}
|
|
|
|
getTheme();
|
|
|
|
let user = 'ameiro';
|
|
let url = 'https://lastfm-last-played.biancarosa.com.br/' + user + '/latest-song';
|
|
let song = document.querySelector('#song');
|
|
fetch(url)
|
|
.then(function (response) {
|
|
return response.json()
|
|
}).then(function (json) {
|
|
song.innerHTML = json['track']['name'] + ' - ' + json['track']['artist']['#text'];
|
|
}); |