<commit_before><commit_msg>added browser test<commit_after><!DOCTYPE html>

<!-- Test: Typical fullscreen usage; autoload an image and overlay. -->

<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

    <script type="text/javascript" src="../release/current/nifti-reader.js"></script>

    <script type="text/javascript">
        function toHTML(str) {
            str = str.replace(/^\s*/mg, function(x) { return new Array(++x.length).join('&nbsp;&nbsp;') });
            str = str.replace(/(?:\r\n|\r|\n)/g, '<br />');
            return str;
        }

        function readNIFTI(name, buf) {
            var header = nifti.readHeader(buf);

            var logger = document.getElementById('daikon');
            logger.innerHTML = toHTML(header.toFormattedString());
        }

        function makeSlice(file, start, length) {
            var fileType = (typeof File);

            if (fileType === 'undefined') {
                return function () {};
            }

            if (File.prototype.slice) {
                return file.slice(start, start + length);
            }

            if (File.prototype.mozSlice) {
                return file.mozSlice(start, length);
            }

            if (File.prototype.webkitSlice) {
                return file.webkitSlice(start, length);
            }

            return null;
        }

        function readFile(file) {
            var blob = makeSlice(file, 0, file.size);

            var reader = new FileReader();

            reader.onloadend = function (evt) {
                if (evt.target.readyState === FileReader.DONE) {
                    readNIFTI(file.name, evt.target.result);
                }
            };

            reader.readAsArrayBuffer(blob);
        }

        function handleFileSelect(evt) {
            var files = evt.target.files;
            readFile(files[0]);
        }
    </script>

    <title>NIFTI-Reader-JS Test</title>
</head>

<body>

<div id="select" style="font-family:sans-serif">
    <h3>NIFTI-Reader-JS &mdash; JavaScript NIFTI Reader</h3>
    <h4><a href="https://github.com/rii-mango/NIFTI-Reader-JS">https://github.com/rii-mango/NIFTI-Reader-JS</a></h4>
    <p>Select a file: <input type="file" id="file" name="files" /></p>
    <hr />
</div>

<div id="daikon" style="font-family:sans-serif"></div>

<script type="text/javascript">
    document.getElementById('file').addEventListener('change', handleFileSelect, false);
</script>

</body>

</html>

{'fraction_non_alphanumeric': 0.15876127009016072, 'fraction_numerical': 0.004704037632301058, 'mean_word_length': 2.082125603864734, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 35, 'https://': 2, 'lorem ipsum': 0, 'www.': 1, 'xml': 1}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5243204', 'n_tokens_mistral': 801, 'n_tokens_neox': 766, 'n_words': 143}