import { Share } from './share' ; import { LoadSave } from './LoadSave' ; description export class DesktopApplicationManager { private static _desktop = true ; static setFilename ( fullpathfilename ) { if ( DesktopApplicationManager . is ) { const ipc = require ( 'electron' ) . ipcRenderer ; ipc . send ( "filename" , fullpathfilename ) ; } } static init ( ) { try { /** setting when desktop app*/ const ipc = require ( 'electron' ) . ipcRenderer ; ipc . on ( "new" , ( ) => Share . execute ( "boardReset" , [ ] ) ) ; ipc . on ( "open" , ( evt , data ) => { Share . execute ( "loadBoard" , [ data ] ) ; } ) ; ipc . on ( "save" , ( ) => ipc . send ( "save" , LoadSave . getTableauNoirString ( ) ) ) ; console . log ( "Desktop version of Tableaunoir" ) ; DesktopApplicationManager . _desktop = true ; } catch ( e ) { /** setting when online web app*/ console . log ( "Web version of Tableaunoir" ) ; DesktopApplicationManager . _desktop = false ; window . onbeforeunload = function ( ) { return "If you leave Tableaunoir, you will lose any unsaved changes." ; } ; } } returns static get is ( ) : boolean { return DesktopApplicationManager . _desktop ; } }