MCPcopy
hub / github.com/csev/py4e / loadFile

Function loadFile

tools/pythonauto/static/codemirrorepl/codemirror.js:2760–2772  ·  view source on GitHub ↗
(file, i)

Source from the content-addressed store, hash-verified

2758 if (files && files.length && window.FileReader && window.File) {
2759 var n = files.length, text = Array(n), read = 0;
2760 var loadFile = function(file, i) {
2761 var reader = new FileReader;
2762 reader.onload = operation(cm, function() {
2763 text[i] = reader.result;
2764 if (++read == n) {
2765 pos = clipPos(cm.doc, pos);
2766 var change = {from: pos, to: pos, text: splitLines(text.join("\n")), origin: "paste"};
2767 makeChange(cm.doc, change);
2768 setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change)));
2769 }
2770 });
2771 reader.readAsText(file);
2772 };
2773 for (var i = 0; i < n; ++i) loadFile(files[i], i);
2774 } else { // Normal drop
2775 // Don't do a replace if the drop happened inside of the selected text.

Callers 1

onDropFunction · 0.70

Calls 5

simpleSelectionFunction · 0.85
operationFunction · 0.70
clipPosFunction · 0.70
makeChangeFunction · 0.70

Tested by

no test coverage detected