mirror of
https://github.com/IrosTheBeggar/mStream.git
synced 2025-10-27 07:31:02 +00:00
cleanup js
This commit is contained in:
parent
38f4521272
commit
75846b3eff
@ -135,7 +135,7 @@ function renderAlbum(id, artist, name, albumArtFile) {
|
||||
|
||||
function renderFileWithMetadataHtml(filepath, lokiId, metadata) {
|
||||
return `<div data-lokiid="${lokiId}" class="clear relative">
|
||||
<div data-lokiid="${lokiId}" data-file_location="${filepath}" class="filez left" onclick="onFileClick(this);">
|
||||
<div data-file_location="${filepath}" class="filez left" onclick="onFileClick(this);">
|
||||
<img class="album-art-box" ${metadata['album-art'] ? `data-original="/album-art/${metadata['album-art']}?token=${MSTREAMAPI.currentServer.token}"` : 'src="assets/img/default.png"'}>
|
||||
<span class="explorer-label-1">${(!metadata || !metadata.title) ? filepath : `${metadata.artist} - ${metadata.title}`}</span>
|
||||
</div>
|
||||
@ -145,6 +145,18 @@ function renderFileWithMetadataHtml(filepath, lokiId, metadata) {
|
||||
</div>`;
|
||||
}
|
||||
|
||||
function createMusicFileHtml(fileLocation, title, aa, rating) {
|
||||
return `<div class="clear relative">
|
||||
<div data-file_location="${fileLocation}" class="filez left" onclick="onFileClick(this);">
|
||||
${aa ? `<img class="album-art-box" ${aa}>` : '<svg class="music-image" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40"><path d="M9 37.5c-3.584 0-6.5-2.916-6.5-6.5s2.916-6.5 6.5-6.5a6.43 6.43 0 012.785.634l.715.34V5.429l25-3.846V29c0 3.584-2.916 6.5-6.5 6.5s-6.5-2.916-6.5-6.5 2.916-6.5 6.5-6.5a6.43 6.43 0 012.785.634l.715.34V11.023l-19 2.931V31c0 3.584-2.916 6.5-6.5 6.5z" fill="#8bb7f0"/><path d="M37 2.166V29c0 3.308-2.692 6-6 6s-6-2.692-6-6 2.692-6 6-6a5.93 5.93 0 012.57.586l1.43.68V10.441l-1.152.178-18 2.776-.848.13V31c0 3.308-2.692 6-6 6s-6-2.692-6-6 2.692-6 6-6a5.93 5.93 0 012.57.586l1.43.68V5.858l24-3.692M38 1L12 5v19.683A6.962 6.962 0 009 24a7 7 0 107 7V14.383l18-2.776v11.076A6.962 6.962 0 0031 22a7 7 0 107 7V1z" fill="#4e7ab5"/></svg>'}
|
||||
<span class="${aa ? 'explorer-label-1' : 'item-text'}">${rating ? `[${rating}] ` : ''}${title}</span>
|
||||
</div>
|
||||
<div class="song-button-box">
|
||||
<span data-file_location="${fileLocation}" class="removePlaylistSong">add</span>
|
||||
</div>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
function renderDirHtml(name) {
|
||||
return `<div class="clear relative">
|
||||
<div data-directory="${name}" class="dirz" onclick="handleDirClick(this);">
|
||||
@ -189,13 +201,6 @@ function renderPlaylist(playlistName) {
|
||||
</div>`;
|
||||
}
|
||||
|
||||
function createMusicfileHtml(fileLocation, title, titleClass) {
|
||||
return `<div data-file_location="${fileLocation}" class="filez" onclick="onFileClick(this);">
|
||||
<svg class="music-image" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40"><path d="M9 37.5c-3.584 0-6.5-2.916-6.5-6.5s2.916-6.5 6.5-6.5a6.43 6.43 0 012.785.634l.715.34V5.429l25-3.846V29c0 3.584-2.916 6.5-6.5 6.5s-6.5-2.916-6.5-6.5 2.916-6.5 6.5-6.5a6.43 6.43 0 012.785.634l.715.34V11.023l-19 2.931V31c0 3.584-2.916 6.5-6.5 6.5z" fill="#8bb7f0"/><path d="M37 2.166V29c0 3.308-2.692 6-6 6s-6-2.692-6-6 2.692-6 6-6a5.93 5.93 0 012.57.586l1.43.68V10.441l-1.152.178-18 2.776-.848.13V31c0 3.308-2.692 6-6 6s-6-2.692-6-6 2.692-6 6-6a5.93 5.93 0 012.57.586l1.43.68V5.858l24-3.692M38 1L12 5v19.683A6.962 6.962 0 009 24a7 7 0 107 7V14.383l18-2.776v11.076A6.962 6.962 0 0031 22a7 7 0 107 7V1z" fill="#4e7ab5"/></svg>
|
||||
<span class="${titleClass}">${title}</span>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
function getLoadingSvg() {
|
||||
return '<svg class="spinner" width="65px" height="65px" viewBox="0 0 66 66" xmlns="http://www.w3.org/2000/svg"><circle class="spinner-path" fill="none" stroke-width="6" stroke-linecap="round" cx="33" cy="33" r="30"></circle></svg>';
|
||||
}
|
||||
@ -309,7 +314,7 @@ function printdir(response, previousState) {
|
||||
filelist += createFileplaylistHtml(file.name);
|
||||
} else {
|
||||
const title = file.artist != null || file.title != null ? file.artist + ' - ' + file.title : file.name;
|
||||
filelist += createMusicfileHtml(file.path || response.path + file.name, title, "item-text");
|
||||
filelist += createMusicFileHtml(file.path || response.path + file.name, title);
|
||||
}
|
||||
}
|
||||
|
||||
@ -719,10 +724,7 @@ function getAlbumSongs(album, artist) {
|
||||
let files = '';
|
||||
response.forEach(song => {
|
||||
currentBrowsingList.push({ type: 'file', name: song.metadata.title ? song.metadata.title : song.metadata.filename });
|
||||
files += `<div data-file_location="${song.filepath}" class="filez" onclick="onFileClick(this);">
|
||||
<svg class="music-image" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40"><path d="M9 37.5c-3.584 0-6.5-2.916-6.5-6.5s2.916-6.5 6.5-6.5a6.43 6.43 0 012.785.634l.715.34V5.429l25-3.846V29c0 3.584-2.916 6.5-6.5 6.5s-6.5-2.916-6.5-6.5 2.916-6.5 6.5-6.5a6.43 6.43 0 012.785.634l.715.34V11.023l-19 2.931V31c0 3.584-2.916 6.5-6.5 6.5z" fill="#8bb7f0"/><path d="M37 2.166V29c0 3.308-2.692 6-6 6s-6-2.692-6-6 2.692-6 6-6a5.93 5.93 0 012.57.586l1.43.68V10.441l-1.152.178-18 2.776-.848.13V31c0 3.308-2.692 6-6 6s-6-2.692-6-6 2.692-6 6-6a5.93 5.93 0 012.57.586l1.43.68V5.858l24-3.692M38 1L12 5v19.683A6.962 6.962 0 009 24a7 7 0 107 7V14.383l18-2.776v11.076A6.962 6.962 0 0031 22a7 7 0 107 7V1z" fill="#4e7ab5"/></svg>
|
||||
<span class="title">${song.metadata.title ? song.metadata.title : song.metadata.filename}</span>
|
||||
</div>`;
|
||||
files += createMusicFileHtml(song.filepath, song.metadata.title ? song.metadata.title : song.metadata.filename);
|
||||
});
|
||||
|
||||
document.getElementById('filelist').innerHTML = files;
|
||||
@ -756,10 +758,7 @@ function redoRecentlyAdded() {
|
||||
name: el.metadata.title ? el.metadata.artist + ' - ' + el.metadata.title : el.filepath.split("/").pop()
|
||||
});
|
||||
|
||||
filelist += `<div data-file_location="${el.filepath}" class="filez" onclick="onFileClick(this);">
|
||||
<svg class="music-image" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40"><path d="M9 37.5c-3.584 0-6.5-2.916-6.5-6.5s2.916-6.5 6.5-6.5a6.43 6.43 0 012.785.634l.715.34V5.429l25-3.846V29c0 3.584-2.916 6.5-6.5 6.5s-6.5-2.916-6.5-6.5 2.916-6.5 6.5-6.5a6.43 6.43 0 012.785.634l.715.34V11.023l-19 2.931V31c0 3.584-2.916 6.5-6.5 6.5z" fill="#8bb7f0"/><path d="M37 2.166V29c0 3.308-2.692 6-6 6s-6-2.692-6-6 2.692-6 6-6a5.93 5.93 0 012.57.586l1.43.68V10.441l-1.152.178-18 2.776-.848.13V31c0 3.308-2.692 6-6 6s-6-2.692-6-6 2.692-6 6-6a5.93 5.93 0 012.57.586l1.43.68V5.858l24-3.692M38 1L12 5v19.683A6.962 6.962 0 009 24a7 7 0 107 7V14.383l18-2.776v11.076A6.962 6.962 0 0031 22a7 7 0 107 7V1z" fill="#4e7ab5"/></svg>
|
||||
<span class="title">${el.metadata.title ? `${el.metadata.artist} - ${el.metadata.title}`: el.filepath.split("/").pop()}</span>
|
||||
</div>`;
|
||||
filelist += createMusicFileHtml(el.filepath, el.metadata.title ? `${el.metadata.artist} - ${el.metadata.title}`: el.filepath.split("/").pop());
|
||||
});
|
||||
|
||||
document.getElementById('filelist').innerHTML = filelist;
|
||||
@ -798,12 +797,10 @@ function getRatedSongs(el) {
|
||||
metadata: value.metadata
|
||||
});
|
||||
|
||||
files += `<div data-file_location="${value.filepath}" class="filez" onclick="onFileClick(this);">
|
||||
<img class="album-art-box"
|
||||
${value.metadata['album-art'] ? `data-original="album-art/${value.metadata['album-art']}?token=${MSTREAMAPI.currentServer.token}"` : `src="assets/img/default.png"` }
|
||||
>
|
||||
<span class="explorer-label-1">[${rating}] ${value.metadata.artist ? `${value.metadata.artist} - ${value.metadata.title}` : value.filepath}</span>
|
||||
</div>`;
|
||||
files +=createMusicFileHtml(value.filepath,
|
||||
value.metadata.artist ? `${value.metadata.artist} - ${value.metadata.title}` : value.filepath,
|
||||
value.metadata['album-art'] ? `data-original="album-art/${value.metadata['album-art']}?token=${MSTREAMAPI.currentServer.token}"` : `src="assets/img/default.png"`,
|
||||
rating );
|
||||
});
|
||||
|
||||
document.getElementById('filelist').innerHTML = files;
|
||||
@ -1122,7 +1119,7 @@ function runLocalSearch(el) {
|
||||
} else {
|
||||
const fileLocation = x.path || getFileExplorerPath() + x.name;
|
||||
const title = x.artist != null || x.title != null ? x.artist + ' - ' + x.title : x.name;
|
||||
filelist += createMusicfileHtml(fileLocation, title, "title");
|
||||
filelist += createMusicFileHtml(fileLocation, title);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user