From 9442aac222463ce81e4800bd1830f94ad22cde06 Mon Sep 17 00:00:00 2001 From: samerbam Date: Thu, 24 Aug 2023 16:56:55 -0400 Subject: [PATCH] api link v1 --- application/static/index.html | 2 +- application/static/scripts.js | 29 ++++++++++++++++++++++++++++- application/static/styles.css | 4 ++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/application/static/index.html b/application/static/index.html index 74e8c5b..cf0bc3d 100644 --- a/application/static/index.html +++ b/application/static/index.html @@ -3,7 +3,7 @@ - + Test diff --git a/application/static/scripts.js b/application/static/scripts.js index 6f2b8c6..4b8cbe6 100644 --- a/application/static/scripts.js +++ b/application/static/scripts.js @@ -577,8 +577,33 @@ function savePrintButtonListener(e) { } +function sendPrintRequest(action, date, sentence="") { + return fetch("/api/todos/print", { + method: "post", + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json' + }, + + //make sure to serialize your JSON body + body: JSON.stringify({ + date: date, + action: action, + sentence: sentence + }) + }) + .then( (response) => { + return response.json().then(r => { + return r.status + }) + //do something awesome that makes the world a better place + }); +} + + function printButtonListener(e) { let action = "" + let sentence = "" switch(this.id) { case "printGreeting": action = "greeting" @@ -597,7 +622,7 @@ function printButtonListener(e) { break; case "printSentence": action = "sentence" - let sentence = prompt("What would you like to print?") + sentence = prompt("What would you like to print?") break; case "printAll": action = "all" @@ -606,6 +631,8 @@ function printButtonListener(e) { document.getElementById("printModel").classList.add("hidden") return } + + console.log(sendPrintRequest(action, dayjs(document.getElementById("date-view").innerHTML.slice(4), "MMM D, YYYY").format("YYYY-MM-DD")), sentence) } function switchDayListener(e) { diff --git a/application/static/styles.css b/application/static/styles.css index df806f1..03768ae 100644 --- a/application/static/styles.css +++ b/application/static/styles.css @@ -1,3 +1,7 @@ +body { + touch-action: manipulation; +} + #radios { position: relative; background-color:rgba(239,239,240,1);