<commit_before>define [
	'public/library/helpers/mixable'
	'public/library/helpers/mixin.eventbindings'
	'qrcode'
	], ( Mixable, EventBindings, QRCode ) ->
	class InfoScreen extends Mixable

		@concern EventBindings

		# Creates a InfoScreen in the DOM that can show information to the player
		#
		# @param context [jQuery DOM-object] The object to add this info view to.
		# @param forceKeyboard [Boolean] Force to use the keyboard as input without showing the selection screen
		#
		constructor: ( context, @forceKeyboard = false ) ->
			@views = {}
			$('head').append('<link rel="stylesheet" type="text/css" href="../stylesheets/infoScreen.css">');

			context.append $ '<div id="info"></div>'
			@container = $ '#info'
			do @showLoadingScreen

		# Load a view from a file, cache it and show it
		#
		# @param file [String] the filename to load
		# @param onShow [Function] function to execute after the view has been shown to the user
		# @param onHide [Function] function to execute just before the view gets replaced by a new one
		#
		_showFromFile: ( file, onShow = (->), onHide = (->) ) =>
			if @_activeScreen
				@_activeScreen()
				@_activeScreen = false

			unless @views[file]
				@container.load "views/infoScreen/#{file}", (contents) =>
					@views[file] = contents
					@_activeScreen = onHide
					onShow()
				return

			@container.html @views[file]
			@_activeScreen = onHide
			onShow()

		# Shows a loading screen to the user
		#
		showLoadingScreen: =>
			@_showFromFile 'loading.html'

		# Shows a welcome screen to the user that the user can click away to get to the controller selection
		#
		showWelcomeScreen: ( ) =>
			if @forceKeyboard
				@trigger 'controllerType', 'keyboard'
				return

			@_showFromFile 'welcome.html', =>
					@_clickHandler = =>
						@showControllerSelection()
					@container.click @_clickHandler
				, =>
					@container.unbind 'click', @_clickHandler
					@_clickHandler = null

		# Shows the controller selection screen; choices are Keyboard/Mouse and Mobile Phone
		#
		showControllerSelection: =>
			@_showFromFile 'controller.html', =>
					_clickHandler = ( controller ) =>
						=>
							@trigger 'controllerType', controller
					@_clickHandlerKeyboard = _clickHandler 'mouse'
					@_clickHandlerMobile = _clickHandler 'mobile'

					$('#keyboard').click @_clickHandlerKeyboard
					$('#mobile').click @_clickHandlerMobile
				, =>
					$('#keyboard').unbind 'click', @_clickHandlerKeyboard
					$('#mobile').unbind 'click', @_clickHandlerMobile
					@_clickHandlerKeyboard = null
					@_clickHandlerMobile = null

		# Shows explanation on how to play the game
		#
		# @param controller [String] the controllertype
		#
		showInfoScreen: ( controller ) =>
			if @forceKeyboard
				@hide
				return

			@_showFromFile "info_#{controller}.html"

		# Shows the QR code to connect via mobile phone
		#
		# @param url [String] URL that after visiting connects to this user
		#
		showMobileConnectScreen: ( url ) =>
			@_showFromFile "mobile_qr.html", =>
				$('#controllerQRCodeImage').qrcode(url)
				$('#controllerQRCodeLink').html("<a href=\"#{url}\">#{url}</a>")

		# Tells the user that he died and how to respawn
		#
		showPlayerDiedScreen: ( ) =>
			@_showFromFile "player_died.html"

		# Shows the InfoView
		#
		show: =>
			@container.show()

		# Hides the InfoView
		#
		hide: =>
			@container.hide()<commit_msg>Use ' instead of " for static strings<commit_after>define [
	'public/library/helpers/mixable'
	'public/library/helpers/mixin.eventbindings'
	'qrcode'
	], ( Mixable, EventBindings, QRCode ) ->
	class InfoScreen extends Mixable

		@concern EventBindings

		# Creates a InfoScreen in the DOM that can show information to the player
		#
		# @param context [jQuery DOM-object] The object to add this info view to.
		# @param forceKeyboard [Boolean] Force to use the keyboard as input without showing the selection screen
		#
		constructor: ( context, @forceKeyboard = false ) ->
			@views = {}
			$('head').append('<link rel="stylesheet" type="text/css" href="../stylesheets/infoScreen.css">');

			context.append $ '<div id="info"></div>'
			@container = $ '#info'
			do @showLoadingScreen

		# Load a view from a file, cache it and show it
		#
		# @param file [String] the filename to load
		# @param onShow [Function] function to execute after the view has been shown to the user
		# @param onHide [Function] function to execute just before the view gets replaced by a new one
		#
		_showFromFile: ( file, onShow = (->), onHide = (->) ) =>
			if @_activeScreen
				@_activeScreen()
				@_activeScreen = false

			unless @views[file]
				@container.load "views/infoScreen/#{file}", (contents) =>
					@views[file] = contents
					@_activeScreen = onHide
					onShow()
				return

			@container.html @views[file]
			@_activeScreen = onHide
			onShow()

		# Shows a loading screen to the user
		#
		showLoadingScreen: =>
			@_showFromFile 'loading.html'

		# Shows a welcome screen to the user that the user can click away to get to the controller selection
		#
		showWelcomeScreen: ( ) =>
			if @forceKeyboard
				@trigger 'controllerType', 'keyboard'
				return

			@_showFromFile 'welcome.html', =>
					@_clickHandler = =>
						@showControllerSelection()
					@container.click @_clickHandler
				, =>
					@container.unbind 'click', @_clickHandler
					@_clickHandler = null

		# Shows the controller selection screen; choices are Keyboard/Mouse and Mobile Phone
		#
		showControllerSelection: =>
			@_showFromFile 'controller.html', =>
					_clickHandler = ( controller ) =>
						=>
							@trigger 'controllerType', controller
					@_clickHandlerKeyboard = _clickHandler 'mouse'
					@_clickHandlerMobile = _clickHandler 'mobile'

					$('#keyboard').click @_clickHandlerKeyboard
					$('#mobile').click @_clickHandlerMobile
				, =>
					$('#keyboard').unbind 'click', @_clickHandlerKeyboard
					$('#mobile').unbind 'click', @_clickHandlerMobile
					@_clickHandlerKeyboard = null
					@_clickHandlerMobile = null

		# Shows explanation on how to play the game
		#
		# @param controller [String] the controllertype
		#
		showInfoScreen: ( controller ) =>
			if @forceKeyboard
				@hide
				return

			@_showFromFile "info_#{controller}.html"

		# Shows the QR code to connect via mobile phone
		#
		# @param url [String] URL that after visiting connects to this user
		#
		showMobileConnectScreen: ( url ) =>
			@_showFromFile 'mobile_qr.html', =>
				$('#controllerQRCodeImage').qrcode(url)
				$('#controllerQRCodeLink').html("<a href=\"#{url}\">#{url}</a>")

		# Tells the user that he died and how to respawn
		#
		showPlayerDiedScreen: ( ) =>
			@_showFromFile 'player_died.html'

		# Shows the InfoView
		#
		show: =>
			@container.show()

		# Hides the InfoView
		#
		hide: =>
			@container.hide()
{'fraction_non_alphanumeric': 0.11951722107742126, 'fraction_numerical': 0.0, 'mean_word_length': 3.5059681697612732, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5267441', 'n_tokens_mistral': 2466, 'n_tokens_neox': 2047, 'n_words': 604}