mirror of
https://github.com/libretro/RetroArch
synced 2025-02-11 15:40:28 +00:00
(ems) update webplayer template too
This commit is contained in:
parent
1efdffd191
commit
e48cd885f9
@ -3,9 +3,7 @@
|
|||||||
*
|
*
|
||||||
* This provides the basic JavaScript for the RetroArch web player.
|
* This provides the basic JavaScript for the RetroArch web player.
|
||||||
*/
|
*/
|
||||||
|
var client = new Dropbox.Client({ key: "--your-api-key--" }); /* setup key*/
|
||||||
/* setup your key for dropbox support */
|
|
||||||
var client = new Dropbox.Client({ key: "--your-api-key--" });
|
|
||||||
var BrowserFS = browserfs;
|
var BrowserFS = browserfs;
|
||||||
var afs;
|
var afs;
|
||||||
|
|
||||||
@ -107,19 +105,18 @@ function preLoadingComplete()
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function idbfsSync()
|
function idbfsInit()
|
||||||
{
|
{
|
||||||
var imfs = new BrowserFS.FileSystem.InMemory();
|
var imfs = new BrowserFS.FileSystem.InMemory();
|
||||||
if (BrowserFS.FileSystem.IndexedDB.isAvailable())
|
if (BrowserFS.FileSystem.IndexedDB.isAvailable())
|
||||||
{
|
{
|
||||||
var idbfs = BrowserFS.FileSystem.IndexedDB;
|
|
||||||
afs = new BrowserFS.FileSystem.AsyncMirror(imfs,
|
afs = new BrowserFS.FileSystem.AsyncMirror(imfs,
|
||||||
new BrowserFS.FileSystem.IndexedDB(function(e, fs)
|
new BrowserFS.FileSystem.IndexedDB(function(e, fs)
|
||||||
{
|
{
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
//fallback to imfs
|
//fallback to imfs
|
||||||
afs = imfs;
|
afs = new BrowserFS.FileSystem.InMemory();
|
||||||
setupFileSystem("browser");
|
setupFileSystem("browser");
|
||||||
preLoadingComplete();
|
preLoadingComplete();
|
||||||
console.log("WEBPLAYER: error: " + e + " falling back to in-memory filesystem");
|
console.log("WEBPLAYER: error: " + e + " falling back to in-memory filesystem");
|
||||||
@ -131,7 +128,9 @@ function idbfsSync()
|
|||||||
{
|
{
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
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
|
else
|
||||||
@ -365,7 +364,7 @@ $(function() {
|
|||||||
{
|
{
|
||||||
$('#lblDrop').removeClass('active');
|
$('#lblDrop').removeClass('active');
|
||||||
$('#lblLocal').addClass('active');
|
$('#lblLocal').addClass('active');
|
||||||
idbfsSync();
|
idbfsInit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -106,20 +106,20 @@ function preLoadingComplete()
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function idbfsSync()
|
function idbfsInit()
|
||||||
{
|
{
|
||||||
var imfs = new BrowserFS.FileSystem.InMemory();
|
var imfs = new BrowserFS.FileSystem.InMemory();
|
||||||
if (BrowserFS.FileSystem.IndexedDB.isAvailable())
|
if (BrowserFS.FileSystem.IndexedDB.isAvailable())
|
||||||
{
|
{
|
||||||
var idbfs = BrowserFS.FileSystem.IndexedDB;
|
|
||||||
afs = new BrowserFS.FileSystem.AsyncMirror(imfs,
|
afs = new BrowserFS.FileSystem.AsyncMirror(imfs,
|
||||||
new BrowserFS.FileSystem.IndexedDB(function(e, fs)
|
new BrowserFS.FileSystem.IndexedDB(function(e, fs)
|
||||||
{
|
{
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
//fallback to imfs
|
//fallback to imfs
|
||||||
afs = imfs;
|
afs = new BrowserFS.FileSystem.InMemory();
|
||||||
setupFileSystem("browser")
|
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
|
else
|
||||||
@ -129,13 +129,16 @@ function idbfsSync()
|
|||||||
{
|
{
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
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
|
else
|
||||||
{
|
{
|
||||||
console.log("WEBPLAYER: idbfs setup successful");
|
console.log("WEBPLAYER: idbfs setup successful");
|
||||||
setupFileSystem("browser")
|
setupFileSystem("browser");
|
||||||
|
preLoadingComplete();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -358,7 +361,7 @@ $(function() {
|
|||||||
{
|
{
|
||||||
//$('#icnDrop').addClass('fa-globe');
|
//$('#icnDrop').addClass('fa-globe');
|
||||||
//$('#icnDrop').removeClass('fa-dropbox');
|
//$('#icnDrop').removeClass('fa-dropbox');
|
||||||
idbfsSync();
|
idbfsInit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -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)
|
function dropboxSync(dropboxClient, cb)
|
||||||
{
|
{
|
||||||
var dbfs = new BrowserFS.FileSystem.Dropbox(dropboxClient);
|
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()
|
function preLoadingComplete()
|
||||||
{
|
{
|
||||||
/* Make the Preview image clickable to start RetroArch. */
|
/* Make the Preview image clickable to start RetroArch. */
|
||||||
@ -119,33 +160,15 @@ function setupFileSystem(backend)
|
|||||||
var xfs2 = new BrowserFS.FileSystem.XmlHttpRequest
|
var xfs2 = new BrowserFS.FileSystem.XmlHttpRequest
|
||||||
(".index-xhr", "/assets/cores/");
|
(".index-xhr", "/assets/cores/");
|
||||||
|
|
||||||
console.log("WEBPLAYER: Initializing Filesystem");
|
console.log("WEBPLAYER: initializing filesystem: " + backend);
|
||||||
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 */
|
|
||||||
mfs.mount('/home/web_user/retroarch/userdata', afs);
|
mfs.mount('/home/web_user/retroarch/userdata', afs);
|
||||||
}
|
|
||||||
|
|
||||||
mfs.mount('/home/web_user/retroarch/bundle', xfs1);
|
mfs.mount('/home/web_user/retroarch/bundle', xfs1);
|
||||||
mfs.mount('/home/web_user/retroarch/userdata/content/downloads', xfs2);
|
mfs.mount('/home/web_user/retroarch/userdata/content/downloads', xfs2);
|
||||||
BrowserFS.initialize(mfs);
|
BrowserFS.initialize(mfs);
|
||||||
var BFS = new BrowserFS.EmscriptenFS();
|
var BFS = new BrowserFS.EmscriptenFS();
|
||||||
FS.mount(BFS, {root: '/home'}, '/home');
|
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.onload = function(){uploadData(this.result, this.file_name)};
|
||||||
filereader.onloadend = function(evt)
|
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)
|
if (evt.target.readyState == FileReader.DONE)
|
||||||
{
|
{
|
||||||
$('#btnAdd').removeClass('disabled');
|
$('#btnAdd').removeClass('disabled');
|
||||||
@ -333,8 +356,7 @@ $(function() {
|
|||||||
{
|
{
|
||||||
$('#lblDrop').removeClass('active');
|
$('#lblDrop').removeClass('active');
|
||||||
$('#lblLocal').addClass('active');
|
$('#lblLocal').addClass('active');
|
||||||
preLoadingComplete();
|
idbfsInit();
|
||||||
setupFileSystem("browser");
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user