MCPcopy Create free account
hub / github.com/Tampermonkey/tampermonkey / loadFile

Function loadFile

src/cm/codemirror.js:559–572  ·  view source on GitHub ↗
(file, i)

Source from the content-addressed store, hash-verified

557 if (files && files.length && window.FileReader && window.File) {
558 var n = files.length, text = Array(n), read = 0;
559 var loadFile = function(file, i) {
560 var reader = new FileReader;
561 reader.onload = function() {
562 text[i] = reader.result;
563 if (++read == n) {
564 pos = clipPos(pos);
565 operation(function() {
566 var end = replaceRange(text.join(""), pos, pos);
567 setSelectionUser(pos, end);
568 })();
569 }
570 };
571 reader.readAsText(file);
572 };
573 for (var i = 0; i < n; ++i) loadFile(files[i], i);
574 } else {
575 // Don't do a replace if the drop happened inside of the selected text.

Callers 1

onDropFunction · 0.85

Calls 4

clipPosFunction · 0.85
operationFunction · 0.85
replaceRangeFunction · 0.85
setSelectionUserFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…