Skip to content
This repository was archived by the owner on Oct 4, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions src/DOM/HTML/Location.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/* global exports */
"use strict";

// module DOM.HTML.Location

exports.hash = function (location) {
return function () {
return location.hash;
};
};

exports.host = function (location) {
return function () {
return location.host;
};
};

exports.hostname = function (location) {
return function () {
return location.hostname;
};
};

exports.href = function (location) {
return function () {
return location.href;
};
};

exports.origin = function (location) {
return function () {
return location.origin;
};
};

exports.pathname = function (location) {
return function () {
return location.pathname;
};
};

exports.port = function (location) {
return function () {
return location.port;
};
};

exports.protocol = function (location) {
return function () {
return location.protocol;
};
};

exports.search = function (location) {
return function () {
return location.search;
};
};
16 changes: 16 additions & 0 deletions src/DOM/HTML/Location.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module DOM.HTML.Location where

import Control.Monad.Eff (Eff())

import DOM
import DOM.HTML.Types

foreign import hash :: forall eff. Location -> Eff (dom :: DOM | eff) String
foreign import host :: forall eff. Location -> Eff (dom :: DOM | eff) String
foreign import hostname :: forall eff. Location -> Eff (dom :: DOM | eff) String
foreign import href :: forall eff. Location -> Eff (dom :: DOM | eff) String
foreign import origin :: forall eff. Location -> Eff (dom :: DOM | eff) String
foreign import pathname :: forall eff. Location -> Eff (dom :: DOM | eff) String
foreign import port :: forall eff. Location -> Eff (dom :: DOM | eff) String
foreign import protocol :: forall eff. Location -> Eff (dom :: DOM | eff) String
foreign import search :: forall eff. Location -> Eff (dom :: DOM | eff) String
3 changes: 3 additions & 0 deletions src/DOM/HTML/Types.purs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module DOM.HTML.Types
, htmlElementToNode
, htmlElementToEventTarget
, readHTMLElement
, Location()
) where

import Prelude
Expand Down Expand Up @@ -84,3 +85,5 @@ readHTMLElement = _readHTMLElement (Left <<< TypeMismatch "HTMLElement") Right

instance isForeignHTMLElement :: IsForeign HTMLElement where
read = readHTMLElement

foreign import data Location :: *
6 changes: 6 additions & 0 deletions src/DOM/HTML/Window.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@ exports.navigator = function (window) {
return window.navigator;
};
};

exports.location = function (window) {
return function () {
return window.location;
};
};
2 changes: 2 additions & 0 deletions src/DOM/HTML/Window.purs
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ import DOM.HTML.Types
foreign import document :: forall eff. Window -> Eff (dom :: DOM | eff) HTMLDocument

foreign import navigator :: forall eff. Window -> Eff (dom :: DOM | eff) Navigator

foreign import location :: forall eff. Window -> Eff (dom :: DOM | eff) Location