overleaf/services/web/public/coffee/app/ide.coffee

49 lines
1.2 KiB
CoffeeScript
Raw Normal View History

2014-06-21 17:20:37 -04:00
define [
"base"
"ide/file-tree/FileTreeManager"
"ide/directives/layout"
2014-06-22 07:10:42 -04:00
"ide/services/ide"
"directives/focusOn"
2014-06-22 12:32:15 -04:00
"directives/fineUpload"
2014-06-21 17:20:37 -04:00
], (
App
FileTreeManager
) ->
2014-06-22 07:10:42 -04:00
App.controller "IdeController", ["$scope", "$timeout", "ide", ($scope, $timeout, ide) ->
2014-06-21 17:20:37 -04:00
$scope.state = {
loading: true
load_progress: 40
}
2014-06-22 07:10:42 -04:00
window._ide = ide
2014-06-21 17:20:37 -04:00
2014-06-22 12:32:15 -04:00
ide.project_id = $scope.project_id = window.project_id
2014-06-22 07:10:42 -04:00
ide.$scope = $scope
ide.socket = io.connect null,
reconnect: false
"force new connection": true
2014-06-21 17:20:37 -04:00
2014-06-22 07:10:42 -04:00
ide.fileTreeManager = new FileTreeManager(ide, $scope)
2014-06-21 17:20:37 -04:00
2014-06-22 07:10:42 -04:00
ide.socket.on "connect", () ->
2014-06-21 17:20:37 -04:00
$scope.$apply () ->
$scope.state.load_progress = 80
joinProject = () =>
2014-06-22 07:10:42 -04:00
ide.socket.emit 'joinProject', {
project_id: ide.project_id
2014-06-21 17:20:37 -04:00
}, (err, project, permissionsLevel, protocolVersion) =>
if $scope.protocolVersion? and $scope.protocolVersion != protocolVersion
location.reload(true)
$scope.$apply () ->
$scope.protocolVersion = protocolVersion
$scope.project = project
$scope.state.load_progress = 100
$scope.state.loading = false
$scope.$emit "project:joined"
setTimeout(joinProject, 100) ]
angular.bootstrap(document.body, ["SharelatexApp"])