summaryrefslogtreecommitdiff
path: root/src/index.js
blob: 5895a8c7e6c53ffc37145f7461faa906c7880b9a (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
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();
} );