Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
79f0ebc1
Commit
79f0ebc1
authored
Jun 30, 2013
by
Ujvari Gergely
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Throw out sockjswrapper.coffee
parent
af478dbd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
41 deletions
+55
-41
displayer.coffee
h/js/displayer.coffee
+19
-6
sockjswrapper.coffee
h/js/sockjswrapper.coffee
+0
-27
streamer.coffee
h/js/streamer.coffee
+18
-4
userstream.coffee
h/js/userstream.coffee
+18
-4
No files found.
h/js/displayer.coffee
View file @
79f0ebc1
...
...
@@ -9,9 +9,11 @@ get_quote = (annotation) ->
quote
class
Displayer
this
.
$inject
=
[
'$scope'
,
'$element'
,
'$timeout'
,
'streamfilter'
]
path
:
window
.
location
.
protocol
+
'//'
+
window
.
location
.
hostname
+
':'
+
window
.
location
.
port
+
'/__streamer__'
idTable
:
{}
this
.
$inject
=
[
'$scope'
,
'$element'
,
'$timeout'
,
'streamfilter'
]
constructor
:
(
$scope
,
$element
,
$timeout
,
streamfilter
)
->
$scope
.
annotation
=
{}
$scope
.
annotations
=
[
$scope
.
annotation
]
...
...
@@ -37,14 +39,25 @@ class Displayer
to_change
.
replies
=
replies
to_change
.
reply_count
=
reply_count
$scope
.
open
=
=>
$scope
.
sock
=
new
SockJSWrapper
$scope
,
$scope
.
filter
,
null
,
$scope
.
manage_new_data
,
=>
$scope
.
sock
=
new
SockJS
@
path
$scope
.
sock
.
onopen
=
=>
$scope
.
sock
.
send
JSON
.
stringify
$scope
.
filter
$scope
.
sock
.
onclose
=
=>
$timeout
$scope
.
open
,
5000
$scope
.
sock
.
onmessage
=
(
msg
)
=>
console
.
log
'Got something'
console
.
log
msg
data
=
msg
.
data
[
0
]
action
=
msg
.
data
[
1
]
unless
data
instanceof
Array
then
data
=
[
data
]
$scope
.
$apply
=>
$scope
.
manage_new_data
data
,
action
$scope
.
manage_new_data
=
(
data
,
action
)
=>
#sort annotations by creation date
data
.
sort
(
a
,
b
)
->
...
...
h/js/sockjswrapper.coffee
deleted
100644 → 0
View file @
af478dbd
class
window
.
SockJSWrapper
transports
:
[
'xhr-streaming'
,
'iframe-eventsource'
,
'iframe-htmlfile'
,
'xhr-polling'
,
'iframe-xhr-polling'
,
'jsonp-polling'
]
path
:
window
.
location
.
protocol
+
'//'
+
window
.
location
.
hostname
+
':'
+
window
.
location
.
port
+
'/__streamer__'
constructor
:
(
$scope
,
filter
,
fn_open
,
fn_message
,
fn_close
)
->
@
sock
=
new
SockJS
(
@
path
,
@
transports
)
@
sock
.
onopen
=
=>
@
sock
.
send
JSON
.
stringify
filter
if
fn_open
?
then
fn_open
()
@
sock
.
onclose
=
fn_close
@
sock
.
onmessage
=
(
msg
)
=>
console
.
log
'Got something'
console
.
log
msg
data
=
msg
.
data
[
0
]
action
=
msg
.
data
[
1
]
unless
data
instanceof
Array
then
data
=
[
data
]
if
fn_message
?
$scope
.
$apply
=>
fn_message
data
,
action
close
:
->
@
sock
.
close
()
h/js/streamer.coffee
View file @
79f0ebc1
...
...
@@ -23,6 +23,8 @@ syntaxHighlight = (json) ->
)
class
Streamer
path
:
window
.
location
.
protocol
+
'//'
+
window
.
location
.
hostname
+
':'
+
window
.
location
.
port
+
'/__streamer__'
strategies
:
[
'include_any'
,
'include_all'
,
'exclude_any'
,
'exclude_all'
]
past_modes
:
[
'none'
,
'hits'
,
'time'
]
...
...
@@ -109,13 +111,25 @@ class Streamer
$scope
.
open
()
$scope
.
open
=
=>
$scope
.
sock
=
new
SockJSWrapper
$scope
,
$scope
.
filter
,
=>
$scope
.
sock
=
new
SockJS
@
path
$scope
.
sock
.
onopen
=
=>
$scope
.
sock
.
send
JSON
.
stringify
$scope
.
filter
$scope
.
streaming
=
true
,
$scope
.
manage_new_data
,
=>
$scope
.
sock
.
onclose
=
=>
$scope
.
streaming
=
false
$scope
.
sock
.
onmessage
=
(
msg
)
=>
console
.
log
'Got something'
console
.
log
msg
data
=
msg
.
data
[
0
]
action
=
msg
.
data
[
1
]
unless
data
instanceof
Array
then
data
=
[
data
]
$scope
.
$apply
=>
$scope
.
manage_new_data
data
,
action
$scope
.
manage_new_data
=
(
data
,
action
)
=>
for
annotation
in
data
annotation
.
action
=
action
...
...
h/js/userstream.coffee
View file @
79f0ebc1
...
...
@@ -9,6 +9,8 @@ get_quote = (annotation) ->
quote
class
UserStream
path
:
window
.
location
.
protocol
+
'//'
+
window
.
location
.
hostname
+
':'
+
window
.
location
.
port
+
'/__streamer__'
this
.
$inject
=
[
'$scope'
,
'$timeout'
,
'streamfilter'
]
constructor
:
(
$scope
,
$timeout
,
streamfilter
)
->
...
...
@@ -29,12 +31,24 @@ class UserStream
$scope
.
annotations
.
splice
0
,
0
,
annotation
$scope
.
open
=
=>
$scope
.
sock
=
new
SockJSWrapper
$scope
,
$scope
.
filter
,
null
,
$scope
.
manage_new_data
,
=>
$scope
.
sock
=
new
SockJS
(
@
path
)
$scope
.
sock
.
onopen
=
=>
$scope
.
sock
.
send
JSON
.
stringify
$scope
.
filter
$scope
.
sock
.
onclose
=
=>
$timeout
$scope
.
open
,
5000
$scope
.
sock
.
onmessage
=
(
msg
)
=>
console
.
log
'Got something'
console
.
log
msg
data
=
msg
.
data
[
0
]
action
=
msg
.
data
[
1
]
unless
data
instanceof
Array
then
data
=
[
data
]
$scope
.
$apply
=>
$scope
.
manage_new_data
data
,
action
$scope
.
open
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment