init
1 parent c7c2663 commit fbbef7db5b59c9cbc491ce1826fbb5d70bf772f3
@ubuntu ubuntu authored on 23 May
Showing 4 changed files
View
15
api.php 0 → 100644
<?php
 
function playlist_name_is_exists_action() {
}
 
if(isset($_GET["action"]) and $_GET["action"]) {
$action_name = $_GET["action"] . "_action";
if(!function_exists($action_name)) {
return die("Action {$action_name} not exists");
}
echo $action_name();
}
View
54
app.js 0 → 100644
function validateURL(url) {
const pattern = new RegExp('^(https?:\\/\\/)?' + // проверка на протокол
'((([a-zA-Z\\d]([a-zA-Z\\d-]*[a-zA-Z\\d])*)\\.)+[a-zA-Z]{2,}|' + // доменные имена
'((\\d{1,3}\\.){3}\\d{1,3}))' + // или IP (v4) адреса
'(\\:\\d+)?(\\/[-a-zA-Z\\d%_.~+]*)*' + // порт и путь
'(\\?[;&a-zA-Z\\d%_.~+=-]*)?' + // параметры запроса
'(\\#[-a-zA-Z\\d_]*)?$', 'i'); // якорь (фрагмент)
return pattern.test(url);
}
 
document.addEventListener("DOMContentLoaded", e => {
console.log("App start");
 
const form = document.querySelector(".main-form");
const startBtn = document.querySelector("[data-start-download]");
const urlToPlaylistInp = document.querySelector("[name='url-to-playlist']");
const playlistNameInp = document.querySelector("[name='playlist-name']");
 
form.resetValidationClasses = () => form.querySelectorAll(".is-invalid").forEach(i => i.classList.remove("is-invalid"));
 
form.querySelectorAll("input").forEach(i => i.addEventListener("input", e => {
e.currentTarget.classList.remove("is-invalid");
}));
startBtn.addEventListener("click", e => {
if(startBtn.classList.contains("disabled")) {
return;
}
 
form.resetValidationClasses();
let plUrl = urlToPlaylistInp.value;
let plName = playlistNameInp.value;
let dataIsValid = true;
 
if(!plUrl.length || !validateURL(plUrl)) {
urlToPlaylistInp.classList.add("is-invalid");
dataIsValid = false;
}
 
if(plName.length < 4) {
playlistNameInp.classList.add("is-invalid");
dataIsValid = false;
}
 
if(!dataIsValid) {
return;
}
 
});
});
View
32
index.html 0 → 100644
<html>
<head>
<title>GN Music Loader</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<link rel="stylesheet" href="style.css">
</head>
<body>
 
<div class="container">
<h1>Music Loader</h1>
<p>Просто вставь ссылку на плейлист, дай ему новое название и через некоторое время этот плейлист станет доступен в общей медиатеке</p>
<div class="main-form">
<div class="mb-3">
<label for="exampleFormControlInput1" class="form-label">Ссылка на плейлист</label>
<input type="url" name="url-to-playlist" class="form-control" id="exampleFormControlInput1" placeholder="https://soundcloud.com/...">
</div>
<div class="mb-3">
<label for="exampleFormControlInput2" class="form-label">Новое название плейлиста (минимум 4 символа)</label>
<input type="text" class="form-control" name="playlist-name" id="exampleFormControlInput2" placeholder="Some playlist name">
</div>
 
<button class="btn btn-primary" data-start-download>Начать скачивание</button>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
<script src="app.js"></script>
</body>
</html>
View
4
style.css 0 → 100644
body > .container:first-of-type {
margin-top: 50px;
}