<commit_before>Utils = require "./Utils"

{_} = require "./Underscore"
{BaseClass} = require "./BaseClass"
{Config} = require "./Config"
{EventManager} = require "./EventManager"

Counter = 1

class exports.Context extends BaseClass
	
	constructor: (options={}) ->
		
		super

		Counter++

		options = _.defaults options,
			contextName: null
			parentLayer: null
			name: null


		if not options.name
			throw Error("Contexts need a name")

		@_parentLayer = options.parentLayer
		@_name = options.name
		
		if options.perspective != undefined
			@perspective = options.perspective
		else
			@perspective = 800
		
		@reset()

	reset: ->

		@eventManager?.reset()
		@eventManager = new EventManager

		if @_rootElement
			# Clean up the current root element:
			if @_rootElement.parentNode
				# Already attached to the DOM - remove it:
				@_rootElement.parentNode.removeChild(@_rootElement)
			else
				# Not on the DOM yet. Prevent it from being added (for this happens
				# async):
				@_rootElement.__cancelAppendChild = true

		# Create a fresh root element:
		@_createRootElement()
<commit_msg>up default perspective to 1200<commit_after>Utils = require "./Utils"

{_} = require "./Underscore"
{BaseClass} = require "./BaseClass"
{Config} = require "./Config"
{EventManager} = require "./EventManager"

Counter = 1

class exports.Context extends BaseClass
	
	constructor: (options={}) ->
		
		super

		Counter++

		options = _.defaults options,
			contextName: null
			parentLayer: null
			name: null


		if not options.name
			throw Error("Contexts need a name")

		@_parentLayer = options.parentLayer
		@_name = options.name
		
		if options.perspective != undefined
			@perspective = options.perspective
		else
			@perspective = 1200
		
		@reset()

	reset: ->

		@eventManager?.reset()
		@eventManager = new EventManager

		if @_rootElement
			# Clean up the current root element:
			if @_rootElement.parentNode
				# Already attached to the DOM - remove it:
				@_rootElement.parentNode.removeChild(@_rootElement)
			else
				# Not on the DOM yet. Prevent it from being added (for this happens
				# async):
				@_rootElement.__cancelAppendChild = true

		# Create a fresh root element:
		@_createRootElement()

{'fraction_non_alphanumeric': 0.10261026102610261, 'fraction_numerical': 0.0058505850585058505, 'mean_word_length': 3.4194831013916502, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '7518527', 'n_tokens_mistral': 788, 'n_tokens_neox': 642, 'n_words': 204}