Skip to content

Commit 2e2abff

Browse files
committed
Initial Commit
0 parents  commit 2e2abff

File tree

13 files changed

+214
-0
lines changed

13 files changed

+214
-0
lines changed

.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# The directory Mix will write compiled artifacts to.
2+
/_build/
3+
4+
# If you run "mix test --cover", coverage assets end up here.
5+
/cover/
6+
7+
# The directory Mix downloads your dependencies sources to.
8+
/deps/
9+
10+
# Where 3rd-party dependencies like ExDoc output generated docs.
11+
/doc/
12+
13+
# Ignore .fetch files in case you like to edit your project deps locally.
14+
/.fetch
15+
16+
# If the VM crashes, it generates a dump, let's ignore it too.
17+
erl_crash.dump
18+
19+
# Also ignore archive artifacts (built via "mix archive.build").
20+
*.ez

.tool-versions

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
elixir 1.5.1-otp-20
2+
nodejs 8.5.0

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# ElixirScriptWeb
2+
3+
An ElixirScript FFI Library for Web APIs
4+
5+
## Installation
6+
7+
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
8+
by adding `elixir_script_web` to your list of dependencies in `mix.exs`:
9+
10+
```elixir
11+
def deps do
12+
[
13+
{:elixir_script_web, "~> 0.1.0"}
14+
]
15+
end
16+
```
17+
18+
Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
19+
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
20+
be found at [https://hexdocs.pm/elixir_script_web](https://hexdocs.pm/elixir_script_web).
21+

config/config.exs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This file is responsible for configuring your application
2+
# and its dependencies with the aid of the Mix.Config module.
3+
use Mix.Config
4+
5+
# This configuration is loaded before any dependency and is restricted
6+
# to this project. If another project depends on this project, this
7+
# file won't be loaded nor affect the parent project. For this reason,
8+
# if you want to provide default values for your application for
9+
# 3rd-party users, it should be done in your "mix.exs" file.
10+
11+
# You can configure your application as:
12+
#
13+
# config :elixir_script_web, key: :value
14+
#
15+
# and access this configuration in your application as:
16+
#
17+
# Application.get_env(:elixir_script_web, :key)
18+
#
19+
# You can also configure a 3rd-party app:
20+
#
21+
# config :logger, level: :info
22+
#
23+
24+
# It is also possible to import configuration files, relative to this
25+
# directory. For example, you can emulate configuration per environment
26+
# by uncommenting the line below and defining dev.exs, test.exs and such.
27+
# Configuration from the imported file will override the ones defined
28+
# here (which is why it is important to import them last).
29+
#
30+
# import_config "#{Mix.env}.exs"

lib/elixir_scrip_web/console.ex

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
defmodule ElixirScript.Web.Console do
2+
use ElixirScript.FFI, global: true, name: :console
3+
4+
defexternal clear()
5+
6+
defexternal count()
7+
8+
defexternal count(label)
9+
10+
defexternal debug(obj)
11+
12+
defexternal info(obj)
13+
14+
defexternal log(obj)
15+
16+
defexternal warn(obj)
17+
18+
defexternal error(obj)
19+
20+
defexternal table(data)
21+
22+
defexternal table(data, columns)
23+
24+
defexternal time(label)
25+
end

lib/elixir_scrip_web/document.ex

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
defmodule ElixirScript.Web.Document do
2+
use ElixirScript.FFI, global: true, name: :document
3+
4+
defexternal createElement(tag_name)
5+
6+
defexternal createElement(tag_name, options)
7+
8+
defexternal createElementNS(namespace_uri, qualified_name)
9+
10+
defexternal createElementNS(namespace_uri, qualified_name, options)
11+
12+
defexternal createComment(data)
13+
14+
defexternal createTextNode(data)
15+
16+
defexternal getElementById(id)
17+
18+
defexternal getElementsByTagName(name)
19+
20+
defexternal getElementsByTagNameNS(namespace, name)
21+
22+
defexternal getElementsByClassName(names)
23+
24+
defexternal querySelector(selectors)
25+
26+
defexternal querySelectorAll(selectors)
27+
end

lib/elixir_scrip_web/history.ex

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
defmodule ElixirScript.Web.History do
2+
use ElixirScript.FFI, global: true, name: :history
3+
4+
defexternal back()
5+
6+
defexternal forward(request_id)
7+
8+
defexternal go(location)
9+
10+
defexternal pushState(state, title, url)
11+
12+
defexternal replaceState(state, title, url)
13+
end

lib/elixir_scrip_web/json.ex

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
defmodule ElixirScript.Web.JSON do
2+
use ElixirScript.FFI, global: true, name: :JSON
3+
4+
defexternal stringify(object)
5+
6+
defexternal parse(string)
7+
end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
defmodule ElixirScript.Web.LocalStorage do
2+
use ElixirScript.FFI, global: true, name: :localStorage
3+
4+
defexternal key(key)
5+
6+
defexternal clear()
7+
8+
defexternal getItem(key_name)
9+
10+
defexternal removeItem(key_name)
11+
12+
defexternal setItem(key_name, key_value)
13+
end

lib/elixir_scrip_web/window.ex

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
defmodule ElixirScript.Web.JSON do
2+
use ElixirScript.FFI, global: true, name: :window
3+
4+
defexternal requestAnimationFrame(callback)
5+
6+
defexternal cancelAnimationFrame(request_id)
7+
8+
defexternal setTimeout(code, delay)
9+
10+
defexternal clearTimeout(timeout_id)
11+
12+
defexternal setInterval(code, delay)
13+
14+
defexternal clearInterval(interval_id)
15+
16+
defexternal addEventListener(type, listener)
17+
18+
defexternal addEventListener(type, listener, options)
19+
20+
defexternal removeEventListener(type, listener)
21+
22+
defexternal removeEventListener(type, listener, options)
23+
end

0 commit comments

Comments
 (0)