diff --git a/src/Electron/BrowserWindow.js b/src/Electron/BrowserWindow.js index 8270b78..5ef2e07 100644 --- a/src/Electron/BrowserWindow.js +++ b/src/Electron/BrowserWindow.js @@ -83,3 +83,45 @@ exports.onWillNavigate = function(webContents) { }; }; } + +exports.onDidNavigate = function(webContents) { + return function(callback) { + return function() { + return webContents.on('did-navigate', function(e, url) { + callback(e)(url)(); + }); + }; + }; +} + +exports.onDidNavigateInPage = function(webContents) { + return function(callback) { + return function() { + return webContents.on('did-navigate-in-page', function(e, url) { + callback(e)(url)(); + }); + }; + }; +} + +exports.onDidGetRedirectRequest = function(webContents) { + return function(callback) { + return function() { + return webContents.on('did-get-redirect-request', function(e, oldURL, + newURL, isMainFrame, httpResponseCode, requestMethod, + referrer, headers) { + callback(e)(oldURL)(newURL)(isMainFrame)(httpResponseCode)(requestMethod)(referrer)(headers)(); + }); + }; + }; +} + +exports.onDomReady = function(webContents) { + return function(callback) { + return function() { + return webContents.on('dom-ready', function(e) { + callback(e)(); + }); + }; + }; +} diff --git a/src/Electron/BrowserWindow.purs b/src/Electron/BrowserWindow.purs index e0a2c29..d0cfae4 100644 --- a/src/Electron/BrowserWindow.purs +++ b/src/Electron/BrowserWindow.purs @@ -15,12 +15,16 @@ module Electron.BrowserWindow , onDidFinishLoad , onNewWindow , onWillNavigate + , onDidNavigate + , onDidGetRedirectRequest + , onDomReady ) where import Prelude (Unit, (>>>)) import Control.Monad.Eff (Eff) import Data.Argonaut.Core (Json()) import Data.Generic (class Generic) +import Data.StrMap (StrMap) import Electron (ELECTRON) import Electron.Options (encodeOptions) import Electron.Event (Event) @@ -110,3 +114,35 @@ foreign import onWillNavigate :: forall eff . WebContents -> (Event -> String -> Eff (electron :: ELECTRON | eff) Unit) -> Eff (electron :: ELECTRON | eff) Unit + +-- | Emitted when a navigation is done. +-- | +-- | [Official Electron documentation](http://electron.atom.io/docs/api/web-contents/#event-did-navigate) +foreign import onDidNavigate :: forall eff + . WebContents + -> (Event -> String -> Eff (electron :: ELECTRON | eff) Unit) + -> Eff (electron :: ELECTRON | eff) Unit + +-- | Emitted when an in-page navigation happened. +-- | +-- | [Official Electron documentation](http://electron.atom.io/docs/api/web-contents/#event-did-navigate-in-page) +foreign import onDidNavigateInPage :: forall eff + . WebContents + -> (Event -> String -> Eff (electron :: ELECTRON | eff) Unit) + -> Eff (electron :: ELECTRON | eff) Unit + +-- | Emitted when a redirect is received while requesting a resource. +-- | +-- | [Official Electron documentation](http://electron.atom.io/docs/api/web-contents/#event-did-get-redirect-request) +foreign import onDidGetRedirectRequest :: forall eff + . WebContents + -> (Event -> String -> String -> Boolean -> Int -> String -> String -> StrMap String -> Eff (electron :: ELECTRON | eff) Unit) + -> Eff (electron :: ELECTRON | eff) Unit + +-- | Emitted when the document in the given frame is loaded. +-- | +-- | [Official Electron documentation](http://electron.atom.io/docs/api/web-contents/#event-dom-ready) +foreign import onDomReady :: forall eff + . WebContents + -> (Event -> Eff (electron :: ELECTRON | eff) Unit) + -> Eff (electron :: ELECTRON | eff) Unit