1import { Controller } from "@hotwired/stimulus" 2 3export default class extends Controller { 4 //static targets = [ "selector" ]; 5 static values = { 6 container: String, 7 contents: String, 8 fileSelectedPrefix: String, 9 targetId: String, 10 } 11 12 connect() { 13 14 } 15 16 dragStart() { 17 $(this.element).addClass('is-active'); 18 } 19 dragStop() { 20 $(this.element).removeClass('is-active'); 21 } 22 23 fileChange() { 24 //console.log("fileChange called", $(this.element).find("input[type=file]").val()); 25 let filename = $(this.element).find("input[type=file]").val().split('\\').pop(); 26 $(this.element).find(".upload-message").html(this.fileSelectedPrefixValue + filename); 27 let id = '#processPdf' 28 if(this.targetIdValue){ 29 id = '#' + this.targetIdValue 30 } 31 if (filename) { 32 $(id).addClass("btn-primary") 33 $(id).removeClass("btn-fg-quinary") 34 $(id).removeClass("disabled") 35 $(id).removeAttr('disabled') 36 $(id).removeClass('disabled-without-opacity') 37 } 38 } 39 40 reset(event) { 41 const input = this.element.querySelector('input[type="file"]') 42 if (input) input.value = null 43 const message = this.element.querySelector(".upload-message") 44 45 if (message) { 46 message.innerHTML = ` 47 <span class="linkcolor">Click to upload</span> or drag and drop 48 <br> 49 PDF, PNG, JPG or GIF 50 ` 51 } 52 } 53 54 /* 55 $fileInput.on('change', function() { 56 var filesCount = $(this)[0].files.length; 57 var $textContainer = $(this).prev(); 58 59 if (filesCount === 1) { 60 // if single file is selected, show file name 61 var fileName = $(this).val().split('\\').pop(); 62 $textContainer.text(fileName); 63 } else { 64 // otherwise show number of files 65 $textContainer.text(filesCount + ' files selected'); 66 } 67 }); 68 */ 69 70};
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.