<commit_before>/* global globals, $ */
'use strict';

function Savegame() {
	// var statusArray = [];

	let langEntries = globals.module.getLangData();

	function initialize() {
		globals.gameData.registerObserver(function(game, property, value) {},
			'version');
	}

	globals.module.on('langChanged', function(id, subId, data) {
		langEntries = data;
	});

	this.display = function() {
		$('#foundSaves').html(langEntries.content['savegame.foundSaves']);

		$('h1').html(langEntries.content['savegame.savegames']);

		// init table
		$('#foundSavesContainer').html('<table>' + '' + '</table>');
	};

	initialize();
}<commit_msg>Started working on savegame<commit_after>/* global globals, $ */
'use strict';

function Savegame() {
	const savesArray = [];

	let langEntries = globals.module.getLangData();

	function initialize() {
		globals.gameData.registerObserver(function(game, property, value) {
			if (value) {
				_lookForSave(game.shortId);
			}
		}.bind(this), 'version');
	}

	globals.module.on('langChanged', function(id, subId, data) {
		langEntries = data;
	});

	this.display = function() {
		$('#foundSaves').html(langEntries.content['savegame.foundSaves']);

		$('h1').html(langEntries.content['savegame.savegames']);

		// init table
		$('#foundSavesContainer').html('<table>' + _getTable() + '</table>');
	};

	function _lookForSave(version) {
		let file = path.join(globalData.versionList[version], '..', 'cc.save');
		if(fs.existsSync(file)) {
			fs.readFile(file, 'utf8', function(err, data) {
				if(err)
					throw err;
					
				savesArray[version] = JSON.parse(data);
				globals.module.sharedMemory['savegame'].controller.display();
			});
		}
	}

	function _getTable(){
		let tableString = '<tr><th>' +
			langEntries.content['savegame.savegame'] +
			'</th><th></th></tr>';

		if (savesArray.length === 0) {
			return langEntries.content['status.noGames'];
		}

		for (let i in savesArray) {
			tableString += '<tr><td>' + savesArray[i].version + '</td><td><!-- Display edit button here --></td></tr>';
		}

		return tableString;
	}


	initialize();
}
{'fraction_non_alphanumeric': 0.19903846153846153, 'fraction_numerical': 0.0019230769230769232, 'mean_word_length': 4.295165394402035, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, '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': '7530154', 'n_tokens_mistral': 770, 'n_tokens_neox': 689, 'n_words': 119}