Make other Algolia clients use the common factory.

This commit is contained in:
Paulo Reis 2016-07-11 12:31:52 +01:00
parent bf67fedc73
commit fb7c437098
2 changed files with 6 additions and 18 deletions

View file

@ -1,15 +1,9 @@
define [
"base"
"services/algolia-search"
], (App) ->
App.factory "algoliawiki", ->
if window.sharelatex?.algolia? and window.sharelatex.algolia?.indexes?.wiki?
client = new AlgoliaSearch(window.sharelatex.algolia?.app_id, window.sharelatex.algolia?.api_key)
index = client.initIndex(window.sharelatex.algolia?.indexes?.wiki)
return index
App.controller "SearchWikiController", ($scope, algoliawiki, _, $modal) ->
algolia = algoliawiki
App.controller "SearchWikiController", ($scope, algoliaSearch, _, $modal) ->
$scope.hits = []
$scope.clearSearchText = ->
@ -54,7 +48,7 @@ define [
updateHits []
return
algolia.search query, (err, response)->
algoliaSearch.searchWiki query, (err, response)->
if response.hits.length == 0
updateHits []
else

View file

@ -1,15 +1,9 @@
define [
"base"
"services/algolia-search"
], (App) ->
App.factory "algoliawiki", ->
if window.sharelatex?.algolia? and window.sharelatex.algolia?.indexes?.wiki?
client = new AlgoliaSearch(window.sharelatex.algolia?.app_id, window.sharelatex.algolia?.api_key)
index = client.initIndex(window.sharelatex.algolia?.indexes?.wiki)
return index
App.controller "SearchWikiController", ($scope, algoliawiki, _) ->
algolia = algoliawiki
App.controller "SearchWikiController", ($scope, algoliaSearch, _) ->
$scope.hits = []
$scope.clearSearchText = ->
@ -54,7 +48,7 @@ define [
updateHits []
return
algolia.search query, (err, response)->
algoliaSearch.searchWiki query, (err, response)->
if response.hits.length == 0
updateHits []
else