mirror of
https://gitlab.com/RemixDev/deemix-webui.git
synced 2024-12-29 10:56:05 +00:00
Moved distinction between URL and Search query to frontend
This commit is contained in:
parent
c4d5624c37
commit
42264d0353
|
@ -60,5 +60,6 @@
|
|||
</body>
|
||||
<script type="text/javascript" src="/public/js/jquery-3.3.1.min.js"></script>
|
||||
<script type="text/javascript" src="/public/js/vue.min.js"></script>
|
||||
<script type="text/javascript" src="/public/js/utils.js"></script>
|
||||
<script type="text/javascript" src="/public/js/frontend.js"></script>
|
||||
</html>
|
||||
|
|
|
@ -79,7 +79,10 @@ $("#searchbar").keyup(function(e){
|
|||
if(e.keyCode == 13){
|
||||
term = this.value
|
||||
console.log(term)
|
||||
doAjax("/search", "POST", searchHandler, {term: term});
|
||||
if (isValidURL(term))
|
||||
doAjax("/download", "POST", null, {url: term});
|
||||
else
|
||||
doAjax("/search", "POST", searchHandler, {term: term});
|
||||
}
|
||||
})
|
||||
|
||||
|
|
8
public/js/utils.js
Normal file
8
public/js/utils.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
function isValidURL(text){
|
||||
if (text.toLowerCase().startsWith("http"))
|
||||
if (text.toLowerCase().indexOf("deezer.com") >= 0 || text.toLowerCase().indexOf("open.spotify.com") >= 0)
|
||||
return true
|
||||
else if (text.toLowerCase().startsWith("spotify:"))
|
||||
return true
|
||||
return false
|
||||
}
|
Loading…
Reference in a new issue