summaryrefslogtreecommitdiffstats
path: root/assets/js
diff options
context:
space:
mode:
Diffstat (limited to 'assets/js')
-rw-r--r--assets/js/_helpers.js11
-rw-r--r--assets/js/handlers.js2
-rw-r--r--assets/js/player.js2
-rw-r--r--assets/js/themes.js4
4 files changed, 13 insertions, 6 deletions
diff --git a/assets/js/_helpers.js b/assets/js/_helpers.js
index 7c50670e..8e18169e 100644
--- a/assets/js/_helpers.js
+++ b/assets/js/_helpers.js
@@ -6,6 +6,7 @@
Array.prototype.find = Array.prototype.find || function (condition) {
return this.filter(condition)[0];
};
+
Array.from = Array.from || function (source) {
return Array.prototype.slice.call(source);
};
@@ -201,15 +202,19 @@ window.helpers = window.helpers || {
if (localStorageIsUsable) {
return {
get: function (key) {
- if (!localStorage[key]) return;
+ let storageItem = localStorage.getItem(key)
+ if (!storageItem) return;
try {
- return JSON.parse(decodeURIComponent(localStorage[key]));
+ return JSON.parse(decodeURIComponent(storageItem));
} catch(e) {
// Erase non parsable value
helpers.storage.remove(key);
}
},
- set: function (key, value) { localStorage[key] = encodeURIComponent(JSON.stringify(value)); },
+ set: function (key, value) {
+ let encoded_value = encodeURIComponent(JSON.stringify(value))
+ localStorage.setItem(key, encoded_value);
+ },
remove: function (key) { localStorage.removeItem(key); }
};
}
diff --git a/assets/js/handlers.js b/assets/js/handlers.js
index 29810e72..539974fb 100644
--- a/assets/js/handlers.js
+++ b/assets/js/handlers.js
@@ -137,7 +137,7 @@
if (focused_tag === 'textarea') return;
if (focused_tag === 'input') {
let focused_type = document.activeElement.type.toLowerCase();
- if (!focused_type.match(allowed)) return;
+ if (!allowed.test(focused_type)) return;
}
// Focus search bar on '/'
diff --git a/assets/js/player.js b/assets/js/player.js
index ee678663..bb53ac24 100644
--- a/assets/js/player.js
+++ b/assets/js/player.js
@@ -261,7 +261,7 @@ function updateCookie(newVolume, newSpeed) {
var date = new Date();
date.setFullYear(date.getFullYear() + 2);
- var ipRegex = /^((\d+\.){3}\d+|[A-Fa-f0-9]*:[A-Fa-f0-9:]*:[A-Fa-f0-9:]+)$/;
+ var ipRegex = /^((\d+\.){3}\d+|[\dA-Fa-f]*:[\d:A-Fa-f]*:[\d:A-Fa-f]+)$/;
var domainUsed = location.hostname;
// Fix for a bug in FF where the leading dot in the FQDN is not ignored
diff --git a/assets/js/themes.js b/assets/js/themes.js
index 76767d5f..84a9f6d9 100644
--- a/assets/js/themes.js
+++ b/assets/js/themes.js
@@ -22,9 +22,11 @@ function setTheme(theme) {
if (theme === THEME_DARK) {
toggle_theme.children[0].className = 'icon ion-ios-sunny';
document.body.className = 'dark-theme';
- } else {
+ } else if (theme === THEME_LIGHT) {
toggle_theme.children[0].className = 'icon ion-ios-moon';
document.body.className = 'light-theme';
+ } else {
+ document.body.className = 'no-theme';
}
}