1+ const electron = require ( "electron" ) ;
2+ const app = electron . app ;
3+ const BrowserWindow = electron . BrowserWindow ;
4+ const path = require ( "path" ) ;
5+ const fs = require ( "fs" ) ;
6+ const Menu = require ( "electron" ) . Menu ;
7+ const MenuItem = require ( "electron" ) . MenuItem ;
8+
9+ let mainWindow ;
10+ var pluginName ;
11+ switch ( process . platform ) {
12+ case "win32" :
13+ pluginName = "pepflashplayer.dll" ;
14+ break ;
15+ case "darwin" :
16+ pluginName = "PepperFlashPlayer.plugin" ;
17+ break ;
18+ case "linux" :
19+ pluginName = "libpepflashplayer.so" ;
20+ break ;
21+ }
22+ app . commandLine . appendSwitch ( "ppapi-flash-path" , path . join ( __dirname , pluginName ) ) ;
23+
24+ function createWindow ( ) {
25+ mainWindow = new BrowserWindow ( { width : 800 , height : 600 , webPreferences : { plugins : true } } ) ;
26+ mainWindow . loadURL ( `file://${ __dirname } /SharpUpdate.html` ) ;
27+ mainWindow . on ( "closed" , function ( ) {
28+ mainWindow = null ;
29+ } ) ;
30+ }
31+
32+ //Change prompt to execute in render process
33+ var template = [
34+ {
35+ label : "About" ,
36+ submenu : [
37+ {
38+ label : "Tool Menu" ,
39+ click : function ( item , focusedWindow ) {
40+ if ( focusedWindow ) focusedWindow . loadURL ( `file://${ __dirname } /SharpToolMenu.html` ) ;
41+ }
42+ } ,
43+ {
44+ label : "About Version" ,
45+ click : function ( item , focusedWindow ) {
46+ if ( focusedWindow ) focusedWindow . loadURL ( `file://${ __dirname } /SharpAbout.html` ) ;
47+ }
48+ }
49+ ]
50+ } ,
51+ {
52+ label : "Developer Tools" ,
53+ submenu : [
54+ {
55+ label : "Toggle Developer Tools" ,
56+ click : function ( item , focusedWindow ) {
57+ if ( focusedWindow ) focusedWindow . webContents . toggleDevTools ( ) ;
58+ }
59+ } ,
60+ {
61+ label : "Refresh Page (Loses project!)" ,
62+ click : function ( item , focusedWindow ) {
63+ if ( focusedWindow ) focusedWindow . webContents . executeJavaScript ( "window.location.reload();" ) ;
64+ }
65+ } ,
66+ {
67+ label : "Visit URL (Loses project!)" ,
68+ click : function ( item , focusedWindow ) {
69+ if ( focusedWindow ) focusedWindow . loadURL ( `file://${ __dirname } /SharpBrowser.html` ) ;
70+ }
71+ } ,
72+ {
73+ label : "Open Sharp Browser" ,
74+ click : function ( item , focusedWindow ) {
75+ if ( focusedWindow ) focusedWindow . webContents . executeJavaScript ( "window.open('SharpBrowser.html', '')" ) ;
76+ }
77+ }
78+ ]
79+ } ,
80+ {
81+ label : "Help" ,
82+ submenu : [
83+ {
84+ label : "Bugs and Support" ,
85+ click : function ( item , focusedWindow ) {
86+ if ( focusedWindow ) focusedWindow . webContents . executeJavaScript ( "window.open('https://github.com/SharpScratchMod/SharpOfflineMacLinux/issues', '');" ) ;
87+ }
88+ } ,
89+ {
90+ label : "Troubleshoot" ,
91+ click : function ( item , focusedWindow ) {
92+ if ( focusedWindow ) focusedWindow . webContents . executeJavaScript ( "window.open('https://github.com/SharpScratchMod/SharpOfflineMacLinux/wiki/Troubleshoot', '');" ) ;
93+ }
94+ }
95+ ]
96+ }
97+ ] ;
98+ var menu = Menu . buildFromTemplate ( template ) ;
99+ Menu . setApplicationMenu ( menu ) ;
100+
101+ app . on ( "ready" , createWindow ) ;
102+ app . on ( "window-all-closed" , function ( ) {
103+ if ( process . platform !== "darwin" ) {
104+ app . quit ( ) ;
105+ }
106+ } ) ;
107+ app . on ( "activate" , function ( ) {
108+ if ( mainWindow === null ) {
109+ createWindow ( ) ;
110+ }
111+ } ) ;
0 commit comments