Use Api.js to handle api calls to gitlab
This commit is contained in:
parent
a163135cb5
commit
3cdac0b934
3 changed files with 70 additions and 42 deletions
|
@ -1,12 +1,9 @@
|
|||
@Wall =
|
||||
note_ids: []
|
||||
notes_path: null
|
||||
notes_params: null
|
||||
project_id: null
|
||||
|
||||
init: (project_id) ->
|
||||
Wall.project_id = project_id
|
||||
Wall.notes_path = "/api/" + gon.api_version + "/projects/" + project_id + "/notes.json"
|
||||
Wall.getContent()
|
||||
Wall.initRefresh()
|
||||
Wall.initForm()
|
||||
|
@ -15,22 +12,15 @@
|
|||
# Gets an initial set of notes.
|
||||
#
|
||||
getContent: ->
|
||||
$.ajax
|
||||
url: Wall.notes_path,
|
||||
data:
|
||||
private_token: gon.api_token
|
||||
gfm: true
|
||||
recent: true
|
||||
dataType: "json"
|
||||
success: (notes) ->
|
||||
notes.sort (a, b) ->
|
||||
return a.id - b.id
|
||||
$.each notes, (i, note)->
|
||||
if $.inArray(note.id, Wall.note_ids) == -1
|
||||
Wall.note_ids.push(note.id)
|
||||
Wall.renderNote(note)
|
||||
Wall.scrollDown()
|
||||
$("abbr.timeago").timeago()
|
||||
Api.notes Wall.project_id, (notes) ->
|
||||
$.each notes, (i, note) ->
|
||||
# render note if it not present in loaded list
|
||||
# or skip if rendered
|
||||
if $.inArray(note.id, Wall.note_ids) == -1
|
||||
Wall.note_ids.push(note.id)
|
||||
Wall.renderNote(note)
|
||||
Wall.scrollDown()
|
||||
$("abbr.timeago").timeago()
|
||||
|
||||
initRefresh: ->
|
||||
setInterval("Wall.refresh()", 10000)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue