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.
@@ -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,4 +0,0 @@
1
- div.section
2
- span id='url-input-error'
3
- input type='text' id='url-input' placeholder='video id'
4
- button id='url-input-submitter' load
@@ -1,2 +0,0 @@
1
- div.section
2
- ul#videos
@@ -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,11 +0,0 @@
1
- coffee:
2
-
3
- $input = $ "#url-input"
4
- $submitter = $ "#url-input-submitter"
5
- $error = $ "#url-input-error"
6
-
7
- Mixer.init_add_video ->
8
-
9
- $submitter.on "click", (e) ->
10
- val = $input.val()
11
- Mixer.add_video(val)
@@ -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'
@@ -1,15 +0,0 @@
1
- sass:
2
-
3
- .section
4
- border: 1px solid black
5
- display: inline-block
6
- padding: 10px
7
- margin: 10px
8
-
9
- .url-input-error
10
- color: red
11
-
12
- body, html
13
- width: 100%
14
- height: 100%
15
- background-color: grey