Skip to content

Commit

Permalink
Merge branch 'release/4.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
svenackermann committed Jul 18, 2016
2 parents b68a3ac + 99f2b8a commit bb3ab2c
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 35 deletions.
1 change: 0 additions & 1 deletion .jscsrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"disallowDanglingUnderscores": true,
"disallowEmptyBlocks": true,
"disallowMixedSpacesAndTabs": true,
"disallowMultipleLineBreaks": true,
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "primeplayer",
"version": "4.1.0",
"version": "4.2.0",
"dependencies": {
"jquery": "3.0.0",
"jquery": "3.1.0",
"npm-polymer-elements": "^0.0.1"
},
"devDependencies": {
Expand All @@ -15,7 +15,7 @@
"gulp-jscs": "^4.0.0",
"gulp-jscs-stylish": "^1.4.0",
"gulp-jshint": "^2.0.1",
"gulp-json-transform": "^0.3.2",
"gulp-json-transform": "^0.4.2",
"gulp-native2ascii": "^0.0.3",
"gulp-replace": "^0.5.4",
"gulp-sass": "^2.3.2",
Expand All @@ -27,8 +27,8 @@
"jshint": "^2.9.2",
"jshint-stylish": "^2.2.0",
"merge-stream": "^1.0.0",
"run-sequence": "^1.2.1",
"yargs": "^4.7.1"
"run-sequence": "^1.2.2",
"yargs": "^4.8.1"
},
"scripts": {
"preinstall": "npm i -g gulp-cli"
Expand Down
15 changes: 15 additions & 0 deletions src/_locales/de/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,21 @@
"setting_pauseOnIdleSec": {
"message": "Sekunden im Leerlauf, bevor die Musik pausiert wird"
},
"setting_keepAwakeLevel": {
"message": "System aktiv halten"
},
"setting_keepAwakeLevelHint": {
"message": "Hiermit kannst du verhindern, dass während Musik läuft der Computer oder Bildschirm wegen Inaktivität abgeschaltet oder in den Ruhemodus/Standby versetzt wird."
},
"setting_keepAwakeLevel_": {
"message": "nicht aktiv halten"
},
"setting_keepAwakeLevel_system": {
"message": "Computer aktiv halten"
},
"setting_keepAwakeLevel_display": {
"message": "Computer und Bildschirm aktiv halten"
},
"setting_preventCommandRatingReset": {
"message": "Setze Bewertungen niemals zurück, die nicht sichtbar sind"
},
Expand Down
20 changes: 20 additions & 0 deletions src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,26 @@
"message": "Seconds to be idle before music is paused",
"description": "label for option to set the seconds for pause on idle"
},
"setting_keepAwakeLevel": {
"message": "Keep system awake",
"description": "label for option to set the keep awake level"
},
"setting_keepAwakeLevelHint": {
"message": "Here you can prevent your system or screen from going to sleep due to inactivity while music is playing.",
"description": "hint for option to set the keep awake level"
},
"setting_keepAwakeLevel_": {
"message": "don't keep awake",
"description": "label for no keep awake level"
},
"setting_keepAwakeLevel_system": {
"message": "keep only system awake",
"description": "label for system keep awake level"
},
"setting_keepAwakeLevel_display": {
"message": "keep system and screen awake",
"description": "label for display keep awake level"
},
"setting_preventCommandRatingReset": {
"message": "Prevent rating resets without feedback",
"description": "label for option to prevent rating resets"
Expand Down
49 changes: 25 additions & 24 deletions src/js/beans.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,36 @@ function Bean(defaults, useLocalStorage) {
* If the value has been set but did not actually change, the callbacks won't be notified.
*/
this.al = function(props, listener, src) {
props.split(" ").forEach(function(prop) {
if (src) {
if (!srcListeners[src]) srcListeners[src] = [];
srcListeners[src].push({ l: listener, p: prop });
var wrappedCallback = listener._wrappedCallback;
if (!wrappedCallback) {
wrappedCallback = function() {
try {
return listener.apply(this, arguments);
} catch (e) {
console.error("error in listener for " + props, e);
}
};
listener._wrappedCallback = wrappedCallback;
}
props.split(/\s+/).forEach(function(prop) {
if (!callbacks[prop].has(wrappedCallback)) {
if (src) {
if (!srcListeners[src]) srcListeners[src] = [];
srcListeners[src].push({ l: listener, p: prop });
}
callbacks[prop].add(wrappedCallback);
}
if (callbacks[prop].every(function(cb) { return cb != listener; })) callbacks[prop].push(listener);
});
};

/** Removes a listener function for the given (space separated) properties. */
this.rl = function(props, listener) {
props.split(" ").forEach(function(prop) {
callbacks[prop].some(function(cb, i, cbs) {
if (listener == cb) {
cbs.splice(i, 1);
return true;
}
var wrappedCallback = listener._wrappedCallback;
if (wrappedCallback) {
props.split(/\s+/).forEach(function(prop) {
callbacks[prop].remove(wrappedCallback);
});
});
}
};

/** Either adds or removes (specified by 'add' argument) a listener function for the given (space separated) properties. */
Expand Down Expand Up @@ -203,20 +214,10 @@ function Bean(defaults, useLocalStorage) {
return val === old && (typeof val != "object" || val === null);
}

function notify(name, val, old) {
callbacks[name].forEach(function(listener) {
try {
listener(val, old, name);
} catch (e) {
console.error("error in listener for " + name, e);
}
});
}

/** Setup an object property with the given name */
function setting(name, defaultValue) {
cache[name] = parse(name, defaultValue);
callbacks[name] = [];
callbacks[name] = $.Callbacks();

Object.defineProperty(that, name, {
get: function() { return cache[name]; },
Expand All @@ -234,7 +235,7 @@ function Bean(defaults, useLocalStorage) {
}
cache[name] = val;
if (useSyncStorage) saveSyncStorage();
notify(name, val, old);
callbacks[name].fire(val, old, name);
},
enumerable: true
});
Expand Down
10 changes: 10 additions & 0 deletions src/js/bp.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ function fixForUri(string) {
pauseOnLock: false,
pauseOnIdle: false,
pauseOnIdleSec: 60,
keepAwakeLevel: "",
connectedIndicator: true,
preventCommandRatingReset: true,
autoActivateGm: true,
Expand Down Expand Up @@ -2085,6 +2086,15 @@ function fixForUri(string) {
updateBrowserActionInfo();
});

function keepAwake(playing) {
if (playing) chrome.power.requestKeepAwake(settings.keepAwakeLevel);
else chrome.power.releaseKeepAwake();
}
settings.w("keepAwakeLevel", function(val) {
player.wrl("playing", keepAwake, !!val);
if (!val) keepAwake(false);//release keep awake
});

function saveLastSongInfo(info) {
if (settings.saveLastPosition && googlemusicport) {//if info is null but we are still connected (playlist finished), clear the lastSong storage
chromeLocalStorage.set({ lastSong: info, lastPosition: song.position, rating: song.rating });
Expand Down
24 changes: 21 additions & 3 deletions src/js/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,26 @@ $(function() {
return playing;
}

function repeatGetter(el) {
el = $(el);
if (el.css("display") != "none" && enabledGetter(el)) {
if (el.hasClass("active")) {
var svgPath = el.find("path").attr("d");
// path for SINGLE_REPEAT is longer because of the "1" that is additionally drawn
if (svgPath) return svgPath.length > 64 ? "SINGLE_REPEAT" : "LIST_REPEAT";
}
return "NO_REPEAT";
}
return "";
}

/** @return shuffle state (NO_SHUFFLE/ALL_SHUFFLE) or null if shuffle is not available */
function shuffleGetter(el) {
return enabledGetter(el) ? el.getAttribute("value") : null;
el = $(el);
if (el.css("display") != "none" && enabledGetter(el)) {
return el.hasClass("active") ? "ALL_SHUFFLE" : "NO_SHUFFLE";
}
return "";
}

/** Execute 'executeOnContentLoad' (if set) when #queueContainer is changed. */
Expand Down Expand Up @@ -407,6 +424,7 @@ $(function() {
* @param fn function to execute, gets the jQuery object for the selector as parameter
* @param selector element(s) to be watched for DOM manipulation
* @param timeout time to wait after DOM manipulation before executing the function
* @param attributes if given, execute callback only if one of the (space-separated) attributes changes
*/
function watchContent(fn, selector, timeout, attributes) {
var content = $(selector);
Expand Down Expand Up @@ -483,8 +501,8 @@ $(function() {
watchAttr("class disabled", playerButtonPrefix + "play-pause']", "player-playing", playingGetter, 500);
watchAttr("class disabled", playerButtonPrefix + "rewind']", "player-rewind", enabledGetter);
watchAttr("class disabled", playerButtonPrefix + "forward']", "player-forward", enabledGetter);
watchAttr("value", playerButtonPrefix + "repeat']", "player-repeat");
watchAttr("value", playerButtonPrefix + "shuffle']", "player-shuffle", shuffleGetter);
watchAttr("title style disabled", playerButtonPrefix + "repeat']", "player-repeat", repeatGetter, 250);
watchAttr("class style disabled", playerButtonPrefix + "shuffle']", "player-shuffle", shuffleGetter);
watchAttr("aria-valuenow", "#material-vslider", "player-volume");

$("#music-content,#queueContainer").on("DOMSubtreeModified", ".song-row td[data-col='rating']", function() {
Expand Down
5 changes: 3 additions & 2 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Prime Player for Google Play Music\u2122",
"short_name": "__MSG_extTitle__",
"description": "__MSG_extDesc__",
"version": "4.1",
"version": "4.2",
"author": "Sven Ackermann",
"homepage_url": "https://chrome.google.com/webstore/detail/prime-player-for-google-p/npngaakpdgeaajbnidkkginekmnaejbi",
"minimum_chrome_version": "50",
Expand All @@ -18,7 +18,8 @@
"notifications",
"storage",
"contextMenus",
"idle"
"idle",
"power"
],
"optional_permissions": [ "http://www.songlyrics.com/*", "http://lyrics.wikia.com/*", "https://www.musixmatch.com/*" ],
"browser_action": {
Expand Down
1 change: 1 addition & 0 deletions src/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ <h3 id="iconClickActionTitle"></h3>
<pp-toggle class="v-3.0 adv" id="pauseOnLock"></pp-toggle>
<pp-toggle class="v-4.0.1 adv" id="pauseOnIdle" watched listener="subsEnabled"></pp-toggle>
<pp-input class="v-3.0 sub adv" id="pauseOnIdleSec" min="15"></pp-input>
<pp-select class="v-4.2 adv" id="keepAwakeLevel" options=",system,display" hint></pp-select>
<pp-input class="v-3.0 exp" id="skipSongSeconds" min="0" local></pp-input>
<pp-input class="v-2.14 exp" id="googleAccountNo" min="0" local hint></pp-input>
<pp-toggle class="v-2.0 exp" id="connectedIndicator"></pp-toggle>
Expand Down

0 comments on commit bb3ab2c

Please sign in to comment.