mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
40 lines
919 B
CoffeeScript
40 lines
919 B
CoffeeScript
define [
|
|
], () ->
|
|
class ReferencesSearchManager
|
|
constructor: (@ide, @$scope) ->
|
|
console.log ">> yay"
|
|
|
|
@$scope.$on 'document:closed', (e, doc) =>
|
|
if doc.doc_id
|
|
entity = @ide.fileTreeManager.findEntityById doc.doc_id
|
|
if entity?.name?.match /.*\.bib$/
|
|
@$scope.$emit 'references:changed', entity
|
|
console.log ">> references changed"
|
|
@indexReferences doc.doc_id
|
|
|
|
indexReferences: (doc_id) ->
|
|
console.log ">> doc id #{doc_id}"
|
|
$.post(
|
|
"/project/#{@$scope.project_id}/references",
|
|
{
|
|
docId: doc_id,
|
|
_csrf: window.csrfToken
|
|
},
|
|
(data) =>
|
|
console.log(data)
|
|
setTimeout(
|
|
( () -> @getReferenceKeys() ).bind(this),
|
|
100
|
|
)
|
|
)
|
|
|
|
getReferenceKeys: () ->
|
|
$.get(
|
|
"/project/#{@$scope.project_id}/references/keys",
|
|
{
|
|
_csrf: window.csrfToken
|
|
},
|
|
(data) =>
|
|
console.log ">> got keys"
|
|
console.log(data)
|
|
)
|