PageSourceSearch

https://scoring.evidencebasedwyoming.com/js/fileHelpers.js

js evidencebasedwyoming.com collected 2026-10-01 02:04:08 UTC 1,506 bytes, 39 lines download raw bytes

1// fileHelpers.js - JavaScript helpers for file download/upload in Blazor
2// Copyright (c) 2024-Present Jackalope Technologies and Douglas Gerard All rights reserved.
3
4/**
5 * Downloads a file with the given content.
6 * @param {string} fileName - The name of the file to download.
7 * @param {string} content - The file content as a string.
8 * @param {string} contentType - The MIME type of the file (e.g., "application/json").
9 */
10window.downloadFile = function (fileName, content, contentType) {
11    const blob = new Blob([content], { type: contentType });
12    const url = URL.createObjectURL(blob);
13    const link = document.createElement('a');
14    link.href = url;
15    link.download = fileName;
16    document.body.appendChild(link);
17    link.click();
18    document.body.removeChild(link);
19    URL.revokeObjectURL(url);
20};
21
22/**
23 * Reads a file and returns its text content.
24 * @param {HTMLInputElement} inputElement - The file input element.
25 * @returns {Promise<string>} - A promise that resolves to the file content as a string.
26 */
27window.readFileAsText = function (inputElement) {
28    return new Promise((resolve, reject) => {
29        if (!inputElement.files || inputElement.files.length === 0) {
30            reject('No file selected');
31            return;
32        }
33        const file = inputElement.files[0];
34        const reader = new FileReader();
35        reader.onload = () => resolve(reader.result);
36        reader.onerror = () => reject(reader.error);
37        reader.readAsText(file);
38    });
39};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.