diff --git a/classes/article.php b/classes/article.php index 1e90c843e..e64c17a32 100755 --- a/classes/article.php +++ b/classes/article.php @@ -419,21 +419,6 @@ class Article extends Handler_Protected { return $tags; } - static function _format_note_html($id, $note, $allow_edit = true) { - if ($allow_edit) { - $onclick = "onclick='Plugins.Note.edit($id)'"; - $note_class = 'editable'; - } else { - $onclick = ''; - $note_class = ''; - } - - return "
- note -
$note
-
"; - } - function getmetadatabyid() { $id = clean($_REQUEST['id']); diff --git a/classes/feeds.php b/classes/feeds.php index 5ad21ded9..b95ade2f5 100755 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -260,11 +260,6 @@ class Feeds extends Handler_Protected { $this->_mark_timestamp(" disk_cache_rewrite"); - if ($line['note']) - $line['note'] = Article::_format_note_html($id, $line['note']); - else - $line['note'] = ""; - $this->_mark_timestamp(" note"); if (!get_pref("CDM_EXPANDED")) { diff --git a/js/Article.js b/js/Article.js index 21973518c..d039882ec 100644 --- a/js/Article.js +++ b/js/Article.js @@ -130,6 +130,11 @@ const Article = { Headlines.toggleUnread(id, 0); }, + renderNote: function (id, note) { + return `
+ ${App.FormFields.icon('note')}
${note ? App.escapeHtml(note) : ""}
+
`; + }, renderTags: function (id, tags) { const tags_short = tags.length > 5 ? tags.slice(0, 5) : tags; @@ -300,7 +305,7 @@ const Article = {
${hl.buttons}
-
${hl.note}
+ ${Article.renderNote(hl.id, hl.note)}
${hl.content} ${Article.renderEnclosures(hl.enclosures)} diff --git a/js/Headlines.js b/js/Headlines.js index 9bc5747c2..60066164f 100755 --- a/js/Headlines.js +++ b/js/Headlines.js @@ -483,7 +483,7 @@ const Headlines = {
-
${hl.note}
+ ${Article.renderNote(hl.id, hl.note)}
diff --git a/js/common.js b/js/common.js index e88b62602..e616c70ba 100755 --- a/js/common.js +++ b/js/common.js @@ -71,9 +71,9 @@ Element.prototype.fadeOut = function() { }()); }; -Element.prototype.fadeIn = function(display){ +Element.prototype.fadeIn = function(display = undefined){ this.style.opacity = 0; - this.style.display = display || "block"; + this.style.display = display == undefined ? "block" : display; const self = this; (function fade() { diff --git a/plugins/note/init.php b/plugins/note/init.php index 278cfe6c3..f4bdf45bc 100644 --- a/plugins/note/init.php +++ b/plugins/note/init.php @@ -55,17 +55,14 @@ class Note extends Plugin { } function setNote() { - $id = $_REQUEST["id"]; - $note = trim(strip_tags($_REQUEST["note"])); + $id = (int)clean($_REQUEST["id"]); + $note = clean($_REQUEST["note"]); $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET note = ? WHERE ref_id = ? AND owner_uid = ?"); $sth->execute([$note, $id, $_SESSION['uid']]); - $formatted_note = Article::_format_note_html($id, $note); - - print json_encode(array("note" => $formatted_note, - "raw_length" => mb_strlen($note))); + print json_encode(["id" => $id, "note" => $note]); } function api_version() { diff --git a/plugins/note/note.js b/plugins/note/note.js index d42fca2c1..a46acb355 100644 --- a/plugins/note/note.js +++ b/plugins/note/note.js @@ -13,16 +13,14 @@ Plugins.Note = { dialog.hide(); if (reply) { - const elem = App.byId("POSTNOTE-" + id); + App.findAll(`div[data-note-for="${reply.id}"]`).forEach((elem) => { + elem.querySelector(".body").innerHTML = reply.note; - if (elem) { - elem.innerHTML = reply.note; - - if (reply.raw_length != 0) - Element.show(elem); + if (reply.note) + elem.show(); else - Element.hide(elem); - } + elem.hide(); + }); } }); }