<commit_before>/*©agpl*************************************************************************
*                                                                              *
* This file is part of FRIEND UNIFYING PLATFORM.                               *
* Copyright (c) Friend Software Labs AS. All rights reserved.                  *
*                                                                              *
* Licensed under the Source EULA. Please refer to the copy of the GNU Affero   *
* General Public License, found in the file license_agpl.txt.                  *
*                                                                              *
*****************************************************************************©*/

// App settings.. --------------------------------------------------------------
var settings = {
	wordWrap: true,
	wordWrapWidth: 80,
	codeFolding: true,
	ownScreen: false,
	theme: 'twilight'
};

// Gui settings and callbacks --------------------------------------------------
var gui = {
	sideBar: null,
	sideBarCallbacks: {
		// Check a file on file extension
		checkFile( path, extension )
		{
			if( extension == 'apf' )
			{
				Confirm( 
					i18n( 'i18n_loading_project' ), 
					i18n( 'i18n_loading_project_desc' ), function( info )
				{
					if( info.data == true )
					{
						OpenProject( path );
					}
					// Just load it
					else
					{
						OpenFile( path );
					}
				} );
				return false;
			}
			if( Application.checkFileType( path ) )
			{
				( new EditorFile( path ) );
			}
			return true;
		},
		// Load a file
		loadFile( path )
		{
			( new EditorFile( path ) );
		},
		// Do we permit?
		permitFiletype( path )
		{
			return Application.checkFileType( path );
		}
	}
};

// Files and projects ----------------------------------------------------------

var files = [];
var projectFiles = {}; // Index
var projects = [];

// Launch view logic -----------------------------------------------------------

Application.run = function( msg )
{
	InitGui();
	( new EditorFile( 'New file' ) );
	RefreshProjects();
}


// Set current file ------------------------------------------------------------
function SetCurrentFile( index )
{
	Application.currentFile = files[ index ];
}

// Check if we support the filetype --------------------------------------------
Application.checkFileType = function( path )
{
	if( !path || ( path && !path.split ) ) return;
	var ext = path.split ( '.' );
	ext = ext[ ext.length-1 ];
	switch ( ext.toLowerCase() )
	{
		case 'php':
		case 'pl':
		case 'sql':
		case 'sh':
		case 'as':
		case 'txt':
		case 'js':
		case 'lang':
		case 'pls':
		case 'json':
		case 'tpl':
		case 'ptpl':
		case 'xml':
		case 'html':
		case 'htm':
		case 'c':
		case 'h':
		case 'cpp':
		case 'd':
		case 'ini':
		case 'jsx':
		case 'java':
		case 'css':
		case 'run':
		case 'apf':
		case 'conf':
			return true;
		default:
			return false;
	}
}

function RefreshFiletypeSelect()
{
	if( !Application.currentFile ) return;
	var ext = Application.currentFile.path ? Application.currentFile.path.split( '.' ).pop().toLowerCase() : 'txt';
	
	var types = {
		'php': 'ace/mode/php',
		'pl': 'ace/mode/perl',
		'sql': 'ace/mode/sql',
		'sh': 'ace/mode/sh',
		'as': 'ace/mode/actionscript',
		'txt': 'ace/mode/txt',
		'js': 'ace/mode/javascript',
		'lang': 'ace/mode/txt',
		'pls': 'ace/mode/json',
		'json': 'ace/mode/json',
		'tpl': 'ace/mode/html',
		'ptpl': 'ace/mode/perl',
		'xml': 'ace/mode/xml',
		'html': 'ace/mode/html',
		'htm': 'ace/mode/html',
		'c': 'ace/mode/c_cpp',
		'h': 'ace/mode/c_cpp',
		'cpp': 'ace/mode/c_cpp',
		'd': 'ace/mode/d',
		'ini': 'ace/mode/ini',
		'jsx': 'ace/mode/javascript',
		'java': 'ace/mode/java',
		'css': 'ace/mode/css',
		'run': 'ace/mode/txt',
		'apf': 'ace/mode/json',
		'conf': 'ace/mode/json'
	};<commit_msg>Correct text type.<commit_after>/*©agpl*************************************************************************
*                                                                              *
* This file is part of FRIEND UNIFYING PLATFORM.                               *
* Copyright (c) Friend Software Labs AS. All rights reserved.                  *
*                                                                              *
* Licensed under the Source EULA. Please refer to the copy of the GNU Affero   *
* General Public License, found in the file license_agpl.txt.                  *
*                                                                              *
*****************************************************************************©*/

// App settings.. --------------------------------------------------------------
var settings = {
	wordWrap: true,
	wordWrapWidth: 80,
	codeFolding: true,
	ownScreen: false,
	theme: 'twilight'
};

// Gui settings and callbacks --------------------------------------------------
var gui = {
	sideBar: null,
	sideBarCallbacks: {
		// Check a file on file extension
		checkFile( path, extension )
		{
			if( extension == 'apf' )
			{
				Confirm( 
					i18n( 'i18n_loading_project' ), 
					i18n( 'i18n_loading_project_desc' ), function( info )
				{
					if( info.data == true )
					{
						OpenProject( path );
					}
					// Just load it
					else
					{
						OpenFile( path );
					}
				} );
				return false;
			}
			if( Application.checkFileType( path ) )
			{
				( new EditorFile( path ) );
			}
			return true;
		},
		// Load a file
		loadFile( path )
		{
			( new EditorFile( path ) );
		},
		// Do we permit?
		permitFiletype( path )
		{
			return Application.checkFileType( path );
		}
	}
};

// Files and projects ----------------------------------------------------------

var files = [];
var projectFiles = {}; // Index
var projects = [];

// Launch view logic -----------------------------------------------------------

Application.run = function( msg )
{
	InitGui();
	( new EditorFile( 'New file' ) );
	RefreshProjects();
}


// Set current file ------------------------------------------------------------
function SetCurrentFile( index )
{
	Application.currentFile = files[ index ];
}

// Check if we support the filetype --------------------------------------------
Application.checkFileType = function( path )
{
	if( !path || ( path && !path.split ) ) return;
	var ext = path.split ( '.' );
	ext = ext[ ext.length-1 ];
	switch ( ext.toLowerCase() )
	{
		case 'php':
		case 'pl':
		case 'sql':
		case 'sh':
		case 'as':
		case 'txt':
		case 'js':
		case 'lang':
		case 'pls':
		case 'json':
		case 'tpl':
		case 'ptpl':
		case 'xml':
		case 'html':
		case 'htm':
		case 'c':
		case 'h':
		case 'cpp':
		case 'd':
		case 'ini':
		case 'jsx':
		case 'java':
		case 'css':
		case 'run':
		case 'apf':
		case 'conf':
			return true;
		default:
			return false;
	}
}

function RefreshFiletypeSelect()
{
	if( !Application.currentFile ) return;
	var ext = Application.currentFile.path ? Application.currentFile.path.split( '.' ).pop().toLowerCase() : 'txt';
	
	var types = {
		'php': 'ace/mode/php',
		'pl': 'ace/mode/perl',
		'sql': 'ace/mode/sql',
		'sh': 'ace/mode/sh',
		'as': 'ace/mode/actionscript',
		'txt': 'ace/mode/text',
		'js': 'ace/mode/javascript',
		'lang': 'ace/mode/txt',
		'pls': 'ace/mode/json',
		'json': 'ace/mode/json',
		'tpl': 'ace/mode/html',
		'ptpl': 'ace/mode/perl',
		'xml': 'ace/mode/xml',
		'html': 'ace/mode/html',
		'htm': 'ace/mode/html',
		'c': 'ace/mode/c_cpp',
		'h': 'ace/mode/c_cpp',
		'cpp': 'ace/mode/c_cpp',
		'd': 'ace/mode/d',
		'ini': 'ace/mode/ini',
		'jsx': 'ace/mode/javascript',
		'java': 'ace/mode/java',
		'css': 'ace/mode/css',
		'run': 'ace/mode/txt',
		'apf': 'ace/mode/json',
		'conf': 'ace/mode/json'
	};
{'fraction_non_alphanumeric': 0.2722410644403861, 'fraction_numerical': 0.002869814766501435, 'mean_word_length': 1.6807692307692308, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2272168', 'n_tokens_mistral': 2706, 'n_tokens_neox': 2358, 'n_words': 592}