message auto wrap

This commit is contained in:
wangjiacai 2023-04-04 00:38:02 +08:00
parent f4bd302e9d
commit ce89247a9c

View File

@ -54,14 +54,12 @@
if (msg.response == "" && msg.request != "") { if (msg.response == "" && msg.request != "") {
li.style.textAlign = "right" li.style.textAlign = "right"
pre.innerText = msg.request pre.innerText = msg.request
pre.style.backgroundColor = "lightblue" pre.style = "background-color: lightblue; border-radius: 10px; padding: 5px; white-space: pre-wrap; word-wrap: break-word;"
} else if (msg.request != "") { } else if (msg.request != "") {
li.style.textAlign = "left" li.style.textAlign = "left"
pre.innerText = msg.response pre.innerText = msg.response
pre.style.backgroundColor = "lightgreen" pre.style = "background-color: lightgreen; border-radius: 10px; padding: 5px; white-space: pre-wrap; word-wrap: break-word;"
} }
pre.style.borderRadius = "10px"
pre.style.padding = "5px"
msg_list.appendChild(li) msg_list.appendChild(li)
}) })
window.scrollTo(0,document.documentElement.scrollHeight) window.scrollTo(0,document.documentElement.scrollHeight)
@ -85,9 +83,7 @@
li.style.textAlign="right" li.style.textAlign="right"
li.style.marginBottom="20px" li.style.marginBottom="20px"
pre.innerText=data.msg pre.innerText=data.msg
pre.style.backgroundColor="lightblue" pre.style = "background-color: lightblue; border-radius: 10px; padding: 5px; white-space: pre-wrap; word-wrap: break-word;"
pre.style.borderRadius="10px"
pre.style.padding="5px"
msg_list.appendChild(li) msg_list.appendChild(li)
} }
msgbox.value="" msgbox.value=""
@ -108,9 +104,7 @@
pre.innerText=response.message pre.innerText=response.message
li.style.textAlign="left" li.style.textAlign="left"
li.style.marginBottom="20px" li.style.marginBottom="20px"
pre.style.backgroundColor="lightgreen" pre.style = "background-color: lightgreen; border-radius: 10px; padding: 5px; white-space: pre-wrap; word-wrap: break-word;"
pre.style.borderRadius="10px"
pre.style.padding="5px"
msg_list.appendChild(li) msg_list.appendChild(li)
msg_list.appendChild(document.createElement('br')) msg_list.appendChild(document.createElement('br'))
} }