(ems) update webplayer template too

This commit is contained in:
radius 2016-09-24 17:30:03 -05:00
parent 1efdffd191
commit e48cd885f9
3 changed files with 78 additions and 54 deletions

View File

@ -3,9 +3,7 @@
*
* This provides the basic JavaScript for the RetroArch web player.
*/
/* setup your key for dropbox support */
var client = new Dropbox.Client({ key: "--your-api-key--" });
var client = new Dropbox.Client({ key: "--your-api-key--" }); /* setup key*/
var BrowserFS = browserfs;
var afs;
@ -107,22 +105,21 @@ function preLoadingComplete()
});
}
function idbfsSync()
function idbfsInit()
{
var imfs = new BrowserFS.FileSystem.InMemory();
if (BrowserFS.FileSystem.IndexedDB.isAvailable())
{
var idbfs = BrowserFS.FileSystem.IndexedDB;
afs = new BrowserFS.FileSystem.AsyncMirror(imfs,
new BrowserFS.FileSystem.IndexedDB(function(e, fs)
{
if (e)
{
//fallback to imfs
afs = imfs;
afs = new BrowserFS.FileSystem.InMemory();
setupFileSystem("browser");
preLoadingComplete();
console.log("WEBPLAYER: error: " + e + "falling back to in-memory filesystem");
console.log("WEBPLAYER: error: " + e + " falling back to in-memory filesystem");
}
else
{
@ -131,8 +128,10 @@ function idbfsSync()
{
if (e)
{
afs = imfs;
console.log("WEBPLAYER: error: " + e + "falling back to in-memory filesystem");
afs = new BrowserFS.FileSystem.InMemory();
setupFileSystem("browser");
preLoadingComplete();
console.log("WEBPLAYER: error: " + e + " falling back to in-memory filesystem");
}
else
{
@ -365,7 +364,7 @@ $(function() {
{
$('#lblDrop').removeClass('active');
$('#lblLocal').addClass('active');
idbfsSync();
idbfsInit();
}
});
});

View File

@ -106,21 +106,21 @@ function preLoadingComplete()
});
}
function idbfsSync()
function idbfsInit()
{
var imfs = new BrowserFS.FileSystem.InMemory();
if (BrowserFS.FileSystem.IndexedDB.isAvailable())
{
var idbfs = BrowserFS.FileSystem.IndexedDB;
afs = new BrowserFS.FileSystem.AsyncMirror(imfs,
new BrowserFS.FileSystem.IndexedDB(function(e, fs)
{
if (e)
{
//fallback to imfs
afs = imfs;
setupFileSystem("browser")
console.log("WEBPLAYER: error: " + e + "falling back to in-memory filesystem");
afs = new BrowserFS.FileSystem.InMemory();
setupFileSystem("browser");
preLoadingComplete();
console.log("WEBPLAYER: error: " + e + " falling back to in-memory filesystem");
}
else
{
@ -129,13 +129,16 @@ function idbfsSync()
{
if (e)
{
afs = imfs;
console.log("WEBPLAYER: error: " + e + "falling back to in-memory filesystem");
afs = new BrowserFS.FileSystem.InMemory();
setupFileSystem("browser");
preLoadingComplete();
console.log("WEBPLAYER: error: " + e + " falling back to in-memory filesystem");
}
else
{
console.log("WEBPLAYER: idbfs setup successful");
setupFileSystem("browser")
setupFileSystem("browser");
preLoadingComplete();
}
});
}
@ -358,7 +361,7 @@ $(function() {
{
//$('#icnDrop').addClass('fa-globe');
//$('#icnDrop').removeClass('fa-dropbox');
idbfsSync();
idbfsInit();
}
});
});

View File

@ -70,17 +70,6 @@ function dropboxInit()
});
}
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");
preLoadingComplete();
}
function dropboxSync(dropboxClient, cb)
{
var dbfs = new BrowserFS.FileSystem.Dropbox(dropboxClient);
@ -96,6 +85,58 @@ function dropboxSync(dropboxClient, cb)
});
}
function dropboxSyncComplete()
{
document.getElementById('btnRun').disabled = false;
$('#icnDrop').removeClass('fa-spinner').removeClass('fa-spin');
$('#icnDrop').addClass('fa-check');
console.log("WEBPLAYER: Dropbox sync successful");
setupFileSystem("dropbox");
preLoadingComplete();
}
function idbfsInit()
{
var imfs = new BrowserFS.FileSystem.InMemory();
if (BrowserFS.FileSystem.IndexedDB.isAvailable())
{
afs = new BrowserFS.FileSystem.AsyncMirror(imfs,
new BrowserFS.FileSystem.IndexedDB(function(e, fs)
{
if (e)
{
//fallback to imfs
afs = new BrowserFS.FileSystem.InMemory();
setupFileSystem("browser");
preLoadingComplete();
console.log("WEBPLAYER: error: " + e + " falling back to in-memory filesystem");
}
else
{
// initialize afs by copying files from async storage to sync storage.
afs.initialize(function (e)
{
if (e)
{
afs = new BrowserFS.FileSystem.InMemory();
setupFileSystem("browser");
preLoadingComplete();
console.log("WEBPLAYER: error: " + e + " falling back to in-memory filesystem");
}
else
{
console.log("WEBPLAYER: idbfs setup successful");
setupFileSystem("browser");
preLoadingComplete();
}
});
}
},
"RetroArch"));
}
}
function preLoadingComplete()
{
/* Make the Preview image clickable to start RetroArch. */
@ -119,33 +160,15 @@ function setupFileSystem(backend)
var xfs2 = new BrowserFS.FileSystem.XmlHttpRequest
(".index-xhr", "/assets/cores/");
console.log("WEBPLAYER: Initializing Filesystem");
if(backend == "browser")
{
console.log("WEBPLAYER: Initializing LocalStorage");
/* create a local filesystem */
var lsfs = new BrowserFS.FileSystem.LocalStorage()
/* 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
{
/* mount the filesystems onto mfs */
console.log("WEBPLAYER: initializing filesystem: " + backend);
mfs.mount('/home/web_user/retroarch/userdata', afs);
}
mfs.mount('/home/web_user/retroarch/bundle', xfs1);
mfs.mount('/home/web_user/retroarch/userdata/content/downloads', xfs2);
BrowserFS.initialize(mfs);
var BFS = new BrowserFS.EmscriptenFS();
FS.mount(BFS, {root: '/home'}, '/home');
console.log("WEBPLAYER: " + backend + " filesystem initialized");
console.log("WEBPLAYER: " + backend + " filesystem initialization successful");
}
/**
@ -194,7 +217,7 @@ 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");
console.log("WEBPLAYER: file: " + this.file_name + " upload complete");
if (evt.target.readyState == FileReader.DONE)
{
$('#btnAdd').removeClass('disabled');
@ -333,8 +356,7 @@ $(function() {
{
$('#lblDrop').removeClass('active');
$('#lblLocal').addClass('active');
preLoadingComplete();
setupFileSystem("browser");
idbfsInit();
}
});
});