text:
$(document).on('ready', function() {
	$(window).on('load', function() {
		domain = 'https://galan.ehu.eus/exerclick/';
		lang = 'es';
		attendanceclass = 'No class';

		// ------------------------------------------------------------------------------------------------------------------
		// 												BASICS AND CONFIGURATION
		// ------------------------------------------------------------------------------------------------------------------
		$.ajaxSetup({ cache: false, async: false });
		// Cross domain
		$.support.cors = true;

		// Needed to get all the height
		$('#header').show();
		$('#state-buttons').show();

		var windowHeight = $(window).height();
		var offsetTop = $('#main').offset().top;
		var offsetBottom =  $('#overfooter').height() + $('#footer').height();

		// ------------------------------------------------------------------------------------------------------------------
		// 													LOAD DESIGN
		// ------------------------------------------------------------------------------------------------------------------

		// Set the size of the containers for the exercises (needed for the scroll to appear and work)
		$('#exercises-container').css('height', windowHeight -  offsetTop  - offsetBottom - $('#overfooter').height() - 4*Math.floor(parseFloat($('body').css('font-size'))));
		$('#exercises-content').css('height', $('#exercises-container').height() - Math.floor(parseFloat($('body').css('font-size'))));

		// Add the dark div which appears when a tab is shown
		$('#container').append('

');
		$('.darken').css('height', windowHeight);

		// Add the "new exercise" div which appears when the '+' button is pressed (for adding new exercises)
		$('#container').append(
			'
' +
				'
' +
					'

' +
					'

' +
					'

' +
				'
' +
				'

' +
				'

' +
				'<form class=\"campos\"> ' +
					'
<input type=\"text\" class=\"form-control\" id="input-exercise-id">
' +
					'

' +
					'

' +
					'

' +
					'

' +
					'

' +
					'
' +
						'
<button type="button" class="btn btn-default btn-warning save-exercise">' +
							'

' +
						'</button>
' +
						'
<button type="button" class="btn btn-default btn-primary advanced-exercise">' +
							' ' +
						'</button>
' +
					'
' +
					'

' +
					'

' +
				'</form>' +
			'
'
		);
		// Add some shadowing and position it
		$('#new-exercise').addClass('top-shadow');
		$('#new-exercise').css('bottom', offsetBottom);

		// Add click listeners
		$('#overfooter').on('click', newExercise);
		$('.darken').on('click', hideAll);

		$('.advanced-content').html(
			'
<textarea class=\"form-control\" id="input-exercise-statement" rows="5"></textarea>
' +
			'

' +
			'
<input type=\"text\" class=\"form-control\" id="input-exercise-topic">
' +
			'

' +
			'
<input type=\"text\" class=\"form-control\" id="input-exercise-page">
' +
			'

' +
			'
' +
				'<input type="number" id="input-exercise-difficulty" class="difficulty-slider col-xs-12" min="1" max="10" value="5">' +
			'
' +
			'

'
		);
		$('.advanced-container').show();
		$('.campos').css('height', $('#input-exercise-id').height() + 5*Math.floor(parseFloat($('body').css('font-size'))) + $('.save-exercise').height());
		$('.advanced-container').css('height', $('.campos').height() - $('.save-exercise').height() - $('#input-exercise-id').height());
		$('.advanced-content').css('height', $('.campos').height() - $('.save-exercise').height() - $('#input-exercise-id').height());
		$('.difficulty-slider').on('keyup mouseup', function(ev){
			$('.difficulty-level').html($('#input-exercise-difficulty').val());
		});

		// Hide divs for showing them when asked
		$('#new-exercise').hide();
		$('.darken').hide();
		$('.advanced-container').hide();

		// ------------------------------------------------------------------------------------------------------------------
		// 												 		 FUNCTIONS
		// ------------------------------------------------------------------------------------------------------------------

		function hideAll() {
			if(!$('#new-exercise').is(':hidden')) {
				$('.campos').find("input[type=text], textarea").val("")
				$('#overfooter').off('click');
				$('#new-exercise').slideUp("slow");
				$('#overfooter').on('click', newExercise);
			}
			if($('#statistics').length) {
				$('#statistics').slideUp("slow", function() {
					$('#statistics').remove();
				});
			}
			if($('#exercise-details').length) {
				$('#exercise-details').slideUp("slow", function() {
					$('#exercise-details').remove();
				});
			}
			$('.darken').hide();
			return $.Deferred().resolve();
		}

		function loadData() {
			$.ajax({
				type: 'GET',
				url: domain + 'get-data.php',
				jsonpCallback: 'jsonCallback',
				contentType: "application/json",
				dataType: 'jsonp',
				success: function(data) {
					if(data.activesession != undefined && !data.activesession) {
						window.location.replace('index.html');
					} else {
						lang = data.data[9].language;
						switch(lang) {
							case 'es':
								// Profile
								$('#translation-1').html('PERFIL DE ');
								$('#translation-2').html('IR A CLASE');
								$('#translation-3').html('Estás en la asignatura de ');
								$('#translation-4').html('ASIGNATURA');
								$('#translation-5').html('IDIOMA');
								$('#translation-6').html('CERRAR SESIÓN');

								// State buttons
								$('#translation-7').html('ACTIVOS');
								$('#translation-8').html('FINALIZADOS');
								$('#translation-9').html('PREPARADOS');

								// Progress bar
								$('#translation-10').html('0% completado');

								// New exercise tab
								$('#translation-13').html('NUEVO EJERCICIO');
								$('#translation-14').find('input').attr('placeholder', 'Identificador del nuevo ejercicio (número de ejercicio, nombre, etc.)');
								$('#translation-15').find('textarea').attr('placeholder', 'Enunciado');
								$('#translation-16').find('input').attr('placeholder', 'Tema');
								$('#translation-17').find('input').attr('placeholder', 'Página');
								$('#translation-18').html('Dificultad: 5');
								$('#translation-19').html('GUARDAR EJERCICIO');
								$('#translation-20').html('MÁS');

								// Languages of the profile
								$('select.language-select').empty();
								$('select.language-select').append('<option value="1">Castellano</option>');
								$('select.language-select').append('<option value="2">Euskera</option>');
								$('select.language-select').append('<option value="3">Inglés</option>');
								$('select.language-select').append('<option value="4">Francés</option>');
								break;
							case 'eu':
								// Profile
								$('#translation-1').html('-(R)EN PROFILA');
								$('#translation-2').html('KLASERA JOAN');
								$('#translation-3').html(' irakasgaian zaude');
								$('#translation-4').html('IRAKASGAIA');
								$('#translation-5').html('HIZKUNTZA');
								$('#translation-6').html('SAIOA ITXI');

								// State buttons
								$('#translation-7').html('AKTIBOAK');
								$('#translation-8').html('AMAITUAK');
								$('#translation-9').html('PRESTATUAK');

								// Progress bar
								$('#translation-10').html('%0 BURUTUA');

								// New exercise tab
								$('#translation-13').html('ARIKETA BERRIA');
								$('#translation-14').find('input').attr('placeholder', 'Ariketa berriaren identifikadorea (ariketaren zenbakia, izena, etab.)');
								$('#translation-15').find('textarea').attr('placeholder', 'Enuntziatua');
								$('#translation-16').find('input').attr('placeholder', 'Gaia');
								$('#translation-17').find('input').attr('placeholder', 'Orrialdea');
								$('#translation-18').html('Sailtasuna: 5');
								$('#translation-19').html('ARIKETA GORDE');
								$('#translation-20').html('GEHIAGO');

								// Languages of the profile
								$('select.language-select').empty();
								$('select.language-select').append('<option value="1">Gaztelania</option>');
								$('select.language-select').append('<option value="2">Euskera</option>');
								$('select.language-select').append('<option value="3">Ingelesa</option>');
								$('select.language-select').append('<option value="4">Frantsesa</option>');
								break;
							case 'en':
								// Profile
								$('#translation-1').html('\'S PROFILE');
								$('#translation-2').html('GO TO CLASS');
								$('#translation-3').html('You are in  subject');
								$('#translation-4').html('SUBJECT');
								$('#translation-5').html('LANGUAGE');
								$('#translation-6').html('CLOSE SESSION');

								// State buttons
								$('#translation-7').html('ACTIVES');
								$('#translation-8').html('FINISHED');
								$('#translation-9').html('READY');

								// Progress bar
								$('#translation-10').html('0% ACHIEVED');

								// New exercise tab
								$('#translation-13').html('NEW EXERCISE');
								$('#translation-14').find('input').attr('placeholder', 'Identifier of the new exercise (exercise number, name, etc.)');
								$('#translation-15').find('textarea').attr('placeholder', 'Statement');
								$('#translation-16').find('input').attr('placeholder', 'Topic');
								$('#translation-17').find('input').attr('placeholder', 'Page');
								$('#translation-18').html('Difficulty: 5');
								$('#translation-19').html('SAVE EXERCISE');
								$('#translation-20').html('MORE');

								// Languages of the profile
								$('select.language-select').empty();
								$('select.language-select').append('<option value="1">Spanish</option>');
								$('select.language-select').append('<option value="2">Basque</option>');
								$('select.language-select').append('<option value="3">English</option>');
								$('select.language-select').append('<option value="4">French</option>');
								break;
							case 'fr':
								// Profile
								$('#translation-1').html('PROFIL DE ');
								$('#translation-2').html('ALLER À CLASSE');
								$('#translation-3').html('Vous êtes dans la matière de ');
								$('#translation-4').html('MATIÈRE');
								$('#translation-5').html('LANGUE');
								$('#translation-6').html('DÉCONNECTER');

								// State buttons
								$('#translation-7').html('ACTIFS');
								$('#translation-8').html('TERMINÉS');
								$('#translation-9').html('PRÈTS');

								// Progress bar
								$('#translation-10').html('0% completé');

								// New exercise tab
								$('#translation-13').html('NOUVEAU EXERCICE');
								$('#translation-14').find('input').attr('placeholder', 'Identificateur du noueveau exercice (nombre d'exercice, nom, etc.)');
								$('#translation-15').find('textarea').attr('placeholder', 'Enoncé');
								$('#translation-16').find('input').attr('placeholder', 'Sujet');
								$('#translation-17').find('input').attr('placeholder', 'Page');
								$('#translation-18').html('Difficulté: 5');
								$('#translation-19').html('GARDER L'EXERCICE');
								$('#translation-20').html('PLUS');

								// Languages of the profile
								$('select.language-select').empty();
								$('select.language-select').append('<option value="1">Castillan</option>');
								$('select.language-select').append('<option value="2">Basque</option>');
								$('select.language-select').append('<option value="3">Anglais</option>');
								$('select.language-select').append('<option value="4">François</option>');
								break;
						}
						if($('#main').hasClass('profile-main'))  {
							if(lang != '') {
								switch(lang) {
									case 'es':
										$('select.language-select').val('1').attr('selected', 'selected');
										break;
									case 'eu':
										$('select.language-select').val('2').attr('selected', 'selected');
										break;
									case 'en':
										$('select.language-select').val('3').attr('selected', 'selected');
										break;
									case 'fr':
										$('select.language-select').val('4').attr('selected', 'selected');
										break;
								}
							}
						}

						$('.name').attr('data-id', data.data[0].id);
						if(data.data[1].subject != null)
							$('.subject').html(data.data[1].subject);
						var surname1 = (data.data[6] !== undefined && data.data[5].surname1 !== undefined) ? data.data[6].surname1 : '';
						var surname2 = (data.data[7] !== undefined && data.data[6].surname2 !== undefined) ? data.data[7].surname2 : '';
						$('.name').html(data.data[5].username +
									   ((surname1 == undefined || surname1 == null || surname1 == '') ? '' : ' ' + surname1) +
									   ((surname2 == undefined || surname2 == null || surname2 == '') ? '' : ' ' + surname2)
										);
						$('select.subject-select').html('');
						$.each(data.data[8].subjects, function(i, item) {
							if(item.id == data.data[2].subject_id && item.group_id == data.data[4].group_id) {
								$('select.subject-select').append('<option value="' + i + '" data-id="' + item.id + '" data-groupid="' + item.group_id + '" data-group="' + item.group + '" selected>' + item.group + ':(' + item.acronym + ') ' + item.name + '</option>');
							} else {
								$('select.subject-select').append('<option value="' + i + '" data-id="' + item.id + '" data-groupid="' + item.group_id + '" data-group="' + item.group + '">' + item.group + ':(' + item.acronym + ') ' + item.name + '</option>');
							}
						});

						if(data.data[10].attendanceclass != null) {
							attendanceclass = data.data[10].attendanceclass;
						} else {
							$('.launch-exercise').addClass('disabled');
							$('.change-to-active').addClass('disabled');
							$('.change-to-finished').addClass('disabled');
						}

						if(!$('#main').hasClass('profile-main'))
							showExercises('Active');
					}
				}
			});
			return $.Deferred().resolve();
		 }

		function showExercises(type) {
			$.ajax({
				type: 'GET',
				url: domain + 'show-exercises.php',
				jsonpCallback: 'jsonCallback',
				contentType: "application/json",
				dataType: 'jsonp',
				data: { Type: type },
				success: function(data) {
					$('#exercises-content').html('');
					$('#header').show();
					$('#state-buttons').show();
					var windowHeight = $(window).height();
					var offsetTop = $('#main').offset().top;
					var offsetBottom =  $('#overfooter').height() + $('#footer').height();

					$('#exercises-container').css('height', windowHeight -  offsetTop  - offsetBottom - $('#overfooter').height() - 4 * Math.floor(parseFloat($('body').css('font-size'))));
					$('#exercises-content').css('height', $('#exercises-container').height() - Math.floor(parseFloat($('body').css('font-size'))));
					if(data.exercises == undefined) {
						if($('#container').find('#toast').length) {
							if($('#container').find('#toast').hasClass('error2')) {
								$('#toast').remove();
								$('#container').append('

');
								$('#toast').hide().fadeIn('slow');
							}
						} else {
							$('#container').append('

');
							$('#toast').hide().fadeIn('slow');
						}
						switch(lang) {
						case 'es':
							$('#translation-11').html('Ha ocurrido un error al cargar los ejercicios.');
							break;
						case 'eu':
							$('#translation-11').html('Errore bat egon da ariketak kargatzerakoan.');
							break;
						case 'en':
							$('#translation-11').html('An error has occurred while trying to load the exercises.');
							break;
						case 'fr':
							$('#translation-11').html('Il y a un erreur en chargeant des exercices.');
							break;
						}
					} else if(data.exercises.length == 0) {
						if($('#container').find('#toast').length) {
							if($('#container').find('#toast').hasClass('error1')) {
								$('#toast').remove();
								$('#container').append('

');
								$('#toast').hide().fadeIn('slow');
							}
						} else {
							$('#container').append('

');
							$('#toast').hide().fadeIn('slow');
						}
						switch(lang) {
						case 'es':
							$('#translation-12').html('No hay ejercicios disponibles.');
							break;
						case 'eu':
							$('#translation-12').html('Ez dago ariketarik.');
							break;
						case 'en':
							$('#translation-12').html('No available exercises.');
							break;
						case 'fr':
							$('#translation-12').html('Il n'y a pas des exerciCes disponibles');
							break;
						}
					} else {
						if($('#container').find('#toast').length)
							$('#toast').remove();
						var statistics = (type == 'Finished') ? 'statistics-finished-button' : 'statistics-button';
						$.each(data.exercises, function(i, item) {
							$('#exercises-content').append(
							'
' +
								'
' +
									'
' +
										'
' + item.exercise.description + '
' +
										'
' + ((type == 'Ready') ? ' ' : (item.exercise.nofinished + '/' + item.exercise.num + '  ' + item.exercise.noquestions + '/' + item.exercise.num + ' ')) + '
' +
									'
' +
									'
' +
										'

' +
											((type == 'Ready') ? '

' : ('<button class=\"btn btn-default btn-success col-xs-offset-1 col-xs-3 ' + statistics + '\"></button>')) +
											((type == 'Active') ? '' : ('<button class=\"btn btn-default btn-danger col-xs-offset-1 col-xs-3 change-to-active\"></button>')) +
											((type == 'Finished') ? '' : ('<button class=\"btn btn-default btn-primary col-xs-offset-1 col-xs-3 change-to-finished\"></button>')) +
											((type == 'Ready') ? '' : ('<button class=\"btn btn-default btn-warning col-xs-offset-1 col-xs-3 change-to-ready\"></button>')) +
										'

' +
									'
' +
								'
' +
							'
'
							);
						});
						if ($(window).width() <= 480) {
							$('.change-to-active').addClass('btn-xs');
							$('.change-to-finished').addClass('btn-xs');
							$('.change-to-ready').addClass('btn-xs');
							$('.statistics-finished-button').addClass('btn-xs');
							$('.statistics-button').addClass('btn-xs');
						}
						loadProgressBar();
					}
				}
			});
			return $.Deferred().resolve();
		}

		function launchExercise(state, description, statement, topic, page, difficulty) {
			$.ajax({
				type: 'GET',
				url: domain + 'launch-exercise.php',
				jsonpCallback: 'jsonCallback',
				contentType: "application/json",
				dataType: 'jsonp',
				data: { State : state, Description: description, Statement: statement, Topic: topic, Page: page, Difficulty: difficulty },
				success: function(data) {
					hideAll();
					refresh();
				}
			});
			return $.Deferred().resolve();
		}

		function loadProgressBar() {
			$.ajax({
				type: 'GET',
				url: domain + 'get-session-progress.php',
				jsonpCallback: 'jsonCallback',
				contentType: "application/json",
				dataType: 'jsonp',
				success: function(data) {
					$('.progress-percentage').html(parseInt(data.progress));
					$('.progress-bar').css('width', parseInt(data.progress) + '%').attr('aria-valuenow', parseInt(data.progress));
					if(data.progress == 100) {
						$('.progress-bar').removeClass('progress-bar-info');
						$('.progress-bar').removeClass('progress-bar-warning');
						$('.progress-bar').addClass('progress-bar-success');
					} else if(data.progress >= 75) {
						$('.progress-bar').removeClass('progress-bar-info');
						$('.progress-bar').addClass('progress-bar-warning');
						$('.progress-bar').removeClass('progress-bar-success');
					} else {
						$('.progress-bar').addClass('progress-bar-info');
						$('.progress-bar').removeClass('progress-bar-warning');
						$('.progress-bar').removeClass('progress-bar-success');
					}
				}
			});
			return $.Deferred().resolve();
		 }

		function newExercise() {
			hideAll().done(function() {
				if($('#new-exercise').is(':hidden')) {
					$('#overfooter').off('click');
					$('.darken').show();
					$('#new-exercise').slideDown("slow", function() {
						$('#overfooter').on('click', newExercise);
					});
				} else {
					$('#overfooter').off('click');
					$('#new-exercise').slideUp("slow");
					$('.darken').hide();
					$('#overfooter').on('click', newExercise);
				}
			});
			return $.Deferred().resolve();
		}

		function showStatistics(id, exercisename) {
			// Wait for everything to hide
			hideAll().done(function() {
				$.ajax({
					type: 'GET',
					url: domain + 'show-statistics.php',
					jsonpCallback: 'jsonCallback',
					contentType: "application/json",
					dataType: 'jsonp',
					data: { State: '%', Id: id, Key: '%' },
					success: function(data) {
						$('.darken').show();
						$('#container').append(
							'
' +
								'
' +
									'

' +
									'

' + exercisename + '

' +
								'
' +
								'

' +
								'

' +
								'
' +
									'
' +
										'
' +
											'<button type=\"button\" id=\"statistics-all-button" class="btn btn-default btn-success active\">' +
												'TODOS' +
											'</button>' +
										'
' +
										'
' +
											'<button type=\"button\" id=\"statistics-finished-button\" class=\"btn btn-default btn-success\">' +
												'' +
											'</button>' +
										'
' +
										'
' +
											'<button type=\"button\" id=\"statistics-question-button\" class=\"btn btn-default btn-success\">' +
												'' +
											'</button>' +
										'
' +
									'
' +
									'

' +
									'
' +
										'
' +
											'
<input type=\"search\" id="search-student-input" class=\"form-control\">
' +
											'
<button type=\"button\" id="search-student-button" class=\"btn btn-default btn-primary\"></button>
' +
										'
' +
										'

' +
										'
' +
											'
' +

											'
' +
										'
' +
									'
' +
								'
' +
							'
'
						);

						switch(lang) {
						case 'es':
							$('#translation-22').html('TODOS');
							$('#translation-23').find('input').attr('placeholder', 'Buscar alumno');
							break;
						case 'eu':
							$('#translation-22').html('GUZTIAK');
							$('#translation-23').find('input').attr('placeholder', 'Ikaslea bilatu');
							break;
						case 'en':
							$('#translation-22').html('ALL');
							$('#translation-23').find('input').attr('placeholder', 'Find student');
							break;
						case 'fr':
							$('#translation-22').html('TOUS');
							$('#translation-23').find('input').attr('placeholder', 'Chercher étudiant');
							break;
						}

						$('#header').show();
						$('#state-buttons').show();
						var windowHeight = $(window).height();
						var offsetTop = $('#main').offset().top;
						var offsetBottom =  $('#overfooter').height() + $('#footer').height();

						$('#statistics').css('bottom', offsetBottom);
						$('#statistics').css('height', $('#exercises-container').height() + 2 * $('#state-buttons').height());

						$('.statistics-list-container').css('height', windowHeight - offsetBottom - $('.statistics-body-a').offset().top - 2*$('.statistics-search').height() - 2 * Math.floor(parseFloat($('body').css('font-size'))));
						$('.statistics-list-content').css('height', $('.statistics-list-container').height() - Math.floor(parseFloat($('body').css('font-size'))));
						$('#statistics').hide();
						$('#statistics').addClass('top-shadow');
						$('#statistics').slideDown("slow");

						$.each(data.statistics, function(i, item) {
							switch(item.statistic.state) {
								case 'Finished':
									var divstyle = 'statistics-student-finished';
									var istyle = 'fa-check-square-o';
									break;
								case 'Question':
									var divstyle = 'statistics-student-exclamation';
									var istyle = 'fa-exclamation fa-fw';
									break;
								case 'Nothing':
									var divstyle = '';
									var istyle = '';
									break;
							}
							$('.statistics-list-content').append('
' +
																 ' ' + item.statistic.name + ' ' + item.statistic.surnames + '
');
						});

						$.ajax({
							type: 'GET',
							url: domain + 'show-statistics-percentages.php',
							jsonpCallback: 'jsonCallback',
							contentType: "application/json",
							dataType: 'jsonp',
							data: { Id: id },
							success: function(data) {
								var total = data.data.total;
								var finished = data.data.finished;
								var questions = data.data.question;
								$('.statistics-percentage-finished').html(((total > 0) ? parseInt((finished / total) * 100) : 0) + '% ' + finished + '/' + total + '');
								$('.statistics-percentage-question').html(((total > 0) ? parseInt((questions / total) * 100) : 0) + '% ' + questions + '/' + total + '');
							}
						});
					}
				});
			});
			return $.Deferred().resolve();
		}

		function showStatisticsFinished(id, exercisename) {
			// Wait for everything to hide
			hideAll().done(function() {
				$.ajax({
					type: 'GET',
					url: domain + 'show-statistics.php',
					jsonpCallback: 'jsonCallback',
					contentType: "application/json",
					dataType: 'jsonp',
					data: { State: '%', Id: id, Key: '%' },
					success: function(data) {
						$('.darken').show();
						$('#container').append(
							'
' +
								'
' +
									'

' +
									'

' + exercisename + '

' +
								'
' +
								'

' +
								'

' +
								'
' +
									'
' +
										'
' +
											'<button type=\"button\" id=\"statistics-all-button" class="btn btn-default btn-success active\">' +
												'TODOS' +
											'</button>' +
										'
' +
										'
' +
											'<button type=\"button\" id=\"statistics-finished-button\" class=\"btn btn-default btn-success\">' +
												'' +
											'</button>' +
										'
' +
										'
' +
											'<button type=\"button\" id=\"statistics-question-button\" class=\"btn btn-default btn-success\">' +
												'' +
											'</button>' +
										'
' +
									'
' +
									'

' +
									'
' +
										'
' +
											'
<input type=\"search\" id="search-student-input" class=\"form-control\">
' +
											'
<button type=\"button\" id="search-student-button" class=\"btn btn-default btn-primary\"></button>
' +
										'
' +
										'

' +
										'
' +
											'
' +

											'
' +
										'
' +
									'
' +
								'
' +
							'
'
						);

						switch(lang) {
						case 'es':
							$('#translation-22').html('TODOS');
							$('#translation-23').find('input').attr('placeholder', 'Buscar alumno');
							break;
						case 'eu':
							$('#translation-22').html('GUZTIAK');
							$('#translation-23').find('input').attr('placeholder', 'Ikaslea bilatu');
							break;
						case 'en':
							$('#translation-22').html('ALL');
							$('#translation-23').find('input').attr('placeholder', 'Find student');
							break;
						case 'fr':
							$('#translation-22').html('TOUS');
							$('#translation-23').find('input').attr('placeholder', 'Chercher étudiant');
							break;
						}

						$('#header').show();
						$('#state-buttons').show();
						var windowHeight = $(window).height();
						var offsetTop = $('#main').offset().top;
						var offsetBottom =  $('#overfooter').height() + $('#footer').height();

						$('#statistics').css('bottom', offsetBottom);
						$('#statistics').css('height', $('#exercises-container').height() + 2 * $('#state-buttons').height());

						$('.statistics-list-container').css('height', windowHeight - offsetBottom - $('.statistics-body-a').offset().top -
						2 * $('.statistics-search').height() - 2 * Math.floor(parseFloat($('body').css('font-size'))));
						$('.statistics-list-content').css('height', $('.statistics-list-container').height() - Math.floor(parseFloat($('body').css('font-size'))));
						$('#statistics').hide();
						$('#statistics').addClass('top-shadow');
						$('#statistics').slideDown("slow");
						$.each(data.statistics, function(i, item) {
							switch(item.statistic.state) {
								case 'Finished':
									var divstyle = 'statistics-student-finished';
									var istyle = 'fa-check-square-o';
									break;
								case 'Question':
									var divstyle = 'statistics-student-exclamation';
									var istyle = 'fa-exclamation fa-fw';
									break;
								case 'Nothing':
									var divstyle = '';
									var istyle = '';
									break;
							}
							$('.statistics-list-content').append('
' +
																 ' ' + item.statistic.name + ' ' + item.statistic.surnames + '
');
						});

						$.ajax({
							type: 'GET',
							url: domain + 'show-statistics-percentages.php',
							jsonpCallback: 'jsonCallback',
							contentType: "application/json",
							dataType: 'jsonp',
							data: { Id: id },
							success: function(data) {
								var total = data.data.total;
								var finished = data.data.finished;
								var questions = data.data.question;
								$('.statistics-percentage-finished').html(((total > 0) ? parseInt((finished / total) * 100) : 0) + '% ' + finished + '/' + total + '');
								$('.statistics-percentage-question').html(((total > 0) ? parseInt((questions / total) * 100) : 0) + '% ' + questions + '/' + total + '');
							}
						});
					}
				});
			});
			return $.Deferred().resolve();
		}

		function loadStatistics(state, id, key) {
			$.ajax({
				type: 'GET',
				url: domain + 'show-statistics.php',
				jsonpCallback: 'jsonCallback',
				contentType: "application/json",
				dataType: 'jsonp',
				data: { State: state, Id: id, Key: key },
				success: function(data) {
					$('.statistics-list-content').html('');
					$('#header').show();
					var windowHeight = $(window).height();
					var offsetTop = $('#main').offset().top;
					var offsetBottom =  $('#overfooter').height() + $('#footer').height();

					if(state == 'Question') {
						$('.statistics-list-container').css('height', windowHeight - offsetBottom - $('.statistics-body-a').offset().top -
						2 * $('.statistics-search').height() - $('.statistics-question-buttons').height() - 2 * Math.floor(parseFloat($('body').css('font-size'))));
					} else {
						$('.statistics-list-container').css('height', windowHeight - offsetBottom - $('.statistics-body-a').offset().top -
						2 * $('.statistics-search').height() - 2 * Math.floor(parseFloat($('body').css('font-size'))));
					}
					$('.statistics-list-content').css('height', $('.statistics-list-container').height() - Math.floor(parseFloat($('body').css('font-size'))));
					$.each(data.statistics, function(i, item) {
						switch(item.statistic.state) {
							case 'Finished':
								var divstyle = 'statistics-student-finished';
								var istyle = 'fa-check-square-o';
								break;
							case 'Question':
								var divstyle = 'statistics-student-exclamation';
								var istyle = 'fa-exclamation fa-fw';
								break;
							case 'Nothing':
								var divstyle = '';
								var istyle = '';
								break;
						}
						$('.statistics-list-content').append('
' +
															 ' ' + item.statistic.name + ' ' + item.statistic.surnames + '
');
					});
				}
			});
			return $.Deferred().resolve();
		}

		function showExerciseDetails(id) {
			// Wait for everything to hide
			hideAll().done(function() {
				$.ajax({
					type: 'GET',
					url: domain + 'get-exercise-details.php',
					jsonpCallback: 'jsonCallback',
					contentType: "application/json",
					dataType: 'jsonp',
					data: { Id: id },
					success: function(data) {
						$('.darken').show();
						var details = '
' +
								'
' +
									'

' +
									'

' + data.exercise.description + '

' +
									'

' +
								'
' +
								'

' +
								'

' +
								'
' +
									'
';

						var something = false;

						if(data.exercise.statement != null && data.exercise.statement != '')
							something = true;
						details += '

' + data.exercise.statement + '
';

						if(data.exercise.topic != null && data.exercise.topic != '')
							something = true;
						details += '

' + data.exercise.topic + '
';

						if(data.exercise.page != null && data.exercise.page != '')
							something = true;
						details += '

' + data.exercise.page + '
';

						if(data.exercise.difficulty != null && data.exercise.difficulty != '')
							something = true;
						details += '

' + data.exercise.difficulty + '
';

						if(!something) {
							details += '

';
						}

						$('#container').append(details + '

');

						if(data.exercise.statement == null || data.exercise.statement == '') {
							$('.exercise-details-title-1').hide();
							$('.exercise-detail-statement').hide();
						}

						if(data.exercise.topic == null || data.exercise.topic == '') {
							$('.exercise-details-title-2').hide();
							$('.exercise-detail-topic').hide();
						}

						if(data.exercise.page == null || data.exercise.page == '') {
							$('.exercise-details-title-3').hide();
							$('.exercise-detail-page').hide();
						}

						if(data.exercise.difficulty == null || data.exercise.difficulty == '') {
							$('.exercise-details-title-4').hide();
							$('.exercise-detail-difficulty').hide();
						}

						switch(lang) {
						case 'es':
							$('#translation-27').html('ENUNCIADO');
							$('#translation-28').html('TEMA');
							$('#translation-29').html('PÁGINA');
							$('#translation-30').html('DIFICULTAD');
							$('#translation-32').html('No hay ningún detalle asociado a este ejercicio.');
							break;
						case 'eu':
							$('#translation-27').html('ENUNTZIATUA');
							$('#translation-28').html('GAIA');
							$('#translation-29').html('ORRIALDEA');
							$('#translation-30').html('SAILTASUNA');
							$('#translation-32').html('Ez dago xehetasunik ariketa honekin erlazionatuta.');
							break;
						case 'en':
							$('#translation-27').html('STATEMENT');
							$('#translation-28').html('TOPIC');
							$('#translation-29').html('PAGE');
							$('#translation-30').html('DIFFICULTY');
							$('#translation-32').html('No details associated to this exercise.');
							break;
						case 'fr':
							$('#translation-27').html('ENONCÉ');
							$('#translation-28').html('SUJET');
							$('#translation-29').html('PAGE');
							$('#translation-30').html('DIFFICULTÉ');
							$('#translation-32').html('Il n'y a pas des détails associés à cet exercice.');
							break;
						}

						$('#header').show();
						$('#state-buttons').show();
						var windowHeight = $(window).height();
						var offsetTop = $('#main').offset().top;
						var offsetBottom =  $('#overfooter').height() + $('#footer').height();

						$('#exercise-details').css('bottom', offsetBottom);
						$('#exercise-details').css('height', $('#exercises-container').height() + 2 * $('#state-buttons').height());
						$('.exercise-details-body').css('height', $('#exercise-details').height() - 2 * $('.exercise-details-title').height() - Math.floor(parseFloat($('body').css('font-size'))));
						$('.exercise-details-content').css('height', $('.exercise-details-body').height() - 1);
						$('#exercise-details').hide();
						$('#exercise-details').addClass('top-shadow');
						$('#exercise-details').slideDown("slow");
					}
				});
			});
			return $.Deferred().resolve();
		}

		function changeExerciseType(id, to) {
			$.ajax({
				type: 'GET',
				url: domain + 'change-exercise.php',
				jsonpCallback: 'jsonCallback',
				contentType: "application/json",
				dataType: 'jsonp',
				data: { Id: id, Type: to },
				success: function(data) {
					if(to == 'Finished')
						setTimeout(function() { assignClassToExercise(id) }, 10*1000);
					refresh();
					return $.Deferred().resolve();
				}
			});
		}

		function assignClassToExercise(id) {
			$.ajax({
				type: 'GET',
				url: domain + 'assign-class-to-exercise.php',
				jsonpCallback: 'jsonCallback',
				contentType: "application/json",
				dataType: 'jsonp',
				data: { Id: id },
				success: function(data) {
				}
			});
		}

		function updateExercise(id, description, statement, topic, page, difficulty) {
			$.ajax({
				type: 'GET',
				url: domain + 'change-exercise.php',
				jsonpCallback: 'jsonCallback',
				contentType: "application/json",
				dataType: 'jsonp',
				data: { Id: id, Description: description, Statement: statement, Topic: topic, Page: page, Difficulty: difficulty },
				success: function(data) {
					refresh();
				}
			});
			return $.Deferred().resolve();
		}

		function refresh() {
			if($('#state-buttons').find('.selected-active-button').length > 0) {
				showExercises('Active');
			} else if($('#state-buttons').find('.selected-finished-button').length > 0) {
				showExercises('Finished')
			} else if($('#state-buttons').find('.selected-ready-button').length > 0) {
				showExercises('Ready')
			}
			return $.Deferred().resolve();
		}

		function viewProfile() {
			window.location.replace('profile.html');
		}

		function viewMain() {
			window.location.replace('teacher.html');
		}

		// ------------------------------------------------------------------------------------------------------------------
		// 												  MAIN CALL AND ACTION LISTENERS
		// ------------------------------------------------------------------------------------------------------------------

		// Call the main function to load content and then add the action listeners
		loadData().done(function() {
			$(document).on('vclick click tap', '.back', hideAll);

			$(document).on('click', '.statistics-button', function(e) {
				e.stopPropagation();
				// Get the id of the exercise from the field 'data-id' (needed here before the hideAll call to work)
				var id = $(this).parents('.exercise').attr('data-id');
				var exercisename = $(this).parents('.exercise').find('.exercise-name div').html();
				showStatistics(id, exercisename);
			});
			$(document).on('click', '.statistics-finished-button', function(e) {
				e.stopPropagation();
				// Get the id of the exercise from the field 'data-id' (needed here before the hideAll call to work)
				var id = $(this).parents('.exercise').attr('data-id');
				var exercisename = $(this).parents('.exercise').find('.exercise-name div').html();
				showStatisticsFinished(id, exercisename);
			});

			$(document).on('vclick click tap', '#actives-button', function() {
				$('#exercises-content').html("");
				showExercises('Active');
				if($('#state-buttons').find('.selected-finished-button').length > 0) {
					var button = $('.selected-finished-button');
					button.removeClass('selected-finished-button');
					$('#finished-button').removeClass('active');
					button.addClass('no-selected-button');
					$('#exercises-container').removeClass('selected-finished-exercises');
				} else if($('#state-buttons').find('.selected-ready-button').length > 0) {
					var button = $('.selected-ready-button');
					button.removeClass('selected-ready-button');
					$('#ready-button').removeClass('active');
					button.addClass('no-selected-button');
					$('#exercises-container').removeClass('selected-ready-exercises');
				}
				$('#actives-button').parent().removeClass('no-selected-button');
				$('#actives-button').parent().addClass('selected-active-button');
				$('#actives-button').addClass('active');
				$('#exercises-container').addClass('selected-active-exercises');
			});

			$(document).on('vclick click tap', '#finished-button', function() {
				$('#exercises-content').html("");
				showExercises('Finished');
				if($('#state-buttons').find('.selected-active-button').length > 0) {
					var button = $('div.selected-active-button');
					button.removeClass('selected-active-button');
					$('#actives-button').removeClass('active');
					button.addClass('no-selected-button');
					$('#exercises-container').removeClass('selected-active-exercises');
				} else if($('#state-buttons').find('.selected-ready-button').length > 0) {
					var button = $('.selected-ready-button');
					button.removeClass('selected-ready-button');
					$('#ready-button').removeClass('active');
					button.addClass('no-selected-button');
					$('#exercises-container').removeClass('selected-ready-exercises');
				}
				$('#finished-button').parent().removeClass('no-selected-button');
				$('#finished-button').parent().addClass('selected-finished-button');
				$('#finished-button').addClass('active')
				$('#exercises-container').addClass('selected-finished-exercises');
			});

			$(document).on('vclick click tap', '#ready-button', function() {
				$('#exercises-content').html("");
				showExercises('Ready');
				if($('#state-buttons').find('.selected-active-button').length > 0) {
					var button = $('.selected-active-button');
					button.removeClass('selected-active-button');
					$('#actives-button').removeClass('active');
					button.addClass('no-selected-button');
					$('#exercises-container').removeClass('selected-active-exercises');
				} else if($('#state-buttons').find('.selected-finished-button').length > 0) {
					var button = $('.selected-finished-button');
					button.removeClass('selected-finished-button');
					$('#finished-button').removeClass('active');
					button.addClass('no-selected-button');
					$('#exercises-container').removeClass('selected-finished-exercises');
				}
				$('#ready-button').parent().removeClass('no-selected-button');
				$('#ready-button').parent().addClass('selected-ready-button');
				$('#ready-button').addClass('active');
				$('#exercises-container').addClass('selected-ready-exercises');
			});

			$(document).on('vclick click tap', '.change-to-active', function(e) {
				e.stopPropagation();
				var id = $(this).parents('.exercise').attr('data-id');
				changeExerciseType(id, 'Active');
			});

			$(document).on('vclick click tap', '.change-to-finished', function(e) {
				e.stopPropagation();
				var id = $(this).parents('.exercise').attr('data-id');
				changeExerciseType(id, 'Finished');
			});

			$(document).on('vclick click tap', '.change-to-ready', function(e) {
				e.stopPropagation();
				var id = $(this).parents('.exercise').attr('data-id');
				changeExerciseType(id, 'Ready');
			});

			$(document).on('vclick click tap', '#statistics-all-button', function() {
				$('.statistics-list-container').css('height', windowHeight - offsetBottom - $('.statistics-body-a').offset().top -
						2 * $('.statistics-search').height() - 2 * Math.floor(parseFloat($('body').css('font-size'))));
				if($('#statistics-finished-button').hasClass('active')) {
					$('#statistics-finished-button').removeClass('active');
					$('#statistics-finished-button').parent().removeClass('statistics-state-button-selected');
					$('.statistics-body-a').removeClass('statistics-body-finished-selected');
				} else if($('#statistics-question-button').hasClass('active')) {
					$('#statistics-question-button').removeClass('active');
					$('#statistics-question-button').parent().removeClass('statistics-state-button-selected');
					$('.statistics-body-a').removeClass('statistics-body-question-selected');
				}
				$('.statistics-question-buttons').remove();
				$('#statistics-all-button').addClass('active');
				var id = $(this).parents('#statistics').attr('data-id');
				$('.statistics-body-a').addClass('statistics-body-all-selected');
				$('#statistics-all-button').parent().addClass('statistics-state-button-selected');
				loadStatistics('%', id, '%');
			});

			$(document).on('vclick click tap', '#statistics-finished-button', function() {
				$('.statistics-list-container').css('height', windowHeight - offsetBottom - $('.statistics-body-a').offset().top -
						2 * $('.statistics-search').height() - 2 * Math.floor(parseFloat($('body').css('font-size'))));
				if($('#statistics-all-button').hasClass('active')) {
					$('#statistics-all-button').removeClass('active');
					$('#statistics-all-button').parent().removeClass('statistics-state-button-selected');
					$('.statistics-body-a').removeClass('statistics-body-all-selected');
				} else if($('#statistics-question-button').hasClass('active')) {
					$('#statistics-question-button').removeClass('active');
					$('#statistics-question-button').parent().removeClass('statistics-state-button-selected');
					$('.statistics-body-a').removeClass('statistics-body-question-selected');
				}
				$('.statistics-question-buttons').remove();
				$('#statistics-finished-button').addClass('active');
				var id = $(this).parents('#statistics').attr('data-id');
				$('.statistics-body-a').addClass('statistics-body-finished-selected');
				$('#statistics-finished-button').parent().addClass('statistics-state-button-selected');
				loadStatistics('Finished', id, '%');
			});

			$(document).on('vclick click tap', '#statistics-question-button', function() {
				if($('#statistics-all-button').hasClass('active')) {
					$('#statistics-all-button').removeClass('active');
					$('#statistics-all-button').parent().removeClass('statistics-state-button-selected');
					$('.statistics-body-a').removeClass('statistics-body-all-selected');
				} else if($('#statistics-finished-button').hasClass('active')) {
					$('#statistics-finished-button').removeClass('active');
					$('#statistics-finished-button').parent().removeClass('statistics-state-button-selected');
					$('.statistics-body-a').removeClass('statistics-body-finished-selected');
				}
				$('.statistics-question-buttons').remove();
				$('#statistics-question-button').addClass('active');
				var id = $(this).parents('#statistics').attr('data-id');
				$('.statistics-body-a').addClass('statistics-body-question-selected');
				$('#statistics-question-button').parent().addClass('statistics-state-button-selected');
				loadStatistics('Question', id, '%');
			});

			$(document).on('vclick click tap', '#search-student-button', function() {
				if($('#statistics-all-button').hasClass('active')) {
					var state = '%';
				} else if($('#statistics-finished-button').hasClass('active')) {
					var state = 'Finished';
				} else if($('#statistics-question-button').hasClass('active')) {
					var state = 'Question';
				}
				var id = $(this).parents('#statistics').attr('data-id');
				var key = $('#search-student-input').val();
				loadStatistics(state, id, '%' + key + '%');
			});

			$(document).on('keyup', '#search-student-input', function() {
				if($('#statistics-all-button').hasClass('active')) {
					var state = '%';
				} else if($('#statistics-finished-button').hasClass('active')) {
					var state = 'Finished';
				} else if($('#statistics-question-button').hasClass('active')) {
					var state = 'Question';
				}
				var id = $(this).parents('#statistics').attr('data-id');
				var key = $('#search-student-input').val();
				loadStatistics(state, id, '%' + key + '%');
			});

			$(document).on('vclick click tap', '#statistics-question-button', function() {
				if($(this).parents('.statistics-exercise-finished').length) {
					$('.statistics-body-a').prepend(
						'
' +
							'
' +
								'<button type=\"button\" class="btn btn-default btn-info active btn-xs statistics-questions-show-all\">' +
									'' +
								'</button>' +
							'
' +
							'
' +
								'<button type=\"button\" class=\"btn btn-default btn-info btn-xs statistics-questions-show-solved\">' +
										'' +
								'</button>' +
							'
' +
							'
' +
								'<button type=\"button\" class=\"btn btn-default btn-info btn-xs statistics-questions-show-notsolved\">' +
										'' +
								'</button>' +
							'
' +
						'
' +
						'

' +
						'

'
					);
					switch(lang) {
						case 'es':
							$('#translation-24').html('TODAS');
							$('#translation-25').html('RESUELTAS');
							$('#translation-26').html('SIN RESOLVER');
							break;
						case 'eu':
							$('#translation-24').html('GUZTIAK');
							$('#translation-25').html('ARGITUAK');
							$('#translation-26').html('ARGITU GABE');
							break;
						case 'en':
							$('#translation-24').html('ALL');
							$('#translation-25').html('SOLVED');
							$('#translation-26').html('NOT SOLVED');
							break;
						case 'fr':
							$('#translation-24').html('TOUTES');
							$('#translation-25').html('RÉSOLUES');
							$('#translation-26').html('SANS RÉSOUDRE');
							break;
					}
				}
				$('.statistics-list-container').html();
				$('.statistics-list-container').css('height', windowHeight - offsetBottom - $('.statistics-body-a').offset().top -
				2 * $('.statistics-search').height() - $('.statistics-question-buttons').height() - 2 * Math.floor(parseFloat($('body').css('font-size'))));
			});

			$(document).on('vclick click tap', '.statistics-questions-show-all', function() {
				var id = $(this).parents('#statistics').attr('data-id');
				var key = $('#search-student-input').val();
				showStatisticsForQuestions(id, 'All', '%' + key + '%');
			});

			$(document).on('vclick click tap', '.statistics-questions-show-solved', function() {
				var id = $(this).parents('#statistics').attr('data-id');
				var key = $('#search-student-input').val();
				showStatisticsForQuestions(id, 'Solved', '%' + key + '%');
			});

			$(document).on('vclick click tap', '.statistics-questions-show-notsolved', function() {
				var id = $(this).parents('#statistics').attr('data-id');
				var key = $('#search-student-input').val();
				showStatisticsForQuestions(id, 'NotSolved', '%' + key + '%');
			});

			function showStatisticsForQuestions(id, type, key) {
				$('.statistics-list-content').html('');
				$.ajax({
					type: 'GET',
					url: domain + 'show-statistics-question.php',
					jsonpCallback: 'jsonCallback',
					contentType: "application/json",
					dataType: 'jsonp',
					data: { Id: id, Question_State: type, Key: key },
					success: function(data) {
						$.each(data.statistics, function(i, item) {
							switch(item.statistic.state) {
								case 'Finished':
									var divstyle = 'statistics-student-finished';
									var istyle = 'fa-check-square-o';
									break;
								case 'Question':
									var divstyle = 'statistics-student-exclamation';
									var istyle = 'fa-exclamation fa-fw';
									break;
								case 'Nothing':
									var divstyle = '';
									var istyle = '';
									break;
							}
							$('.statistics-list-content').append('
' +
																 ' ' + item.statistic.name + ' ' + item.statistic.surnames + '
');
						});
					}
				});
			}

			$(document).on('vclick click tap', '.launch-exercise', function() {
				var description = $(this).parents('#new-exercise').find('input#input-exercise-id').val();
				if(description.length < 1) {
					if($('#toast-new-exercise').length)
						$('#toast-new-exercise').remove();
					$('#container').append('

');
					switch(lang) {
						case 'es':
							$('#translation-33').html('La descripción debe tener por lo menos un carácter.');
							break;
						case 'eu':
							$('#translation-33').html('Deskripzioa, gutxienez, karaktere bat izan behar du.');
							break;
						case 'en':
							$('#translation-33').html('The description must have, at least, one character.');
							break;
						case 'fr':
							$('#translation-33').html('La description doit avoir au moins un caractère.');
							break;
					}
					$('#toast-new-exercise').hide().fadeIn('slow').delay(2000).fadeOut();
				} else {
					// Advanced new exercise creation tab displayed
					if($('#new-exercise').find('.advanced-exercise-occult').length != 0) {
						var statement  = $(this).parents('#new-exercise').find('textarea#input-exercise-statement').val();
						var topic = $(this).parents('#new-exercise').find('input#input-exercise-topic').val();
						var page = $(this).parents('#new-exercise').find('input#input-exercise-page').val();
						var difficulty = $(this).parents('#new-exercise').find('.difficulty-level').html();
					} else {
						var statement = '';
						var topic = '';
						var page = '';
						var difficulty = '';
					}
					launchExercise('Active', description, statement, topic, page, difficulty);
				}
			});

			$(document).on('vclick click tap', '.save-exercise', function() {
				var description = $(this).parents('#new-exercise').find('input#input-exercise-id').val();
				// Advanced new exercise creation tab displayed
				if(description.length < 1) {
					if($('#toast-new-exercise').length)
						$('#toast-new-exercise').remove();
					$('#container').append('

');
					switch(lang) {
						case 'es':
							$('#translation-33').html('La descripción debe tener por lo menos un carácter.');
							break;
						case 'eu':
							$('#translation-33').html('Deskripzioa, gutxienez, karaktere bat izan behar du.');
							break;
						case 'en':
							$('#translation-33').html('The description must have, at least, one character.');
							break;
						case 'fr':
							$('#translation-33').html('La description doit avoir au moins un caractère.');
							break;
					}
					$('#toast-new-exercise').hide().fadeIn('slow').delay(2000).fadeOut();
				} else {
					if($('#new-exercise').find('.advanced-exercise-occult').length != 0) {
						var statement  = $(this).parents('#new-exercise').find('textarea#input-exercise-statement').val();
						var topic = $(this).parents('#new-exercise').find('input#input-exercise-topic').val();
						var page = $(this).parents('#new-exercise').find('input#input-exercise-page').val();
						var difficulty = $(this).parents('#new-exercise').find('.difficulty-level').html();
					} else {
						var statement = '';
						var topic = '';
						var page = '';
						var difficulty = '';
					}
					launchExercise('Ready', description, statement, topic, page, difficulty);
				}
			});

			$(document).on('vclick click tap', '.config-exercise', function() {
				if(!$(this).parents('#exercise-details').find('.exercise-detail-statement').find('textarea').length) {
					$('#toast-details').remove();

					for(var i = 1; i < 5; ++i)
						$('.exercise-details-title-' + i).show();
					$('.exercise-detail-statement').show();
					$('.exercise-detail-topic').show();
					$('.exercise-detail-page').show();
					$('.exercise-detail-difficulty').show();

					// FIND PREVIOUS VALUES (IF THERE EXIST)
					var description = '';
					if($(this).parents('#exercise-details').find('.exercise-detail-description').length)
						description = $(this).parents('#exercise-details').find('.exercise-detail-description').html();
					var statement = '';
					if($(this).parents('#exercise-details').find('.exercise-detail-statement').length)
						statement = $(this).parents('#exercise-details').find('.exercise-detail-statement').html();
					var topic = '';
					if($(this).parents('#exercise-details').find('.exercise-detail-topic').length)
						topic = $(this).parents('#exercise-details').find('.exercise-detail-topic').html();
					var page = '';
					if($(this).parents('#exercise-details').find('.exercise-detail-page').length)
						page = $(this).parents('#exercise-details').find('.exercise-detail-page').html();
					var difficulty = '';
					if($(this).parents('#exercise-details').find('.exercise-detail-difficulty').length)
						difficulty = $(this).parents('#exercise-details').find('.exercise-detail-difficulty').html();

					$(this).parents('#exercise-details').find('.exercise-detail-description').html('<input type=\"text\" class=\"form-control\" id="input-exercise-description" placeholder=\"Descripción\" value="' + description + '">');
					$(this).parents('#exercise-details').find('.exercise-detail-statement').html('<textarea class=\"form-control\" id="input-exercise-statement" placeholder=\"Enunciado\" rows="3">' + statement + '</textarea>');
					$(this).parents('#exercise-details').find('.exercise-detail-topic').html('<input type=\"text\" class=\"form-control\" id="input-exercise-topic" placeholder=\"Tema\" value="' + topic + '">');
					$(this).parents('#exercise-details').find('.exercise-detail-page').html('<input type=\"text\" class=\"form-control\" id="input-exercise-page" placeholder=\"Página\" value="' + page + '">');
					$(this).parents('#exercise-details').find('.exercise-detail-difficulty').html('<input type="number" id="input-exercise-difficulty" class="difficulty-slider col-xs-12" min="1" max="10" value="' + difficulty + '">');

					$('.exercise-details-content').append(
						'<button type="button" class="btn btn-default btn-primary save-changes">' +
							'

' +
						'</button>'
					);
					switch(lang) {
						case 'es':
							$('#translation-31').html('GUARDAR CAMBIOS');
							break;
						case 'eu':
							$('#translation-31').html('ALDAKETAK GORDE');
							break;
						case 'en':
							$('#translation-31').html('SAVE CHANGES');
							break;
						case 'fr':
							$('#translation-31').html('GARDER LES CHANGEMENTS');
							break;
					}
					var windowHeight = $(window).height();
					var offsetTop = $('#main').offset().top;
					var offsetBottom =  $('#overfooter').height() + $('#footer').height();

					$('#exercise-details').css('bottom', offsetBottom);
					$('#exercise-details').css('height', $('#exercises-container').height() + 2 * $('#state-buttons').height());
					$('.exercise-details-body').css('height', $('#exercise-details').height() - 2 * $('.exercise-details-title').height() - Math.floor(parseFloat($('body').css('font-size'))));
					$('.exercise-details-content').css('height', $('.exercise-details-body').height() - 1);
				} else {
					var description = $(this).parents('#exercise-details').find('#input-exercise-description').val();
					var statement  = $(this).parents('#exercise-details').find('#input-exercise-statement').val();
					var topic = $(this).parents('#exercise-details').find('#input-exercise-topic').val();
					var page = $(this).parents('#exercise-details').find('#input-exercise-page').val();
					var difficulty = $(this).parents('#exercise-details').find('#input-exercise-difficulty').val();

					if(description.length < 1) {
					if($('#toast-new-exercise').length)
						$('#toast-new-exercise').remove();
						$('#container').append('

');
						switch(lang) {
							case 'es':
								$('#translation-33').html('La descripción debe tener por lo menos un carácter.');
								break;
							case 'eu':
								$('#translation-33').html('Deskripzioa, gutxienez, karaktere bat izan behar du.');
								break;
							case 'en':
								$('#translation-33').html('The description must have, at least, one character.');
								break;
							case 'fr':
								$('#translation-33').html('La description doit avoir au moins un caractère.');
								break;
						}
						$('#toast-new-exercise').hide().fadeIn('slow').delay(2000).fadeOut();
					} else {
						$(this).parents('#exercise-details').find('.exercise-detail-description').html(description);
						$(this).parents('#exercise-details').find('.exercise-detail-statement').html(statement);
						$(this).parents('#exercise-details').find('.exercise-detail-topic').html(topic);
						$(this).parents('#exercise-details').find('.exercise-detail-page').html(page);
						$(this).parents('#exercise-details').find('.exercise-detail-difficulty').html(difficulty);

						var something = 0;

						if(statement == null || statement == '') {
							$('.exercise-details-title-1').hide();
							$('.exercise-detail-statement').hide();
						} else something++;

						if(topic == null || topic == '') {
							$('.exercise-details-title-2').hide();
							$('.exercise-detail-topic').hide();
						} else something++;

						if(page == null || page == '') {
							$('.exercise-details-title-3').hide();
							$('.exercise-detail-page').hide();
						} else something++;

						if(difficulty == null || difficulty == '') {
							$('.exercise-details-title-4').hide();
							$('.exercise-detail-difficulty').hide();
						} else something++;

						$('.save-changes').remove();

						if(something == 0) {
							$('.exercise-details-content').append('

');
							$('#toast-details').hide().fadeIn('slow');
							switch(lang) {
							case 'es':
								$('#translation-32').html('No hay ningún detalle asociado a este ejercicio.');
								break;
							case 'eu':
								$('#translation-32').html('Ez dago xehetasunik ariketa honekin erlazionatuta.');
								break;
							case 'en':
								$('#translation-32').html('No details associated to this exercise.');
								break;
							case 'fr':
								$('#translation-32').html('Il n'y a pas des détails associés à cet exercice.');
								break;
							}
						}
					}
				}
			});

			$(document).on('vclick click tap', '.save-changes', function() {
				var id = $(this).parents('#exercise-details').attr('data-id');
				var description = $(this).parents('#exercise-details').find('#input-exercise-description').val();
				var statement  = $(this).parents('#exercise-details').find('#input-exercise-statement').val();
				var topic = $(this).parents('#exercise-details').find('#input-exercise-topic').val();
				var page = $(this).parents('#exercise-details').find('#input-exercise-page').val();
				var difficulty = $(this).parents('#exercise-details').find('#input-exercise-difficulty').val();
				if(description.length < 1) {
					if($('#toast-new-exercise').length)
						$('#toast-new-exercise').remove();
					$('#container').append('

');
					switch(lang) {
						case 'es':
							$('#translation-33').html('La descripción debe tener por lo menos un carácter.');
							break;
						case 'eu':
							$('#translation-33').html('Deskripzioa, gutxienez, karaktere bat izan behar du.');
							break;
						case 'en':
							$('#translation-33').html('The description must have, at least, one character.');
							break;
						case 'fr':
							$('#translation-33').html('La description doit avoir au moins un caractre.');
							break;
					}
					$('#toast-new-exercise').hide().fadeIn('slow').delay(2000).fadeOut();
				} else {
					parent = $(this).parents('#exercise-details');

					updateExercise(id, description, statement, topic, page, difficulty).done(function() {
						parent.find('.exercise-detail-description').html(description);
						parent.find('.exercise-detail-statement').html(statement);
						parent.find('.exercise-detail-topic').html(topic);
						parent.find('.exercise-detail-page').html(page);
						parent.find('.exercise-detail-difficulty').html(difficulty);

						var something = 0;

						if(statement == null || statement == '') {
							$('.exercise-details-title-1').hide();
							$('.exercise-detail-statement').hide();
						} else something++;

						if(topic == null || topic == '') {
							$('.exercise-details-title-2').hide();
							$('.exercise-detail-topic').hide();
						} else something++;

						if(page == null || page == '') {
							$('.exercise-details-title-3').hide();
							$('.exercise-detail-page').hide();
						} else something++;

						if(difficulty == null || difficulty == '') {
							$('.exercise-details-title-4').hide();
							$('.exercise-detail-difficulty').hide();
						} else something++;

						$('.save-changes').remove();

						if(something == 0) {
							$('.exercise-details-content').append('

');
							$('#toast-details').hide().fadeIn('slow');
							switch(lang) {
							case 'es':
								$('#translation-32').html('No hay ningún detalle asociado a este ejercicio.');
								break;
							case 'eu':
								$('#translation-32').html('Ez dago xehetasunik ariketa honekin erlazionatuta.');
								break;
							case 'en':
								$('#translation-32').html('No details associated to this exercise.');
								break;
							case 'fr':
								$('#translation-32').html('Il n'y a pas des détails associés à cet exercice.');
								break;
							}
						}
					});
				}
			});

			$(document).on('vclick click tap', '.advanced-exercise', function() {
				$('.advanced-exercise').html(' ');
				switch(lang) {
					case 'es':
						$('#translation-21').html('MENOS');
						break;
					case 'eu':
						$('#translation-21').html('GUTXIAGO');
						break;
					case 'en':
						$('#translation-21').html('LESS');
						break;
					case 'fr':
						$('#translation-21').html('MOINS');
						break;
				}
				$('.advanced-exercise').addClass('advanced-exercise-occult');
				$('.advanced-exercise-occult').removeClass('advanced-exercise');

				var windowHeight = $(window).height();
				var offsetTop = $('#main').offset().top;
				var offsetBottom =  $('#overfooter').height() + $('#footer').height();

				$('#new-exercise').css('height', $('#exercises-container').height() + 2 * $('#state-buttons').height());
				$('#new-exercise').css('bottom', offsetBottom);
				$('.campos').css('height', windowHeight - offsetBottom - $('.campos').offset().top);
				$('.advanced-container').css('height', $('.campos').height() - 3 * $('.save-exercise').height() - $('#input-exercise-id').height());
				$('.advanced-content').css('height', $('.campos').height() - 3 * $('.save-exercise').height() - $('#input-exercise-id').height());
				$('.advanced-container').slideDown('slow');
			});

			$(document).on('vclick click tap', '.advanced-exercise-occult', function() {
				$('.advanced-exercise-occult').html(' ');
				switch(lang) {
					case 'es':
						$('#translation-20').html('MÁS');
						break;
					case 'eu':
						$('#translation-20').html('GEHIAGO');
						break;
					case 'en':
						$('#translation-20').html('MORE');
						break;
					case 'fr':
						$('#translation-20').html('PLUS');
						break;
				}
				$('.advanced-exercise-occult').addClass('advanced-exercise');
				$('.advanced-exercise').removeClass('advanced-exercise-occult');

				var windowHeight = $(window).height();
				var offsetTop = $('#main').offset().top;
				var offsetBottom =  $('#overfooter').height() + $('#footer').height();

				hideAdvanced().done(function() {
					$('.advanced-container').css('height', $('.campos').height() - $('.save-exercise').height() - $('#input-exercise-id').height());
					$('.advanced-content').css('height', $('.campos').height() - $('.save-exercise').height() - $('#input-exercise-id').height());
					$('#new-exercise').css('bottom', offsetBottom);
					$('#new-exercise').css('height', '');
				});

			});

			function hideAdvanced() {
				$('.advanced-container').slideUp('slow');
				setTimeout(function() {
					$('.campos').animate({'height': $('#input-exercise-id').height() + 5*Math.floor(parseFloat($('body').css('font-size'))) + $('.save-exercise').height()}, 500);
				}, 250);
				return $.Deferred().resolve();
			}

			$(document).on('vclick click tap', '.userName', function() {
				viewProfile();
			});

			$(document).on('vclick click tap', '.profile-back', function() {
				 viewMain();
			});

			$(document).on('vclick click tap', '.exercise', function(e) {
				e.stopPropagation();
				var id = $(this).attr('data-id');
				showExerciseDetails(id);
			});

			$('select.subject-select').on('change', function (e) {
				var optionSelected = $('option:selected', this);
				var valueSelected = this.value;
				var text = optionSelected.text();
				$.ajax({
					type: 'GET',
					url: domain + 'change-subject.php',
					jsonpCallback: 'jsonCallback',
					contentType: "application/json",
					dataType: 'jsonp',
					data: { Subject: text.substr(text.indexOf(' ') + 1), Id: optionSelected.attr('data-id'), Group_id: optionSelected.attr('data-groupid'), Group: optionSelected.attr('data-group') },
					success: function() {
						$('.subject').html(text.substr(text.indexOf(' ') + 1));
					}
				});
			});

			$('select.language-select').on('change', function (e) {
				var optionSelected = $('option:selected', this);
				var valueSelected = this.value;
				var val = optionSelected.val();
				switch(val) {
					case '1':
						lang = 'es';
						break;
					case '2':
						lang = 'eu';
						break;
					case '3':
						lang = 'en';
						break;
					case '4':
						lang = 'fr';
						break;
				}

				$.ajax({
					type: 'GET',
					url: domain + 'change-lang.php',
					jsonpCallback: 'jsonCallback',
					contentType: "application/json",
					dataType: 'jsonp',
					data: { Language: lang },
					success: function(data) {
						loadData();
					}
				});
			});

			$('.profile-logout').on('click', logout);

			function logout() {
				$.ajax({
					type: 'GET',
					url: domain + 'end-session.php',
					jsonpCallback: 'jsonCallback',
					contentType: "application/json",
					dataType: 'jsonp',
					success: function(data) {
						if(data.next == undefined)
							logout();
						else
							window.location.replace(data.next);
					}
				});
			}

			$(window).on('resize', function() {
				$('#header').show();
				$('#state-buttons').show();
				var windowHeight = $(window).height();
				var offsetTop = $('#main').offset().top;
				var offsetBottom =  $('#overfooter').height() + $('#footer').height();

				if($('#main').hasClass('profile-main')) {
					$('#main').css('height', windowHeight - offsetTop);
					$('#main').css('bottom', Math.floor(parseFloat($('body').css('font-size'))));
					$('#main-content').css('height', windowHeight - offsetTop - Math.floor(parseFloat($('body').css('font-size'))));
				}

				// DYNAMIC RESIZINGS
				$('#exercises-container').css('height', windowHeight -  offsetTop  - offsetBottom - $('#overfooter').height() - 4*Math.floor(parseFloat($('body').css('font-size'))));
				$('#exercises-content').css('height', $('#exercises-container').height() - Math.floor(parseFloat($('body').css('font-size'))));

				$('.darken').css('height', windowHeight);
				$('.darken').css('bottom', windowHeight - $('#overfooter').offset().top);
				$('#new-exercise').css('bottom', offsetBottom);

				$('#statistics').css('bottom', offsetBottom);
				$('#statistics').css('height', $('#exercises-container').height() + 2 * $('#state-buttons').height());

				if ($(window).width() <= 480) {
					$('.change-to-active').addClass('btn-xs');
					$('.change-to-finished').addClass('btn-xs');
					$('.change-to-ready').addClass('btn-xs');
					$('.statistics-finished-button').addClass('btn-xs');
					$('.statistics-button').addClass('btn-xs');
				} else {
					$('.change-to-active').removeClass('btn-xs');
					$('.change-to-finished').removeClass('btn-xs');
					$('.change-to-ready').removeClass('btn-xs');
					$('.statistics-finished-button').removeClass('btn-xs');
					$('.statistics-button').removeClass('btn-xs');
				}

				if($('#statistics').length != 0) {
					$('.statistics-list-container').css('height', windowHeight - offsetBottom - $('.statistics-body-a').offset().top -
					2*$('.statistics-search').height() - Math.floor(parseFloat($('body').css('font-size'))));
					$('.statistics-list-content').css('height', $('.statistics-list-container').height() - Math.floor(parseFloat($('body').css('font-size'))));
				}

				if($('#exercise-details').length != 0) {
					$('#exercise-details').css('bottom', offsetBottom);
					$('#exercise-details').css('height', $('#exercises-container').height() + 2 * $('#state-buttons').height());
					$('.exercise-details-body').css('height', $('#exercise-details').height() - 2 * $('.exercise-details-title').height() - Math.floor(parseFloat($('body').css('font-size'))));
					$('.exercise-details-content').css('height', $('.exercise-details-body').height() - 1);
				}

				// Advanced new exercise creation tab displayed
				if($('#new-exercise').find('.advanced-exercise-occult').length != 0) {
					$('#new-exercise').css('height', $('#exercises-container').height() + 2 * $('#state-buttons').height());
					$('#new-exercise').css('bottom', offsetBottom);
					$('.campos').css('height', windowHeight - offsetBottom - $('.campos').offset().top);
					$('.advanced-container').css('height', $('.campos').height() - 3 * $('.save-exercise').height() - $('#input-exercise-id').height());
					$('.advanced-content').css('height', $('.campos').height() - 3 * $('.save-exercise').height() - $('#input-exercise-id').height());
				// Naive new exercise creation tab displayed
				} else if($('#new-exercise').find('.advanced-exercise-occult').length == 0) {
					$('.campos').css('height', $('#input-exercise-id').height() + 5*Math.floor(parseFloat($('body').css('font-size'))) + $('.save-exercise').height());
					$('.advanced-container').css('height', $('.campos').height() - $('.save-exercise').height() - $('#input-exercise-id').height());
					$('.advanced-content').css('height', $('.campos').height() - $('.save-exercise').height() - $('#input-exercise-id').height());
					$('#new-exercise').css('bottom', offsetBottom);
					$('#new-exercise').css('height', '');
				}
			});
		});

		setInterval(refresh, 3000);
	});
});

redpajama_set_name: RedPajamaGithub


text:
package org.eclipse.collections.api;

/**
 * PrimitiveIterable includes API that is common to all primitive collections.
 *
 * @since 3.0
 */
public interface PrimitiveIterable
{
    /**
     * Returns the number of items in this iterable.
     *
     * @since 3.0
     */
    int size();

    /**
     * Returns true if this iterable has zero items.
     *
     * @since 3.0
     */
    default boolean isEmpty()
    {
        return this.size() == 0;
    }

    /**
     * The English equivalent of !this.isEmpty()
     *
     * @since 3.0
     */
    default boolean notEmpty()
    {
        return this.size() != 0;
    }

    /**
     * Returns a string representation of this PrimitiveIterable.  The string representation consists of a list of the
     * PrimitiveIterable's elements in the order they are returned by its iterator, enclosed in square brackets
     * (<tt>"[]"</tt>).  Adjacent elements are separated by the characters <tt>", "</tt> (comma and space).  Elements
     * are converted to strings as by String#valueOf().
     *
     * @return a string representation of this PrimitiveIterable
     */
    @Override
    String toString();

    /**
     * Returns a string representation of this collection by delegating to {@link #makeString(String)} and defaulting
     * the separator parameter to the characters <tt>", "</tt> (comma and space).
     *
     * @return a string representation of this collection.
     * @since 3.0
     */
    default String makeString()
    {
        return this.makeString(", ");
    }

    /**
     * Returns a string representation of this collection by delegating to {@link #makeString(String, String, String)}
     * and defaulting the start and end parameters to <tt>""</tt> (the empty String).
     *
     * @return a string representation of this collection.
     * @since 3.0
     */
    default String makeString(String separator)
    {
        return this.makeString("", separator, "");
    }

    /**
     * Returns a string representation of this collection.  The string representation consists of a list of the
     * collection's elements in the order they are returned by its iterator, enclosed in the start and end strings.
     * Adjacent elements are separated by the separator string.  Elements are converted to strings using the appropriate
     * version of <tt>String.valueOf()</tt>.
     *
     * @return a string representation of this collection.
     * @since 3.0
     */
    default String makeString(String start, String separator, String end)
    {
        Appendable stringBuilder = new StringBuilder();
        this.appendString(stringBuilder, start, separator, end);
        return stringBuilder.toString();
    }

    /**
     * Prints a string representation of this collection onto the given {@code Appendable}.  Prints the string returned
     * by {@link #makeString()}.
     *
     * @since 3.0
     */
    default void appendString(Appendable appendable)
    {
        this.appendString(appendable, ", ");
    }

    /**
     * Prints a string representation of this collection onto the given {@code Appendable}.  Prints the string returned
     * by {@link #makeString(String)}.
     *
     * @since 3.0
     */
    default void appendString(Appendable appendable, String separator)
    {
        this.appendString(appendable, "", separator, "");
    }

    /**
     * Prints a string representation of this collection onto the given {@code Appendable}.  Prints the string returned
     * by {@link #makeString(String, String, String)}.
     *
     * @since 3.0
     */
    void appendString(Appendable appendable, String start, String separator, String end);
}


text:
SYNONYM

#### According to
The Catalogue of Life, 3rd January 2011

#### Published in
Beih. Nova Hedwigia 96: 126 (1989)

#### Original name
Stecchericium trimiticum Corner, 1989

### Remarks
null


text:
<chapter xml:id="chapter-deferred-and-compensating-tasks">

    <title>Transaction (in progress)</title>

    <sect1>
        <title>Introduction</title>
        <para>
              This chapter contains many of the txn config options.
        </para>
    </sect1>

    <sect1>
        <title>Customizing a txn</title>
        <para>
            Transactions can be configured by creating a custom AtomicBlock, e.g.
            <programlisting language="java">

    import org.multiverse.api.*;
    import org.multiverse.api.refs.*;
    import static org.multiverse.api.StmUtils.*;
    import static org.multiverse.api.GlobalStmInstance.*

    public class Account{
        private final static AtomicBlock transferBlock = getGlobalStmInstance()
            .newTransactionFactoryBuilder()
            .newAtomicBlock();

        private final IntRef amount = newTxnInteger(0);

        public void transfer(final int a){
            transferBlock.execute(new AtomicVoidClosure()){
                public void execute(Transaction tx){
                    amount.increment(tx, a);
                }
            });
        }

        ...
    }
    </programlisting>
            By configuring the TransactionFactoryBuilder, you can control the behavior of the Transaction.
            AtomicBlocks are designed to be threadsafe and not form a contention point. It is easiest to
            store them in a final static field so that they can be shared over multiple threads and objects.
        </para>

        <para>
            It is important to realize that a TransactionFactoryBuilder is immutable, so if a config
            method is called, a new instance is returned. This instance should be used to do the following
            config step or by used for creating the AtomicBlock.
        </para>
    </sect1>

    <sect1>
        <title>Familyname</title>
        <para>
            For debugging purposes, the txn family name can be set. It is best to choose a name that makes
            it easy to find the code that is executed by the AtomicBlock, e.g.:
            <programlisting language="java">

                import org.multiverse.api.*;
                import org.multiverse.api.refs.*;
                import static org.multiverse.api.StmUtils.*;
                import static org.multiverse.api.GlobalStmInstance.*

                public class Account{
                    private final static AtomicBlock transferBlock = getGlobalStmInstance()
                        .newTransactionFactoryBuilder()
                        .setFamilyName("Account.transfer")
                        .newAtomicBlock();

                    private final IntRef amount = newTxnInteger(0);

                    public void transfer(final int a){
                        transferBlock.execute(new AtomicVoidClosure()){
                            public void execute(Transaction tx){
                                amount.increment(tx, a);
                            }
                        });
                    }

                    ...
                }
                </programlisting>
            If no value is set, some generated value (which most likely is not very usable) is used.
        </para>
    </sect1>

    <sect1>
        <title>Readonly</title>
        <para>
            By default a txn is configured as an update txn; so it is allowed to make changes to transactional
            references. This behavior can be changed by setting the readonly property of the Transaction, e.g.:
            <programlisting language="java">

    import org.multiverse.api.*;
    import org.multiverse.api.refs.*;
    import static org.multiverse.api.StmUtils.*;
    import static org.multiverse.api.GlobalStmInstance.*

    public class Account{
        private final static AtomicBlock transferBlock = getGlobalStmInstance()
            .newTransactionFactoryBuilder()
            .setReadonly(true)
            .newAtomicBlock();

        private final IntRef amount = newTxnInteger(0);

        public void transfer(final int a){
            transferBlock.execute(new AtomicVoidClosure()){
                public void execute(Transaction tx){
                    amount.increment(tx, a);
                }
            });
        }

        ...
    }
    </programlisting>
            In this case a org.multiverse.api.exceptions.ReadonlyException is thrown when the amount.increment is called. In case of the GammaStm
            it doesn't make much of a performance impact if a txn is configured as readonly.
        </para>

    </sect1>

    <sect1>
        <title>Maximum retries</title>
        <para>
            An AtomicBlock automatically is going to be retried until one of the following things happens:
            <itemizedlist>
                <listitem>
                    It completes.
                </listitem>
                <listitem>
                    An exception (a Throwable) is thrown during the execution of the atomic block.
                </listitem>
                <listitem>
                    The txn has executed too many times and a org.multiverse.api.exceptions.TooManyRetriesException
                    is thrown.
                </listitem>
                <listitem>
                    The txn is going to block (see the retry functionality for more information how this works).
                </listitem>
            </itemizedlist>
            The default for the maximum retries is 1000 and can be configured through the TransactionFactoryBuilder:
              <programlisting language="java">

    import org.multiverse.api.*;
    import org.multiverse.api.refs.*;
    import static org.multiverse.api.StmUtils.*;
    import static org.multiverse.api.GlobalStmInstance.*

    public class Account{
        private final static AtomicBlock transferBlock = getGlobalStmInstance()
            .newTransactionFactoryBuilder()
            .setMaximumRetries(200)
            .newAtomicBlock();

        private final IntRef amount = newTxnInteger(0);

        public void transfer(final int a){
            transferBlock.execute(new AtomicVoidClosure()){
                public void execute(Transaction tx){
                    amount.increment(tx, a);
                }
            });
        }

        ...
    }
    </programlisting>
            In this example the maximum number of retries is configured to be 200. Setting the value very low, could lead to txns
            not being able to complete. If the speculative config mechanism is enabled for an AtomicBlock (defaults to true), it
            can happen that the first few times an AtomicBlock is used, some ControlFlowErrors (org.multiverse.api.exceptions.SpeculativeConfigurationError)
            are thrown even though there is no contention. If the value is set to a very high value, the system could suffer more from
            livelock problems. The consequence of a livelock is that the system is doing work (so consuming cpu and memory), but isn't making
            any progress.
        </para>
    </sect1>

    <sect1>
        <title>Don't rely on Transaction instance</title>
        <para>
            To prevent causing a lot of unwanted gc overhead, txn instances are reused. This means that the same txn instance
            could be used for different executions of the same AtomicBlock, but it also could be reused to execute a completely different
            AtomicBlock. That is why it is important to realize that Transaction instances should not be stored.
        </para>
    </sect1>
</chapter>


text:
/**
 * A namespace containing utils for the rest of the lunr library
 */
lunr.utils = {}

/**
 * Print a warning message to the console.
 *
 * @param {String} message The message to be printed.
 * @memberOf Utils
 */
lunr.utils.warn = (function (global) {
  return function (message) {
    if (global.console && console.warn) {
      console.warn(message)
    }
  }
})(this)

/**
 * Returns a zero filled array of the length specified.
 *
 * @param {Number} length The number of zeros required.
 * @returns {Array}
 * @memberOf Utils
 */
lunr.utils.zeroFillArray = (function () {
  var zeros = [0]

  return function (length) {
    while (zeros.length < length) {
      zeros = zeros.concat(zeros)
    }

    return zeros.slice(0, length)
  }
})()


text:
"""
.. module: lemur.policies.schemas
    :platform: unix
    :copyright: (c) 2018 by Netflix Inc., see AUTHORS for more
    :license: Apache, see LICENSE for more details.
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
"""
from marshmallow import fields

from lemur.common.schema import LemurOutputSchema

class RotationPolicyOutputSchema(LemurOutputSchema):
    id = fields.Integer()
    days = fields.Integer()

class RotationPolicyNestedOutputSchema(RotationPolicyOutputSchema):
    pass


text:
require 'spec_helper'

describe DLeagueModels::Location, type: :model do
  context "associations" do
    it { is_expected.to have_many :base_locations }

    it { is_expected.to have_many(:courts).through(:base_locations).source(:locatable) }
    it { is_expected.to have_many(:players).through(:base_locations).source(:locatable) }
    it { is_expected.to have_many(:teams).through(:base_locations).source(:locatable) }
    it { is_expected.to have_many(:leagues).through(:base_locations).source(:locatable) }
  end
end


text:
        <button type="button" class="close" data-dismiss="modal">×Close</button>

Copy below code and run to generate models

        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>


text:
package com.mitchellbdunn.stockinfo.exception;

import java.io.IOException;
import junit.framework.TestCase;

/**
 *
 * @author Mitch
 */
public class TestException extends TestCase {

    public void testExceptionConstructor1() {
        String expResult = "Testing constructor 1";
        StockException se = new StockException(expResult);
        String result = se.getMessage();
        assertEquals(expResult, result);
    }

    public void testExceptionConstructor2() {
        Throwable expResult = new NullPointerException();
        StockException se = new StockException(expResult);
        Throwable result = se.getCause();
        assertEquals(expResult, result);
    }

    public void testExceptionConstructor3() {
        String expResult1 = "Testing constructor 3";
        Throwable expResult2 = new IOException();
        StockException se = new StockException(expResult1, expResult2);
        String result1 = se.getMessage();
        Throwable result2 = se.getCause();
        assertEquals(expResult1, result1);
        assertEquals(expResult2, result2);
    }
}


text:
<!DOCTYPE html>

    <title>WPF Digitale Kommunikation – Medieninformatik am Campus Gummersbach</title>

	<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1.0, maximum-scale=1.0">
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css">
	<link href="https://fonts.googleapis.com/css?family=PT+Sans" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="/mi-wpf-digitale-kommunikation/style.css" />
    <link rel="alternate" type="application/rss+xml" title="WPF Digitale Kommunikation - Medieninformatik am Campus Gummersbach" href="/mi-wpf-digitale-kommunikation/feed.xml" />
    <link rel="shortcut icon" type="image/x-icon" href="/mi-wpf-digitale-kommunikation/favicon.ico">

	          Termine

	          Links

	          Frage stellen
	          Repo

				WPF Digitale Kommunikation

				Medieninformatik am Campus Gummersbach

Über das Modul

Worum geht es?

Dieses Modul befasst sich mit verschiedenen Perspektiven der digitalen Kommunikation und bietet Platz zum entwickeln und ausprobieren eigener Ansätze und Lösungen in diesem Themenfeld. Das Modul hat eine hohe Praxisorientierung. Als Voraussetzung sollten Sie die Module "Grundlagen der visuellen Kommunikation" und "Audiovisuelle Medienprojekt" erfolgreich abgeschlossen haben. Auch die erfolgreich abgeschlossenen Module "Web-basierte Anwendungen 1 + 2" und "Computergrafik und Animation" erhöhen Ihre Handlungsfähigkeit in diesem Modul.

Was sind die Ziele?

Das Modul konzentriert sich auch die Entwicklung und Erweiterung der Medienkompetenz der Teilnehmer. Dabei werden die folgenden Lernziele adressiert:

Die Studierenden können, auf Basis einer gegebenen Zielsetzung und eines vorhandenen Kontextes (organisationale, soziale, gestalterische und kulturelle Kontexte, Vorgaben und Regeln) Kommunikationsziele entwicklen und dokumentieren, um eine Strategie für ein Gestaltungsprojekt zu verstehen, als auch entwerfen und diskutieren zu können.

Die Studierenden können die Perspektive der Medienkonzeption einnehmen, haben eine mediengestalterische Grundkompetenz entwickelt und sind in der Lage, bezüglich der erarbeiteten Kommunikationsziele, eine geeignete Medienauswahl zu treffen und auf Basis dieser Auswahl und der Zielsetzung passgenaue Mediengestaltungen zu erarbeiten.

Die Studierenden kennen die Gestaltungsdimensionen von Medien und besitzen aktive Vokabularien zur Beschreibung und Realisierung angemessener Konzeptionen, um aus einem Konzept eine konkrete und professionelle Realisierung zu erarbeiten.

Wie funktioniert das Modul?

Wir starten mit einer konzentrierten Woche in der Profil2 Projektwoche, in der wir die Grundlage für das weitere Schaffen legen. Auf dieser Basis werden Projektideen erarbeitet und im weiteren Semesterverlauf umgesetzt. Zur Unterstützung werden eine Reihe von Review- und Feedbackterminen angeboten. Die Projektpräsentation erfolgt in der vorlesungsfreien Zeit.

Prüfungsform

Projekt mit Projektpräsentation und Kurzdokumentation. Die Präsentation wird vor allen Teilnehmern des WPFs abgehalten. Details dazu werden im Rahmen der Veranstaltung noch erörtert.

Wer macht es?

Verantwortlicher Dozent des Moduls ist Prof. Christian Noss.

Termine

Links

Frage stellen

Repo


text:
layout: post
title: Malasadas- Portuguese Donuts
date: '2013-02-13 11:31:00'
---

*Malasadas are a traditional Portuguese dessert deep fried and coated with sugar. This malasadas recipe is a variation on a Bermudian family classic, from my aunt.*

> 5 lbs flour
> 1 cup sugar
> 1 teaspoon salt
> 3+ packages of yeast
> 1 1/4 cup warm water
> 3 tablespoons vanilla
> 1/4 lb melted butter, warm
> 12 beaten eggs at room temperature
> 4 cup evaporated milk, warm

* Stir yeast into warm water and let activate for at least 10 minutes.
In a large bowl stir together flour, sugar and salt. Make a well in the middle of the dry ingredients.
* Pour yeast, water, vanilla and eggs into the well in the flour mixture and stir with your hands. Slowly add milk until dough forms a shaggy ball.
* Turn dough out onto a lightly floured surface and and knead gently- turning and folding the dough 8 or so times. Don't overdo it.
* Let dough rise, covered, in a greased bowl until double in size (about 4 hours).
* Punch down dough and let rise again for 30 minutes.
* Heat a large pan of oil on the stove or preheat a deep fryer.
* When ready to fry donuts cut off small ~1/4 cup pieces of dough. Stretch dough out like a pancake and make a hole in the middle. Drop into hot oil and fry on both sides until golden.
* Coat donuts in sugar and enjoy with a cup of tea.


text:
<!DOCTYPE html>

    <meta charset="UTF-8">
    <title>Hello Lilacs</title>
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />

Hello Lilacs!


text:
<?php

namespace ONGR\FilterManagerBundle\DependencyInjection\Filter;

/**
 * Factory for multi choice filter.
 */
class MultiChoiceFilterFactory extends ChoiceFilterFactory
{
    /**
     * {@inheritdoc}
     */
    protected function getNamespace()
    {
        return 'ONGR\FilterManagerBundle\Filters\Widget\Choice\MultiTermChoice';
    }

    /**
     * {@inheritdoc}
     */
    public function getName()
    {
        return 'multi_choice';
    }
}


text:
//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Alachisoft.NosDB.Common
{
    public static class ExtensionsMethods
    {
        public static Dictionary<TKey, TValue> Clone<TKey, TValue>(this Dictionary<TKey, TValue> original) //where TValue : ICloneable
        {
            Dictionary<TKey, TValue> ret = new Dictionary<TKey, TValue>(original.Count, original.Comparer);

            bool isKeyCloneable = typeof(TKey).IsAssignableFrom(typeof(ICloneable)) ? true : false;
            bool isValueCloneable = typeof(TValue).IsAssignableFrom(typeof(ICloneable)) ? true : false;

            foreach (KeyValuePair<TKey, TValue> entry in original)
            {
                TKey clonedKey = isKeyCloneable ? (TKey)((ICloneable)entry.Key).Clone() : entry.Key;
                TValue clonedValue = isValueCloneable ? (TValue)((ICloneable)entry.Value).Clone() : entry.Value;

                ret.Add(clonedKey, clonedValue);
            }
            return ret;
        }

        public static Dictionary<TKey, List<TValue>> Clone<TKey, TValue>(this Dictionary<TKey, List<TValue>> original) //where TValue : ICloneable
        {
            Dictionary<TKey, List<TValue>> ret = new Dictionary<TKey, List<TValue>>(original.Count, original.Comparer);

            bool isKeyCloneable = typeof(TKey).IsAssignableFrom(typeof(ICloneable)) ? true : false;

            foreach (KeyValuePair<TKey, List<TValue>> entry in original)
            {
                TKey clonedKey = isKeyCloneable ? (TKey)((ICloneable)entry.Key).Clone() : entry.Key;
                List<TValue> clonedValue = entry.Value.Clone<TValue>();

                ret.Add(clonedKey, clonedValue);
            }
            return ret;
        }

        public static Dictionary<TKey, TValue[]> Clone<TKey, TValue>(this Dictionary<TKey, TValue[]> original) //where TValue : ICloneable
        {
            Dictionary<TKey, TValue[]> ret = new Dictionary<TKey, TValue[]>(original.Count, original.Comparer);

            bool isKeyCloneable = typeof(TKey).IsAssignableFrom(typeof(ICloneable)) ? true : false;

            foreach (KeyValuePair<TKey, TValue[]> entry in original)
            {
                TKey clonedKey = isKeyCloneable ? (TKey)((ICloneable)entry.Key).Clone() : entry.Key;
                TValue[] clonedValue = entry.Value.Clone<TValue>();

                ret.Add(clonedKey, clonedValue);
            }
            return ret;
        }

        public static List<TValue> Clone<TValue>(this List<TValue> original) //where TValue : ICloneable
        {
            List<TValue> ret = new List<TValue>(original.Count);

            bool isValueCloneable = typeof(TValue).IsAssignableFrom(typeof(ICloneable)) ? true : false;

            foreach (TValue value in original)
            {
                TValue clonedValue = isValueCloneable ? (TValue)((ICloneable)value).Clone() : value;
                ret.Add(clonedValue);
            }
            return ret;
        }

        public static TValue[] Clone<TValue>(this TValue[] original) //where TValue : ICloneable
        {
            TValue[] ret = new TValue[original.Length];

            bool isValueCloneable = typeof(TValue).IsAssignableFrom(typeof(ICloneable)) ? true : false;

            int index = 0;
            foreach (TValue value in original)
            {
                TValue clonedValue = isValueCloneable ? (TValue)((ICloneable)value).Clone() : value;
                ret[index] =clonedValue;
                index++;
            }
            return ret;
        }
    }
}


text:
<!DOCTYPE HTML>

  <title>Acme Air - Your Account</title>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  <link rel="stylesheet" type="text/css" href="css/style.css">
  <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.7.1/dijit/themes/claro/claro.css">
  <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.7.1/dijit/themes/dijit.css">
  <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.7.1/dojox/grid/resources/claroGrid.css">

Logging in ...

				Login
				<input type="text" trim="true" dojoType="dijit.form.TextBox" value="uid0@email.com" name="login" id="userId"/>

				Password
				<input type="password" trim="true" dojoType="dijit.form.TextBox" value="password" name="password" id="password"/>

							<button dojoType="dijit.form.Button" id="LoginButton" onClick="login()">Ok</button>

							<button dojoType="dijit.form.Button" onclick="hideLoginDialog()" id="Cancel">Cancel</button>

Customer Information Updated Successfully

	<button dojoType="dijit.form.Button" onclick="dijit.byId('updatedStatusDialog').hide()" id="updatedStatusDialogOkButton">Ok</button>

Flights, Baggage, and Loyalty all with a Smile

			${label}:

Home

Flights

Checkin

Login

Logout

Account

Account Profile Information:

      			account id:
      			<input type="text" dojoType="dijit.form.TextBox" id="accountIdInput" data-dojo-props="readOnly:true"></input>

      			password:
      			<input type="password" dojoType="dijit.form.TextBox" id="passwordInput" data-dojo-props="trim:true" required="true"></input>

Contact Information:

      			Phone Number:
      			<input type="text" dojoType="dijit.form.TextBox" id="phoneNumberInput" data-dojo-props="trim:true" required="true"></input>

      			Phone Type:

      			<select dojoType="dijit.form.FilteringSelect" id="phoneNumberTypeInput">
      				<option value="MOBILE">Mobile</option>
      				<option value="HOME">Home</option>
      				<option value="BUSINESS">Business</option>
      				<option value="UNKNOWN">Unspecified</option>
      			</select>

      			Street Address:
      			<input type="text" dojoType="dijit.form.TextBox" id="street1AddressInput" data-dojo-props="trim:true" required="true"></input>

      			Street Address 2:
      			<input type="text" dojoType="dijit.form.TextBox" id="street2AddressInput" data-dojo-props="trim:true"></input>

      			City:
      			<input type="text" dojoType="dijit.form.TextBox" id="cityInput" data-dojo-props="trim:true" required="true"></input>

      			State (Province):
      			<input type="text" dojoType="dijit.form.TextBox" id="stateProvinceInput" data-dojo-props="trim:true" required="true"></input>

      			Country:
      			<input type="text" dojoType="dijit.form.TextBox" id="countryInput" data-dojo-props="trim:true" required="true"></input>

      			Postal Code:
      			<input type="text" dojoType="dijit.form.TextBox" id="postalCodeInput" data-dojo-props="trim:true" required="true"></input>

Customer Loyalty Information:

      			Membership status:
      			<input type="text" dojoType="dijit.form.TextBox" id="memberShipStatusInput" data-dojo-props="readOnly:true"></input>

      			Miles year to date:
      			<input type="text" dojoType="dijit.form.NumberTextBox" id="milesYTDInput" data-dojo-props="readOnly:true"></input>

      			Total miles:
      			<input type="text" dojoType="dijit.form.NumberTextBox" id="totalMilesInput" data-dojo-props="readOnly:true"></input>

      			<button dojoType="dijit.form.Button" id="updateProfileButton" onClick="updateProfile()">Update Profile</button>

Acme Air