Current section

51 Versions

Jump to

Compare versions

6 files changed
+36 additions
-20 deletions
  @@ -41,4 +41,4 @@
41 41 {<<"name">>,<<"phoenix_html">>},
42 42 {<<"optional">>,false},
43 43 {<<"requirement">>,<<"~> 2.6">>}]]}.
44 - {<<"version">>,<<"0.2.3">>}.
44 + {<<"version">>,<<"0.2.4">>}.
  @@ -9,7 +9,7 @@ defmodule Drab.Socket do
9 9
10 10 ## Transports
11 11 transport :websocket, Phoenix.Transports.WebSocket
12 - transport :longpoll, Phoenix.Transports.LongPoll
12 + # transport :longpoll, Phoenix.Transports.LongPoll
13 13
14 14 # Socket params are passed from the client and can
15 15 # be used to verify and authenticate a user. After
  @@ -1,6 +1,6 @@
1 1 defmodule Drab.Mixfile do
2 2 use Mix.Project
3 - @version "0.2.3"
3 + @version "0.2.4"
4 4
5 5 def project do
6 6 [app: :drab,
  @@ -22,16 +22,20 @@
22 22 this.already_connected = false
23 23 this.path = location.pathname
24 24
25 + var drab = this
26 +
25 27 // launch all on_load functions
26 - for(var f of this.load) {
27 - f(this)
28 - }
28 + // for(var f of this.load) {
29 + // f(this)
30 + // }
31 + drab.load.forEach(function(fx) {
32 + fx(drab)
33 + })
29 34
30 35 var socket = new this.Socket("<%= Drab.config.socket %>", {params: {drab_return: drab_return_token}})
31 36 socket.connect()
32 - this.channel = socket.channel(`drab:${this.path}`, {})
37 + this.channel = socket.channel("drab:" + this.path, {})
33 38
34 - var drab = this
35 39 this.channel.join()
36 40 .receive("error", function(resp) {
37 41 // TODO: communicate it to user
  @@ -39,9 +43,12 @@
39 43 })
40 44 .receive("ok", function(resp) {
41 45 // launch on_connect
42 - for(var f of drab.connected) {
43 - f(resp, drab)
44 - }
46 + // for(var f of drab.connected) {
47 + // f(resp, drab)
48 + // }
49 + drab.connected.forEach(function(fx) {
50 + fx(resp, drab)
51 + })
45 52 drab.already_connected = true
46 53 // event is sent after Drab finish processing the event
47 54 drab.channel.on("event", function (message) {
  @@ -58,9 +65,12 @@
58 65 // socket.onClose(function(ev) {console.log("SOCKET CLOSE", ev);});
59 66 socket.onClose(function(event) {
60 67 // on_disconnect
61 - for(var f of drab.disconnected) {
62 - f(drab)
63 - }
68 + // for(var f of drab.disconnected) {
69 + // f(drab)
70 + // }
71 + drab.disconnected.forEach(function(fx) {
72 + fx(drab)
73 + })
64 74 })
65 75 },
66 76 //
  @@ -7,7 +7,7 @@ const MODAL_BUTTONS = ".drab-modal-button"
7 7 Drab.on_connect(function(resp, drab) {
8 8 function modal_button_clicked(message, button_clicked) {
9 9 var vals = {}
10 - $(`${MODAL} form :input`).map(function() {
10 + $(MODAL + " form :input").map(function() {
11 11 var key = $(this).attr("name") || $(this).attr("id")
12 12 vals[key] = $(this).val()
13 13 })
Loading more files…