<commit_before>/**
 * Execute a script in a sandbox.
 * @param {String}           js     The Javascript code.
 * @param {Webos.Arguments}  [args] Arguments to provide to the script.
 * @constructor
 */
Webos.Script = function WScript(js, args) {
	this.js = js;
	this.args = args;
	
	if (typeof args == 'undefined') { //Si les arguments sont vides
		args = new Webos.Arguments({});
	}
	
	var options = args.getOptions(), params = args.getParams();

	if (js != '' && js != null) {
		js = 'try {'+js+"\n"+'} catch(error) { W.Error.catchError(error); }';
	}
	
	//On ajoute la sandbox
	js = '(function(args) { '+js+"\n"+' })(new W.Arguments({ options: '+JSON.stringify(options)+', params: '+JSON.stringify(params)+' }));';
	Webos.Script.run(js); //On execute le tout
};

/**
 * Run a script.
 * @param  {String} js The Javascript code.
 * @static
 */
Webos.Script.run = function $_WScript_run(js) {
	js = js.replace(/\/\*([\s\S]*?)\*\//g, ''); //On enleve les commentaires
	$.globalEval(js);
};

/**
 * Load a script from a Javascript file.
 * The script is loaded synchronously.
 * @param  {String} path The file's path.
 * @static
 */
Webos.Script.load = function $_WScript_load(path) {
	$.ajax({
		url: path,
		dataType: "script",
		async: false
	});
};

/**
 * A Javascript file.
 * @param {String} path The file's path.
 * @constructor
 */
Webos.ScriptFile = function WScriptFile(path) { //Permet d'inclure un fichier Javascript
	if (!/^(\/|~\/)/.test(path)) {
		path = '/'+path;
	}
	
	this.run = function() {
		Webos.ScriptFile._cache[this.path] = this._js;
		if (this._js) {
			var js = 'try {'+this._js+"\n"+'} catch(error) { W.Error.catchError(error); }';
			Webos.Script.run(js);
		}
	};
	
	this._js = null;
	this.path = path;
	
	if (typeof W.ScriptFile._cache[path] != 'undefined') {
		this._js = W.ScriptFile._cache[path];
		this.run();
		return;
	}<commit_msg>Scripts loaded via Webos.Script.load() are now cached.<commit_after>/**
 * Execute a script in a sandbox.
 * @param {String}           js     The Javascript code.
 * @param {Webos.Arguments}  [args] Arguments to provide to the script.
 * @constructor
 */
Webos.Script = function WScript(js, args) {
	this.js = js;
	this.args = args;
	
	if (typeof args == 'undefined') { //Si les arguments sont vides
		args = new Webos.Arguments({});
	}
	
	var options = args.getOptions(), params = args.getParams();

	if (js != '' && js != null) {
		js = 'try {'+js+"\n"+'} catch(error) { W.Error.catchError(error); }';
	}
	
	//On ajoute la sandbox
	js = '(function(args) { '+js+"\n"+' })(new W.Arguments({ options: '+JSON.stringify(options)+', params: '+JSON.stringify(params)+' }));';
	Webos.Script.run(js); //On execute le tout
};

/**
 * Run a script.
 * @param  {String} js The Javascript code.
 * @static
 */
Webos.Script.run = function $_WScript_run(js) {
	js = js.replace(/\/\*([\s\S]*?)\*\//g, ''); //On enleve les commentaires
	$.globalEval(js);
};

/**
 * Load a script from a Javascript file.
 * The script is loaded synchronously.
 * @param  {String} path The file's path.
 * @static
 */
Webos.Script.load = function $_WScript_load(path) {
	$.ajax({
		url: path,
		dataType: "script",
		cache: true,
		async: false
	});
};

/**
 * A Javascript file.
 * @param {String} path The file's path.
 * @constructor
 */
Webos.ScriptFile = function WScriptFile(path) { //Permet d'inclure un fichier Javascript
	if (!/^(\/|~\/)/.test(path)) {
		path = '/'+path;
	}
	
	this.run = function() {
		Webos.ScriptFile._cache[this.path] = this._js;
		if (this._js) {
			var js = 'try {'+this._js+"\n"+'} catch(error) { W.Error.catchError(error); }';
			Webos.Script.run(js);
		}
	};
	
	this._js = null;
	this.path = path;
	
	if (typeof W.ScriptFile._cache[path] != 'undefined') {
		this._js = W.ScriptFile._cache[path];
		this.run();
		return;
	}
{'fraction_non_alphanumeric': 0.20015822784810128, 'fraction_numerical': 0.0, 'mean_word_length': 3.281038374717833, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4501505', 'n_tokens_mistral': 1457, 'n_tokens_neox': 1370, 'n_words': 350}