MCPcopy Create free account
hub / github.com/compiler-explorer/compiler-explorer / onLocalFile

Method onLocalFile

static/widgets/load-save.ts:208–227  ·  view source on GitHub ↗
(event: JQuery.ChangeEvent)

Source from the content-addressed store, hash-verified

206 }
207
208 private onLocalFile(event: JQuery.ChangeEvent) {
209 const files = event.target.files;
210 if (files.length !== 0) {
211 const file = files[0];
212 const reader = new FileReader();
213 reader.onload = () => {
214 let result: string;
215 if (reader.result instanceof ArrayBuffer) {
216 result = LoadSave.ab2str(reader.result);
217 } else {
218 result = reader.result ?? '';
219 }
220 this.onLoad(result, file.name);
221 };
222 reader.readAsText(file);
223 }
224 if (this.modal) {
225 BootstrapUtils.hideModal(this.modal);
226 }
227 }
228
229 public run(onLoad, editorText, currentLanguage: Language) {
230 this.initializeIfNeeded();

Callers 1

initializeIfNeededMethod · 0.95

Calls 2

onLoadMethod · 0.95
ab2strMethod · 0.80

Tested by

no test coverage detected