Moved distinction between URL and Search query to frontend
This commit is contained in:
parent
c4d5624c37
commit
42264d0353
@ -60,5 +60,6 @@ <h1>{{ names[section] }}</h1>
|
|||||||
</body>
|
</body>
|
||||||
<script type="text/javascript" src="/public/js/jquery-3.3.1.min.js"></script>
|
<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/vue.min.js"></script>
|
||||||
|
<script type="text/javascript" src="/public/js/utils.js"></script>
|
||||||
<script type="text/javascript" src="/public/js/frontend.js"></script>
|
<script type="text/javascript" src="/public/js/frontend.js"></script>
|
||||||
</html>
|
</html>
|
||||||
|
@ -79,6 +79,9 @@ $("#searchbar").keyup(function(e){
|
|||||||
if(e.keyCode == 13){
|
if(e.keyCode == 13){
|
||||||
term = this.value
|
term = this.value
|
||||||
console.log(term)
|
console.log(term)
|
||||||
|
if (isValidURL(term))
|
||||||
|
doAjax("/download", "POST", null, {url: term});
|
||||||
|
else
|
||||||
doAjax("/search", "POST", searchHandler, {term: term});
|
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 New Issue
Block a user