MCPcopy Index your code
hub / github.com/EmulatorJS/EmulatorJS / openCacheMenu

Method openCacheMenu

data/src/emulator.js:2336–2388  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2334 }
2335 }
2336 openCacheMenu() {
2337 (async () => {
2338 const list = this.createElement("table");
2339 const tbody = this.createElement("tbody");
2340 const body = this.createPopup("Cache Manager", {
2341 "Clear All": async () => {
2342 const roms = await this.storage.rom.getSizes();
2343 for (const k in roms) {
2344 await this.storage.rom.remove(k);
2345 }
2346 tbody.innerHTML = "";
2347 },
2348 "Close": () => {
2349 this.closePopup();
2350 }
2351 });
2352 const roms = await this.storage.rom.getSizes();
2353 list.style.width = "100%";
2354 list.style["padding-left"] = "10px";
2355 list.style["text-align"] = "left";
2356 body.appendChild(list);
2357 list.appendChild(tbody);
2358 const getSize = function (size) {
2359 let i = -1;
2360 do {
2361 size /= 1024, i++;
2362 } while (size > 1024);
2363 return Math.max(size, 0.1).toFixed(1) + [" kB", " MB", " GB", " TB", "PB", "EB", "ZB", "YB"][i];
2364 }
2365 for (const k in roms) {
2366 const line = this.createElement("tr");
2367 const name = this.createElement("td");
2368 const size = this.createElement("td");
2369 const remove = this.createElement("td");
2370 remove.style.cursor = "pointer";
2371 name.innerText = k;
2372 size.innerText = getSize(roms[k]);
2373
2374 const a = this.createElement("a");
2375 a.innerText = this.localization("Remove");
2376 this.addEventListener(remove, "click", () => {
2377 this.storage.rom.remove(k);
2378 line.remove();
2379 })
2380 remove.appendChild(a);
2381
2382 line.appendChild(name);
2383 line.appendChild(size);
2384 line.appendChild(remove);
2385 tbody.appendChild(line);
2386 }
2387 })();
2388 }
2389 getControlScheme() {
2390 if (this.config.controlScheme && typeof this.config.controlScheme === "string") {
2391 return this.config.controlScheme;

Callers 1

createBottomMenuBarMethod · 0.95

Calls 7

createElementMethod · 0.95
createPopupMethod · 0.95
closePopupMethod · 0.95
localizationMethod · 0.95
addEventListenerMethod · 0.95
getSizesMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected