Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions src/templates/report.html
Original file line number Diff line number Diff line change
Expand Up @@ -468,36 +468,37 @@ <h2 class="system-info-heading">System Information</h2>
// Function to recursively create formatted HTML
function formatJSON(obj, indent = 0, isTopLevel = true) {
const indentString = ' '.repeat(indent)
let html = ''
let result = ''

if (Array.isArray(obj)) {
html += '[\n'
result += '[\n'
obj.forEach((item, index) => {
html += indentString + ' '
html += formatJSON(item, indent + 1, false)
if (index < obj.length - 1) html += ','
html += '\n'
result += indentString + ' '
result += formatJSON(item, indent + 1, false)
if (index < obj.length - 1) result += ','
result += '\n'
})
html += indentString + ']'
result += indentString + ']'
} else if (typeof obj === 'object' && obj !== null) {
html += '{\n'
result += '{\n'
const keys = Object.keys(obj)
keys.forEach((key, index) => {
html += indentString + ' '
html += isTopLevel ? `<strong>"${key}"</strong>: ` : `"${key}": `
html += formatJSON(obj[key], indent + 1, false)
if (index < keys.length - 1) html += ','
html += '\n'
result += indentString + ' '
result += isTopLevel ? `"${key}": ` : `"${key}": `
result += formatJSON(obj[key], indent + 1, false)
if (index < keys.length - 1) result += ','
result += '\n'
})
html += indentString + '}'
result += indentString + '}'
} else {
html += JSON.stringify(obj)
result += JSON.stringify(obj)
}

return html
return result
}

preElement.innerHTML = formatJSON(jsonObject)
const formattedJSON = formatJSON(jsonObject)
preElement.appendChild(document.createTextNode(formattedJSON))
jsonObjectElement.appendChild(preElement)
} catch (error) {
console.error('Error parsing JSON:', error)
Expand Down
Loading