|
@@ -7,20 +7,12 @@ define [
|
|
|
|
|
|
|
|
$scope.bibtexPreview =
|
|
$scope.bibtexPreview =
|
|
|
loading: false
|
|
loading: false
|
|
|
|
|
+ shouldShowDots: false
|
|
|
error: false
|
|
error: false
|
|
|
data: null
|
|
data: null
|
|
|
|
|
|
|
|
$scope.failedLoad = false
|
|
$scope.failedLoad = false
|
|
|
|
|
|
|
|
- $rootScope.$on 'entity:selected', () ->
|
|
|
|
|
- $scope.failedLoad = false
|
|
|
|
|
- $scope.loadBibtexIfRequired()
|
|
|
|
|
-
|
|
|
|
|
- $scope.loadBibtexIfRequired = () ->
|
|
|
|
|
- if $scope.extension($scope.openFile) == 'bib'
|
|
|
|
|
- $scope.bibtexPreview.data = null
|
|
|
|
|
- $scope.loadBibtexFilePreview()
|
|
|
|
|
-
|
|
|
|
|
window.sl_binaryFilePreviewError = () =>
|
|
window.sl_binaryFilePreviewError = () =>
|
|
|
$scope.failedLoad = true
|
|
$scope.failedLoad = true
|
|
|
$scope.$apply()
|
|
$scope.$apply()
|
|
@@ -31,11 +23,15 @@ define [
|
|
|
$scope.loadBibtexFilePreview = () ->
|
|
$scope.loadBibtexFilePreview = () ->
|
|
|
url = "/project/#{project_id}/file/#{$scope.openFile.id}?range=0-#{TWO_MEGABYTES}"
|
|
url = "/project/#{project_id}/file/#{$scope.openFile.id}?range=0-#{TWO_MEGABYTES}"
|
|
|
$scope.bibtexPreview.loading = true
|
|
$scope.bibtexPreview.loading = true
|
|
|
|
|
+ $scope.bibtexPreview.shouldShowDots = false
|
|
|
$scope.$apply()
|
|
$scope.$apply()
|
|
|
$http.get(url)
|
|
$http.get(url)
|
|
|
.success (data) ->
|
|
.success (data) ->
|
|
|
$scope.bibtexPreview.loading = false
|
|
$scope.bibtexPreview.loading = false
|
|
|
$scope.bibtexPreview.error = false
|
|
$scope.bibtexPreview.error = false
|
|
|
|
|
+ # show dots when payload is closs to cutoff
|
|
|
|
|
+ if data.length >= (TWO_MEGABYTES - 200)
|
|
|
|
|
+ $scope.bibtexPreview.shouldShowDots = true
|
|
|
try
|
|
try
|
|
|
# remove last partial line
|
|
# remove last partial line
|
|
|
data = data.replace(/\n.*$/, '')
|
|
data = data.replace(/\n.*$/, '')
|
|
@@ -56,6 +52,11 @@ define [
|
|
|
table_wrap.style.height = desired_height + 'px'
|
|
table_wrap.style.height = desired_height + 'px'
|
|
|
table_wrap.style['max-height'] = desired_height + 'px'
|
|
table_wrap.style['max-height'] = desired_height + 'px'
|
|
|
|
|
|
|
|
|
|
+ $scope.loadBibtexIfRequired = () ->
|
|
|
|
|
+ if $scope.extension($scope.openFile) == 'bib'
|
|
|
|
|
+ $scope.bibtexPreview.data = null
|
|
|
|
|
+ $scope.loadBibtexFilePreview()
|
|
|
|
|
+
|
|
|
$scope.loadBibtexIfRequired()
|
|
$scope.loadBibtexIfRequired()
|
|
|
|
|
|
|
|
]
|
|
]
|