summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/flashrunner.css208
-rw-r--r--src/flashrunner.html47
-rw-r--r--src/flashrunner.js211
-rw-r--r--src/index.js109
-rw-r--r--src/package.json25
5 files changed, 600 insertions, 0 deletions
diff --git a/src/flashrunner.css b/src/flashrunner.css
new file mode 100644
index 0000000..42de56c
--- /dev/null
+++ b/src/flashrunner.css
@@ -0,0 +1,208 @@
+body{
+ font-family: "sans-serif", "arial";
+}
+
+.start_text{
+ color: #000000;
+ font-size: 24px;
+}
+
+.wtext{
+ color: #FFFFFF;
+ font-size: 16px;
+}
+
+.menubar{
+ position: fixed;
+ width: 100%;
+ height: 35px;
+ background-color: #000000;
+ margin: 0px;
+ top: 0px;
+ left: 0px;
+ z-index: 99;
+}
+
+.menu_container{
+ display: inline-block;
+}
+
+.menu_container:hover .menu_link_dropdown{
+ display: block;
+ transition-duration: 0.25s;
+ -webkit-transition-duration: 0.25s;
+}
+
+.menu_container:not(:hover) .menu_link_dropdown{
+ display: none;
+ transition-duration: 0.25s;
+ -webkit-transition-duration: 0.25s;
+}
+
+.menu_link{
+ color: #FFFFFF;
+ font-size: 24px;
+ position: relative;
+ padding: 0px 5px;
+ display: inline-block;
+ cursor: pointer;
+ text-decoration: underline;
+ height: 100%;
+}
+
+.menu_link:hover{
+ font-size: 26px;
+ background-color: #FFFFFF;
+ color: #000000;
+ transition-duration: 0.25s;
+ -webkit-transition-duration: 0.25s;
+}
+
+.menu_link:not(:hover){
+ transition-duration: 0.25s;
+ -webkit-transition-duration: 0.25s;
+}
+
+.submenu_link{
+ font-size: 18px;
+ color: #000000;
+ display: block;
+ width: 100%;
+}
+
+.submenu_link:hover{
+ color: #FFFFFF;
+ background-color: #000000;
+ transition-duration: 0.25s;
+ -webkit-transition-duration: 0.25s;
+}
+
+.submenu_link:not(:hover){
+ transition-duration: 0.25s;
+ -webkit-transition-duration: 0.25s;
+}
+
+.menu_link_dropdown{
+ position: fixed;
+ width: 150px;
+ display: none;
+ background-color: #FFFFFF;
+ border-bottom-left-radius: 5px;
+ border-bottom-right-radius: 5px;
+ box-shadow: 0px 0px 10px #000000;
+ z-index: 105;
+}
+
+.modal_background{
+ width: 100%;
+ height: 100%;
+ background-color: rgba(0, 0, 0, 0.8);
+ z-index: 100;
+ margin: 0px;
+ top: 0px;
+ left: 0px;
+ position: absolute;
+ display: none;
+ overflow: auto;
+}
+
+.modal_game_selector_menu_item{
+ font-size: 30px;
+ color: #FFFFFF;
+ display: block;
+ position: relative;
+ word-wrap: break-word;
+ z-index: 111;
+}
+
+.modal_game_selector_menu_item:hover{
+ font-size: 32px;
+ background-color: #FFFFFF;
+ color: #000000;
+ transition-duration: 0.25s;
+ -webkit-transition-duration: 0.25s;
+}
+
+.modal_game_selector_menu_item:not(:hover){
+ transition-duration: 0.25s;
+ -webkit-transition-duration: 0.25s;
+}
+
+#games_list{
+ display: none;
+ z-index: 110;
+}
+
+.opener_modal{
+ position: relative;
+ margin: auto;
+ top: 30%;
+ display: none;
+ width: 500px;
+ background-color: #FFFFFF;
+ box-shadow: 0px 0px 10px #FFFFFF;
+ border-radius: 5px;
+ z-index: 101;
+}
+
+.modal_input{
+ width: 95%;
+ border-radius: 5px;
+ left: 0px;
+ background-color: #FFFFFF;
+ position: relative;
+ font-size: 24px;
+ outline: 0px;
+}
+
+.modal_input:focus{
+ box-shadow: 0px 0px 10px #2c76ff;
+ transition-duration: 0.25s;
+ -webkit-transition-duration: 0.25s;
+}
+
+.modal_input:not(:focus){
+ transition-duration: 0.25s;
+ -webkit-transition-duration: 0.25s;
+}
+
+#modal_run_btn{
+ border-radius: 5px;
+ height: 35px;
+ background-color: #000000;
+ color: #FFFFFF;
+ cursor: pointer;
+ position: relative;
+ outline: 0px;
+ border: 0px;
+ left: 45%;
+ font-size: 16px;
+}
+
+#modal_run_btn:hover{
+ background-color: #2b2b2b;
+ transition-duration: 0.25s;
+ -webkit-transition-duration: 0.25s;
+}
+
+#modal_run_btn:not(:hover){
+ transition-duration: 0.25s;
+ -webkit-transition-duration: 0.25s;
+}
+
+#close_flash_opener{
+ right: 20px;
+ top: 10px;
+ position: fixed;
+ font-size: 48px;
+ color: #FFFFFF;
+ cursor: pointer;
+}
+
+#flash_container{
+ position: absolute;
+ margin: 0px;
+ left: 0px;
+ top: 35px;
+ width: 100%;
+}
diff --git a/src/flashrunner.html b/src/flashrunner.html
new file mode 100644
index 0000000..05959be
--- /dev/null
+++ b/src/flashrunner.html
@@ -0,0 +1,47 @@
+<meta name="content-type" content="text/html; charset=utf-8"/>
+<link rel="stylesheet" href="flashrunner.css" type="text/css"/>
+<html>
+<body>
+<div class="modal_background" id="file_opener_bg"><span id="close_flash_opener">&times;</span></div>
+<div id="game_selector">
+<center>
+<br/><br/><br/>
+<div id="games_list">
+<center>
+{game_list}
+</center>
+</div>
+</center>
+</div>
+<div class="opener_modal" id="file_opener">
+<br/>
+<center>
+<input type="text" class="modal_input" id="flash_file" placeholder="Link or path to flash file"/>
+</center>
+<br/>
+<br/>
+<button id="modal_run_btn">Run</button>
+<br/><br/>
+</div>
+<div class="menubar">
+<a href="#" id="menu_open" class="menu_link">Open</a>
+<a href="#" id="menu_game_selector" class="menu_link">Choose from list</a>
+<div class="menu_container">
+<div class="menu_link">Other</div>
+<div class="menu_link_dropdown">
+<center>
+<a href="#" id="menu_about" class="submenu_link">About</a>
+<a href="#" id="menu_steamgroup" class="submenu_link">Steam group</a>
+<a href="#" id="menu_exit" class="submenu_link">Close</a>
+</center>
+</div>
+</div>
+</div>
+<div id="flash_container">
+<center>
+<span class="start_text">No flash file opened</span>
+</center>
+</div>
+<script src="flashrunner.js" type="text/javascript"></script>
+</body>
+</html>
diff --git a/src/flashrunner.js b/src/flashrunner.js
new file mode 100644
index 0000000..65f9bdb
--- /dev/null
+++ b/src/flashrunner.js
@@ -0,0 +1,211 @@
+const { mainWindow, ipcRenderer, ipcMain, dialog } = require( 'electron' );
+
+const r_fsys = require( 'fs' );
+
+const version_str = '2.0.7';
+
+var open_menu_name = '';
+
+const flash_container = document.getElementById( 'flash_container' );
+
+/*
+ * window_resize is used to resize
+ * the container element of flash content
+ * container to fit under the menu bar.
+*/
+function window_resize(){
+ flash_container.style.height = window.innerHeight - 35;
+}
+
+/*
+ * set_container_content function
+ * is used to set the flash container
+ * element's flash content
+*/
+function set_container_content( flash_url ){
+ if ( flash_url[flash_url.indexOf('.swf') + 4] === undefined ){
+ document.getElementById( 'flash_container' ).style.height = window.innerHeight - 35;
+ document.getElementById( 'flash_container' ).innerHTML = '<embed src="' + flash_url + '" type="application/x-shockwave-flash" width="100%" height="100%" style="position: relative; top: 0px; left: 0px;"></embed>';
+ }
+ else
+ {
+ alert( 'Error: That doesn\'t look like a swf link because it doesn\'t end in .swf' );
+ }
+}
+
+/*
+ * open_url is used to open file/url
+*/
+function open_url( runner_url ){
+ try {
+ if ( runner_url === undefined || runner_url === null || runner_url === '' )
+ throw new Error( 'Link must not be empty' );
+ if ( !runner_url.startsWith('http://') && !runner_url.startsWith('https://') && !runner_url.startsWith('file:///') )
+ throw new Error( 'Invalid link' );
+ if ( !runner_url.endsWith('.swf') )
+ throw new Error( 'Invalid swf file link or location' );
+ if ( runner_url.startsWith('file:///') ){
+ if ( !r_fsys.existsSync(runner_url.replace('file:///', '')) )
+ throw new Error( 'File doesn\'t exist' );
+ }
+ if ( runner_url[runner_url.indexOf('.swf') + 4] === undefined ){
+ set_container_content( runner_url );
+ if ( document.getElementById( 'file_opener' ).style.display === 'block' )
+ document.getElementById( 'file_opener' ).style.display = 'none';
+ if ( document.getElementById( 'file_opener_bg' ).style.display === 'block' );
+ document.getElementById( 'file_opener_bg' ).style.display = 'none';
+ if ( document.getElementById( 'game_selector' ).style.display === 'block' )
+ document.getElementById( 'game_selector' ).style.display = 'none';
+ if ( document.getElementById( 'games_list' ).style.display === 'block' )
+ document.getElementById( 'games_list' ).style.display = 'none';
+ }
+ else
+ {
+ alert( 'Error: that doesn\'t look like a swf link because it doesn\'t end in .swf' );
+ }
+ runner_url = undefined;
+ } catch( err_c ){
+ alert( 'Error:\n' + err_c );
+ }
+}
+
+/*
+ * open_modal opens the file/url opener dialog
+*/
+function open_modal(){
+ open_menu_name = 'url_opener';
+ document.getElementById( 'file_opener_bg' ).style.display = 'block';
+ document.getElementById( 'file_opener' ).style.display = 'block';
+}
+
+/*
+ * close_modal closes the file/url opener dialog
+*/
+function close_modal(){
+ open_menu_name = '';
+ document.getElementById( 'file_opener' ).style.display = 'none';
+ document.getElementById( 'file_opener_bg' ).style.display = 'none';
+}
+
+/*
+ * open_game_selector_menu opens the easy to use
+ * game selection menu
+*/
+function open_game_selector_menu(){
+ open_menu_name = 'game_selector';
+ document.getElementById( 'file_opener_bg' ).style.display = 'block';
+ document.getElementById( 'game_selector' ).style.display = 'block';
+ document.getElementById( 'games_list' ).style.display = 'block';
+}
+
+/*
+ * close_game_selector_menu closes the easy to use
+ * game selection menu
+*/
+function close_game_selector_menu(){
+ open_menu_name = '';
+ document.getElementById( 'file_opener_bg' ).style.display = 'none';
+ document.getElementById( 'game_selector' ).style.display = 'none';
+ document.getElementById( 'games_list' ).style.display = 'none';
+}
+
+/*
+ * create_games_list creates the easy to use
+ * list of games received from JSON file on server
+*/
+function create_games_list( parsed_json ){
+ var g_list = document.getElementById( 'games_list' );
+ g_list.innerHTML = '';
+ var game_index = null;
+ for ( game_index in parsed_json.games_menu )
+ if ( parsed_json.games_menu[game_index].game_name !== undefined && parsed_json.games_menu[game_index].game_name !== null && parsed_json.games_menu[game_index].game_name !== '' && typeof parsed_json.games_menu[game_index].game_name === 'string' && parsed_json.games_menu[game_index].game_swf !== undefined && parsed_json.games_menu[game_index].game_swf !== null && parsed_json.games_menu[game_index].game_swf !== '' && typeof parsed_json.games_menu[game_index].game_swf === 'string' )
+ g_list.innerHTML += '<a href="#" onclick="open_url(\'' + parsed_json.games_menu[game_index].game_swf + '\');" class="modal_game_selector_menu_item">' + parsed_json.games_menu[game_index].game_name + '</a>';
+ game_index = undefined;
+ g_list = undefined;
+}
+
+/*
+ * flashrunner_get_game_list gets the list of games
+ * from JSON file for the easy to use game selection menu
+*/
+function flashrunner_get_game_list(){
+ try {
+ if ( r_fsys.existsSync('./flashrunner_game_list.json') ){
+ var game_list_json = r_fsys.readFileSync( './flashrunner_game_list.json', {
+ encoding: 'utf8',
+ flag: 'r'
+ } );
+ var games_list_parsed = JSON.parse( game_list_json );
+ create_games_list( games_list_parsed );
+ games_list_parsed = undefined;
+ game_list_json = undefined;
+ }
+ else
+ {
+ document.getElementById( 'game_list' ).innerHTML = '<span class="wtext">Error: could not find games list file</span>';
+ }
+ } catch ( err_m ){
+ document.getElementById( 'game_list' ).innerHTML = '<span class="wtext">Error loading games list</span>';
+ }
+}
+
+/*
+ * flashrunner_about is the about dialog, simple
+*/
+function flashrunner_about(){
+ alert( 'FlashRunner by VoidNet\nVersion: ' + version_str + '\n\nFlash copyright:\n\u00A9 Adobe Systems Incorporated and its licensors. All rights reserved.' );
+}
+
+document.getElementById( 'menu_open' ).addEventListener( 'click', function(){
+ open_modal();
+} );
+
+document.getElementById( 'menu_about' ).addEventListener( 'click', function(){
+ flashrunner_about();
+} );
+
+document.getElementById( 'modal_run_btn' ).addEventListener( 'click', function(){
+ if ( document.getElementById('flash_file').value !== undefined && document.getElementById('flash_file').value !== null && document.getElementById('flash_file').value !== '' ){
+ if ( document.getElementById('flash_file').value.startsWith('http://') || document.getElementById('flash_file').value.startsWith('https://') )
+ open_url( document.getElementById('flash_file').value );
+ else
+ open_url( 'file:///' + document.getElementById('flash_file').value );
+ }
+ else
+ {
+ alert( 'Flash file URL or path can\'t be empty' );
+ }
+} );
+
+document.getElementById( 'menu_game_selector' ).addEventListener( 'click', function(){
+ open_game_selector_menu();
+} );
+
+document.getElementById( 'menu_steamgroup' ).addEventListener( 'click', function(){
+ ipcRenderer.send( 'asyncmsg', 'OPEN_URL https://steamcommunity.com/groups/VoidNet_' );
+} );
+
+window.addEventListener( 'resize', window_resize );
+
+document.getElementById( 'menu_exit' ).addEventListener( 'click', function(){
+ ipcRenderer.send( 'asyncmsg', 'APP_SHUTDOWN' );
+} );
+
+document.getElementById( 'close_flash_opener' ).addEventListener( 'click', function(){
+ switch ( open_menu_name ){
+ case 'url_opener':
+ close_modal();
+ break;
+ case 'game_selector':
+ close_game_selector_menu();
+ break;
+ default:
+ break;
+ }
+} );
+
+document.addEventListener( 'contextmenu', function(ctx_event){
+ ctx_event.preventDefault();
+} );
+
+flashrunner_get_game_list();
diff --git a/src/index.js b/src/index.js
new file mode 100644
index 0000000..d7c092a
--- /dev/null
+++ b/src/index.js
@@ -0,0 +1,109 @@
+/*
+Copyright VoidNet
+License: https://creativecommons.org/licenses/by-nc-nd/4.0/
+*/
+
+const { app, BrowserWindow, ipcMain, dialog } = require( 'electron' );
+const pt = require( 'path' );
+const proc = require( 'process' );
+const cproc = require( 'child_process' );
+const fsys = require( 'fs' );
+const hts = require( 'https' );
+const ht = require( 'http' );
+const DNS = require( 'dns' );
+
+app.commandLine.appendSwitch( 'ppapi' );
+app.commandLine.appendSwitch( 'enable-accelerated-2d-canvas' );
+
+/*
+ * The code commented out below was supposed
+ * to be for android but hasn't been fully tested
+ * because of not finding way to run it before making apk
+ * out of it.
+*/
+
+/*
+if ( proc.platform === 'linux' && proc.arch === 'arm64' ){
+ app.commandLine.appendSwitch( 'ppapi-flash-path', './fa.obj' );
+ app.commandLine.appendSwitch( 'ppapi-flash-version', '11.1.115.81' );
+} else */
+if ( proc.platform === 'linux' ){
+ app.commandLine.appendSwitch( 'ppapi-flash-path', './fl.obj' );
+ app.commandLine.appendSwitch( 'ppapi-flash-version', '32.0.0.114' );
+ app.commandLine.appendSwitch( 'enable-gpu-rasterization' );
+ app.commandLine.appendSwitch( 'enable-nacl' );
+} else if ( proc.platform === 'win32' ){
+ app.commandLine.appendSwitch( 'ppapi-flash-path', './fw.obj' );
+ app.commandLine.appendSwitch( 'ppapi-flash-version', '32.0.0.114' );
+ app.commandLine.appendSwitch( 'enable-gpu-rasterization' );
+ app.commandLine.appendSwitch( 'enable-nacl' );
+}
+else
+{
+ app.quit();
+}
+
+function open_url( url_link ){
+ switch ( proc.platform ){
+ case 'linux':
+ cproc.exec( '$(which xdg-open) ' + url_link, function(err_msg, std_out, std_err){
+ //executed
+ } );
+ break;
+ case 'win32':
+ cproc.exec( 'start ' + url_link, {
+ windowsHide: true
+ }, function(exec_exception, std_out_msg, std_err_msg){
+ //executed
+ } );
+ break;
+ default:
+ break;
+ }
+}
+
+ipcMain.on( 'asyncmsg', function(ev_data, msg_arg){
+ if ( typeof msg_arg === 'string' && msg_arg !== undefined && msg_arg !== null && msg_arg !== '' ){
+ var split_arg = msg_arg.split( ' ' );
+ switch ( split_arg[0] ){
+ case 'ERR_BAN_LIST_FAIL':
+ app.quit();
+ break;
+ case 'APP_SHUTDOWN':
+ app.quit();
+ break;
+ case 'OPEN_URL':
+ open_url( split_arg[1] );
+ break;
+ default:
+ break;
+ }
+ split_arg = undefined;
+ }
+} );
+
+app.on( 'ready', function(){
+ const runner_window = new BrowserWindow( {
+ width: 1200,
+ height: 700,
+ title: "FlashRunner 2.0.7",
+ show: false,
+ webPreferences: {
+ devTools: false,
+ plugins: true,
+ webviewTag: false
+ }
+ } );
+
+ runner_window.setMenuBarVisibility( false );
+
+ runner_window.loadFile( pt.join(__dirname, 'flashrunner.html') );
+
+ runner_window.on( 'ready-to-show', function(){
+ runner_window.show();
+ } );
+} );
+
+app.on( 'window-all-closed', function(){
+ app.quit();
+} );
diff --git a/src/package.json b/src/package.json
new file mode 100644
index 0000000..f763165
--- /dev/null
+++ b/src/package.json
@@ -0,0 +1,25 @@
+{
+ "name": "flashrunner",
+ "version": "2.0.6",
+ "productName": "FlashRunner",
+ "description": "FlashRunner",
+ "author": "VoidNet",
+ "build": {
+ "appId": "com.freemyip.voidnet.flashrunner",
+ "linux": {
+ "target": "tar.gz",
+ "maintainer": "VoidNet",
+ "vendor": "VoidNet",
+ "executableName": "FlashRunner",
+ "synopsis": "FlashRunner",
+ "description": "FlashRunner"
+ }
+ },
+ "devDependencies": {
+ "electron": "4.2.12",
+ "asar": "latest",
+ "electron-packager": "latest"
+ },
+ "dependencies": {
+ }
+} \ No newline at end of file