31 lines
1.1 KiB
JavaScript
31 lines
1.1 KiB
JavaScript
var imgContainer = document.getElementById('response-container')
|
|
function filling(line){
|
|
const Container =
|
|
`<button class="col-xxl-4 col-lg-6 col-12 p-0 btn mx-auto my-2 my-sm-4 p-0 bg-image rounded-8 PictureButton" data-bs-toggle="modal" data-bs-target="#imageModal">
|
|
<img src="` + line + `" class="rounded-8 width-100" alt="image">
|
|
</button>`
|
|
imgContainer.innerHTML += Container
|
|
}
|
|
function Fill(){
|
|
fetch('imgs.txt')
|
|
.then(response => response.text())
|
|
.then(data => {
|
|
readFile(data)
|
|
})
|
|
.catch(error => {
|
|
console.error('Ошибка:', error);
|
|
});
|
|
}
|
|
|
|
|
|
async function readFile(file) {
|
|
console.log(file);
|
|
const arr = file.split(/\r?\n/gm)
|
|
arr.map(line => filling(line))
|
|
console.log('done')
|
|
imgContainer.innerHTML += `
|
|
<button onclick="file.click()" type="button" class="col-xxl-4 col-lg-6 col-12 p-0 btn btn-dark mx-auto my-4 rounded-8 fw-bold fs-1 PictureButton">
|
|
+
|
|
</button>
|
|
<input id="file" type="file" hidden`
|
|
} |