sinatra_sockets 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/server_skeleton/Gemfile +4 -5
- data/lib/server_skeleton/Gemfile.lock +28 -0
- data/lib/server_skeleton/README.md +19 -8
- data/lib/server_skeleton/lib/routes/ws.rb +46 -0
- data/lib/server_skeleton/server.rb +123 -51
- data/lib/version.rb +1 -1
- metadata +2 -14
- data/lib/server_skeleton/client.rb +0 -33
- data/lib/server_skeleton/deps.js +0 -3
- data/lib/server_skeleton/lib/routes/index.rb +0 -48
- data/lib/server_skeleton/lib/websocket.rb +0 -48
- data/lib/server_skeleton/package.json +0 -17
- data/lib/server_skeleton/public/bundle.js +0 -10383
- data/lib/server_skeleton/views/index.slim +0 -26
- data/lib/server_skeleton/views/partials/url_input.slim +0 -4
- data/lib/server_skeleton/views/partials/videos.slim +0 -2
- data/lib/server_skeleton/views/script/add_video.slim +0 -51
- data/lib/server_skeleton/views/script/url_input.slim +0 -11
- data/lib/server_skeleton/views/script/websocket.slim +0 -13
- data/lib/server_skeleton/views/style/main.slim +0 -15
@@ -1,26 +0,0 @@
|
|
1
|
-
doctype html
|
2
|
-
|
3
|
-
html
|
4
|
-
|
5
|
-
head
|
6
|
-
|
7
|
-
/ Browserify deps
|
8
|
-
script src='bundle.js'
|
9
|
-
|
10
|
-
/ Style
|
11
|
-
== slim :"style/main"
|
12
|
-
|
13
|
-
body
|
14
|
-
|
15
|
-
/ HTML Components
|
16
|
-
== slim :"partials/url_input"
|
17
|
-
== slim :"partials/videos"
|
18
|
-
|
19
|
-
coffee:
|
20
|
-
# namespace for script stuff
|
21
|
-
window.Mixer = {}
|
22
|
-
|
23
|
-
/ Scripts
|
24
|
-
== slim :"script/add_video"
|
25
|
-
== slim :"script/websocket"
|
26
|
-
== slim :"script/url_input"
|
@@ -1,51 +0,0 @@
|
|
1
|
-
coffee:
|
2
|
-
|
3
|
-
# Since the Youtube iFrame API is loaded asynchronously,
|
4
|
-
# all dependent code must be run through this callback:
|
5
|
-
Mixer.init_add_video = (callback) ->
|
6
|
-
window.onYouTubeIframeAPIReady = -> callback()
|
7
|
-
Mixer.$videos = $("#videos")
|
8
|
-
Mixer.$first_script = document.getElementsByTagName("script")[0]
|
9
|
-
tag = document.createElement "script"
|
10
|
-
tag.src = "http://www.youtube.com/iframe_api"
|
11
|
-
Mixer.$first_script.parentNode.insertBefore(tag, Mixer.$first_script)
|
12
|
-
|
13
|
-
Mixer.add_video = (id) ->
|
14
|
-
embed_code = "
|
15
|
-
<div class='video'>
|
16
|
-
<button class='close-button'>X</button>
|
17
|
-
<b>#{id}</b>
|
18
|
-
<div class='iframe-target'></div>
|
19
|
-
</div>
|
20
|
-
"
|
21
|
-
$video = $ embed_code
|
22
|
-
Mixer.$videos.append($video)
|
23
|
-
Mixer.add_close_video_event($video)
|
24
|
-
Mixer.create_video_player(id, $video)
|
25
|
-
|
26
|
-
# Namespaced on window.
|
27
|
-
# Callback of the Youtube API, loaded through iFrame
|
28
|
-
Mixer.create_video_player = (videoId, $video) ->
|
29
|
-
player = new YT.Player $video[0],
|
30
|
-
height: 400
|
31
|
-
width: 640
|
32
|
-
videoId: videoId
|
33
|
-
events:
|
34
|
-
onReady: Mixer.onPlayerReady
|
35
|
-
onStateChange: Mixer.onPlayerStateChange
|
36
|
-
|
37
|
-
|
38
|
-
Mixer.onPlayerReady = (event) ->
|
39
|
-
event.target.playVideo
|
40
|
-
|
41
|
-
Mixer.onPlayerStateChange = (event) ->
|
42
|
-
if (event.data == TY.PlayerState.PLAYING)
|
43
|
-
setTimeout Mixer.stopVideo, 1000
|
44
|
-
|
45
|
-
Mixer.stopVideo = ->
|
46
|
-
player.stopVideo
|
47
|
-
|
48
|
-
Mixer.add_close_video_event = ($video) ->
|
49
|
-
$close = $video.find(".close-button")
|
50
|
-
$close.on "click", (e) ->
|
51
|
-
$(e.currentTarget).parent(".video").remove()
|
@@ -1,13 +0,0 @@
|
|
1
|
-
coffee:
|
2
|
-
|
3
|
-
pathname = window.location.pathname
|
4
|
-
host = window.location.host
|
5
|
-
ws = new WebSocket "ws://#{host}#{pathname}"
|
6
|
-
|
7
|
-
ws.onopen = ->
|
8
|
-
console.log "opened"
|
9
|
-
ws.send("hello from client")
|
10
|
-
|
11
|
-
ws.onmessage= (m) -> console.log m.data
|
12
|
-
|
13
|
-
ws.onclose = -> console.log 'closed'
|