shumway/extension/firefox/content/web/viewer.html

262 строки
9.8 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>Shumway viewer</title>
<script>
SHUMWAY_ROOT = "resource://shumway/";
</script>
<!-- <base href="resource://shumway/web/viewer.html" /> -->
<script src="../lib/DataView.js/DataView.js"></script>
<script src="../lib/Kanvas/kanvas.js"></script>
<!-- Load SWF Dependencies -->
<script src="../swf/util.js"></script>
<script src="../swf/swf.js"></script>
<script src="../swf/types.js"></script>
<script src="../swf/structs.js"></script>
<script src="../swf/tags.js"></script>
<script src="../swf/inflate.js"></script>
<script src="../swf/stream.js"></script>
<script src="../swf/templates.js"></script>
<script src="../swf/generator.js"></script>
<script src="../swf/parser.js"></script>
<script src="../swf/bitmap.js"></script>
<script src="../swf/button.js"></script>
<script src="../swf/font.js"></script>
<script src="../swf/image.js"></script>
<script src="../swf/label.js"></script>
<script src="../swf/shape.js"></script>
<script src="../swf/text.js"></script>
<!-- Load AVM1 Dependencies -->
<script src="../avm1/classes.js"></script>
<script src="../avm1/globals.js"></script>
<script src="../avm1/stream.js"></script>
<script src="../avm1/interpreter.js"></script>
<script src="../swf/embed.js"></script>
<script src="../swf/renderer.js"></script>
<!-- Load AVM2 Dependencies -->
<script src="../avm2/util.js"></script>
<script src="../avm2/options.js"></script>
<script src="../avm2/metrics.js"></script>
<script>
var Counter = new metrics.Counter(true);
var Timer = metrics.Timer;
var Option = options.Option;
var OptionSet = options.OptionSet;
var systemOptions = new OptionSet("System Options");
var disassemble = systemOptions.register(new Option("d", "disassemble", "boolean", false, "disassemble"));
var traceLevel = systemOptions.register(new Option("t", "traceLevel", "number", 0, "trace level"));
</script>
<script src="../avm2/constants.js"></script>
<script src="../avm2/errors.js"></script>
<script src="../avm2/opcodes.js"></script>
<script src="../avm2/parser.js"></script>
<script src="../avm2/analyze.js"></script>
<script src="../avm2/compiler/lljs/src/estransform.js"></script>
<script src="../avm2/compiler/lljs/src/escodegen.js"></script>
<script src="../avm2/compiler/inferrer.js"></script>
<script src="../avm2/compiler/compiler.js"></script>
<script src="../avm2/domain.js"></script>
<script src="../avm2/runtime.js"></script>
<script src="../avm2/native.js"></script>
<script src="../avm2/disassembler.js"></script>
<script src="../avm2/interpreter.js"></script>
<script src="../avm2/vm.js"></script>
<script src="avm2utils.js"></script>
<!-- Load Flash Dependencies -->
<script src="../flash/util.js"></script>
<script src="../flash/events/Event.js"></script>
<script src="../flash/events/KeyboardEvent.js"></script>
<script src="../flash/events/MouseEvent.js"></script>
<script src="../flash/events/TimerEvent.js"></script>
<script src="../flash/events/EventDispatcher.js"></script>
<script src="../flash/net/NetConnection.js"></script>
<script src="../flash/net/NetStream.js"></script>
<script src="../flash/display/DisplayObject.js"></script>
<script src="../flash/display/InteractiveObject.js"></script>
<script src="../flash/display/DisplayObjectContainer.js"></script>
<script src="../flash/display/Sprite.js"></script>
<script src="../flash/display/MovieClip.js"></script>
<script src="../flash/display/Loader.js"></script>
<script src="../flash/display/LoaderInfo.js"></script>
<script src="../flash/display/Stage.js"></script>
<script src="../flash/display/Bitmap.js"></script>
<script src="../flash/display/BitmapData.js"></script>
<script src="../flash/display/Graphics.js"></script>
<script src="../flash/display/Shape.js"></script>
<script src="../flash/display/SimpleButton.js"></script>
<script src="../flash/geom/Point.js"></script>
<script src="../flash/geom/Rectangle.js"></script>
<script src="../flash/geom/Matrix.js"></script>
<script src="../flash/geom/ColorTransform.js"></script>
<script src="../flash/geom/Transform.js"></script>
<!--
<script src="../flash/media/SoundTransform.js"></script>
-->
<script src="../flash/media/Video.js"></script>
<!--
<script src="../flash/text/Font.js"></script>
-->
<script src="../flash/text/StaticText.js"></script>
<script src="../flash/text/TextField.js"></script>
<script src="../flash/ui/Keyboard.js"></script>
<!--
<script src="../flash/ui/Mouse.js"></script>
-->
<script src="../flash/utils/Timer.js"></script>
<script src="../flash/stubs.js"></script>
<script>
// Extenstion communication object... as it used in pdf.js
var FirefoxCom = (function FirefoxComClosure() {
return {
/**
* Creates an event that the extension is listening for and will
* synchronously respond to.
* NOTE: It is reccomended to use request() instead since one day we may not
* be able to synchronously reply.
* @param {String} action The action to trigger.
* @param {String} data Optional data to send.
* @return {*} The response.
*/
requestSync: function(action, data) {
var request = document.createTextNode('');
request.setUserData('action', action, null);
request.setUserData('data', data, null);
request.setUserData('sync', true, null);
document.documentElement.appendChild(request);
var sender = document.createEvent('Events');
sender.initEvent('shumway.message', true, false);
request.dispatchEvent(sender);
var response = request.getUserData('response');
document.documentElement.removeChild(request);
return response;
},
/**
* Creates an event that the extension is listening for and will
* asynchronously respond by calling the callback.
* @param {String} action The action to trigger.
* @param {String} data Optional data to send.
* @param {Function} callback Optional response callback that will be called
* with one data argument.
*/
request: function(action, data, callback) {
var request = document.createTextNode('');
request.setUserData('action', action, null);
request.setUserData('data', data, null);
request.setUserData('sync', false, null);
if (callback) {
request.setUserData('callback', callback, null);
document.addEventListener('shumway.response', function listener(event) {
var node = event.target,
callback = node.getUserData('callback'),
response = node.getUserData('response');
document.documentElement.removeChild(node);
document.removeEventListener('shumway.response', listener, false);
return callback(response);
}, false);
}
document.documentElement.appendChild(request);
var sender = document.createEvent('HTMLEvents');
sender.initEvent('shumway.message', true, false);
return request.dispatchEvent(sender);
}
};
})();
function fallback() {
FirefoxCom.requestSync('fallback', null)
}
function runViewer() {
var flashParams = JSON.parse(FirefoxCom.requestSync('getPluginParams', null));
var movieUrl = flashParams.url;
var movieArgs = flashParams.arguments;
var isOverlay = flashParams.isOverlay;
console.log("url=" + movieUrl + ";params=" + uneval(movieArgs));
FirefoxCom.requestSync('loadFile', movieUrl);
if (isOverlay) {
var fallbackDiv = document.getElementById('fallback');
fallbackDiv.className = 'enabled';
fallbackDiv.addEventListener('click', function(e) {
fallback();
e.preventDefault();
});
}
}
addEventListener("message", function handlerMessage(e) {
var args = e.data;
switch (args.callback) {
case "loadFile":
parseSwf(args.url, args.array);
break;
}
}, true);
function parseSwf(url, file) {
console.log("Parsing " + url + "...");
function terminate() {}
createAVM2(builtinPath, playerGlobalPath, EXECUTION_MODE.INTERPRET, EXECUTION_MODE.COMPILE, function (avm2) {
SWF.embed(file, document.getElementById("viewer"), { onComplete: terminate });
});
}
</script>
<style>
body {
margin: 0;
overflow: hidden;
}
#viewer {
position:fixed;
left:0;top:0;bottom:0;right:0;
overflow: hidden;
/* background-color:magenta; */
}
#fallback {
display: none;
}
#fallback.enabled {
display: block;
position:fixed;
right: 10px; bottom: 10px; width: 70px; height: 14px;
color: white;
background-color: #400040;
font: bold 10px sans-serif;
text-align: center;
text-decoration: none;
border-radius: 5px;
box-shadow: 0px 0px 3px 3px #888;
}
#fallback .icon {
display: inline-block;
color: white;
}
</style>
</head>
<body onload="runViewer()">
<div id="viewer"></div>
<a id="fallback" href="#">shumway <span class="icon">&times;</span></a>
</body>
</html>