From 3038875533895fb50b676d586edaa9510c07eb5f Mon Sep 17 00:00:00 2001 From: jcass Date: Sat, 7 Oct 2017 09:52:31 +0200 Subject: [PATCH] Include details of currently selected page in HTML title tag. Fixes #243. --- README.rst | 1 + mopidy_musicbox_webclient/static/index.html | 2 +- mopidy_musicbox_webclient/static/js/gui.js | 17 ++++++++++++----- mopidy_musicbox_webclient/static/mb.appcache | 2 +- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/README.rst b/README.rst index 8d99f1b..00b7699 100644 --- a/README.rst +++ b/README.rst @@ -112,6 +112,7 @@ Changelog - Detect additional stream formats (rtmp, rtmps, rtsp). - Prevent excessive calls to the Mopidy server while buffering. (Fixes: `#237 `_). +- Include details of currently selected page in HTML title tag. (Addresses: `#243 `_). v2.4.0 (2017-03-15) ------------------- diff --git a/mopidy_musicbox_webclient/static/index.html b/mopidy_musicbox_webclient/static/index.html index f7b1eed..715c7b0 100644 --- a/mopidy_musicbox_webclient/static/index.html +++ b/mopidy_musicbox_webclient/static/index.html @@ -36,7 +36,7 @@ - +
diff --git a/mopidy_musicbox_webclient/static/js/gui.js b/mopidy_musicbox_webclient/static/js/gui.js index ee1d242..aaafd49 100644 --- a/mopidy_musicbox_webclient/static/js/gui.js +++ b/mopidy_musicbox_webclient/static/js/gui.js @@ -338,11 +338,12 @@ function switchContent (divid, uri) { function setHeadline (site) { site = site.trim() - str = $('.mainNav').find('a[href$=' + site + ']').text() - if (str === '') { - str = site.charAt(0).toUpperCase() + site.slice(1) + headline = $('.mainNav').find('a[href$=' + site + ']').text() + if (headline === '') { + headline = site.charAt(0).toUpperCase() + site.slice(1) } - $('#contentHeadline').html('' + str + '') + $('#contentHeadline').html('' + headline + '') + return headline } // update tracklist options. @@ -371,7 +372,8 @@ function locationHashChanged () { var divid = hash[0].substr(1) var uri = hash[1] - setHeadline(divid) + headline = setHeadline(divid) + updateDocumentTitle(headline) if ($(window).width() < 880) { $('#panel').panel('close') @@ -621,3 +623,8 @@ function updatePlayIcons (uri, tlid, popupMenuIcon) { }) } } + +function updateDocumentTitle (headline) { + headline = headline || $('#contentHeadline').text() + document.title = headline + ' | ' + $(document.body).data('title') +} diff --git a/mopidy_musicbox_webclient/static/mb.appcache b/mopidy_musicbox_webclient/static/mb.appcache index d9397c6..bc10b6f 100644 --- a/mopidy_musicbox_webclient/static/mb.appcache +++ b/mopidy_musicbox_webclient/static/mb.appcache @@ -1,6 +1,6 @@ CACHE MANIFEST -# 2017-04-14:v1 +# 2017-10-07:v1 NETWORK: *