(emscripten) disable buttons for real, use inmemory file system for content to be able to upload more than 10MB

This commit is contained in:
radius 2016-09-13 19:37:00 -05:00
parent 6ff07a04b3
commit d6f82b4a16
2 changed files with 52 additions and 32 deletions

View File

@ -84,17 +84,17 @@
<a class="dropdown-item" href="." data-core="yabause">Yabause</a>
</div>
<button class="btn btn-primary disabled" id="btnRun" onclick="startRetroArch()">
<button class="btn btn-primary disabled" id="btnRun" onclick="startRetroArch()" disabled>
<span class="fa fa-spinner fa-spin" id="icnRun"></span> Run
</button>
<button class="btn btn-primary disabled" id="btnAdd" onclick="document.getElementById('btnRom').click()">
<button class="btn btn-primary disabled" id="btnAdd" onclick="document.getElementById('btnRom').click()" disabled>
<span class="fa fa-plus" id="icnAdd"></span> Add Content
</button>
<input class="btn btn-primary" style="display: none" type="file" id="btnRom" name="upload" onclick="document.getElementById('btnAdd').click();" onchange="selectFiles(event.target.files)" multiple />
<button class="btn btn-primary disabled" id="btnFullscreen" onclick="Module.requestFullScreen()" title="Fullscreen">
<input class="btn btn-primary disabled" style="display: none" type="file" id="btnRom" name="upload" onclick="document.getElementById('btnAdd').click();" onchange="selectFiles(event.target.files)" multiple />
<button class="btn btn-primary disabled" id="btnFullscreen" onclick="Module.requestFullScreen()" title="Fullscreen" disabled>
<span class="fa fa-desktop" id="icnAdd"></span> <span class="sr-only">Fullscreen</span>
</button>
<button class="btn btn-primary" id="btnMenu" onclick="keyPress(112);" title="Menu toggle">
<button class="btn btn-primary disabled" id="btnMenu" onclick="keyPress(112);" title="Menu toggle" disabled>
<span class="fa fa-bars" id="btnMenu"></span> <span class="sr-only">Menu</span>
</button>
</li>

View File

@ -61,17 +61,20 @@ function dropboxInit()
{
return showError(error);
}
dropboxSync(client, success);
dropboxSync(client, dropboxSyncComplete);
});
}
function success()
function dropboxSyncComplete()
{
document.getElementById('btnRun').disabled = false;
$('#icnDrop').removeClass('fa-spinner').removeClass('fa-spin');
$('#icnDrop').addClass('fa-check');
console.log("WEBPLAYER: Sync successful");
setupFileSystem("dropbox");
setupFolderStructure();
preLoadingComplete();
}
var afs;
@ -91,6 +94,16 @@ function dropboxSync(dropboxClient, cb)
});
}
function preLoadingComplete()
{
/* Make the Preview image clickable to start RetroArch. */
$('.webplayer-preview').addClass('loaded').click(function () {
startRetroArch();
return false;
});
}
function setupFileSystem(backend)
{
/* create a mountable filesystem that will server as a root
@ -114,6 +127,12 @@ function setupFileSystem(backend)
/* mount the filesystems onto mfs */
mfs.mount('/home/web_user/retroarch/userdata', lsfs);
/* create a memory filesystem for content only */
var imfs = new BrowserFS.FileSystem.InMemory();
/* mount the filesystems onto mfs */
mfs.mount('/home/web_user/retroarch/userdata/content/', imfs);
}
else
{
@ -165,9 +184,15 @@ function startRetroArch()
document.getElementById('btnRun').disabled = true;
$('#btnFullscreen').removeClass('disabled');
$('#btnMenu').removeClass('disabled');
$('#btnAdd').removeClass('disabled');
$('#btnRom').removeClass('disabled');
document.getElementById("btnAdd").disabled = false;
document.getElementById("btnRom").disabled = false;
document.getElementById("btnMenu").disabled = false;
document.getElementById("btnFullscreen").disabled = false;
Module['callMain'](Module['arguments']);
document.getElementById('canvas').focus();
}
@ -187,9 +212,9 @@ function selectFiles(files)
filereader.onload = function(){uploadData(this.result, this.file_name)};
filereader.onloadend = function(evt)
{
console.log("WEBPLAYER: File: " + this.file_name + " Upload Complete");
if (evt.target.readyState == FileReader.DONE)
{
console.log("WEBPLAYER: File: " + this.file_name + " Upload Complete");
$('#btnAdd').removeClass('disabled');
$('#icnAdd').removeClass('fa-spinner spinning');
$('#icnAdd').addClass('fa-plus');
@ -309,32 +334,27 @@ $(function() {
// Load the Core's related JavaScript.
$.getScript(core + '_libretro.js', function ()
{
/**
* Make the Preview image clickable to start RetroArch.
*/
$('.webplayer-preview').addClass('loaded').click(function () {
startRetroArch();
return false;
});
// Activate the Start RetroArch button.
$('#btnRun').removeClass('disabled');
$('#icnRun').removeClass('fa-spinner').removeClass('fa-spin');
$('#icnRun').addClass('fa-play');
// Activate the Start RetroArch button.
$('#btnRun').removeClass('disabled');
$('#icnRun').removeClass('fa-spinner').removeClass('fa-spin');
$('#icnRun').addClass('fa-play');
document.getElementById("btnRun").disabled = false;
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"));
if (localStorage.getItem("backend") == "dropbox")
{
$('#lblDrop').addClass('active');
$('#lblLocal').removeClass('active');
dropboxInit();
}
else
{
$('#lblDrop').removeClass('active');
$('#lblLocal').addClass('active');
preLoadingComplete();
setupFileSystem("browser");
setupFolderStructure();
}
});
});