<commit_before>// voter-info-egypt.js
// By <NAME> - http://mg.to/
// See UNLICENSE or http://unlicense.org/ for public domain notice.

// Language and prefs

var defaultLanguage = 'ar';
var supportedLanguages = {
	ar: 'عربي',
	en: 'English',
	fr: 'Français',
	_: null
};

var prefs = new _IG_Prefs();
var pref = {
	lang: prefs.getString( '.lang' )
};

if( ! supportedLanguages[pref.lang] )
	pref.lang = defaultLanguage;

function localPrefs( pref ) {
	pref.voterIdElection = true;
	pref.analyticsUA = 'UA-26399777-1';
	pref.fontFamily = 'Tahoma,Geneva,sans-serif';
}

// [ W, S, E, N ]
var initialBbox = [ 25.0, 22.0, 36.9, 31.6 ];

// Output formatters

function attribution() {
	return T( 'attributionEG' );
}

function stateLocator() {
	return '';
}

function locationWarning() {
	return '';
}

function electionInfo() {
	return S(
		//generalInfo(),
		contestsInfo(),
		//infoLinks(),
		attribution(),
		''
	);
}

function electionHeader() {
	return S(
		'<div style="font-weight:bold;">',
		'</div>'
	);
}

function generalInfo() {
	return S(
		'<div style="margin-bottom:0.5em;">',
		'</div>'
	);
}

function contestsInfo( ) {
	var contests = getContests();
	if( !( contests && contests.length ) ) return '';
	return S(
		'<div>',
			'<div>',
				T('electoralRollLabel'), ' ', contests[0].citizen_number,
			'</div>',
			'<div>',
				T('pollingStationLabel'), ' ', contests[0].box_number,
			'</div>',
			contests.mapjoin( function( contest ) {
				return contestInfo(
					contest, 'electionDate',
					'date', 'candidates', 'choices'
				);
			}),
			contests.mapjoin( function( contest ) {
				return contestInfo(
					contest, 'runoffDate',
					'date_round_2', 'candidates_round_2'
				)
			}),
		'</div>'
	);
}

function contestInfo( contest, label, date$, candidates$, choices$ ) {
	var date = dateFromYMD( contest[date$] );
	var completed = ( today - date ) > ( 1 * days );
	return S(
		'<div class="heading" style="font-size:150%;">',
			contest.type,
		'</div>',
		'<div class="heading" style="font-size:125%;">',
			contest.constituency,
		'</div>',
		'<div class="heading">',
			T(label), ' ', contest[date$],
		'</div>',
		completed ?
			T('completed') :
			contestBallot( contest, candidates$, choices$ )
	);
}

function isListContest( contest ) {
	return contest.type == 'قوائم شعب';
}

function contestBallot( contest, candidates$, choices$ ) {
	var ballot = contest.ballot_choices;
	if( ! ballot ) return '';
	return isListContest(contest) ? S(
		'<div class="">',<commit_msg>Don't display contest when date is empty<commit_after>// voter-info-egypt.js
// By <NAME> - http://mg.to/
// See UNLICENSE or http://unlicense.org/ for public domain notice.

// Language and prefs

var defaultLanguage = 'ar';
var supportedLanguages = {
	ar: 'عربي',
	en: 'English',
	fr: 'Français',
	_: null
};

var prefs = new _IG_Prefs();
var pref = {
	lang: prefs.getString( '.lang' )
};

if( ! supportedLanguages[pref.lang] )
	pref.lang = defaultLanguage;

function localPrefs( pref ) {
	pref.voterIdElection = true;
	pref.analyticsUA = 'UA-26399777-1';
	pref.fontFamily = 'Tahoma,Geneva,sans-serif';
}

// [ W, S, E, N ]
var initialBbox = [ 25.0, 22.0, 36.9, 31.6 ];

// Output formatters

function attribution() {
	return T( 'attributionEG' );
}

function stateLocator() {
	return '';
}

function locationWarning() {
	return '';
}

function electionInfo() {
	return S(
		//generalInfo(),
		contestsInfo(),
		//infoLinks(),
		attribution(),
		''
	);
}

function electionHeader() {
	return S(
		'<div style="font-weight:bold;">',
		'</div>'
	);
}

function generalInfo() {
	return S(
		'<div style="margin-bottom:0.5em;">',
		'</div>'
	);
}

function contestsInfo( ) {
	var contests = getContests();
	if( !( contests && contests.length ) ) return '';
	return S(
		'<div>',
			'<div>',
				T('electoralRollLabel'), ' ', contests[0].citizen_number,
			'</div>',
			'<div>',
				T('pollingStationLabel'), ' ', contests[0].box_number,
			'</div>',
			contests.mapjoin( function( contest ) {
				return contestInfo(
					contest, 'electionDate',
					'date', 'candidates', 'choices'
				);
			}),
			contests.mapjoin( function( contest ) {
				return contestInfo(
					contest, 'runoffDate',
					'date_round_2', 'candidates_round_2'
				)
			}),
		'</div>'
	);
}

function contestInfo( contest, label, date$, candidates$, choices$ ) {
	var ymd = contest[date$];
	if( ! ymd ) return '';
	var date = dateFromYMD( ymd );
	var completed = ( today - date ) > ( 1 * days );
	return S(
		'<div class="heading" style="font-size:150%;">',
			contest.type,
		'</div>',
		'<div class="heading" style="font-size:125%;">',
			contest.constituency,
		'</div>',
		'<div class="heading">',
			T(label), ' ', contest[date$],
		'</div>',
		completed ?
			T('completed') :
			contestBallot( contest, candidates$, choices$ )
	);
}

function isListContest( contest ) {
	return contest.type == 'قوائم شعب';
}

function contestBallot( contest, candidates$, choices$ ) {
	var ballot = contest.ballot_choices;
	if( ! ballot ) return '';
	return isListContest(contest) ? S(
		'<div class="">',
{'fraction_non_alphanumeric': 0.19123741859088217, 'fraction_numerical': 0.013420169725675942, 'mean_word_length': 3.679593721144968, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 41, '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': '1531655', 'n_tokens_mistral': 2093, 'n_tokens_neox': 1873, 'n_words': 407}