+ ${ovk_proc_strtr(escapeHtml(this.findTrack(this.tracks["previousTrack"]).name), 20) ?? ""}
+
+ `)
+
+ document.querySelector(".nextTrackTip").style.display = "block"
+ })
+
+ u(".bigPlayer .backButton").on("mouseover mouseleave", (e) => {
+ if(this.tracks["currentTrack"] == null)
+ return
+
+ if(e.type == "mouseleave") {
+ $(".previousTrackTip").remove()
+ return
+ }
+
+ e.currentTarget.parentNode.insertAdjacentHTML("afterbegin", `
+
+ ${ovk_proc_strtr(escapeHtml(this.findTrack(this.tracks["nextTrack"]).name), 20) ?? ""}
+
+ `)
+
+ document.querySelector(".previousTrackTip").style.display = "block"
})
u(".bigPlayer .trackPanel .track").on("mouseleave", (e) => {
if(this.tracks["currentTrack"] == null)
return
- document.querySelector(".bigPlayer .track .timeTip").style.display = "none"
+ document.querySelector(".bigPlayer .track .bigPlayerTip").style.display = "none"
})
u(".bigPlayer .volumePanel > div").on("click mouseup mousemove", (e) => {
@@ -200,7 +240,7 @@ class bigPlayer {
if(this.tracks["currentTrack"] == null)
return
- this.tracks["tracks"].sort(() => Math.random() - 0.5)
+ this.tracks["tracks"].sort(() => Math.random() - 0.59)
this.setTrack(this.tracks["tracks"].at(0).id)
})
@@ -316,9 +356,8 @@ class bigPlayer {
}
pause() {
- if(this.tracks["currentTrack"] == null) {
+ if(this.tracks["currentTrack"] == null)
return
- }
document.querySelector(`.audioEmbed[data-realid='${this.tracks["currentTrack"].id}'] .audioEntry .playerButton .playIcon`) != null ? document.querySelector(`.audioEmbed[data-realid='${this.tracks["currentTrack"].id}'] .audioEntry .playerButton .playIcon`).classList.remove("paused") : void(0)
this.player().pause()
@@ -329,17 +368,15 @@ class bigPlayer {
}
showPreviousTrack() {
- if(this.tracks["currentTrack"] == null || this.tracks["previousTrack"] == null) {
+ if(this.tracks["currentTrack"] == null || this.tracks["previousTrack"] == null)
return
- }
this.setTrack(this.tracks["previousTrack"])
}
showNextTrack() {
- if(this.tracks["currentTrack"] == null || this.tracks["nextTrack"] == null) {
+ if(this.tracks["currentTrack"] == null || this.tracks["nextTrack"] == null)
return
- }
this.setTrack(this.tracks["nextTrack"])
}
@@ -349,16 +386,28 @@ class bigPlayer {
let prevButton = this.nodes["thisPlayer"].querySelector(".nextButton")
let nextButton = this.nodes["thisPlayer"].querySelector(".backButton")
- if(this.tracks["previousTrack"] == null) {
+ if(this.tracks["previousTrack"] == null)
prevButton.classList.add("lagged")
- } else {
+ else
prevButton.classList.remove("lagged")
+
+ if(this.tracks["nextTrack"] == null)
+ nextButton.classList.add("lagged")
+ else
+ nextButton.classList.remove("lagged")
+
+ if(document.querySelector(".nextTrackTip") != null) {
+ let track = this.findTrack(this.tracks["previousTrack"])
+ document.querySelector(".nextTrackTip").innerHTML = `
+ ${track != null ? ovk_proc_strtr(escapeHtml(track.name), 20) : ""}
+ `
}
- if(this.tracks["nextTrack"] == null) {
- nextButton.classList.add("lagged")
- } else {
- nextButton.classList.remove("lagged")
+ if(document.querySelector(".previousTrackTip") != null) {
+ let track = this.findTrack(this.tracks["nextTrack"])
+ document.querySelector(".previousTrackTip").innerHTML = `
+ ${track != null ? ovk_proc_strtr(escapeHtml(track.name ?? ""), 20) : ""}
+ `
}
}
@@ -449,11 +498,12 @@ class bigPlayer {
this.play()
- document.querySelector(`.audioEmbed[data-realid='${this.tracks["currentTrack"].id}'] .audioEntry`) != null ?
- document.querySelector(`.audioEmbed[data-realid='${this.tracks["currentTrack"].id}'] .audioEntry`).classList.add("nowPlaying") :
- null
+ let playerAtPage = document.querySelector(`.audioEmbed[data-realid='${this.tracks["currentTrack"].id}'] .audioEntry`)
+ if(playerAtPage != null)
+ playerAtPage.classList.add("nowPlaying")
document.querySelectorAll(`.audioEntry .playerButton .playIcon.paused`).forEach(el => el.classList.remove("paused"))
+
localStorage.lastPlayedTrack = this.tracks["currentTrack"].id
if(this.timeType == 1)
@@ -543,10 +593,9 @@ function initPlayer(id, keys, url, length) {
if(window.player.tracks["tracks"] == null)
return
- if(window.player.tracks["currentTrack"] == null || window.player.tracks["currentTrack"].id != playerObject.dataset.realid) {
+ if(window.player.tracks["currentTrack"] == null || window.player.tracks["currentTrack"].id != playerObject.dataset.realid)
window.player.setTrack(playerObject.dataset.realid)
- playButton.addClass("paused")
- } else
+ else
document.querySelector(".bigPlayer .playButton").click()
})
@@ -576,10 +625,19 @@ function initPlayer(id, keys, url, length) {
const time = audio.currentTime;
const ps = Math.ceil((time * 100) / length);
volumeSpan.html(fmtTime(Math.floor(time)));
+
if (ps <= 100)
- trackDiv.nodes[0].style.width = `${ ps}%`;
+ playerObject.querySelector(".lengthTrack .slider").style.left = `${ ps}%`;
});
+ u(audio).on("volumechange", (e) => {
+ const volume = audio.volume;
+ const ps = Math.ceil((volume * 100) / 1);
+
+ if (ps <= 100)
+ playerObject.querySelector(".volumeTrack .slider").style.left = `${ ps}%`;
+ })
+
const playButtonImageUpdate = () => {
if (!audio.paused) {
playButton.addClass("paused")
@@ -603,13 +661,30 @@ function initPlayer(id, keys, url, length) {
u(audio).on("play", playButtonImageUpdate);
u(audio).on(["pause", "ended", "suspended"], playButtonImageUpdate);
- u(`#audioEmbed-${ id} .track > div`).on("click", (e) => {
+ u(`#audioEmbed-${ id} .lengthTrack > div`).on("click", (e) => {
let rect = document.querySelector("#audioEmbed-" + id + " .selectableTrack").getBoundingClientRect();
const width = e.clientX - rect.left;
const time = Math.ceil((width * length) / (rect.right - rect.left));
audio.currentTime = time;
});
+
+ u(`#audioEmbed-${ id} .volumeTrack > div`).on("click mouseup mousemove", (e) => {
+ if(e.type == "mousemove") {
+ let buttonsPresseed = _bsdnUnwrapBitMask(e.buttons)
+ if(!buttonsPresseed[0])
+ return;
+ }
+
+ let rect = document.querySelector("#audioEmbed-" + id + " .volumeTrack").getBoundingClientRect();
+
+ const width = e.clientX - rect.left;
+ const volume = (width * 1) / (rect.right - rect.left);
+
+ audio.volume = volume;
+ });
+
+ u(audio).trigger("volumechange")
}
$(document).on("click", ".musicIcon.edit-icon", (e) => {
@@ -638,7 +713,7 @@ $(document).on("click", ".musicIcon.edit-icon", (e) => {
@@ -694,7 +769,7 @@ $(document).on("click", ".musicIcon.edit-icon", (e) => {
e.currentTarget.setAttribute("data-lyrics", response.new_info.lyrics_unformatted)
e.currentTarget.setAttribute("data-explicit", Number(response.new_info.explicit))
- e.currentTarget.setAttribute("data-searchable", Number(response.new_info.unlisted))
+ e.currentTarget.setAttribute("data-searchable", Number(!response.new_info.unlisted))
player.setAttribute("data-genre", response.new_info.genre)
let url = new URL(location.href)
@@ -781,6 +856,86 @@ $(document).on("click", ".musicIcon.remove-icon", (e) => {
})
})
+$(document).on("click", ".musicIcon.remove-icon-group", (e) => {
+ let id = e.currentTarget.dataset.id
+
+ let formdata = new FormData()
+ formdata.append("hash", u("meta[name=csrf]").attr("value"))
+ formdata.append("club", e.currentTarget.dataset.club)
+
+ ky.post(`/audio${id}/action?act=remove_club`, {
+ hooks: {
+ beforeRequest: [
+ (_request) => {
+ e.currentTarget.classList.add("lagged")
+ }
+ ],
+ afterResponse: [
+ async (_request, _options, response) => {
+ let json = await response.json()
+
+ if(json.success)
+ $(e.currentTarget.closest(".audioEmbed")).remove()
+ else
+ fastError(json.flash.message)
+ }
+ ]
+ }, body: formdata
+ })
+})
+
+$(document).on("click", ".musicIcon.add-icon-group", async (ev) => {
+ let body = `
+ ${tr("what_club_add")}
+
+
+
+
+
+ `
+ MessageBox(tr("add_audio_to_club"), body, [tr("close")], [Function.noop])
+
+ document.querySelector(".ovk-diag-body").style.padding = "11px"
+
+ if(window.openvk.writeableClubs == null) {
+ try {
+ window.openvk.writeableClubs = await API.Groups.getWriteableClubs()
+ } catch (e) {
+ document.querySelector(".errorPlace").innerHTML = tr("no_access_clubs")
+ document.querySelector(".ovk-diag-body input[name='addButton']").classList.add("lagged")
+
+ return
+ }
+ }
+
+ window.openvk.writeableClubs.forEach(el => {
+ document.querySelector("#addIconsWindow").insertAdjacentHTML("beforeend", `
+
${ovk_proc_strtr(el.name, 20)}
+ `)
+ })
+
+ $(".ovk-diag-body").on("click", "input[name='addButton']", (e) => {
+ $.ajax({
+ type: "POST",
+ url: `/audio${ev.currentTarget.dataset.id}/action?act=add_to_club`,
+ data: {
+ hash: u("meta[name=csrf]").attr("value"),
+ club: document.querySelector("#addIconsWindow").value
+ },
+ beforeSend: () => {
+ e.currentTarget.classList.add("lagged")
+ document.querySelector(".errorPlace").innerHTML = ""
+ },
+ success: (response) => {
+ if(!response.success)
+ document.querySelector(".errorPlace").innerHTML = response.flash.message
+
+ e.currentTarget.classList.remove("lagged")
+ }
+ })
+ })
+})
+
$(document).on("click", ".musicIcon.add-icon", (e) => {
let id = e.currentTarget.dataset.id
@@ -836,7 +991,11 @@ $(document).on("click", "#_audioAttachment", (e) => {
let form = e.currentTarget.closest("form")
let body = `
-
+
+
+ ${tr("by_name")}
+ ${tr("by_performer")}
+
@@ -847,7 +1006,7 @@ $(document).on("click", "#_audioAttachment", (e) => {
document.querySelector(".ovk-diag-cont").style.width = "580px"
document.querySelector(".ovk-diag-body").style.height = "335px"
- async function insertAudios(page, query = "") {
+ async function insertAudios(page, query = "", type = "by_name") {
document.querySelector(".audiosInsert").insertAdjacentHTML("beforeend", `
`)
$.ajax({
@@ -859,6 +1018,7 @@ $(document).on("click", "#_audioAttachment", (e) => {
page: page,
query: query == "" ? null : query,
context_entity: 0,
+ type: type,
returnPlayers: 1,
},
success: (response) => {
@@ -911,11 +1071,17 @@ $(document).on("click", "#_audioAttachment", (e) => {
if(e.currentTarget.value === document.querySelector(".searchBox input").value) {
document.querySelector(".audiosInsert").innerHTML = ""
- insertAudios(1, e.currentTarget.value)
+ insertAudios(1, e.currentTarget.value, document.querySelector(".searchBox select").value)
return;
}
})
+ $(".searchBox select").on("change", async (e) => {
+ document.querySelector(".audiosInsert").innerHTML = ""
+ insertAudios(1, document.querySelector(".searchBox input").value, e.currentTarget.value)
+ return;
+ })
+
function insertAttachment(id) {
let audios = form.querySelector("input[name='audios']")
@@ -1074,7 +1240,7 @@ $(document).on("click", "#bookmarkPlaylist, #unbookmarkPlaylist", (e) => {
})
})
-function getPlayers(page = 1, query = "", playlist = 0) {
+function getPlayers(page = 1, query = "", playlist = 0, club = 0) {
$.ajax({
type: "POST",
url: "/audios/context",
@@ -1082,12 +1248,12 @@ function getPlayers(page = 1, query = "", playlist = 0) {
context: query == "" ? (playlist == 0 ? "entity_audios" : "playlist_context") : "search_context",
hash: u("meta[name=csrf]").attr("value"),
page: page,
- context_entity: playlist,
+ context_entity: playlist == 0 ? club * -1 : playlist,
query: query,
returnPlayers: 1,
},
beforeSend: () => {
- document.querySelector(".playlistAudiosContainer").insertAdjacentHTML("beforeend", `
`)
+ document.querySelector(".playlistAudiosContainer").parentNode.insertAdjacentHTML("beforeend", `
`)
if(document.querySelector(".showMoreAudiosPlaylist") != null)
document.querySelector(".showMoreAudiosPlaylist").style.display = "none"
@@ -1143,7 +1309,10 @@ function getPlayers(page = 1, query = "", playlist = 0) {
}
$(document).on("click", ".showMoreAudiosPlaylist", (e) => {
- getPlayers(Number(e.currentTarget.dataset.page), "", e.currentTarget.dataset.playlist != null ? Number(e.currentTarget.dataset.playlist) : 0)
+ getPlayers(Number(e.currentTarget.dataset.page), "",
+ e.currentTarget.dataset.playlist != null ? Number(e.currentTarget.dataset.playlist) : 0,
+ e.currentTarget.dataset.club != null ? Number(e.currentTarget.dataset.club) : 0,
+ )
})
$(document).on("change", "input#playlist_query", async (e) => {
diff --git a/locales/en.strings b/locales/en.strings
index 89cdf891..fc4e2f65 100644
--- a/locales/en.strings
+++ b/locales/en.strings
@@ -728,6 +728,7 @@
"audio" = "Audio";
"playlist" = "Playlist";
"upload_audio" = "Upload audio";
+"upload_audio_to_group" = "Upload audio to group";
"performer" = "Performer";
"audio_name" = "Name";
@@ -778,6 +779,10 @@
"no_playlists_user" = "This user has not added any playlists yet.";
"no_playlists_club" = "This group hasn't added playlists yet.";
+"no_audios_thisuser" = "You haven't added any audios yet.";
+"no_audios_user" = "This user has not added any audios yet.";
+"no_audios_club" = "This group has not added any audios yet.";
+
"new_playlist" = "New playlist";
"created_playlist" = "created";
"bookmark" = "Add to collection";
@@ -807,6 +812,15 @@
"minutes_count_many" = "lasts $1 minutes";
"minutes_count_other" = "lasts $1 minutes";
+"add_audio_to_club" = "Add audio to group";
+"what_club_add" = "Which group do you want to add the song to?";
+"group_has_audio" = "This group already has this song.";
+"group_hasnt_audio" = "This group doesn't have this song.";
+
+"by_name" = "by name";
+"by_performer" = "by performer";
+"no_access_clubs" = "There are no groups where you are an administrator.";
+
/* Notifications */
"feedback" = "Feedback";
diff --git a/locales/ru.strings b/locales/ru.strings
index b53de206..a035e8f2 100644
--- a/locales/ru.strings
+++ b/locales/ru.strings
@@ -684,6 +684,7 @@
"audio" = "Аудиозапись";
"playlist" = "Плейлист";
"upload_audio" = "Загрузить аудио";
+"upload_audio_to_group" = "Загрузить аудио в группу";
"performer" = "Исполнитель";
"audio_name" = "Название";
@@ -734,6 +735,10 @@
"no_playlists_user" = "Этот пользователь ещё не добавлял плейлистов.";
"no_playlists_club" = "Эта группа ещё не добавляла плейлистов.";
+"no_audios_thisuser" = "Вы ещё не добавляли аудиозаписей.";
+"no_audios_user" = "Этот пользователь ещё не добавлял аудиозаписей.";
+"no_audios_club" = "Эта группа ещё не добавляла аудиозаписей.";
+
"new_playlist" = "Новый плейлист";
"created_playlist" = "создан";
"bookmark" = "Добавить в коллекцию";
@@ -762,6 +767,15 @@
"minutes_count_many" = "длится $1 минут";
"minutes_count_other" = "длится $1 минут";
+"add_audio_to_club" = "Добавить аудио в группу";
+"what_club_add" = "В какую группу вы хотите добавить песню?";
+"group_has_audio" = "У группы уже есть эта песня.";
+"group_hasnt_audio" = "У группы нет этой песни.";
+
+"by_name" = "по композициям";
+"by_performer" = "по исполнителю";
+"no_access_clubs" = "Нет групп, где вы являетесь администратором.";
+
/* Notifications */
"feedback" = "Ответы";