mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #2506 from overleaf/as-remove-dead-code
Remove some dead code GitOrigin-RevId: 1f6c04bded2528f9dea95fa1608b688f85b35059
This commit is contained in:
parent
a084d620ae
commit
c4bf80216f
3 changed files with 0 additions and 191 deletions
|
@ -11,7 +11,6 @@
|
|||
*/
|
||||
define([
|
||||
'main/project-list/index',
|
||||
'main/user-details',
|
||||
'main/account-settings',
|
||||
'main/clear-sessions',
|
||||
'main/account-upgrade',
|
||||
|
|
|
@ -1,82 +0,0 @@
|
|||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
max-len,
|
||||
no-return-assign,
|
||||
no-undef,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS101: Remove unnecessary use of Array.from
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* DS207: Consider shorter variations of null checks
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
define(['base', 'services/algolia-search'], App =>
|
||||
App.controller('SearchWikiController', function($scope, algoliaSearch, _) {
|
||||
$scope.hits = []
|
||||
|
||||
$scope.clearSearchText = function() {
|
||||
$scope.searchQueryText = ''
|
||||
return updateHits([])
|
||||
}
|
||||
|
||||
$scope.safeApply = function(fn) {
|
||||
const phase = $scope.$root.$$phase
|
||||
if (phase === '$apply' || phase === '$digest') {
|
||||
return $scope.$eval(fn)
|
||||
} else {
|
||||
return $scope.$apply(fn)
|
||||
}
|
||||
}
|
||||
|
||||
const buildHitViewModel = function(hit) {
|
||||
const page_underscored = hit.pageName.replace(/\s/g, '_')
|
||||
const section_underscored = hit.sectionName.replace(/\s/g, '_')
|
||||
let content = hit._highlightResult.content.value
|
||||
// Replace many new lines
|
||||
content = content.replace(/\n\n+/g, '\n\n')
|
||||
const lines = content.split('\n')
|
||||
// Only show the lines that have a highlighted match
|
||||
const matching_lines = []
|
||||
for (let line of Array.from(lines)) {
|
||||
if (!/^\[edit\]/.test(line)) {
|
||||
content += line + '\n'
|
||||
if (/<em>/.test(line)) {
|
||||
matching_lines.push(line)
|
||||
}
|
||||
}
|
||||
}
|
||||
content = matching_lines.join('\n...\n')
|
||||
const result = {
|
||||
name:
|
||||
hit._highlightResult.pageName.value +
|
||||
' - ' +
|
||||
hit._highlightResult.sectionName.value,
|
||||
url: `/learn/${page_underscored}#${section_underscored}`,
|
||||
content
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
var updateHits = hits => $scope.safeApply(() => ($scope.hits = hits))
|
||||
|
||||
return ($scope.search = function() {
|
||||
const query = $scope.searchQueryText
|
||||
if (query == null || query.length === 0) {
|
||||
updateHits([])
|
||||
return
|
||||
}
|
||||
|
||||
return algoliaSearch.searchWiki(query, function(err, response) {
|
||||
if (response.hits.length === 0) {
|
||||
return updateHits([])
|
||||
} else {
|
||||
const hits = _.map(response.hits, buildHitViewModel)
|
||||
return updateHits(hits)
|
||||
}
|
||||
})
|
||||
})
|
||||
}))
|
|
@ -1,108 +0,0 @@
|
|||
/* eslint-disable
|
||||
handle-callback-err,
|
||||
max-len,
|
||||
no-return-assign,
|
||||
no-undef,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* DS207: Consider shorter variations of null checks
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
define(['base', 'algoliasearch'], function(App, AlgoliaSearch) {
|
||||
App.factory('Institutions', () =>
|
||||
AlgoliaSearch(
|
||||
window.algolia.institutions.app_id,
|
||||
window.algolia.institutions.api_key
|
||||
).initIndex('institutions')
|
||||
)
|
||||
|
||||
App.controller('UserProfileController', function($scope, $modal, $http) {
|
||||
$scope.institutions = []
|
||||
$http.get('/user/personal_info').then(function(response) {
|
||||
const { data } = response
|
||||
return ($scope.userInfoForm = {
|
||||
first_name: data.first_name || '',
|
||||
last_name: data.last_name || '',
|
||||
role: data.role || '',
|
||||
institution: data.institution || '',
|
||||
_csrf: window.csrfToken
|
||||
})
|
||||
})
|
||||
|
||||
$scope.showForm = function() {
|
||||
GrooveWidget.toggle()
|
||||
return ($scope.formVisable = true)
|
||||
}
|
||||
|
||||
$scope.getPercentComplete = function() {
|
||||
const results = _.filter(
|
||||
$scope.userInfoForm,
|
||||
value =>
|
||||
value == null || (value != null ? value.length : undefined) !== 0
|
||||
)
|
||||
return results.length * 20
|
||||
}
|
||||
|
||||
$scope.$watch(
|
||||
'userInfoForm',
|
||||
function(value) {
|
||||
if (value != null) {
|
||||
return ($scope.percentComplete = $scope.getPercentComplete())
|
||||
}
|
||||
},
|
||||
true
|
||||
)
|
||||
|
||||
return ($scope.openUserProfileModal = () =>
|
||||
$modal.open({
|
||||
templateUrl: 'userProfileModalTemplate',
|
||||
controller: 'UserProfileModalController',
|
||||
scope: $scope
|
||||
}))
|
||||
})
|
||||
|
||||
return App.controller('UserProfileModalController', function(
|
||||
$scope,
|
||||
$modalInstance,
|
||||
$http,
|
||||
Institutions
|
||||
) {
|
||||
$scope.roles = [
|
||||
'Student',
|
||||
'Post-graduate student',
|
||||
'Post-doctoral researcher',
|
||||
'Lecturer',
|
||||
'Professor'
|
||||
]
|
||||
|
||||
$modalInstance.result.finally(() => sendUpdate())
|
||||
|
||||
var sendUpdate = function() {
|
||||
const request = $http.post('/user/settings', $scope.userInfoForm)
|
||||
request.then(function() {})
|
||||
return request.catch(() => console.log('the request failed'))
|
||||
}
|
||||
|
||||
$scope.updateInstitutionsList = function(inputVal) {
|
||||
const query = $scope.userInfoForm.institution
|
||||
if ((query != null ? query.length : undefined) <= 3) {
|
||||
return // saves us algolia searches
|
||||
}
|
||||
|
||||
return Institutions.search(
|
||||
$scope.userInfoForm.institution,
|
||||
(err, response) =>
|
||||
($scope.institutions = _.map(
|
||||
response.hits,
|
||||
institution => `${institution.name} (${institution.domain})`
|
||||
))
|
||||
)
|
||||
}
|
||||
|
||||
return ($scope.done = () => $modalInstance.close())
|
||||
})
|
||||
})
|
Loading…
Reference in a new issue