This commit is contained in:
lalka2016 2023-07-03 14:53:16 +03:00
parent 3b50c6d4f8
commit fcf281bf58
3 changed files with 27 additions and 9 deletions

View file

@ -189,14 +189,24 @@ tippy(".client_app", {
} }
}); });
function addNote(textareaId, id, name) function addNote(textareaId, nid)
{ {
note.value = id if(nid > 0) {
note.value = nid
let noteObj = document.querySelector("#nd"+nid)
let nortd = document.querySelector("#post-buttons"+textareaId+" .post-has-note"); let nortd = document.querySelector("#post-buttons"+textareaId+" .post-has-note");
nortd.style.display = "block" nortd.style.display = "block"
nortd.innerHTML = `${tr("note")} ${escapeHtml(name)}` nortd.innerHTML = `${tr("note")} ${escapeHtml(noteObj.dataset.name)}`
} else {
note.value = "none"
let nortd = document.querySelector("#post-buttons"+textareaId+" .post-has-note");
nortd.style.display = "none"
nortd.innerHTML = ""
}
u("body").removeClass("dimmed"); u("body").removeClass("dimmed");
u(".ovk-diag-cont").remove(); u(".ovk-diag-cont").remove();
@ -215,12 +225,18 @@ async function attachNote(id)
} else { } else {
body = ` body = `
${tr("select_or_create_new")} ${tr("select_or_create_new")}
<div id="notesList"> <div id="notesList">`
`
if(note.value != "none") {
body += `
<div class="ntSelect" onclick="addNote(${id}, 0)">
<span>${tr("do_not_attach_note")}</span>
</div>`
}
for(const note of notes.items) { for(const note of notes.items) {
body += ` body += `
<div class="ntSelect" onclick="addNote(${id}, ${note.id}, '${note.name}')"> <div data-name="${note.name}" class="ntSelect" id="nd${note.id}" onclick="addNote(${id}, ${note.id})">
<span>${escapeHtml(note.name)}</span> <span>${escapeHtml(note.name)}</span>
</div> </div>
` `

View file

@ -412,6 +412,7 @@
"select_or_create_new" = "Select existing note or <a href='/notes/create'>create new one</a>"; "select_or_create_new" = "Select existing note or <a href='/notes/create'>create new one</a>";
"notes_closed" = "You can't attach note to post, because only you can see them.<br> You can change it in <a href=\"/settings?act=privacy\">settings</a>."; "notes_closed" = "You can't attach note to post, because only you can see them.<br> You can change it in <a href=\"/settings?act=privacy\">settings</a>.";
"do_not_attach_note" = "Do not attach note";
/* Menus */ /* Menus */

View file

@ -397,6 +397,7 @@
"select_or_create_new" = "Выберите существующую заметку или <a href='/notes/create'>создайте новую</a>"; "select_or_create_new" = "Выберите существующую заметку или <a href='/notes/create'>создайте новую</a>";
"notes_closed" = "Вы не можете прикрепить заметку к записи, так как ваши заметки видны только вам.<br><br> Вы можете поменять это в <a href=\"/settings?act=privacy\">настройках</a>."; "notes_closed" = "Вы не можете прикрепить заметку к записи, так как ваши заметки видны только вам.<br><br> Вы можете поменять это в <a href=\"/settings?act=privacy\">настройках</a>.";
"do_not_attach_note" = "Не прикреплять заметку";
/* Menus */ /* Menus */