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
f5ae332f
Commit
f5ae332f
authored
May 22, 2013
by
Ujvari Gergely
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Basic displayer real-time update for newly created replies
parent
c72e5a12
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
98 additions
and
15 deletions
+98
-15
displayer.coffee
h/js/displayer.coffee
+97
-14
streamer.coffee
h/js/streamer.coffee
+1
-1
No files found.
h/js/displayer.coffee
View file @
f5ae332f
angular
.
module
(
'h.displayer'
,[])
.
controller
(
'DisplayerCtrl'
,
(
$scope
,
$element
)
->
$scope
.
toggleCollapse
=
(
event
,
replynumber
,
thread
)
->
get_quote
=
(
annotation
)
->
if
not
'target'
in
annotation
then
return
''
quote
=
'(This is a reply annotation)'
for
target
in
annotation
[
'target'
]
for
selector
in
target
[
'selector'
]
if
selector
[
'type'
]
is
'TextQuoteSelector'
quote
=
selector
[
'exact'
]
+
' '
quote
class
Displayer
this
.
$inject
=
[
'$scope'
,
'$element'
,
'$timeout'
]
constructor
:
(
$scope
,
$element
,
$timeout
)
->
$scope
.
replies
=
[]
$scope
.
reply_count
=
0
$scope
.
id
=
document
.
body
.
attributes
.
internalid
.
value
$scope
.
filter
=
match_policy
:
'include_all'
clauses
:
[
field
:
"/references"
operator
:
"first_of"
value
:
$scope
.
id
]
actions
:
create
:
true
edit
:
true
delete
:
true
past_data
:
load_past
:
'hits'
go_back
:
5
hits
:
100
console
.
log
$scope
.
filter
$scope
.
open
=
->
transports
=
[
'xhr-streaming'
,
'iframe-eventsource'
,
'iframe-htmlfile'
,
'xhr-polling'
,
'iframe-xhr-polling'
,
'jsonp-polling'
]
$scope
.
sock
=
new
SockJS
(
window
.
location
.
protocol
+
'//'
+
window
.
location
.
hostname
+
':'
+
window
.
location
.
port
+
'/__streamer__'
,
transports
)
$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
$scope
.
$apply
=>
data
=
msg
.
data
[
0
]
unless
data
instanceof
Array
then
data
=
[
data
]
action
=
msg
.
data
[
1
]
for
annotation
in
data
annotation
.
quote
=
get_quote
annotation
switch
action
when
'create'
,
'past'
$scope
.
reply_count
+=
1
#Find the thread for the reply
replies
=
$scope
.
replies
list
=
replies
for
reference
in
annotation
.
references
for
reply
in
replies
if
reply
.
id
is
reference
list
=
reply
reply
.
reply_count
+=
1
replies
=
reply
.
replies
break
#Find the place to insert annotation
pos
=
0
for
reply
in
replies
if
reply
.
updated
<
annotation
.
updated
break
pos
+=
1
annotation
.
replies
=
[]
annotation
.
reply_count
=
0
replies
.
splice
pos
,
0
,
annotation
when
'edit'
console
.
log
'edit'
when
'delete'
console
.
log
'delete'
console
.
log
$scope
.
replies
$scope
.
open
()
#$scope.toggleCollapse = (event, replynumber, thread) ->
#Plus/minus sign and italics
elem
=
(
angular
.
element
event
.
srcElement
).
parent
()
if
elem
.
hasClass
'hyp-collapsed'
elem
.
removeClass
'hyp-collapsed'
expand
=
true
else
elem
.
addClass
'hyp-collapsed'
#
elem = (angular.element event.srcElement).parent()
#
if elem.hasClass 'hyp-collapsed'
#
elem.removeClass 'hyp-collapsed'
#
expand = true
#
else elem.addClass 'hyp-collapsed'
#Now for the replies
if
replynumber
toggle_elem
=
$element
.
find
(
'.thread_'
+
(
thread
+
1
)).
parent
().
parent
()
if
expand
?
then
toggle_elem
.
removeAttr
'style'
else
toggle_elem
.
css
'display'
,
'none'
)
\ No newline at end of file
# if replynumber
# toggle_elem = $element.find('.thread_' + (thread+1)).parent().parent()
# if expand? then toggle_elem.removeAttr 'style'
# else toggle_elem.css 'display', 'none'
angular
.
module
(
'h.displayer'
,[
'h.filters'
,
'bootstrap'
])
.
controller
(
'DisplayerCtrl'
,
Displayer
)
h/js/streamer.coffee
View file @
f5ae332f
...
...
@@ -24,7 +24,7 @@ syntaxHighlight = (json) ->
class
ClauseParser
filter_fields
:
[
'
thread'
,
'text'
,
'user'
,
'uri
'
]
filter_fields
:
[
'
references'
,
'text'
,
'user'
,
'uri'
,
'id
'
]
operators
:
[
'='
,
'>'
,
'<'
,
'=>'
,
'>='
,
'<='
,
'=<'
,
'['
,
'#'
]
operator_mapping
:
'='
:
'equals'
...
...
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