extends ../layout

block content
	//- We need to do .replace(/\//g, '\\/') do that '</script>' -> '<\/script>'
	//- and doesn't prematurely end the script tag.
	script#data(type="application/json").
		!{JSON.stringify({ projects: projects, tags: tags, notifications: notifications }).replace(/\//g, '\\/')}


	script(type="text/javascript").
		window.data = JSON.parse($("#data").text());
		window.algolia = {
			institutions: {
				app_id:  '#{algolia_app_id}',
				api_key: '#{algolia_api_key}'
			}
		};

	if uiConfig.renderAnnouncements
		.announcements(
			ng-controller="AnnouncementsController"
			ng-class="{ 'announcements-open': ui.isOpen }"
			ng-cloak
		)
			.announcements-backdrop(
				ng-if="ui.isOpen"
				ng-click="toggleAnnouncementsUI();"
			)
			a.announcements-btn(
				href
				ng-if="announcements.length"
				ng-click="toggleAnnouncementsUI();"
				ng-class="{ 'announcements-btn-open': ui.isOpen, 'announcements-btn-has-new': ui.newItems }"
			)
				span.announcements-badge(ng-if="ui.newItems") {{ ui.newItems }}
			.announcements-body(
				ng-if="ui.isOpen"
			)
				.announcements-scroller
					.announcement(
						ng-repeat="announcement in announcements | filter:(ui.newItems ? { read: false } : '') track by announcement.id"
					)
						h2.announcement-header {{ announcement.title }}
						p.announcement-description(ng-bind-html="announcement.excerpt")
						.announcement-meta
							p.announcement-date {{ announcement.date | date:"longDate" }}
							a.announcement-link(
								ng-href="{{ announcement.url }}"
								ng-click="logAnnouncementClick()",
								target="_blank"
							) Read more
					div.text-center(
						ng-if="ui.newItems > 0 && ui.newItems < announcements.length"
					)
						a.btn.btn-default.btn-sm(
							href
							ng-click="showAll();"
						) Show all
	main.content.content-alt.project-list-page(
		ng-controller="ProjectPageController"
		role="main"
	)
		- if(typeof(suppressSystemMessages) == "undefined")
			.system-messages(
				ng-cloak
				ng-controller="SystemMessagesController"
			)
				.system-message(
					ng-repeat="message in messages"
					ng-controller="SystemMessageController"
					ng-hide="hidden"
				)
					button(ng-click="hide()").close.pull-right
						span(aria-hidden="true") &times;
						span.sr-only #{translate("close")}
					.system-message-content(ng-bind-html="htmlContent")
			
			include ../translations/translation_message

		.project-list-content(event-tracking=settings.overleaf ? "loads_v2_dash" : "", onboard=settings.overleaf ? "true" : "", event-tracking-trigger=settings.overleaf ? "load" : "", event-tracking-mb="true", event-segmentation="{location: 'dash', v2_onboard: true}")
			.row.project-list-row(ng-cloak)
				.project-list-container(ng-if="projects.length > 0")
					.project-list-sidebar-wrapper.col-md-2.col-xs-3
						aside.project-list-sidebar
							include ./list/side-bar

						if hasFeature('v1-return-message')
							.project-list-sidebar-v2-pane(ng-controller="OverleafV1NotificationController")
								div
									button.btn-link.pull-right.project-list-sidebar-v2-pane-toggle(
										ng-click="toggle()"
									)
										i.fa.fa-fw(ng-class="{ 'fa-chevron-up': !visible, 'fa-close': visible }")
									| Welcome to the Overleaf v2 beta!
								div(ng-show="visible") #[a(href="https://www.overleaf.com/help/342-overleaf-v2-faq") Find out more].
								if userIsFromOLv1(user)
									div(ng-show="visible")
										| To tag or rename your v1 projects, please go back to Overleaf v1.
									div(ng-show="visible")
										a.project-list-sidebar-v1-link(
											href=settings.overleaf.host + "/dash?prefer-v1-dash=1"
										) Go back to v1
								if userIsFromSL(user)
									div(ng-show="visible")
										a.project-list-sidebar-v1-link(
											href=settings.accountMerge.sharelatexHost
										) Go back to ShareLaTeX

					.project-list-main.col-md-10.col-xs-9
						include ./list/notifications
						include ./list/project-list
				
				.project-list-empty(ng-if="projects.length === 0")
					.col-md-offset-2.col-md-8.col-md-offset-2.col-xs-8
						include ./list/empty-project-list

		include ./list/modals

	include ./list/front-chat
