MCPcopy
hub / github.com/copy/v86 / add_image_download_button

Function add_image_download_button

src/browser/main.js:2290–2326  ·  view source on GitHub ↗
(obj, buffer, type)

Source from the content-addressed store, hash-verified

2288 add_image_download_button(settings.cdrom, emulator.disk_images.cdrom, "cdrom");
2289
2290 function add_image_download_button(obj, buffer, type)
2291 {
2292 var elem = $("get_" + type + "_image");
2293
2294 if(!obj || obj.async)
2295 {
2296 elem.style.display = "none";
2297 return;
2298 }
2299
2300 elem.onclick = function(e)
2301 {
2302 const filename = buffer.file && buffer.file.name || ((profile?.id || "v86") + (type === "cdrom" ? ".iso" : ".img"));
2303
2304 if(buffer.get_as_file)
2305 {
2306 var file = buffer.get_as_file(filename);
2307 download(file, filename);
2308 }
2309 else
2310 {
2311 buffer.get_buffer(function(b)
2312 {
2313 if(b)
2314 {
2315 dump_file(b, filename);
2316 }
2317 else
2318 {
2319 alert("The file could not be loaded. Maybe it's too big?");
2320 }
2321 });
2322 }
2323
2324 elem.blur();
2325 };
2326 }
2327
2328 $("change_fda_image").value = settings.fda ? "Eject floppy image" : "Insert floppy image";
2329 $("change_fda_image").onclick = function()

Callers 1

init_uiFunction · 0.85

Calls 3

$Function · 0.85
downloadFunction · 0.85
dump_fileFunction · 0.50

Tested by

no test coverage detected