|
@@ -2,6 +2,7 @@ fetch("/writing/comments/touchscreens")
|
|
|
.then(response => response.json())
|
|
.then(response => response.json())
|
|
|
.then((response)=>{
|
|
.then((response)=>{
|
|
|
if(typeof(response) === "string"){
|
|
if(typeof(response) === "string"){
|
|
|
|
|
+ console.log(response);
|
|
|
}else{
|
|
}else{
|
|
|
let comments = document.getElementById("comments");
|
|
let comments = document.getElementById("comments");
|
|
|
let template = document.getElementById("comment").content.children[0];
|
|
let template = document.getElementById("comment").content.children[0];
|
|
@@ -9,19 +10,22 @@ fetch("/writing/comments/touchscreens")
|
|
|
let dateOptions = {
|
|
let dateOptions = {
|
|
|
month: "long",
|
|
month: "long",
|
|
|
day: "numeric",
|
|
day: "numeric",
|
|
|
- year: "numeric"
|
|
|
|
|
|
|
+ year: "numeric",
|
|
|
|
|
+ hour: "2-digit",
|
|
|
|
|
+ minute: "2-digit"
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
for(let i = 0; i < response.length; i++){
|
|
for(let i = 0; i < response.length; i++){
|
|
|
let comment = template.cloneNode(true);
|
|
let comment = template.cloneNode(true);
|
|
|
comment.children[0].children[0].innerText = response[i].name;
|
|
comment.children[0].children[0].innerText = response[i].name;
|
|
|
- comment.children[0].children[1].innerText = new Date(response[i].date).toLocaleDateString("en-US", dateOptions);
|
|
|
|
|
|
|
+ comment.children[0].children[1].innerText = new Date(response[i].date).toLocaleString("en-US", dateOptions);
|
|
|
comment.children[1].innerText = response[i].content;
|
|
comment.children[1].innerText = response[i].content;
|
|
|
comments.appendChild(comment);
|
|
comments.appendChild(comment);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
.catch((err)=>{
|
|
.catch((err)=>{
|
|
|
|
|
+ console.log(err);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
createComment = ()=>{
|
|
createComment = ()=>{
|
|
@@ -44,23 +48,28 @@ fetch("/writing/comments/touchscreens")
|
|
|
.then(response => response.json())
|
|
.then(response => response.json())
|
|
|
.then((response)=>{
|
|
.then((response)=>{
|
|
|
if(typeof(response) === "string"){
|
|
if(typeof(response) === "string"){
|
|
|
|
|
+ console.log(response);
|
|
|
}else{
|
|
}else{
|
|
|
|
|
+
|
|
|
let comments = document.getElementById("comments");
|
|
let comments = document.getElementById("comments");
|
|
|
let comment = document.getElementById("comment").content.children[0].cloneNode(true);
|
|
let comment = document.getElementById("comment").content.children[0].cloneNode(true);
|
|
|
|
|
|
|
|
let dateOptions = {
|
|
let dateOptions = {
|
|
|
month: "long",
|
|
month: "long",
|
|
|
day: "numeric",
|
|
day: "numeric",
|
|
|
- year: "long"
|
|
|
|
|
|
|
+ year: "numeric",
|
|
|
|
|
+ hour: "2-digit",
|
|
|
|
|
+ minute: "2-digit"
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
comment.children[0].children[0].innerText = response.name;
|
|
comment.children[0].children[0].innerText = response.name;
|
|
|
- comment.children[0].children[1].innerText = new Date(response.date).toLocaleDateString("en-US", dateOptions);
|
|
|
|
|
|
|
+ comment.children[0].children[1].innerText = new Date(response.date).toLocaleString("en-US", dateOptions);
|
|
|
comment.children[1].innerText = response.content;
|
|
comment.children[1].innerText = response.content;
|
|
|
comments.insertBefore(comment, comments.children[1]);
|
|
comments.insertBefore(comment, comments.children[1]);
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
.catch((err)=>{
|
|
.catch((err)=>{
|
|
|
|
|
+ console.log(err);
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|