|
|
|
@ -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) {
|
|
|
|
|