Skip to content

Commit

Permalink
Merge pull request #12 from Iantra/master
Browse files Browse the repository at this point in the history
Fix #11 and issues from #10
  • Loading branch information
tma02 authored Jan 16, 2017
2 parents b5d50b6 + 37be7ae commit 25daf3f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 31 deletions.
2 changes: 0 additions & 2 deletions lib/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@ body {
height: calc(100vh + 40px);
-webkit-filter: blur(20px) brightness(35%);
overflow: hidden;
opacity: 0;
}

#cover {
position: absolute;
left: calc(50vw - 320px);
top: calc(50vh - 320px);
opacity: 0;
}

* {
Expand Down
23 changes: 1 addition & 22 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ ipc.on('coverUrl', function(url) {
});
ipc.on('title', function(title) {
document.getElementById('title').innerHTML = title;
document.getElementById('track-info').style.opacity = 1;
});
ipc.on('album', function(album) {
document.getElementById('album').innerHTML = album;
Expand All @@ -15,12 +16,6 @@ ipc.on('artist', function(artist) {
ipc.on('loadingText', function(text) {
document.getElementById('loading').innerHTML = text;
});
ipc.on('fadein', function() {
fadeIn(document.getElementById('cover'));
fadeIn(document.getElementById('background'));
fadeIn(document.getElementById('track-info'));
});

document.onkeydown = function(e) {
e = e || window.event;
if (e.keyCode == 27) { //ESC
Expand All @@ -30,19 +25,3 @@ document.onkeydown = function(e) {
}*/
};

function fadeIn(el) {
el.style.opacity = 0;

var last = +new Date();
var tick = function() {
el.style.opacity = +el.style.opacity + (new Date() - last) / 800;
last = +new Date();

if (+el.style.opacity < 1) {
(window.requestAnimationFrame && requestAnimationFrame(tick)) || setTimeout(tick, 10);
}
};

tick();
}
13 changes: 6 additions & 7 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ version = {};
version.running = false;
let csrf;
let oauth;
let albumId;
let currentTitle;
let coverUrl;

function copyConfig() {
Expand Down Expand Up @@ -161,11 +161,11 @@ function getCurrentAlbumId() {
config.path = '/remote/status.json?oauth=' + oauth + '&csrf=' + csrf + '&returnafter=1&returnon=' + DEFAULT_RETURN_ON.join();
getJson(config, function(data) {
try {
if (data.track.album_resource.uri.split(':')[2] !== albumId) {
console.log('found new album art.');
albumId = data.track.album_resource.uri.split(':')[2];
console.log('id:', albumId);
getAlbumCover(albumId);
if (data.track.track_resource.name !== currentTitle) {
console.log('found new song title.');
currentTitle = data.track.track_resource.name;
console.log('song title:', currentTitle);
getAlbumCover(data.track.album_resource.uri.split(':')[2]);
if (mainWindow !== null) {
mainWindow.webContents.send('title', data.track.track_resource.name);
mainWindow.webContents.send('album', data.track.album_resource.name);
Expand All @@ -190,7 +190,6 @@ function getAlbumCover(id) {
coverUrl = data.images[0].url;
if (mainWindow !== null) {
mainWindow.webContents.send('coverUrl', coverUrl);
mainWindow.webContents.send('fadein');
}
});
}
Expand Down

0 comments on commit 25daf3f

Please sign in to comment.