mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-01-26 13:25:28 +00:00
(ems) rework storage
This commit is contained in:
parent
2f9dbd2541
commit
2e17af781f
@ -40,7 +40,7 @@ textarea {
|
||||
height: 95%;
|
||||
width: 95%;
|
||||
border-style: none;
|
||||
border-color: Transparent;
|
||||
border-color: transparent;
|
||||
overflow: auto;
|
||||
resize: none;
|
||||
}
|
@ -106,9 +106,6 @@
|
||||
<button class="btn btn-primary disabled" id="btnRun" onclick="startRetroArch()">
|
||||
<span class="fa fa-spinner spinning" id="icnRun"></span> Run
|
||||
</button>
|
||||
<button class="btn btn-primary" id="btnSync" onclick="dropboxInit()">
|
||||
<span class="fa fa-dropbox" id="icnSync"></span> Sync
|
||||
</button>
|
||||
<button class="btn btn-primary disabled" id="btnAdd" onclick="document.getElementById('btnRom').click()">
|
||||
<span class="fa fa-plus" id="icnAdd"></span> Add Content
|
||||
</button>
|
||||
@ -119,7 +116,23 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<div class="col-sm-12 form-group btn-group text-xs-center p-t-2">
|
||||
<div class="btn-group" data-toggle="buttons">
|
||||
<label class="btn btn-primary" id="lblLocal" onclick=switchStorage("browser")>
|
||||
<input type="radio" name="options" id="btnLocal" autocomplete="off" checked>
|
||||
<span class="fa fa-chrome" id="icnLocal"></span> Browser
|
||||
</input>
|
||||
</label>
|
||||
<label class="btn btn-primary" id="lblDrop" onclick=switchStorage("dropbox")>
|
||||
<input type="radio" name="options" id="btnDrop" autocomplete="off">
|
||||
<span class="fa fa-dropbox" id="icnDrop"></span> Dropbox
|
||||
</input>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-12 form-group btn-group text-xs-center p-t-2">
|
||||
<div class="card">
|
||||
<div class="view overlay hm-white-slight" align="center">
|
||||
<textarea id="output" rows="15"></textarea>
|
||||
@ -131,7 +144,7 @@
|
||||
</div>
|
||||
<div align="center">
|
||||
<p>For now, we recommend you use <a href="https://www.google.com/chrome/">Google Chrome</a> for the best possible performance.</p>
|
||||
<a href="http://www.libretro.com"><img align="center" src="http://www.libretro.com/wp-content/uploads/2013/10/copy-libretro_final_thumb.png" /></a>
|
||||
<a href="http://www.libretro.com"><img align="center" src="media/libretro-logo.png" /></a>
|
||||
</div>
|
||||
|
||||
<script src="//code.jquery.com/jquery-3.1.0.min.js"></script>
|
||||
|
@ -48,9 +48,9 @@ var showError = function(error) {
|
||||
function dropboxInit()
|
||||
{
|
||||
document.getElementById('btnRun').disabled = true;
|
||||
document.getElementById('btnSync').disabled = true;
|
||||
$('#icnSync').removeClass('fa-dropbox');
|
||||
$('#icnSync').addClass('fa-spinner spinning');
|
||||
document.getElementById('btnDrop').disabled = true;
|
||||
$('#icnDrop').removeClass('fa-dropbox');
|
||||
$('#icnDrop').addClass('fa-spinner spinning');
|
||||
|
||||
|
||||
client.authDriver(new Dropbox.AuthDriver.Redirect());
|
||||
@ -66,63 +66,77 @@ function dropboxInit()
|
||||
function success()
|
||||
{
|
||||
document.getElementById('btnRun').disabled = false;
|
||||
$('#icnSync').removeClass('fa-spinner spinning');
|
||||
$('#icnSync').addClass('fa-check');
|
||||
$('#icnDrop').removeClass('fa-spinner spinning');
|
||||
$('#icnDrop').addClass('fa-check');
|
||||
console.log("WEBPLAYER: Sync successful");
|
||||
setupFileSystem("dropbox");
|
||||
setupFolderStructure();
|
||||
}
|
||||
|
||||
var afs;
|
||||
|
||||
function dropboxSync(dropboxClient, cb)
|
||||
{
|
||||
var dbfs = new BrowserFS.FileSystem.Dropbox(dropboxClient);
|
||||
// Wrap in AsyncMirrorFS.
|
||||
var asyncMirror = new BrowserFS.FileSystem.AsyncMirror(
|
||||
// Wrap in afsFS.
|
||||
afs = new BrowserFS.FileSystem.AsyncMirror(
|
||||
new BrowserFS.FileSystem.InMemory(), dbfs);
|
||||
|
||||
asyncMirror.initialize(function(err)
|
||||
afs.initialize(function(err)
|
||||
{
|
||||
// Initialize it as the root file system.
|
||||
BrowserFS.initialize(asyncMirror);
|
||||
|
||||
cb();
|
||||
//BrowserFS.initialize(afs);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
|
||||
function setupFileSystem()
|
||||
function setupFileSystem(backend)
|
||||
{
|
||||
console.log("WEBPLAYER: Initializing Filesystem");
|
||||
if(!client.isAuthenticated())
|
||||
{
|
||||
console.log("WEBPLAYER: Initializing LocalStorage");
|
||||
if(localStorage.getItem("fs_inited")!="true")
|
||||
{
|
||||
var lsfs = new BrowserFS.FileSystem.LocalStorage();
|
||||
var mfs = new BrowserFS.FileSystem.MountableFileSystem();
|
||||
var xfs = new BrowserFS.FileSystem.XmlHttpRequest
|
||||
(".index-xhr", "https://bot.libretro.com/web/assets/");
|
||||
mfs.mount('/', lsfs);
|
||||
mfs.mount('/assets', xfs);
|
||||
|
||||
BrowserFS.initialize(mfs);
|
||||
var BFS = new BrowserFS.EmscriptenFS();
|
||||
FS.mount(BFS, {root: '/'}, '/home');
|
||||
console.log('WEBPLAYER: Filesystem initialized');
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log('WEBPLAYER: Filesystem already initialized');
|
||||
}
|
||||
console.log("WEBPLAYER: Initializing Filesystem");
|
||||
if(backend == "browser")
|
||||
{
|
||||
console.log("WEBPLAYER: Initializing LocalStorage");
|
||||
/* create a mountable filesystem that will server as a root
|
||||
mountpoint for browserfs */
|
||||
var mfs = new BrowserFS.FileSystem.MountableFileSystem();
|
||||
/* create a local filesystem */
|
||||
var lsfs = new BrowserFS.FileSystem.LocalStorage();
|
||||
/* create an XmlHttpRequest filesystem for assets */
|
||||
var xfs1 = new BrowserFS.FileSystem.XmlHttpRequest
|
||||
(".index-xhr", "https://bot.libretro.com/web/assets/");
|
||||
var xfs2 = new BrowserFS.FileSystem.XmlHttpRequest
|
||||
(".index-xhr", "https://bot.libretro.com/assets/cores/");
|
||||
|
||||
/* mount the local filesystem at the root of mfs*/
|
||||
mfs.mount('/home/web_user/userdata', lsfs);
|
||||
mfs.mount('/home/web_user/retroarch/bundle', xfs1);
|
||||
mfs.mount('/home/web_user/downloads', xfs2);
|
||||
|
||||
BrowserFS.initialize(mfs);
|
||||
var BFS = new BrowserFS.EmscriptenFS();
|
||||
FS.mount(BFS, {root: '/home'}, '/home');
|
||||
console.log('WEBPLAYER: Filesystem initialized');
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log("WEBPLAYER: Initializing DropBoxFS");
|
||||
// Grab the BrowserFS Emscripten FS plugin.
|
||||
var BFS = new BrowserFS.EmscriptenFS();
|
||||
// Create the folder that we'll turn into a mount point.
|
||||
FS.createPath(FS.root, 'home', true, true);
|
||||
// Mount BFS's root folder into the '/data' folder.
|
||||
console.log('WEBPLAYER: Mounting');
|
||||
FS.mount(BFS, {root: '/'}, '/home');
|
||||
console.log('WEBPLAYER: DropBox initialized');
|
||||
/* create a mountable filesystem that will server as a root
|
||||
mountpoint for browserfs */
|
||||
var mfs = new BrowserFS.FileSystem.MountableFileSystem();
|
||||
/* create an XmlHttpRequest filesystem for assets */
|
||||
var xfs1 = new BrowserFS.FileSystem.XmlHttpRequest
|
||||
(".index-xhr", "https://bot.libretro.com/web/assets/");
|
||||
var xfs2 = new BrowserFS.FileSystem.XmlHttpRequest
|
||||
(".index-xhr", "https://bot.libretro.com/assets/cores/");
|
||||
|
||||
/* mount the local filesystem at the root of mfs*/
|
||||
mfs.mount('/home/web_user/userdata', afs);
|
||||
mfs.mount('/home/web_user/retroarch/bundle', xfs1);
|
||||
mfs.mount('/home/web_user/downloads', xfs2);
|
||||
|
||||
BrowserFS.initialize(mfs);
|
||||
var BFS = new BrowserFS.EmscriptenFS();
|
||||
FS.mount(BFS, {root: '/home'}, '/home');
|
||||
console.log('WEBPLAYER: Filesystem initialized');
|
||||
}
|
||||
}
|
||||
|
||||
@ -139,9 +153,6 @@ function getParam(name) {
|
||||
function setupFolderStructure()
|
||||
{
|
||||
FS.createPath('/', '/home/web_user', true, true);
|
||||
FS.createPath('/', '/home/web_user/.config', true, true);
|
||||
FS.createPath('/', '/home/web_user/.config/retroarch', true, true);
|
||||
FS.createPath('/', '/content', true, true);
|
||||
}
|
||||
|
||||
function stat(path)
|
||||
@ -159,15 +170,16 @@ function stat(path)
|
||||
|
||||
function startRetroArch()
|
||||
{
|
||||
document.getElementById('canvas_div').style.display = 'block';
|
||||
document.getElementById('btnSync').disabled = true;
|
||||
document.getElementById('btnRun').disabled = true;
|
||||
document.getElementById('canvas_div').style.display = 'block';
|
||||
document.getElementById('btnDrop').disabled = true;
|
||||
document.getElementById('btnRun').disabled = true;
|
||||
|
||||
$('#btnFullscreen').removeClass('disabled');
|
||||
$('#btnAdd').removeClass('disabled');
|
||||
$('#btnRom').removeClass('disabled');
|
||||
$('#btnFullscreen').removeClass('disabled');
|
||||
$('#btnAdd').removeClass('disabled');
|
||||
$('#btnRom').removeClass('disabled');
|
||||
|
||||
Module['callMain'](Module['arguments']);
|
||||
Module['callMain'](Module['arguments']);
|
||||
document.getElementById('canvas').focus();
|
||||
}
|
||||
|
||||
function selectFiles(files)
|
||||
@ -198,8 +210,12 @@ function selectFiles(files)
|
||||
|
||||
function uploadData(data,name)
|
||||
{
|
||||
var dataView = new Uint8Array(data);
|
||||
FS.createDataFile('/content/', name, dataView, true, false);
|
||||
var dataView = new Uint8Array(data);
|
||||
FS.createDataFile('/', name, dataView, true, false);
|
||||
|
||||
var data = FS.readFile(name,{ encoding: 'binary' });
|
||||
FS.writeFile('/home/web_user/userdata/content/' + name, data ,{ encoding: 'binary' });
|
||||
FS.unlink(name);
|
||||
}
|
||||
|
||||
var Module =
|
||||
@ -228,18 +244,25 @@ var Module =
|
||||
element.scrollTop = 99999; // focus on bottom
|
||||
},
|
||||
canvas: document.getElementById('canvas'),
|
||||
|
||||
totalDependencies: 0,
|
||||
monitorRunDependencies: function(left)
|
||||
{
|
||||
this.totalDependencies = Math.max(this.totalDependencies, left);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function switchCore(corename) {
|
||||
localStorage.setItem("core", corename);
|
||||
}
|
||||
|
||||
function switchStorage(backend) {
|
||||
if (backend != localStorage.getItem("backend"))
|
||||
{
|
||||
localStorage.setItem("backend", backend);
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
// When the browser has loaded everything.
|
||||
$(function() {
|
||||
// Find which core to load.
|
||||
@ -256,8 +279,19 @@ $(function() {
|
||||
$('#btnRun').removeClass('disabled');
|
||||
$('#icnRun').removeClass('fa-spinner spinning');
|
||||
$('#icnRun').addClass('fa-play');
|
||||
setupFileSystem();
|
||||
setupFolderStructure();
|
||||
|
||||
if (localStorage.getItem("backend") == "dropbox")
|
||||
{
|
||||
$('#lblDrop').addClass('active');
|
||||
$('#lblLocal').removeClass('active');
|
||||
dropboxInit();
|
||||
}
|
||||
else {
|
||||
$('#lblDrop').removeClass('active');
|
||||
$('#lblLocal').addClass('active');
|
||||
setupFileSystem("browser");
|
||||
setupFolderStructure();
|
||||
}
|
||||
//$('#dropdownMenu1').text(localStorage.getItem("core"));
|
||||
/**
|
||||
* Attempt to disable some default browser keys.
|
||||
|
Loading…
x
Reference in New Issue
Block a user