aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/utils.js
diff options
context:
space:
mode:
authorSam Potts <sam@potts.es>2018-04-02 22:40:03 +1000
committerSam Potts <sam@potts.es>2018-04-02 22:40:03 +1000
commit3395e8df903cdd63e227a377b4b3be77da682aa8 (patch)
tree41821293f126cccdd5089aa7cf64a12b14ecb37a /src/js/utils.js
parentcce143a7da5f47e8cffa9a255239288387efe193 (diff)
downloadplyr-3395e8df903cdd63e227a377b4b3be77da682aa8.tar.lz
plyr-3395e8df903cdd63e227a377b4b3be77da682aa8.tar.xz
plyr-3395e8df903cdd63e227a377b4b3be77da682aa8.zip
HTML5 quality selection
Diffstat (limited to 'src/js/utils.js')
-rw-r--r--src/js/utils.js15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/js/utils.js b/src/js/utils.js
index e9687a14..dd1466df 100644
--- a/src/js/utils.js
+++ b/src/js/utils.js
@@ -586,15 +586,15 @@ const utils = {
},
// Trigger event
- dispatchEvent(element, type, bubbles, detail) {
+ dispatchEvent(element, type = '', bubbles = false, detail = {}) {
// Bail if no element
- if (!utils.is.element(element) || !utils.is.string(type)) {
+ if (!utils.is.element(element) || utils.is.empty(type)) {
return;
}
// Create and dispatch the event
const event = new CustomEvent(type, {
- bubbles: utils.is.boolean(bubbles) ? bubbles : false,
+ bubbles,
detail: Object.assign({}, detail, {
plyr: utils.is.plyr(this) ? this : null,
}),
@@ -737,6 +737,15 @@ const utils = {
return utils.extend(target, ...sources);
},
+ // Remove duplicates in an array
+ dedupe(array) {
+ if (!utils.is.array(array)) {
+ return array;
+ }
+
+ return array.filter((item, index) => array.indexOf(item) === index);
+ },
+
// Get the provider for a given URL
getProviderByUrl(url) {
// YouTube