Показать сообщение отдельно
  #9 (permalink)  
Старый 30.06.2021, 10:47
Аспирант
Отправить личное сообщение для prototip Посмотреть профиль Найти все сообщения от prototip
 
Регистрация: 15.05.2021
Сообщений: 35

подскажите, если загружаю файл docx результат не выводится. в чем может быть причина?
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>file</title>
    <link rel="stylesheet" href="index.css">
</head>
<body>
<div>
    <div id="drop-area">
        Drag and drop file here
    </div>
</div>

<div class="file-read">
    <div class="file-input">
        <label class="custom-file-upload">
        <input type="file" onchange="show(this)">
            Upload a file
        </label>
    </div>

    <a href="">Reset</a>

</div>

<div id="table-div">
    <table id="out" width="30%"></table>
</div>

<script src="https://unpkg.com/lodash@4.17.21/lodash.min.js"></script>
<script>
    function show(input) {
        const file = input.files[0];

            const reader = new FileReader();
            reader.readAsText(file, "UTF-8");
            reader.onload = () => {
                const res = _.words(reader.result, /[-а-яё]{4,}/gim);
                const result = _.flow([
                    _.countBy,
                    _.toPairs,
                    _.partial(_.orderBy, _, 1, 'desc'),
                    _.partial(_.take, _, 10),
                ]);
                let txt = result(res).map(([word, num]) => `<tr><td>${word}<td>${num}`).join('');
                let out= document.getElementById('out');
                out.insertAdjacentHTML('beforeend', txt);
            };
    }
</script>
</body>
</html>
Ответить с цитированием