diff --git a/src/main/resources/kinosearch/webapp/static/js/ksplayer.js b/src/main/resources/kinosearch/webapp/static/js/ksplayer.js index 335911d..a129f99 100644 --- a/src/main/resources/kinosearch/webapp/static/js/ksplayer.js +++ b/src/main/resources/kinosearch/webapp/static/js/ksplayer.js @@ -7,6 +7,8 @@ const KSPlayer = function(containerId, data) { let titleElement; let seasonSerials = []; + const _self = this; + let lastActiveSerialItem; /* --- PRIVATE FUNCTIONS --- */ @@ -40,8 +42,21 @@ const KSPlayer = function(containerId, data) { let a = document.createElement('a'); a.href = '#'; a.innerText = item.title; - a.setAttribute('data-file', item.file); - a.onclick = function() { return false; } + a.onclick = function() { + text.nodeValue = item.title; + console.log(text); + _self.setTitle(item.title); + + if (lastActiveSerialItem) { + lastActiveSerialItem.classList.remove('active'); + } + li.classList.add('active'); + lastActiveSerialItem = li; + + setSource(item.file); + + return false; + } li.appendChild(a); ul.appendChild(li); @@ -171,6 +186,10 @@ const KSPlayer = function(containerId, data) { return videoElement; } + function setSource(source) { + videoElement.src = source; + } + /* --- CONSTRUCTOR --------- */ const containerElement = document.getElementById(containerId);