Web-Archives-Misc/Archive/eclipseemu.me/play/js/19.app.js
2023-01-15 20:48:50 +01:00

2 lines
7.9 KiB
JavaScript

(window.webpackJsonp=window.webpackJsonp||[]).push([[19],{20:function(e,t,a){"use strict";a.r(t);var n=a(0),o=a(2);function r(e){return function(e){if(Array.isArray(e))return s(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||l(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var a=[],n=!0,o=!1,r=void 0;try{for(var i,l=e[Symbol.iterator]();!(n=(i=l.next()).done)&&(a.push(i.value),!t||a.length!==t);n=!0);}catch(e){o=!0,r=e}finally{try{n||null==l.return||l.return()}finally{if(o)throw r}}return a}}(e,t)||l(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(e,t){if(e){if("string"==typeof e)return s(e,t);var a=Object.prototype.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?s(e,t):void 0}}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,n=new Array(t);a<t;a++)n[a]=e[a];return n}function c(){var e=[],t=JSON.parse(localStorage.games).map((function(e){return JSON.parse(e).id})),a=t.map((function(e){return"SAVE_"+e})).map((function(e){return localStorage.getItem(e)})).filter(Boolean).map((function(e){return("SAVE_"+JSON.parse(e)).replace("SAVE_SAVE_","SAVE_")}));for(var n in localStorage)!localStorage.hasOwnProperty(n)||!n.toLowerCase().includes("sram")&&!n.toLowerCase().includes("save")||n.toLowerCase().includes("save_type")||"autoSave"===n||a.includes(n)||(console.log(n,a.includes(n)),e.push([n,localStorage[n]]));return e=e.filter((function(e){var a=i(e,1)[0];return!t.includes(a.replace("SAVE_",""))})),console.log(e),{saves:e}}t.default={data:function(){return c()},methods:{handleUpload:function(){var e=this,t=document.createElement("input");t.type="file",t.style.display="none",t.addEventListener("change",(function(t){var a=t.target.files[0],o=a.name.split(".").pop().toLowerCase(),i=new FileReader;i.addEventListener("load",(function(t){var a,i,l=new Uint8Array(t.target.result);["gb","gbc"].includes(o)?(a=r(l.slice(308,319)).map((function(e){return String.fromCharCode(e)})).join(""),i="B64_SRAM_"+a,e.showPopupForKey(i,a,!!localStorage[i])):"gba"===o?(a=r(l.slice(172,179)).map((function(e){return 0<e?String.fromCharCode(e):"_"})).join(""),i="SAVE_GUID_"+a,e.showPopupForKey(i,a,!!localStorage[i])):["smc","sfc"].includes(o)?Object(n.b)(l).then((function(t){i="SAVE_SNES_"+(a=t),e.showPopupForKey(i,a,!!localStorage[i])})):e.$app.dialog.alert("No save data was found for that game.")})),i.readAsArrayBuffer(a)})),document.body.appendChild(t),t.click()},showPopupForKey:function(e,t,a){var n=this,r=!(2<arguments.length&&void 0!==a)||a;this.$app.actions.create({buttons:[[{text:t||"Manage Save",label:!0},r&&{text:"Export Save",onClick:function(){try{console.log(e);var t=Object(o.b)(JSON.parse(localStorage.getItem(e))),a=new Uint8Array(t),r=new Blob([a],{type:"application/octet-stream"});saveAs(r,"".concat(e," ").concat((new Date).getTime(),".sav"))}catch(t){console.log(t),n.$app.dialog.alert("An error occurred while trying to export that save...")}}},{text:"Import Save",onClick:function(){var t=document.createElement("input");t.type="file",t.onchange=function(a){var o=a.target.files[0],r=o.name.split(".").pop().toLowerCase(),i=0===o.name.indexOf("gamesave-")&&o.name.indexOf("-gamesave")===o.name.length-9,l=r.startsWith("eclipsesave_");if(l||"sav"===r||i){var s=new FileReader;s.readAsDataURL(o),s.onload=function(){if(l){var a=JSON.parse(atob(s.result.replace("data:;base64,","").replace("data:text/plain;charset=x-user-defined;base64,","").replace("data:application/octet-stream;base64,","").replace("","")));localStorage.setItem(e,JSON.stringify(a))}else{var o=s.result.replace("data:;base64,","").replace("data:text/plain;charset=x-user-defined;base64,","").replace("data:application/octet-stream;base64,","").replace("","");localStorage.setItem(e,JSON.stringify(o))}n.$app.toast.create({text:l?'Loaded legacy Eclipse save for "'.concat(e,'"'):i?'Loaded Delta save for "'.concat(e,'".'):'Loaded battery save for "'.concat(e,'".'),closeTimeout:2e3}).open(),document.body.removeChild(t)},s.onerror=function(e){n.$app.toast.create({text:l?"Could not load legacy Eclipse save file.":i?"Could not load Delta save file.":"Could not load battery save file.",closeTimeout:2e3}).open(),console.log("Error: ",e),document.body.removeChild(t)}}else n.$app.dialog.alert("Invalid file type. Please upload an .eclipsesave_* or .sav file.")},document.body.appendChild(t),t.click()}},r&&{text:"Delete Save",color:"red",onClick:function(){n.$app.dialog.confirm("Are you sure you want to delete this save? This action cannot be undone.","Delete Save",(function(){localStorage.removeItem(e),n.$setState(c())}))}}].filter(Boolean),[{text:"Cancel",bold:!0}]]}).open()}},id:"66364809f7",render:function(){return'\n <div class="page">\n <div class="navbar">\n <div class="navbar-inner sliding">\n <div class="left">\n <a href="#" class="link back">\n <i class="icon icon-back"></i>\n <span class="ios-only">Back</span>\n </a>\n </div>\n <div class="title">Game Saves</div>\n <div class="title-large">\n <div class="title-large-text">Game Saves</div>\n </div>\n </div>\n </div>\n <div class="page-content">\n <div class="block block-strong">\n <h3>What are these names?</h3>\n <p>\n These may look like random names, but they aren\'t. They\'re basically the game\'s cartridge ID.\n Some, you can easily tell what they are, others not so much. There isn\'t much we can do to make\n them more identifiable. You can also just upload a ROM to download its save file.\n </p>\n </div>\n <div class="block-title">Saves from a ROM</div>\n <div class="list">\n <ul>\n <li>\n <a class="item-link list-button" @click="handleUpload">Upload a Game</a>\n </li>\n </ul>\n </div>\n <div class="block-footer">Uploading a ROM will get its ID for you and let you upload or download its save file.</div>\n <div class="block-title">Saves for Uploaded Games</div>\n <div class="list">\n <ul>\n '.concat(this.saves.map((function(e){var t=i(e,1)[0];return'\n <li>\n <div class="item-content">\n <div class="item-inner">\n <div class="item-title">\n '.concat(t,'\n </div>\n <div class="after">\n <button @click="showPopupForKey(\'').concat(t,'\').bind(this)" class="tint-colored-text button">\n <i class="f7-icons">more_fill</i>\n </button>\n </div>\n </div>\n </div>\n </li>\n ')})).join(""),'\n </ul>\n </div>\n <div class="block-footer">Looking for saves for games in your library? Tap hold or right click on a game to access them.</div>\n </div>\n </div>\n')},styleScoped:!1}}}]);
//# sourceMappingURL=19.app.js.map