<commit_before>;(function(){

var _ = require("underscore");
var $ = require('jquery');
var BackBone = require("backbone");

var ViewStack = module.exports = BackBone.View.extend({

	_stack: null,
	_stackReplace: null,
	_current: null,

	initialize: function initialize(options){
		if ( typeof this.setShared !== "undefined" )
			this.setShared( options.shared );
		this._stack   = [];
		this._stackReplace = [];
		this._current = null;
		this.$el.empty();
	},

	render: function render(){
		return this;
	},

	getView: function getView(){
		return this._stack.length > 0 ? this._stack[ this._stack.length - 1 ] : null;
	},

	getViewActive: function getViewActive(){
		return this._current;
	},

	// pushView
	// Aggiunge una view all'applicazione con z-Index più alto
	pushView: function pushView( newView, options ){

		// Controllo se è la stessa view che sto cercando di pushare
		if ( this._current === newView ) return this;


		if ( options && options.replace == true ){

			if ( this._current ){

				var popped = this._stack.pop();

				this._stackReplace.push( popped );

				popped.$el.detach();

				// Calcolo il nuovo z-Index che è incrementale
				var zIndex = (this._stack.length*100) + 100;
				// Setto lo z-index
				if ( newView.setZindex )
					newView.setZindex( zIndex );
				else
					newView.$el.css("z-index", zIndex);

				this._stack.push( newView );

				this.$el.append( newView.el );

				// setto la view Corrente
				this._current = newView;
				// 
				newView.render();


			}

		}else{

			// Calcolo il nuovo z-Index che è incrementale
			var zIndex = (this._stack.length*100) + 100;
			// Setto lo z-index
			if ( newView.setZindex )
				newView.setZindex( zIndex );
			else
				newView.$el.css("z-index", zIndex);
			// aggiungo allo stack
			this._stack.push( newView );
			// Appendo alla view dell'applicazione
			this.$el.append( newView.el );
			// setto la view Corrente
			this._current = newView;
			// 
			newView.render();

			if ( this._current && this._current.onActivate ) 
				this._current.onActivate();

		}

		// Scateno l'evento active per dire alla view che è attiva
		if ( this._current )
        	this._current.trigger("active");

		this
			.refreshUrl()
			.trigger('pushed', newView);
		return this;
	},

	
	// popView 
	// Rimuove l'ultima view dello stack
	popView: function popView(){

		var self 	   = this,
			poppedView = self._current;

		if ( !poppedView || !poppedView.onDeactivate )
			return self._popView();

		poppedView.onDeactivate(function(){
			self._popView();
		});
		return poppedView;

	},

	// refresh
	// Aggiorna l'url se la view corrette ce l'ha settata
	refreshUrl: function refreshUrl(){
		var shared = this.getShared ? this.getShared() : null;
		if ( typeof shared !== "undefined" && shared && this._current && this._current.url ){
			shared.app.navigate(_.result(this._current, 'url'));
		}	
		return this;
	},

	// clearStack 
	// Pulisce tutto lo stack dalle view
	clearStack: function clearStack(){
		
		while( this._stack.length > 0 ){
			this.popView();
		}

		return this;
	},


	//
	// Private
	// 

	_popView: function _popView(){
		var popped = this._stack.pop();
		if (popped) {
            popped.destroy();
            popped.trigger("deactive");<commit_msg>Delete a specific view from the array of views<commit_after>;(function(){

var _ = require("underscore");
var $ = require('jquery');
var BackBone = require("backbone");

var ViewStack = module.exports = BackBone.View.extend({

	_stack: null,
	_stackReplace: null,
	_current: null,

	initialize: function initialize(options){
		if ( typeof this.setShared !== "undefined" )
			this.setShared( options.shared );
		this._stack   = [];
		this._stackReplace = [];
		this._current = null;
		this.$el.empty();
	},

	render: function render(){
		return this;
	},

	getView: function getView(){
		return this._stack.length > 0 ? this._stack[ this._stack.length - 1 ] : null;
	},

	getViewActive: function getViewActive(){
		return this._current;
	},

	// pushView
	// Aggiunge una view all'applicazione con z-Index più alto
	pushView: function pushView( newView, options ){

		// Controllo se è la stessa view che sto cercando di pushare
		if ( this._current === newView ) return this;


		if ( options && options.replace == true ){

			if ( this._current ){

				var popped = this._stack.pop();

				this._stackReplace.push( popped );

				popped.$el.detach();

				// Calcolo il nuovo z-Index che è incrementale
				var zIndex = (this._stack.length*100) + 100;
				// Setto lo z-index
				if ( newView.setZindex )
					newView.setZindex( zIndex );
				else
					newView.$el.css("z-index", zIndex);

				this._stack.push( newView );

				this.$el.append( newView.el );

				// setto la view Corrente
				this._current = newView;
				// 
				newView.render();


			}

		}else{

			// Calcolo il nuovo z-Index che è incrementale
			var zIndex = (this._stack.length*100) + 100;
			// Setto lo z-index
			if ( newView.setZindex )
				newView.setZindex( zIndex );
			else
				newView.$el.css("z-index", zIndex);
			// aggiungo allo stack
			this._stack.push( newView );
			// Appendo alla view dell'applicazione
			this.$el.append( newView.el );
			// setto la view Corrente
			this._current = newView;
			// 
			newView.render();

			if ( this._current && this._current.onActivate ) 
				this._current.onActivate();

		}

		// Scateno l'evento active per dire alla view che è attiva
		if ( this._current )
        	this._current.trigger("active");

		this
			.refreshUrl()
			.trigger('pushed', newView);
		return this;
	},

	
	// popView 
	// Rimuove l'ultima view dello stack
	popView: function popView(popped){

		var self 	   = this,
			poppedView = self._current;

		if ( !poppedView || !poppedView.onDeactivate )
			return self._popView(popped);

		poppedView.onDeactivate(function(){
			self._popView(popped);
		});
		return poppedView;

	},

	// refresh
	// Aggiorna l'url se la view corrette ce l'ha settata
	refreshUrl: function refreshUrl(){
		var shared = this.getShared ? this.getShared() : null;
		if ( typeof shared !== "undefined" && shared && this._current && this._current.url ){
			shared.app.navigate(_.result(this._current, 'url'));
		}	
		return this;
	},

	// clearStack 
	// Pulisce tutto lo stack dalle view
	clearStack: function clearStack(){
		
		while( this._stack.length > 0 ){
			this.popView();
		}

		return this;
	},


	//
	// Private
	// 

	_popView: function _popView(popped){

		if ( typeof popped !== "undefined" ){
			var index = _.indexOf(this._stack, popped);
			delete this._stack[ index ];
			this._stack = _.compact(this._stack);
		}else{
			popped = this._stack.pop();
		}

		if ( popped ) {
            popped.destroy();
            popped.trigger("deactive");
{'fraction_non_alphanumeric': 0.13964164075225827, 'fraction_numerical': 0.00444247001332741, 'mean_word_length': 2.8749282845668387, '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': '60887', 'n_tokens_mistral': 2618, 'n_tokens_neox': 2222, 'n_words': 556}