Fix bookmarklet bugs
authorJakob Cornell <jakob@jcornell.net>
Sun, 5 Jan 2020 07:50:09 +0000 (01:50 -0600)
committerJakob Cornell <jakob@jcornell.net>
Sun, 5 Jan 2020 07:50:09 +0000 (01:50 -0600)
main.py
table_bookmarklet

diff --git a/main.py b/main.py
index 882888d62ae9dee3cbc996e807434489d910a7e4..ac2e236f0a9923152bd8e8b74d015b71dce52732 100644 (file)
--- a/main.py
+++ b/main.py
@@ -163,6 +163,7 @@ class AsyncHttpServer:
 
        def stop(self):
                self.server.shutdown()
+               self.server.server_close()
 
 class MainView(View):
        @contextmanager
@@ -273,7 +274,7 @@ class MainView(View):
                        server = AsyncHttpServer(57853, data)
                        server.start()
                        messagebox.showinfo(
-                               "Serving Table Data",
+                               "Serving Table Data",
                                "Table data is ready to be transferred to your browser. You may close this dialog when the transfer is complete.",
                        )
                        server.stop()
index fadfd815a7a49a1d8d7b90f78e179f86660ae5de..bf8278a4bd3423cb24a72cbc98bbac074fc22bc0 100644 (file)
@@ -1 +1 @@
-javascript:(function(){var r=new XMLHttpRequest();r.onReadyStateChange=d;function d(){if(r.readyState===XMLHttpRequest.DONE){var rows=JSON.parse(r.responseText);var t=document.createElement('table');var h=t.createTHead();rows.shift().forEach(v=>{var c=document.createElement('th');c.innerText=v;h.appendChild(c);});rows.forEach(r=>{var tr=t.insertRow(-1);r.forEach(v=>{var c=document.createElement('td');c.innerText=v;tr.appendChild(c);});});var box=document.querySelector('[contenteditable="true"]');box.appendChild(document.createElement('br'));box.appendChild(t);box.appendChild(document.createElement('br'));}}})()
+javascript:(function(){var r=new XMLHttpRequest();r.onreadystatechange=d;r.responseType='json';r.open('GET','http://localhost:57853/');r.send();function d(){if(r.readyState===XMLHttpRequest.DONE){var rows=r.response;var t=document.createElement('table');var h=t.createTHead();console.log(rows);rows.shift().forEach(v=>{var c=document.createElement('th');c.innerText=v;h.appendChild(c);});rows.forEach(r=>{var tr=t.insertRow(-1);r.forEach(v=>{var c=document.createElement('td');c.innerText=v;tr.appendChild(c);});});var box=document.querySelector('[contenteditable="true"]');box.appendChild(document.createElement('br'));box.appendChild(t);box.appendChild(document.createElement('br'));}}})()