summaryrefslogtreecommitdiff
path: root/public/assets/js
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/js')
-rw-r--r--public/assets/js/lib/views/details/audio.js9
-rw-r--r--public/assets/js/lib/views/stream/hootfilters.js19
-rw-r--r--public/assets/js/lib/views/stream/hootstream.js13
3 files changed, 40 insertions, 1 deletions
diff --git a/public/assets/js/lib/views/details/audio.js b/public/assets/js/lib/views/details/audio.js
index 0f81bb9..6c20e78 100644
--- a/public/assets/js/lib/views/details/audio.js
+++ b/public/assets/js/lib/views/details/audio.js
@@ -17,6 +17,7 @@ var audio = (function () {
audio.build();
el.src = music[0];
};
+
audio.index = function () {
music = [];
var links = document.querySelectorAll("a");
@@ -32,6 +33,7 @@ var audio = (function () {
audio.set_cursor();
}
};
+
audio.build = function () {
if (built) return;
built = true;
@@ -42,6 +44,7 @@ var audio = (function () {
parent.appendChild(el);
document.body.addEventListener("keydown", audio.keydown);
};
+
audio.destroy = function () {
el.pause();
el = null;
@@ -49,6 +52,7 @@ var audio = (function () {
document.body.removeEventListener("keydown", audio.keydown);
built = false;
};
+
audio.play = function (index) {
playing = true;
current_index = (parseInt(index) + music.length) % music.length;
@@ -56,21 +60,26 @@ var audio = (function () {
el.play();
audio.set_cursor();
};
+
audio.set_cursor = function () {
selected = document.querySelector(".playing");
if (selected) selected.classList.remove("playing");
music[current_index].classList.add("playing");
};
+
audio.prev = function () {
audio.play(current_index - 1);
};
+
audio.next = function () {
audio.play(current_index + 1);
};
+
audio.toggle = function () {
if (el.paused) el.play();
else el.pause();
};
+
audio.keydown = function (e) {
function element_is_text_input(el) {
var tagName = el.tagName.toLowerCase();
diff --git a/public/assets/js/lib/views/stream/hootfilters.js b/public/assets/js/lib/views/stream/hootfilters.js
new file mode 100644
index 0000000..bb060af
--- /dev/null
+++ b/public/assets/js/lib/views/stream/hootfilters.js
@@ -0,0 +1,19 @@
+var HootFilters = View.extend({
+ el: "#hootfilters",
+
+ events: {},
+
+ initialize: function (opt) {
+ this.__super__.initialize.call(this);
+ },
+
+ show: function () {
+ this.$el.show();
+ },
+
+ hide: function () {
+ this.$el.hide();
+ },
+
+ load: function () {},
+});
diff --git a/public/assets/js/lib/views/stream/hootstream.js b/public/assets/js/lib/views/stream/hootstream.js
index ad1fbc9..70d2b2a 100644
--- a/public/assets/js/lib/views/stream/hootstream.js
+++ b/public/assets/js/lib/views/stream/hootstream.js
@@ -18,11 +18,21 @@ var HootStream = View.extend({
},
onClickLink: function (event) {
+ if (event.ctrlKey || event.altKey || event.metaKey || event.shiftKey) {
+ return;
+ }
+ if (!event.target.href) {
+ return;
+ }
// console.log(event.target.className, event.target.href);
const url = new URL(event.target.href);
switch (event.target.className) {
case "file":
- // play audio?
+ console.log(url.pathname);
+ if (url.pathname.match(/(mp3|wav|ogg|opus|flac)$/i)) {
+ event.preventDefault();
+ audio.play(event.target.dataset.index); // index set in audio.js
+ }
break;
case "userLink":
case "threadLink":
@@ -60,6 +70,7 @@ var HootStream = View.extend({
}.bind(this)
);
this.$hootevents.append($els);
+ audio.init();
},
render: (template, object) => {