Page title

This commit is contained in:
James Barnsley
2016-12-15 12:54:41 +13:00
parent a4f5f25636
commit 22d930cba5
4 changed files with 46 additions and 2 deletions

View File

@ -310,4 +310,32 @@ export let sortItems = function (array, property, reverse = false){
**/
export let isNumeric = function (data) {
return !isNaN(parseFloat(data)) && isFinite(data)
}
/**
* Set window title
* @param track
**/
export let setWindowTitle = function (track = false, play_state = false){
var title = 'No track playing'
if (track) {
var icon = '\u25A0 '
var artistString = ''
if (track.artists) {
for( var i = 0; i < track.artists.length; i++) {
if (artistString != '') artistString += ', '
artistString += track.artists[i].name
}
}
if (play_state && play_state == 'playing') icon = '\u25B6 '
title = icon +' '+ track.name +' - '+ artistString
}
document.title = title
}

View File

@ -23,7 +23,6 @@ const UIMiddleware = (function(){
3000
)
// we don't want to stop things happening as usual
next(action)
break
@ -31,7 +30,17 @@ const UIMiddleware = (function(){
store.dispatch(uiActions.createNotification('Added '+action.tracks_uris.length+' tracks to playlist'))
// we don't want to stop things happening as usual
next(action)
break
case 'MOPIDY_STATE':
helpers.setWindowTitle(store.getState().ui.current_track, action.data)
next(action)
break
case 'MOPIDY_CURRENTTLTRACK':
if( action.data && action.data.track ) helpers.setWindowTitle(action.data.track, store.getState().mopidy.play_state)
next(action)
break

View File

@ -76,6 +76,7 @@ main {
padding: 20px;
background: $faint_grey;
white-space: pre-wrap;
word-wrap: break-word;
}
}

View File

@ -54,4 +54,10 @@
section {
padding: 40px;
}
@include responsive( $bp_medium ){
section {
padding: 20px;
}
}
}