about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/index.html32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/index.html b/src/index.html
index 15ccfc0..1fc2a96 100644
--- a/src/index.html
+++ b/src/index.html
@@ -66,7 +66,6 @@
             }
 
             async function query_channels() {
-                return ["main", "likes", "bookmarks"]
                 const response = await fetch(form.action + "?q=config", {
                     headers: {
                         "Authorization": `Bearer ${form.elements.access_token.value}`
@@ -86,10 +85,10 @@
                     const template = document.getElementById("channel_selector").content.cloneNode(true)
                     const input = template.querySelector("input")
                     const label = template.querySelector("label")
-                    input.id = `channel_selector_option_${channel}`
-                    input.value = channel
+                    input.id = `channel_selector_option_${channel.uid}`
+                    input.value = channel.uid
                     label.for = input.id
-                    label.innerHTML = `<code>${channel}</code>`
+                    label.innerHTML = `<a href="${channel.uid}">${channel.name}</a>`
 
                     channel_list.appendChild(template)
                 })
@@ -98,13 +97,24 @@
             form.onsubmit = async (event) => {
                 event.preventDefault()
                 console.log(JSON.stringify(construct_body(form)))
-                return
-                const response = await fetch(form.action, {
-                    headers: {
-                        "Authorization": `Bearer ${form.elements.access_token.value}`
-                    },
-                    body: construct_body(form)
-                })
+                try {
+                    const response = await fetch(form.action, {
+                        method: form.method,
+                        headers: {
+                            "Authorization": `Bearer ${form.elements.access_token.value}`,
+                            "Content-Type": "application/json"
+                        },
+                        body: JSON.stringify(construct_body(form))
+                    })
+                    if (response.status != 201 || response.status != 202) {
+                        console.error(await response.json());
+                    }
+                    if (response.headers.get("Location")) {
+                        window.location.href = response.headers.get("Location");
+                    }
+                } catch (e) {
+                    console.error(e)
+                }
             }
         </script>
     </head>