add material bootstrap template

This commit is contained in:
radius 2016-09-07 00:41:13 -05:00
parent 8fa84c9462
commit 867080965b
4 changed files with 413 additions and 0 deletions

46
pkg/emscripten/proto.css Normal file
View File

@ -0,0 +1,46 @@
/**
* RetroArch Web Player
*
* This provides the basic styling for the RetroArch web player.
*/
/**
* Make sure the background of the player is black.
*/
.webplayer-container {
background-color: black;
}
/**
* Disable the border around the player.
*/
canvas.webplayer {
border: none;
outline: none;
}
.fa.spinning {
animation: spin 1s infinite linear;
-webkit-animation: spin2 1s infinite linear;
}
@keyframes spin {
from { transform: scale(1) rotate(0deg); }
to { transform: scale(1) rotate(360deg); }
}
@-webkit-keyframes spin2 {
from { -webkit-transform: rotate(0deg); }
to { -webkit-transform: rotate(360deg); }
}
textarea {
font-family: monospace;
font-size: 0.7em;
height: 95%;
width: 95%;
border-style: none;
border-color: Transparent;
overflow: auto;
resize: none;
}

106
pkg/emscripten/proto.html Normal file
View File

@ -0,0 +1,106 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>RetroArch Web Player</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap core CSS -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.3/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<!-- Font Awesome -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.0/css/font-awesome.min.css">
<!-- Material Design Bootstrap -->
<link href="https://bot.libretro.com/web/mdb/css/mdb.min.css" rel="stylesheet">
<link href="proto.css" rel="stylesheet" type="text/css">
</head>
<body>
<script src="https://use.fontawesome.com/bb20806e1e.js"></script>
<!--Navbar-->
<nav class="navbar navbar-dark bg-primary">
<!-- Collapse button-->
<button class="navbar-toggler hidden-sm-up" type="button" data-toggle="collapse" data-target="#collapseEx2">
<i class="fa fa-bars"></i>
</button>
<div class="container">
<!--Collapse content-->
<div class="collapse navbar-toggleable-xs" id="collapseEx2">
<!--Navbar Brand-->
<a class="navbar-brand" href="#">RetroArch</a>
<!--Links-->
<ul class="nav navbar-nav">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Core Selection</a>
<div class="dropdown-menu dropdown-primary" aria-labelledby="dropdownMenu1" data-dropdown-in="fadeIn" data-dropdown-out="fadeOut">
<a class="dropdown-item" href="./proto.html" onclick=switchCore("fceumm")>FCEUmm</a>
<a class="dropdown-item" href="./proto.html" onclick=switchCore("gambatte")>Gambatte</a>
<a class="dropdown-item" href="./proto.html" onclick=switchCore("genesis_plus_gx")>Genesis Plus GX</a>
<a class="dropdown-item" href="./proto.html" onclick=switchCore("nestopia")>Nestopia</a>
<a class="dropdown-item" href="./proto.html" onclick=switchCore("prboom")>PrBoom</a>
<a class="dropdown-item" href="./proto.html" onclick=switchCore("quicknes")>QuickNES</a>
<a class="dropdown-item" href="./proto.html" onclick=switchCore("snes9x2005")>Snes9X 2005</a>
<a class="dropdown-item" href="./proto.html" onclick=switchCore("snes9x2010")>Snes9X 2010</a>
<a class="dropdown-item" href="./proto.html" onclick=switchCore("stella")>Stella</a>
<a class="dropdown-item" href="./proto.html" onclick=switchCore("tgbdual")>TGB Dual</a>
<a class="dropdown-item" href="./proto.html" onclick=switchCore("tyrquake")>TyrQuake</a>
<a class="dropdown-item" href="./proto.html" onclick=switchCore("vba_next")>VBA Next</a>
</div>
</li>
</ul>
</div>
<!--/.Collapse content-->
</div>
</nav>
<div class="bg-inverse webplayer-container">
<div class="container">
<div class="webplayer_border text-xs-center" id="canvas_div" style="display: none">
<canvas class="webplayer col-xs-12" id="canvas" tabindex="1" oncontextmenu="event.preventDefault()"></canvas>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-sm-12 form-group btn-group text-xs-center p-t-2" id="openrom">
<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>
<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()">
<span class="fa fa-desktop" id="icnAdd"></span> Fullscreen
</button>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="card">
<div class="view overlay hm-white-slight" align="center">
<textarea id="output" rows="15"></textarea>
</div>
</div>
</div>
</div>
</div>
<script src="//code.jquery.com/jquery-3.1.0.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/tether/1.3.4/js/tether.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.3/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/dropbox.js/0.10.2/dropbox.min.js"></script>
<script src="https://use.fontawesome.com/bb20806e1e.js"></script>
<script src="browserfs.js"></script>
<script src="proto.js"></script>
</body>
</html>

261
pkg/emscripten/proto.js Normal file
View File

@ -0,0 +1,261 @@
/**
* RetroArch Web Player
*
* This provides the basic JavaScript for the RetroArch web player.
*/
var dropbox = false;
var client = new Dropbox.Client({ key: "il6e10mfd7pgf8r" });
var showError = function(error) {
switch (error.status) {
case Dropbox.ApiError.INVALID_TOKEN:
// If you're using dropbox.js, the only cause behind this error is that
// the user token expired.
// Get the user through the authentication flow again.
break;
case Dropbox.ApiError.NOT_FOUND:
// The file or folder you tried to access is not in the user's Dropbox.
// Handling this error is specific to your application.
break;
case Dropbox.ApiError.OVER_QUOTA:
// The user is over their Dropbox quota.
// Tell them their Dropbox is full. Refreshing the page won't help.
break;
case Dropbox.ApiError.RATE_LIMITED:
// Too many API requests. Tell the user to try again later.
// Long-term, optimize your code to use fewer API calls.
break;
case Dropbox.ApiError.NETWORK_ERROR:
// An error occurred at the XMLHttpRequest layer.
// Most likely, the user's network connection is down.
// API calls will not succeed until the user gets back online.
break;
case Dropbox.ApiError.INVALID_PARAM:
case Dropbox.ApiError.OAUTH_ERROR:
case Dropbox.ApiError.INVALID_METHOD:
default:
// Caused by a bug in dropbox.js, in your application, or in Dropbox.
// Tell the user an error occurred, ask them to refresh the page.
}
};
function dropboxInit()
{
document.getElementById('btnRun').disabled = true;
document.getElementById('btnSync').disabled = true;
$('#icnSync').removeClass('fa-dropbox');
$('#icnSync').addClass('fa-spinner spinning');
client.authDriver(new Dropbox.AuthDriver.Redirect());
client.authenticate({ rememberUser: true }, function(error, client)
{
if (error)
{
return showError(error);
}
dropboxSync(client, success);
});
}
function success()
{
document.getElementById('btnRun').disabled = false;
$('#icnSync').removeClass('fa-spinner spinning');
$('#icnSync').addClass('fa-check');
console.log("WEBPLAYER: Sync successful");
}
function dropboxSync(dropboxClient, cb)
{
var dbfs = new BrowserFS.FileSystem.Dropbox(dropboxClient);
// Wrap in AsyncMirrorFS.
var asyncMirror = new BrowserFS.FileSystem.AsyncMirror(
new BrowserFS.FileSystem.InMemory(), dbfs);
asyncMirror.initialize(function(err)
{
// Initialize it as the root file system.
BrowserFS.initialize(asyncMirror);
cb();
});
}
var count = 0;
function setupFileSystem()
{
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();
BrowserFS.initialize(lsfs);
var BFS = new BrowserFS.EmscriptenFS();
FS.mount(BFS, {root: '/'}, '/home');
console.log('WEBPLAYER: Filesystem initialized');
}
else
{
console.log('WEBPLAYER: Filesystem already 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');
}
}
/**
* Retrieve the value of the given GET parameter.
*/
function getParam(name) {
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
if (results) {
return results[1] || null;
}
}
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('/', '/assets', true, true);
FS.createPath('/', '/content', true, true);
}
function stat(path)
{
try{
FS.stat(path);
}
catch(err)
{
console.log("WEBPLAYER: file " + path + " doesn't exist");
return false;
}
return true;
}
function startRetroArch()
{
document.getElementById('canvas_div').style.display = 'block';
document.getElementById('btnSync').disabled = true;
document.getElementById('btnRun').disabled = true;
$('#btnFullscreen').removeClass('disabled');
$('#btnAdd').removeClass('disabled');
$('#btnRom').removeClass('disabled');
setupFileSystem();
setupFolderStructure();
Module['callMain'](Module['arguments']);
}
function selectFiles(files)
{
count = files.length;
for (var i = 0; i < files.length; i++)
{
filereader = new FileReader();
filereader.file_name = files[i].name;
filereader.readAsArrayBuffer(files[i]);
filereader.onload = function(){uploadData(this.result, this.file_name)};
}
}
function uploadData(data,name)
{
var dataView = new Uint8Array(data);
FS.createDataFile('/', name, dataView, true, false);
var data = FS.readFile(name,{ encoding: 'binary' });
FS.writeFile('/content/' + name, data ,{ encoding: 'binary' });
FS.unlink(name);
}
var Module =
{
noInitialRun: true,
arguments: ["-v", "--menu"],
preRun: [],
postRun: [],
print: (function()
{
var element = document.getElementById('output');
element.value = ''; // clear browser cache
return function(text)
{
text = Array.prototype.slice.call(arguments).join(' ');
element.value += text + "\n";
element.scrollTop = 99999; // focus on bottom
};
})(),
printErr: function(text)
{
var text = Array.prototype.slice.call(arguments).join(' ');
var element = document.getElementById('output');
element.value += text + "\n";
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);
$('#lblCore').text(corename);
}
// When the browser has loaded everything.
$(function() {
// Find which core to load.
var core = localStorage.getItem("core", core);
if (!core) {
core = 'gambatte';
}
// Show the current core as the active core.
$('.nav-item.' + core).addClass('active');
// Load the Core's related JavaScript.
$.getScript(core + '_libretro.js', function () {
// Activate the Start RetroArch button.
$('#btnRun').removeClass('disabled');
$('#icnRun').removeClass('fa-spinner spinning');
$('#icnRun').addClass('fa-play');
/**
* Attempt to disable some default browser keys.
*/
window.addEventListener('keydown', function(e) {
// Space key, arrows, and F1.
if([32, 37, 38, 39, 40, 112].indexOf(e.keyCode) > -1) {
e.preventDefault();
}
}, false);
});
});