Skip to content

Commit

Permalink
Feat: Feedback for tags
Browse files Browse the repository at this point in the history
  • Loading branch information
jcorporation committed Sep 8, 2024
1 parent db88b7f commit e129665
Show file tree
Hide file tree
Showing 26 changed files with 88 additions and 113 deletions.
26 changes: 13 additions & 13 deletions docs/references/translating_status.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
- bg-BG: 1080 missing phrases
- es-AR: 26 missing phrases
- bg-BG: 1079 missing phrases
- es-AR: 27 missing phrases
- es-ES: 946 missing phrases
- es-VE: 933 missing phrases
- fi-FI: 930 missing phrases
- fr-FR: 26 missing phrases
- it-IT: 26 missing phrases
- ja-JP: 26 missing phrases
- ko-KR: 26 missing phrases
- nl-NL: 26 missing phrases
- pl-PL: 112 missing phrases
- ru-RU: 182 missing phrases
- zh-Hans: 26 missing phrases
- zh-Hant: 112 missing phrases
- es-VE: 934 missing phrases
- fi-FI: 931 missing phrases
- fr-FR: 27 missing phrases
- it-IT: 27 missing phrases
- ja-JP: 27 missing phrases
- ko-KR: 27 missing phrases
- nl-NL: 27 missing phrases
- pl-PL: 113 missing phrases
- ru-RU: 183 missing phrases
- zh-Hans: 27 missing phrases
- zh-Hant: 113 missing phrases
4 changes: 0 additions & 4 deletions htdocs/css/mympd.css
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,3 @@ table div.alert {
.colMaxContent {
max-width:fit-content;
}

.stickerMympdHide .stickerMympd {
display: none;
}
1 change: 0 additions & 1 deletion htdocs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3181,7 +3181,6 @@ <h5 class="modal-title"><span class="mi title-icon">discount</span> <span data-p
<tbody class="clickable"></tbody>
</table>
</div>
<button id="modalStickerToggleInternal" class="btn btn-sm btn-secondary" data-phrase="Show internal stickers" data-href='{"cmd": "showInternalStickers", "options": ["target"]}'></button>
</div>
</div>
</div>
Expand Down
20 changes: 10 additions & 10 deletions htdocs/js/feedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ function clickFeedback(target) {
const parent = target.closest('.btn-group');
const feedbackType = parent.getAttribute('data-feedback');
if (feedbackType === 'like') {
voteSongLike(target);
voteLike(target);
}
else {
voteSongRating(target);
voteRating(target);
}
}

Expand Down Expand Up @@ -74,12 +74,12 @@ function setFeedback(el, like, rating) {
}

/**
* Song love/hate event handler
* Love/hate event handler
* @param {EventTarget} el triggering element
* @returns {void}
*/
//eslint-disable-next-line no-unused-vars
function voteSongLike(el) {
function voteLike(el) {
if (el.nodeName === 'DIV') {
return;
}
Expand Down Expand Up @@ -115,17 +115,17 @@ function voteSongLike(el) {
}

/**
* Creates the songs hate/love elements
* Creates the hate/love elements
* @param {number} like like value 0 - 2
* @param {string} stickerType MPD sticker type
* @returns {HTMLElement} div element
*/
function createLike(like, stickerType) {
const thDown = elCreateText('button', {"data-vote": "0", "data-title-phrase": "Hate song", "class": ["btn", "btn-secondary", "mi"]}, 'thumb_down');
const thDown = elCreateText('button', {"data-vote": "0", "data-title-phrase": "Hate", "class": ["btn", "btn-secondary", "mi"]}, 'thumb_down');
if (like === 0) {
thDown.classList.add('active');
}
const thUp = elCreateText('button', {"data-vote": "2", "data-title-phrase": "Love song", "class": ["btn", "btn-secondary", "mi"]}, 'thumb_up');
const thUp = elCreateText('button', {"data-vote": "2", "data-title-phrase": "Love", "class": ["btn", "btn-secondary", "mi"]}, 'thumb_up');
if (like === 2) {
thUp.classList.add('active');
}
Expand All @@ -136,7 +136,7 @@ function createLike(like, stickerType) {
}

/**
* Sets the song vote button group
* Sets the vote button group
* @param {HTMLElement | Element} el container for the thumbs
* @param {number} vote The vote
* @returns {void}
Expand All @@ -161,12 +161,12 @@ function setLike(el, vote) {
}

/**
* Song rating event handler
* Rating event handler
* @param {EventTarget} el triggering element
* @returns {void}
*/
//eslint-disable-next-line no-unused-vars
function voteSongRating(el) {
function voteRating(el) {
const rating = Number(el.getAttribute('data-vote'));
const stickerType = el.parentNode.getAttribute('data-type');
const uri = getData(el.parentNode, 'uri');
Expand Down
4 changes: 2 additions & 2 deletions htdocs/js/modalSongDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ function parseSongDetails(obj) {
features.featLike === true)
{
const grp = createLike(obj.result.like, "song");
setData(grp, 'href', {"cmd": "voteSongLike", "options": ["target"]});
setData(grp, 'href', {"cmd": "voteLike", "options": ["target"]});
setData(grp, 'uri', obj.result.uri);
tbody.appendChild(
elCreateNodes('tr', {}, [
Expand All @@ -260,7 +260,7 @@ function parseSongDetails(obj) {
features.featRating === true)
{
const grp = createStarRating(obj.result.rating, "song");
setData(grp, 'href', {"cmd": "voteSongRating", "options": ["target"]});
setData(grp, 'href', {"cmd": "voteRating", "options": ["target"]});
setData(grp, 'uri', obj.result.uri);
tbody.appendChild(
elCreateNodes('tr', {}, [
Expand Down
56 changes: 32 additions & 24 deletions htdocs/js/modalSticker.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ function initModalSticker() {
}
return;
}
if (event.target.nodeName === 'BUTTON') {
const cmd = getData(event.target.parentNode, 'href');
if (cmd !== null) {
parseCmd(event, cmd);
return;
}
}
if (checkTargetClick(target) === true) {
showEditSticker(getData(target, 'name'), getData(target, 'value'));
}
Expand Down Expand Up @@ -206,8 +213,6 @@ function getStickerList() {
*/
function parseStickerList(obj) {
const table = elGetById('modalStickerList');
table.classList.add('stickerMympdHide');
elGetById('modalStickerToggleInternal').classList.remove('active');
const tbodySticker = table.querySelector('tbody');
elClear(tbodySticker);
if (checkResult(obj, table, 'table') === false) {
Expand All @@ -216,15 +221,34 @@ function parseStickerList(obj) {

for (const key of stickerListSongs) {
if (obj.result[key] !== undefined) {
const tr = printStickerRow(key, obj.result[key]);
tr.classList.add('stickerMympd');
let valueEl;
if (key === 'like') {
if (features.featLike === false) {
continue;
}
valueEl = createLike(obj.result.like, obj.result.type);
setData(valueEl, 'href', {"cmd": "voteLike", "options": ["target"]});
setData(valueEl, 'uri', obj.result.uri);
}
else if (key === 'rating') {
if (features.featRating === false) {
continue;
}
valueEl = createStarRating(obj.result.rating, obj.result.type);
setData(valueEl, 'href', {"cmd": "voteRating", "options": ["target"]});
setData(valueEl, 'uri', obj.result.uri);
}
else {
valueEl = printValue(key, obj.result[key]);
}
const tr = printStickerRow(tn(key), obj.result[key], valueEl);
tbodySticker.appendChild(tr);
}
}
let i = 0;
for (const key in obj.result.sticker) {
tbodySticker.appendChild(
printStickerRow(key, obj.result.sticker[key])
printStickerRow(key, obj.result.sticker[key], document.createTextNode(obj.result.sticker[key]))
);
i++;
}
Expand All @@ -244,12 +268,13 @@ function parseStickerList(obj) {
* Prints a sticker table row
* @param {string} name Sticker name
* @param {string} value Sticker value
* @param {Node} valueEl Sticker value element
* @returns {HTMLElement} Table row
*/
function printStickerRow(name, value) {
function printStickerRow(name, value, valueEl) {
const tr = elCreateNodes('tr', {"title": tn('Edit')}, [
elCreateText('td', {}, name),
elCreateText('td', {}, value),
elCreateNode('td', {}, valueEl),
elCreateNodes('td', {"data-col": "Action"}, [
elCreateText('a', {"href": "#", "data-title-phrase": "Delete", "data-action": "delete", "class": ["me-2", "mi", "color-darkgrey"]}, 'delete'),
])
Expand All @@ -258,20 +283,3 @@ function printStickerRow(name, value) {
setData(tr, 'value', value);
return tr;
}

/**
* Shows/hides the interal stickers
* @param {EventTarget} target Toggle button
* @returns {void}
*/
//eslint-disable-next-line no-unused-vars
function showInternalStickers(target) {
if (target.classList.contains('active')) {
target.classList.remove('active');
elGetById('modalStickerList').classList.add('stickerMympdHide');
}
else {
target.classList.add('active');
elGetById('modalStickerList').classList.remove('stickerMympdHide');
}
}
4 changes: 1 addition & 3 deletions src/i18n/json/bg-BG.json
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,6 @@
"Grouping": "",
"HTTP client": "",
"HTTP download": "",
"Hate song": "",
"Help to improve myMPD": "",
"Highlight color": "",
"Highlight contrast color": "",
Expand Down Expand Up @@ -457,7 +456,6 @@
"Logout": "",
"Logs messages to the myMPD log.": "",
"Lookup at musicbrainz": "",
"Love song": "",
"Love, hate": "",
"Lua is not compiled in": "",
"Lyrics": "",
Expand Down Expand Up @@ -1201,4 +1199,4 @@
"url_resolved": "",
"votes": "",
"wasapi": ""
}
}
9 changes: 4 additions & 5 deletions src/i18n/json/de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@
"Grouping": "Gruppierung",
"HTTP client": "HTTP Client",
"HTTP download": "HTTP Download",
"Hate song": "Gefällt mir nicht",
"Hate": "Gefällt mir nicht",
"Help to improve myMPD": "Hilf mit myMPD zu verbessern",
"Highlight color": "Highlight Farbe",
"Highlight contrast color": "Highlight Kontrast-Farbe",
Expand Down Expand Up @@ -458,7 +458,7 @@
"Logout": "Logout",
"Logs messages to the myMPD log.": "Schreibt Meldungen in das myMPD Log.",
"Lookup at musicbrainz": "Bei MusicBrainz nachschlagen",
"Love song": "Gefällt mir",
"Love": "Gefällt mir",
"Love, hate": "Gefällt mir / nicht",
"Lua is not compiled in": "Lua ist nicht verfügbar",
"Lyrics": "Liedtext",
Expand Down Expand Up @@ -1225,6 +1225,5 @@
"Invalid refresh interval": "Ungültiger Aktualisierungsintervall",
"Refresh interval": "Aktualisierungsintervall",
"Resume": "Wiederaufnehmen",
"No user defined stickers.": "Keine benutzerdefinierten Sticker.",
"Show internal stickers": "Zeige interne Sticker"
}
"No user defined stickers.": "Keine benutzerdefinierten Sticker."
}
4 changes: 1 addition & 3 deletions src/i18n/json/es-AR.json
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,6 @@
"Grouping": "Agrupar",
"HTTP client": "Cliente HTTP",
"HTTP download": "Descarga HTTP",
"Hate song": "No me gusta",
"Help to improve myMPD": "Ayuda a mejorar myMPD",
"Highlight color": "Color de resaltado",
"Highlight contrast color": "Color de contraste de realce",
Expand Down Expand Up @@ -457,7 +456,6 @@
"Logout": "Cerrar sesión",
"Logs messages to the myMPD log.": "Registra mensajes en el registro myMPD.",
"Lookup at musicbrainz": "Buscar en MusicBrainz",
"Love song": "Me gusta",
"Love, hate": "Me gusta/No me gusta",
"Lua is not compiled in": "Lua no está compilada en",
"Lyrics": "Letras",
Expand Down Expand Up @@ -1201,4 +1199,4 @@
"url_resolved": "url_resuelto",
"votes": "votos",
"wasapi": "Windows Audio Session API"
}
}
4 changes: 1 addition & 3 deletions src/i18n/json/es-ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,6 @@
"Grouping": "Agrupar",
"HTTP client": "Cliente HTTP",
"HTTP download": "",
"Hate song": "Odio esta canción",
"Help to improve myMPD": "Ayuda a mejorar myMPD",
"Highlight color": "Color de resaltado",
"Highlight contrast color": "",
Expand Down Expand Up @@ -457,7 +456,6 @@
"Logout": "",
"Logs messages to the myMPD log.": "",
"Lookup at musicbrainz": "",
"Love song": "",
"Love, hate": "",
"Lua is not compiled in": "",
"Lyrics": "",
Expand Down Expand Up @@ -1201,4 +1199,4 @@
"url_resolved": "",
"votes": "",
"wasapi": ""
}
}
4 changes: 1 addition & 3 deletions src/i18n/json/es-VE.json
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,6 @@
"Grouping": "Agrupación",
"HTTP client": "",
"HTTP download": "",
"Hate song": "No me gusta esta canción",
"Help to improve myMPD": "",
"Highlight color": "Color de realce",
"Highlight contrast color": "",
Expand Down Expand Up @@ -457,7 +456,6 @@
"Logout": "",
"Logs messages to the myMPD log.": "",
"Lookup at musicbrainz": "",
"Love song": "Me gusta esta canción",
"Love, hate": "",
"Lua is not compiled in": "",
"Lyrics": "Letras",
Expand Down Expand Up @@ -1201,4 +1199,4 @@
"url_resolved": "",
"votes": "",
"wasapi": ""
}
}
4 changes: 1 addition & 3 deletions src/i18n/json/fi-FI.json
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,6 @@
"Grouping": "Ryhmittely",
"HTTP client": "",
"HTTP download": "",
"Hate song": "Dissaa kappaletta",
"Help to improve myMPD": "",
"Highlight color": "Valintaväri",
"Highlight contrast color": "",
Expand Down Expand Up @@ -457,7 +456,6 @@
"Logout": "",
"Logs messages to the myMPD log.": "",
"Lookup at musicbrainz": "",
"Love song": "Tykkää kappaleesta",
"Love, hate": "",
"Lua is not compiled in": "",
"Lyrics": "Sanoitukset",
Expand Down Expand Up @@ -1201,4 +1199,4 @@
"url_resolved": "",
"votes": "",
"wasapi": ""
}
}
4 changes: 1 addition & 3 deletions src/i18n/json/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,6 @@
"Grouping": "Groupement",
"HTTP client": "Client HTTP",
"HTTP download": "Téléchargement HTTP",
"Hate song": "Je n'aime pas cette chanson",
"Help to improve myMPD": "Aider à améliorer myMPD",
"Highlight color": "Couleur de différenciation",
"Highlight contrast color": "Contraste de différenciation",
Expand Down Expand Up @@ -457,7 +456,6 @@
"Logout": "Déconnexion",
"Logs messages to the myMPD log.": "Ecrit les messages dans le journal myMPD",
"Lookup at musicbrainz": "Rechercher sur Musicbrainz",
"Love song": "J'aime cette chanson",
"Love, hate": "J'aime / Je n'aime pas",
"Lua is not compiled in": "Lua n'a pas été compilé",
"Lyrics": "Paroles",
Expand Down Expand Up @@ -1201,4 +1199,4 @@
"url_resolved": "url_résolue",
"votes": "votes",
"wasapi": "Windows Audio Session API"
}
}
Loading

0 comments on commit e129665

Please sign in to comment.