/* CopyLeft 2022-2023 Pascal Engélibert (why copyleft? -> https://txmn.tk/blog/why-copyleft/) This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, version 3 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/. */ var webcomments = {}; const MODE_TOPIC = 1;// param: {topic:str} class Webcomment { constructor(root, api, mode, mode_param) { this.root = root; this.api = api; this.mode = mode; this.mode_param = mode_param; console.log("constr"); switch(mode) { case MODE_TOPIC: this.query_comments_by_topic(mode_param.topic); break; default: console.log("Webcomment: invalid mode"); } } query_comments_by_topic(topic) { console.log("query"); $.ajax({ method: "POST", url: this.api+"/api/comments_by_topic", data: JSON.stringify({ mutation_token: "", topic: topic, }), success: function(resp) { console.log(resp); }, dataType: "json", contentType: "application/json; charset=utf-8", }); } } function webcomment_topic(root_id, api, topic) { webcomments[root_id] = (new Webcomment(document.getElementById(root_id), api, MODE_TOPIC, {topic: topic})); }