Skip to content
This repository has been archived by the owner on Jan 19, 2023. It is now read-only.

Commit

Permalink
Add optional page title changer, #183
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkgroenen committed Feb 25, 2016
1 parent 918ea88 commit b309d7e
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ nosetests.xml
*.egg-info
Mopidy_Mopify.egg-info/
mopidy_mopify/sync.ini
.cache
.cache
10 changes: 7 additions & 3 deletions src/app/account/settings/settings.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ angular.module('mopify.account.settings', [
* After defining the routes we create the controller for this module
*/
.controller("SettingsController", function SettingsController($scope, $rootScope, $timeout, $http, localStorageService, Settings, VersionManager, AutoUpdate, notifier){

// bind settings with the $scope
Settings.bind($scope);

// Set default value
if($scope.settings.pagetitle === undefined)
$scope.settings.pagetitle = true;

$scope.buttonactive = false;
$scope.autoupdate = false;

Expand All @@ -49,9 +53,9 @@ angular.module('mopify.account.settings', [
VersionManager.checkVersion().then(function(version){
$scope.newversion = VersionManager.newVersion;
$scope.newversionnumber = VersionManager.lastversion;
});
});
}

// Run at init
checkVersion();

Expand Down
25 changes: 22 additions & 3 deletions src/app/account/settings/settings.tmpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<div class="col-md-3 col-md-offset-6 alignright">
<div class="button white" ng-class="{ active: buttonactive }">
<span class="text">Saved automatically</span>
<i class="ss-icon ss-sync"></i>
<i class="ss-icon ss-sync"></i>
</div>
</div>
</div>
Expand Down Expand Up @@ -114,6 +114,25 @@
</div>
</div>

<div class="pagetitle row">
<div class="col-md-3">
Settings <span class="sub">Title</span>
</div>
</div>
<div class="pagecontent row">
<div class="settingwrap row">
<div class="label col-md-2">
<label>Show current track in page title</label>
</div>
<div class="input col-md-4">
<toggle-switch ng-model="settings.pagetitle"><toggle-switch>
</div>
<div class="description col-md-4 col-md-offset-1">
<p>Enable this function to show the currnet playing track in the page title. Some people don't like this bedause it will make your pinned tab 'glow' in Chrome.</p>
</div>
</div>
</div>

<div class="pagetitle row">
<div class="col-md-3">
About <span class="sub">Mopify</span>
Expand Down Expand Up @@ -155,11 +174,11 @@
<p ng-if="newversion" style="font-weight: bold">A new version of Mopify is available ({{ newversionnumber }}). Read the <a href="https://github.com/dirkgroenen/mopidy-mopify/blob/master/README.md" target="_blank">Github readme</a> on how to update mopify or use the button below.</p>
<div class="button white fullwidth" ng-click="update()" ng-if="newversion == true && autoupdate == true">
<span class="text">Autoupdate Mopify to version: {{ newversionnumber }}</span>
<i class="ss-icon ss-refresh"></i>
<i class="ss-icon ss-refresh"></i>
</div>
<div class="button white fullwidth" ng-if="newversion == true && autoupdate == false">
<span class="text">Autoupdate isn't possible. Is Mopidy running as root user?</span>
<i class="ss-icon ss-refresh"></i>
<i class="ss-icon ss-refresh"></i>
</div>
</div>
</div>
Expand Down
6 changes: 5 additions & 1 deletion src/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ angular.module('mopify', [
'mopify.services.mopidy',
'mopify.services.versionmanager',
'mopify.services.autoupdate',
"mopify.services.settings",
'spotify',
'mopify.dashboard',
'mopify.search',
Expand Down Expand Up @@ -52,7 +53,7 @@ angular.module('mopify', [
$httpProvider.interceptors.push('SpotifyAuthenticationIntercepter');
})

.controller("AppController", function AppController($scope, $rootScope, $http, $location, $window, mopidyservice, notifier, VersionManager, localStorageService, AutoUpdate, prompt){
.controller("AppController", function AppController($scope, $rootScope, $http, $location, $window, mopidyservice, notifier, VersionManager, localStorageService, AutoUpdate, prompt, Settings){
var connectionStates = {
online: 'Online',
offline: 'Offline'
Expand Down Expand Up @@ -120,6 +121,9 @@ angular.module('mopify', [
* @param object track
*/
function updateTitle(track){
if(!Settings.get("pagetitle", true))
return false;

if(track !== null && track !== undefined){
if(track.name.indexOf("[loading]") > -1){
mopidyservice.lookup(track.uri).then(function(result){
Expand Down
10 changes: 5 additions & 5 deletions src/app/services/settings.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@ angular.module("mopify.services.settings", [

/**
* Get a value from the storage, or return the defaltvalue if it doesn't exist.
* @param {string} key
* @param {string} defaultvalue
* @param {string} key
* @param {string} defaultvalue
*/
Settings.prototype.get = function(key, defaultvalue){
return (localStorageService.get(rootkey) !== null && localStorageService.get(rootkey)[key] !== undefined && localStorageService.get(rootkey)[key] !== "") ? localStorageService.get(rootkey)[key] : defaultvalue;
};

/**
* Save a (new) value
* @param {string} key
* @param {string} value
* @param {string} key
* @param {string} value
* @param {boolean} extend
*/
Settings.prototype.set = function(key, value, extend){
extend = (extend === undefined) ? true : false;

// Set settings and set new key and value
var settings = localStorageService.get(rootkey);

// Extend value if exists
if(settings[key] !== null && settings[key] !== undefined && extend === true){
value = angular.extend(settings[key], value);
Expand Down

0 comments on commit b309d7e

Please sign in to comment.