This commit is contained in:
parent
0d3bf4be19
commit
cfb7baff52
@ -5,6 +5,7 @@ module.exports = (app, client) => {
|
|||||||
{ parser } = require('stream-json'),
|
{ parser } = require('stream-json'),
|
||||||
{ streamArray } = require('stream-json/streamers/StreamArray'),
|
{ streamArray } = require('stream-json/streamers/StreamArray'),
|
||||||
{ chain } = require('stream-chain'),
|
{ chain } = require('stream-chain'),
|
||||||
|
{ stringer } = require('stream-json/jsonl/Stringer'),
|
||||||
clean = str => {
|
clean = str => {
|
||||||
return str.replace(/[/\\^$+?()`'¡¿¨!"·%&=;,\|\[\]{}]+/gmi, '')
|
return str.replace(/[/\\^$+?()`'¡¿¨!"·%&=;,\|\[\]{}]+/gmi, '')
|
||||||
}
|
}
|
||||||
@ -472,12 +473,10 @@ module.exports = (app, client) => {
|
|||||||
parser(),
|
parser(),
|
||||||
pick({ filter: 'hits.hits' }),
|
pick({ filter: 'hits.hits' }),
|
||||||
streamArray(),
|
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('['))
|
result.pipe(pipeline).pipe(res)
|
||||||
pipeline.on('data', data => res.write(data.toString() + ','))
|
|
||||||
pipeline.on('end', () => res.end(']'))
|
|
||||||
result.pipe(pipeline)
|
|
||||||
} else {
|
} else {
|
||||||
res.status(404).end()
|
res.status(404).end()
|
||||||
}
|
}
|
||||||
|
@ -37,9 +37,9 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
if (content && content.length > 0) {
|
if (content && content.length > 0) {
|
||||||
loading()
|
loading()
|
||||||
fetch('/api/block_count/' + content).then(async function (result) {
|
fetch('/api/block_count/' + content).then(async function (result) {
|
||||||
var res = await result.json()
|
var res = await result.text()
|
||||||
if (Array.isArray(res) && res?.length >= 0) {
|
if (res?.length >= 0) {
|
||||||
document.getElementById('blockcount').innerText = res.length
|
document.getElementById('blockcount').innerText = res.split('\n').length
|
||||||
document.getElementById('blockinstance').innerText = 'ing ' + content
|
document.getElementById('blockinstance').innerText = 'ing ' + content
|
||||||
document.getElementById('blocktook').innerText = ''
|
document.getElementById('blocktook').innerText = ''
|
||||||
var list = document.getElementById('blocklist'),
|
var list = document.getElementById('blocklist'),
|
||||||
@ -50,7 +50,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
while (list.hasChildNodes()) {
|
while (list.hasChildNodes()) {
|
||||||
list.removeChild(list.firstChild)
|
list.removeChild(list.firstChild)
|
||||||
}
|
}
|
||||||
res.map(function (instance, index) {
|
res.split('\n').map(JSON.parse).map(function (instance, index) {
|
||||||
var li = document.createElement('li'),
|
var li = document.createElement('li'),
|
||||||
text = document.createTextNode((index + 1) + '. '),
|
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>',
|
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