.client {
display: inline-block;
vertical-align: top;
- width: 300px;
+ width: 600px;
margin-top: 5px;
margin-left: 5px;
border: 2px solid black;
.templatecontainer {
display: inline-block;
vertical-align: top;
- width: 280px;
+ width: 580px;
white-space: normal;
}
border-spacing: 2px;
}
+.message .array {
+ display: flex;
+ flex-direction: row;
+ flex-wrap: wrap;
+}
+
+.message .array > * {
+ vertical-align: baseline;
+}
+
+.message .object {
+ display: flex;
+ flex-direction: column;
+ border: 1px solid black;
+ padding-top: 2px;
+ padding-left: 2px;
+ margin-bottom: 2px;
+}
+
+.message .object > .property {
+ display: flex;
+ flex-direction: row;
+ flex-wrap: wrap;
+}
+
+.message .object > .property > .key {
+ margin-right: 2px;
+ margin-bottom: 2px;
+}
+
+.message .object > .property > .value {
+ display: flex;
+ flex-direction: row;
+ flex-wrap: wrap;
+ margin-right: 2px;
+ margin-bottom: 2px;
+}
+
.message input {
background-color: #35bfd3;
}
}
}
+// Recursively create div structure for arrays, objects and primitive
+// values:
+function createForMessageValue(value) {
+ var result = ''
+ if (typeof(value) == 'object') {
+ if (Array.isArray(value)) {
+ result = document.createElement('div')
+ result.setAttribute('class', 'array')
+ var counter = value.length
+ for (const child of value) {
+ result.appendChild(createForMessageValue(child))
+ if (--counter) {
+ result.appendChild(document.createTextNode(', '))
+ }
+ }
+ } else {
+ result = document.createElement('div')
+ result.setAttribute('class', 'object')
+ for (const key in value) {
+ const property = document.createElement('div')
+ property.setAttribute('class', 'property')
+ const keyDiv = document.createElement('div')
+ keyDiv.setAttribute('class', 'key')
+ keyDiv.appendChild(document.createTextNode(key + ':'))
+ property.appendChild(keyDiv)
+ const valueDiv = document.createElement('div')
+ valueDiv.setAttribute('class', 'value')
+ valueDiv.appendChild(createForMessageValue(value[key]))
+ property.appendChild(valueDiv)
+ result.appendChild(property)
+ }
+ }
+ } else {
+ result = document.createTextNode(JSON.stringify(value))
+ }
+ return result
+}
+
// Create div and table for message:
function createForMessage(message) {
const div = document.createElement('div')
keyTd.appendChild(keyTdContent)
tr.appendChild(keyTd)
const valueTd = document.createElement('td')
- value = JSON.stringify(message[key])
- const valueTdContent = document.createTextNode(value)
- valueTd.appendChild(valueTdContent)
+ valueTd.appendChild(createForMessageValue(message[key]))
tr.appendChild(valueTd)
table.appendChild(tr)
}