api link v1

main
samerbam 1 year ago
parent e6bc1c1b38
commit 9442aac222

@ -3,7 +3,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1,user-scalable=0"/>
<title>Test</title> <title>Test</title>
<script src="https://cdn.tailwindcss.com"></script> <script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@10/swiper-bundle.min.css" /> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@10/swiper-bundle.min.css" />

@ -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) { function printButtonListener(e) {
let action = "" let action = ""
let sentence = ""
switch(this.id) { switch(this.id) {
case "printGreeting": case "printGreeting":
action = "greeting" action = "greeting"
@ -597,7 +622,7 @@ function printButtonListener(e) {
break; break;
case "printSentence": case "printSentence":
action = "sentence" action = "sentence"
let sentence = prompt("What would you like to print?") sentence = prompt("What would you like to print?")
break; break;
case "printAll": case "printAll":
action = "all" action = "all"
@ -606,6 +631,8 @@ function printButtonListener(e) {
document.getElementById("printModel").classList.add("hidden") document.getElementById("printModel").classList.add("hidden")
return return
} }
console.log(sendPrintRequest(action, dayjs(document.getElementById("date-view").innerHTML.slice(4), "MMM D, YYYY").format("YYYY-MM-DD")), sentence)
} }
function switchDayListener(e) { function switchDayListener(e) {

@ -1,3 +1,7 @@
body {
touch-action: manipulation;
}
#radios { #radios {
position: relative; position: relative;
background-color:rgba(239,239,240,1); background-color:rgba(239,239,240,1);

Loading…
Cancel
Save