diff options
author | dan <[email protected]> | 2023-05-16 10:11:55 -0400 |
---|---|---|
committer | dan <[email protected]> | 2023-05-16 10:11:55 -0400 |
commit | b416c82ecc9ac8a94d059338c488507229d0996c (patch) | |
tree | 618bdc9d8b84b5ae3cf933d55db780f526aa351e /client.js | |
parent | aecc6ee8009fa70d012510a9babd50e5f364dece (diff) | |
download | simple-comments-widget-b416c82ecc9ac8a94d059338c488507229d0996c.tar.gz simple-comments-widget-b416c82ecc9ac8a94d059338c488507229d0996c.tar.bz2 simple-comments-widget-b416c82ecc9ac8a94d059338c488507229d0996c.zip |
fix: config moved to config.js
Diffstat (limited to 'client.js')
-rw-r--r-- | client.js | 14 |
1 files changed, 5 insertions, 9 deletions
@@ -1,10 +1,6 @@ -/* Config */ -const pageId = 'add-page-id-here'; -const commentsUrl = `${baseUrl}?page_url=${pageId}`; - /* Running State */ let comments = []; - + /* LocalStorage Access */ function getDeletionKeys() { @@ -38,7 +34,7 @@ function commentsRender() { // GET comments function fetchComments() { - fetch(commentsUrl) + fetch(`${config.base_url}?page_url=${config.page_id}`) .then(r => r.ok && r.json()) .then(xs => { comments = xs; @@ -58,7 +54,7 @@ function generateRandomKey() { // POST new comment function createComment(comment) { comment.deletion_key = generateRandomKey(); - fetch(baseUrl, { + fetch(config.base_url, { method: 'POST', body: JSON.stringify(comment), headers: {'content-type': 'application/json'} @@ -76,7 +72,7 @@ function createComment(comment) { function handleCommentFormSubmit() { if (commentcontent.value !== "") { createComment({ - page_url: pageId, + page_url: config.page_id, content: `${commentcontent.value}\n - ${username.value}`, bot: bot.value }); @@ -87,7 +83,7 @@ function handleCommentFormSubmit() { // DELETE comment function handleDelete(commentId, deletionKey) { fetch( - `${baseUrl}?comment=${commentId}&deletion_key=${deletionKey}`, + `${config.base_url}?comment=${commentId}&deletion_key=${deletionKey}`, {method: 'DELETE'} ).then(r => { if (r.ok) { |