This commit is contained in:
parent
0d3bf4be19
commit
cfb7baff52
@ -5,6 +5,7 @@ module.exports = (app, client) => {
|
||||
{ parser } = require('stream-json'),
|
||||
{ streamArray } = require('stream-json/streamers/StreamArray'),
|
||||
{ chain } = require('stream-chain'),
|
||||
{ stringer } = require('stream-json/jsonl/Stringer'),
|
||||
clean = str => {
|
||||
return str.replace(/[/\\^$+?()`'¡¿¨!"·%&=;,\|\[\]{}]+/gmi, '')
|
||||
}
|
||||
@ -472,12 +473,10 @@ module.exports = (app, client) => {
|
||||
parser(),
|
||||
pick({ filter: 'hits.hits' }),
|
||||
streamArray(),
|
||||
data => ({ instance: data.value._source.instance, comment: data.value._source.blocks.find(block => block.domain === clean(req.params.instance)).comment })
|
||||
data => ({ instance: data.value._source.instance, comment: data.value._source.blocks.find(block => block.domain === clean(req.params.instance)).comment }),
|
||||
stringer({ objectMode: true })
|
||||
])
|
||||
pipeline.on('readable', () => res.write('['))
|
||||
pipeline.on('data', data => res.write(data.toString() + ','))
|
||||
pipeline.on('end', () => res.end(']'))
|
||||
result.pipe(pipeline)
|
||||
result.pipe(pipeline).pipe(res)
|
||||
} else {
|
||||
res.status(404).end()
|
||||
}
|
||||
|
@ -37,9 +37,9 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
if (content && content.length > 0) {
|
||||
loading()
|
||||
fetch('/api/block_count/' + content).then(async function (result) {
|
||||
var res = await result.json()
|
||||
if (Array.isArray(res) && res?.length >= 0) {
|
||||
document.getElementById('blockcount').innerText = res.length
|
||||
var res = await result.text()
|
||||
if (res?.length >= 0) {
|
||||
document.getElementById('blockcount').innerText = res.split('\n').length
|
||||
document.getElementById('blockinstance').innerText = 'ing ' + content
|
||||
document.getElementById('blocktook').innerText = ''
|
||||
var list = document.getElementById('blocklist'),
|
||||
@ -50,7 +50,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
while (list.hasChildNodes()) {
|
||||
list.removeChild(list.firstChild)
|
||||
}
|
||||
res.map(function (instance, index) {
|
||||
res.split('\n').map(JSON.parse).map(function (instance, index) {
|
||||
var li = document.createElement('li'),
|
||||
text = document.createTextNode((index + 1) + '. '),
|
||||
link = '<a href="/' + (new URLSearchParams(window.location.search).has('matrix') ? '?matrix' : '') + '#' + instance.instance + '" onclick="window.location.href=this.href; window.location.reload(false);">' + instance.instance + '</a>',
|
||||
|
Loading…
Reference in New Issue
Block a user