From 4954d6da5747eafd0b0cbe10ddb7fc3fc44a5b94 Mon Sep 17 00:00:00 2001 From: Maxim Stewart Date: Sat, 26 Jan 2019 14:53:15 -0600 Subject: [PATCH] Changed fetch setup for remuxed videos. --- resources/js/uiActions.js | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/resources/js/uiActions.js b/resources/js/uiActions.js index 613f810..4eecb30 100644 --- a/resources/js/uiActions.js +++ b/resources/js/uiActions.js @@ -86,37 +86,23 @@ const showMedia = async (mediaLoc, type) => { imgTag.src = fullMedia; imgDiv.appendChild(imgTag); - - if ((/\.(mkv|avi|flv|mov|m4v|mpg|wmv|mpeg|mp4|mp3|webm|flac|ogg|pdf)$/i).test(tempRef)) { if ((/\.(mkv)$/i).test(tempRef)) { - let data = "remuxVideo=true&mediaPth=" + fullMedia; + const params = "remuxVideo=true&mediaPth=" + fullMedia; + let response = await fetch("resources/php/filesystemActions.php", + {method: "POST", body: new URLSearchParams(params)}); + let xml = new window.DOMParser().parseFromString(await response.text(), "text/xml"); - // This kinda sucks but calling doAjax wont return data for some reason - let xhttp = new XMLHttpRequest(); - xhttp.onreadystatechange = function() { - if (this.readyState === 4 && this.status === 200) { - // Send the returned data to further process - if (this.responseXML != null) { - data = this.responseXML; - fullMedia = data.getElementsByTagName("REMUX_PATH")[0].innerHTML; - } else { - document.getElementById('dynDiv').innerHTML = - "

" - + "No content returned. Check the folder path.

"; - return ; - } - } - }; - xhttp.open("POST", "resources/php/filesystemActions.php", false); - xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - xhttp.overrideMimeType('application/xml'); // Force return to be XML - xhttp.send(data); - } else if ((/\.(avi|flv|mov|m4v|mpg|wmv)$/i).test(tempRef)) { - openInLocalProg(fullMedia); + if (xml.getElementsByTagName("REMUX_PATH")[0]) { + fullMedia = xml.getElementsByTagName("REMUX_PATH")[0].innerHTML; + } else { return ; } + } else if ((/\.(avi|flv|mov|m4v|mpg|wmv)$/i).test(tempRef)) { + openInLocalProg(fullMedia); + return ; } + } iframe.id = "fileViewInner"; iframe.src = fullMedia;