<commit_before>/************************************
 * global scene helper functions
 ************************************/

/**
 * use the Spaz. namespace just to keep from cluttering too much 
 */
if(typeof Spaz === "undefined") {
	Spaz = {};
}

/**
 * grabs the "App" container object and returns it. We use this container
 * to store globally-used properties
 */
Spaz.getAppObj = function() {
	var App = Mojo.Controller.getAppController().assistant.App;
	return App;
};


Spaz.getActiveSceneAssistant = function() {
	var appC = Mojo.Controller.getAppController();
	var stageC = appC.getActiveStageController();
	return stageC.activeScene().assistant;
};


/**
 * This helper looks through the array of scenes and looks for an existing instance of 
 * the given targetScene. If one exists, we pop all scenes before it to return to it. Otherwise
 * we swap to a new instance of the scene
 * 
 * @param {string} targetScene the scene name
 * @param {many} returnValue a return value passed to the pop or swap call
 */
Spaz.findAndSwapScene = function(targetScene, returnValue) {
	/*
		initialize
	*/
	var scene_exists = false;
	
	/*
		get an array of existing scenes
	*/
	var scenes   = Mojo.Controller.stageController.getScenes();
	
	var topscene = Mojo.Controller.stageController.topScene();
	
	if (targetScene == topscene.sceneName) {
		Mojo.Log.info('We are already on the scene %s', targetScene);
		return;
	}

	for (var k=0; k<scenes.length; k++) {
		if (scenes[k].sceneName == targetScene) { // this scene already exists, so popScenesTo it
			scene_exists = true;
		}
	}
	
	if (scene_exists) {
		Mojo.Controller.stageController.popScenesTo({name: targetScene, transition: Mojo.Transition.crossFade}, returnValue);
	} else {
		Mojo.Controller.stageController.swapScene({name: targetScene, transition: Mojo.Transition.crossFade}, returnValue);
	}
};



Spaz.popAllAndPushScene = function(targetScene, returnValue) {
	Mojo.Controller.stageController.popScenesTo(null, null);
	Mojo.Controller.stageController.pushScene(targetScene, returnValue);
};


/**
 * converts various items in a timeline entry's text into clickables
 * @param {string} str
 * @return {string}<commit_msg>Added Spaz.getSceneFromStack() helper<commit_after>/************************************
 * global scene helper functions
 ************************************/

/**
 * use the Spaz. namespace just to keep from cluttering too much 
 */
if(typeof Spaz === "undefined") {
	Spaz = {};
}

/**
 * grabs the "App" container object and returns it. We use this container
 * to store globally-used properties
 */
Spaz.getAppObj = function() {
	var App = Mojo.Controller.getAppController().assistant.App;
	return App;
};


Spaz.getActiveSceneAssistant = function() {
	var appC = Mojo.Controller.getAppController();
	var stageC = appC.getActiveStageController();
	return stageC.activeScene().assistant;
};


/**
 * This helper looks through the array of scenes and looks for an existing instance of 
 * the given targetScene. If one exists, we pop all scenes before it to return to it. Otherwise
 * we swap to a new instance of the scene
 * 
 * @param {string} targetScene the scene name
 * @param {many} returnValue a return value passed to the pop or swap call
 */
Spaz.findAndSwapScene = function(targetScene, returnValue) {
	/*
		initialize
	*/
	var scene_exists = false;
	
	/*
		get an array of existing scenes
	*/
	var scenes   = Mojo.Controller.stageController.getScenes();
	
	var topscene = Mojo.Controller.stageController.topScene();
	
	if (targetScene == topscene.sceneName) {
		Mojo.Log.info('We are already on the scene %s', targetScene);
		return;
	}

	for (var k=0; k<scenes.length; k++) {
		if (scenes[k].sceneName == targetScene) { // this scene already exists, so popScenesTo it
			scene_exists = true;
		}
	}
	
	if (scene_exists) {
		Mojo.Controller.stageController.popScenesTo({name: targetScene, transition: Mojo.Transition.crossFade}, returnValue);
	} else {
		Mojo.Controller.stageController.swapScene({name: targetScene, transition: Mojo.Transition.crossFade}, returnValue);
	}
};



Spaz.popAllAndPushScene = function(targetScene, returnValue) {
	Mojo.Controller.stageController.popScenesTo(null, null);
	Mojo.Controller.stageController.pushScene(targetScene, returnValue);
};


/**
 * @param {String} targetScene the name of the scene we're looking for 
 * @returns {Object|Boolean} the scene object, or false if not found
 */
Spaz.getSceneFromStack = function(targetScene) {
	var stageController = Mojo.Controller.getAppController().getStageController(SPAZ_MAIN_STAGENAME);
	
	if (stageController) {
		var scenes   = stageController.getScenes();
		for (var k=0; k<scenes.length; k++) {
			if (scenes[k].sceneName == targetScene) {
				return scenes[k];
			}
		}
	}
	return false;
}




/**
 * converts various items in a timeline entry's text into clickables
 * @param {string} str
 * @return {string}
{'fraction_non_alphanumeric': 0.14064094713206776, 'fraction_numerical': 0.000612369871402327, 'mean_word_length': 4.420353982300885, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 3, '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': '723752', 'n_tokens_mistral': 1546, 'n_tokens_neox': 1455, 'n_words': 436}