itty-repo/loader.yarn
2025-12-29 19:08:20 -03:00

1 line
No EOL
1.8 KiB
Text

{"protected":false,"mode":"f","metadata":{"name":"loader","author":"Luna Magdalena :3","version":[1],"dependencies":[],"runner":[],"paths":{"loader.js":"%B/loader.js"}},"content":"{\"loader.js\":{\"protected\":true,\"metadata\":{},\"mode\":\"f\",\"content\":\"if (!args[1]) {\\n display.print(\\\"Not enough arguments\\\")\\n quit()\\n}\\n\\nconst command = args[0]\\nargs.splice(0, 1)\\nconst mountpoint = args.join(\\\" \\\")\\nconst node = fs.getNode(mountpoint)\\nlet content\\n\\nswitch(command) {\\n case \\\"save\\\":\\n case \\\"download\\\":\\n content = fs.export(node)\\n\\n const blob = new Blob([content], { type: \\\"text/plain\\\" })\\n const url = URL.createObjectURL(blob)\\n\\n const a = document.createElement(\\\"a\\\")\\n a.href = url\\n a.download = node.name\\n a.style.display = \\\"none\\\"\\n\\n document.body.appendChild(a)\\n a.click()\\n document.body.removeChild(a)\\n\\n URL.revokeObjectURL(url)\\n break\\n case \\\"load\\\":\\n case \\\"upload\\\":\\n content = await getFile()\\n await fs.import(content.text, mountpoint)\\n display.print(\\\"Disk loaded successfully\\\", 0x3000)\\n}\\n\\nquit()\\n\\nfunction getFile() {\\n return new Promise(resolve => {\\n const input = document.createElement(\\\"input\\\")\\n input.type = \\\"file\\\"\\n input.accept = \\\"*/*\\\"\\n input.style.display = \\\"none\\\"\\n\\n document.body.appendChild(input)\\n\\n input.onchange = async () => {\\n const file = input.files[0]\\n const text = await file.text();\\n document.body.removeChild(input)\\n resolve({ file, text })\\n }\\n\\n input.click()\\n })\\n}\"}}"}