Bug Fixes to improve debugging.

This commit is contained in:
Michael Peters 2019-09-30 10:31:20 -04:00
parent 75284afdfc
commit 641161a912
2 changed files with 11 additions and 16 deletions

View File

@ -118,16 +118,6 @@ UI.init = function () {
electron.ipcRenderer.on('extension-connect', (event) => { UI.onExtensionConnect(); }); electron.ipcRenderer.on('extension-connect', (event) => { UI.onExtensionConnect(); });
electron.ipcRenderer.on('extension-disconnect', (event) => { UI.onExtensionDisconnect(); }); electron.ipcRenderer.on('extension-disconnect', (event) => { UI.onExtensionDisconnect(); });
let restartButton = document.getElementById('restart');
let skipButton = document.getElementById('skip');
restartButton.addEventListener('click', (event) => {
electron.ipcRenderer.send('restart-song');
});
skipButton.addEventListener('click', (event) => {
electron.ipcRenderer.send('skip-song');
});
} }
document.addEventListener('DOMContentLoaded', UI.init); document.addEventListener('DOMContentLoaded', UI.init);

View File

@ -59,10 +59,14 @@ function checkSong() {
artists.push(artistElement.innerText); artists.push(artistElement.innerText);
} }
let albumArtLinkStyle = albumArtElement.getAttribute('style'); let albumArtStyle = albumArtElement.getAttribute('style');
albumArtLink = albumArtLinkStyle.substring('background-image: url("'.length, albumArtLinkStyle.length - '");'.length);
albumArt = albumArtStyle.substring('background-image: url("'.length, albumArtStyle.length - '");'.length);
if (name != song.name || artists.join(', ') != song.artists.join(', ')) { if (name != song.name || artists.join(', ') != song.artists.join(', ')) {
console.log('name: ' + name);
console.log('artists: ' + artists.join(', '));
console.log('album art style: ' + albumArtStyle);
// new song // new song
song = { song = {
guid: uuidv4(), guid: uuidv4(),
@ -70,7 +74,7 @@ function checkSong() {
artists: artists, artists: artists,
album: { album: {
name: 'Unknown Album', name: 'Unknown Album',
art: albumArtLink art: albumArt
} }
}; };
console.log('new song', song); console.log('new song', song);
@ -91,12 +95,13 @@ function checkSong() {
let albumName = albumNameElement ? albumNameElement.getAttribute('title') : 'Unknown Album'; let albumName = albumNameElement ? albumNameElement.getAttribute('title') : 'Unknown Album';
let albumArtFullLinkStyle = albumArtFullElement.getAttribute('style'); let albumArtFullStyle = albumArtFullElement.getAttribute('style');
let albumArtFullLink = albumArtLinkStyle.substring('background-image: url("'.length, albumArtFullLinkStyle.length - 3); console.log('album art full style: ' + albumArtFullStyle);
let albumArtFull = albumArtFullStyle.substring('background-image: url("'.length, albumArtFullStyle.length - 3);
song.duration = duration; song.duration = duration;
song.album.name = albumName; song.album.name = albumName;
song.album.artFull = albumArtFullLink; song.album.artFull = albumArtFull;
onUpdateSong(song); onUpdateSong(song);
}, 5000); // give 5 seconds to load }, 5000); // give 5 seconds to load