Skip to content

Commit

Permalink
make vol change handling on generic funct
Browse files Browse the repository at this point in the history
  • Loading branch information
lejenome committed Dec 20, 2014
1 parent 1938fb0 commit aeb40b5
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 30 deletions.
1 change: 1 addition & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"onReady",
"onInit",
"getPreferredFmt",
"handleVolChange",
"asyncGet"
]
}
6 changes: 1 addition & 5 deletions data/break.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@
document.body.innerHTML = "";
document.head.innerHTML = "";
document.body.appendChild(player);
onPrefChange.push(function(pref) {
if (player && pref === "volume") {
player.volume = OPTIONS[pref] / 100;
}
});
handleVolChange(player);
}

function fallback() {
Expand Down
8 changes: 8 additions & 0 deletions data/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ function logify(...args) {
console.log.apply(console, args.map(s => JSON.stringify(s, null, 2)));
}

function handleVolChange(player) {
onPrefChange.push(function(pref) {
if (player && pref === "volume") {
player.volume = OPTIONS[pref] / 100;
}
});
}

function onReady(f) {
//TODO: document readyState is "loading" (and DOMECotentLoaded) even DOM elements are
//accessible
Expand Down
6 changes: 1 addition & 5 deletions data/dailymotion.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@

document.body.innerHTML = "";
document.body.appendChild(player);
onPrefChange.push(function(pref) {
if (player && pref === "volume") {
player.volume = OPTIONS[pref] / 100;
}
});
handleVolChange(player);
}
}());
6 changes: 1 addition & 5 deletions data/facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@

document.getElementsByClassName("_53j5")[0].innerHTML = "";
document.getElementsByClassName("_53j5")[0].appendChild(player);
onPrefChange.push(function(pref) {
if (player && pref === "volume") {
player.volume = OPTIONS[pref] / 100;
}
});
handleVolChange(player);
}
}());
6 changes: 1 addition & 5 deletions data/metacafe.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@
return;
container.innerHTML = "";
container.appendChild(player);
onPrefChange.push(function(pref) {
if (player && pref === "volume") {
player.volume = OPTIONS[pref] / 100;
}
});
handleVolChange(player);
}

function channelPage() {
Expand Down
6 changes: 1 addition & 5 deletions data/vimeo.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@
// type: conf.type
}));
player_container.appendChild(player);
onPrefChange.push(function(pref) {
if (player && pref === "volume") {
player.volume = OPTIONS[pref] / 100;
}
});
handleVolChange(player);
} catch (e) {
console.error("Exception on changePlayer()", e.lineNumber, e.columnNumber, e.message, e.stack);
}
Expand Down
6 changes: 1 addition & 5 deletions data/youtube.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
window.addEventListener("spfdone", function() {
changePlayer();
});
onPrefChange.push(function(pref) {
if (player && pref === "volume") {
player.volume = OPTIONS[pref] / 100;
}
});
handleVolChange(player);
}
onReady(main);

Expand Down

0 comments on commit aeb40b5

Please sign in to comment.