<commit_before>var byejob = {

	KEY_CURRENT_DAY: "byejob.current.day",
	KEY_ENTRY_1: "byejob.entry1",
	KEY_ENTRY_2: "byejob.entry2",
	KEY_LEAVE_1: "byejob.leave1",
	KEY_LAST_WEATHER_CONSULT: "byejob.last.weather.consult",
	KEY_LAST_WEATHER_DESCRIPTION: "byejob.last.weather.description",
	KEY_LAST_TEMPERATURE: "byejob.last.temperature",
	KEY_LAST_CLOUDS: "byejob.last.clouds",

	jEntry1: null,
	jEntry2: null,
	jLeave1: null,
	jLeave2: null,
	jTolerance1: null,
	jTolerance2: null,

	expedient: null,
	temperature: null,
	weatherDescription: null,
	clouds: null,
	filters: {},
	latitude: null,
	longitude: null,

	init : function() {
		this.loadExpedient();
		this.loadJqueryObjects();
		this.loadEvents();
		this.loadCurrentDay();
		this.loadPosition();
	},

	loadPosition: function() {
		var self = this;
		navigator.geolocation.getCurrentPosition(function(position){
			self.latitude = position.coords.latitude;
			self.longitude = position.coords.longitude;
			self.loadWeather();
		});
	},

	loadWeather: function() {
		var self = this;
		if (self.isNeedRefreshWeather() === true) {
			var url = 'http://api.openweathermap.org/data/2.5/weather?lang=en&lat='
				+ self.latitude + '&lon=' + self.longitude
				+ '&APPID=8798ebb0cb4906589ca53da30af6f94e';

			var xhr = new XMLHttpRequest();
			xhr.open("GET", url, true);
			xhr.onreadystatechange = function() {
				if (xhr.readyState == 4) {
					var data = JSON.parse(xhr.response);
					console.log(data);

					var temperature = Math.round(data.main.temp - 273.15);
					var description = data.weather[0].description;
					var clouds = data.clouds.all;

					self.saveKeyLocalSession(self.KEY_LAST_TEMPERATURE, temperature);
					self.temperature = temperature;

					self.saveKeyLocalSession(self.KEY_LAST_WEATHER_DESCRIPTION, description);
					self.weatherDescription = description;

					self.saveKeyLocalSession(self.KEY_LAST_CLOUDS, clouds);
					self.clouds = clouds;

					self.saveKeyLocalSession(self.KEY_LAST_WEATHER_CONSULT, new Date().getTime());
					self.loadWeatherAnimation();
				}
			}
			xhr.send();
		} else {
			self.temperature = self.getKeyLocalSession(self.KEY_LAST_TEMPERATURE);
			self.weatherDescription = self.getKeyLocalSession(self.KEY_LAST_WEATHER_DESCRIPTION);
			self.clouds = self.getKeyLocalSession(self.KEY_LAST_CLOUDS);
			self.loadWeatherAnimation();
		}
	},

	isNeedRefreshWeather: function(){
		var lastConsult = parseInt(this.getKeyLocalSession(this.KEY_LAST_WEATHER_CONSULT));
		if(lastConsult > 0){
			var lastDate = new Date(lastConsult);
			var hours = parseInt(this.timeDifferenceBetween(this.getTimeString(lastDate), this.getTimeString(new Date())).split(":")[0]);
			return lastDate.getDate() != new Date().getDate() || hours > 0;
		}

		return true;
	},

	loadWeatherAnimation: function(){
		this.loadBackgroundAnimation();
		this.loadSunlight();

		$('#first_page').fadeOut(function(){
			$('#content').fadeIn();
		});
	},

	loadBackgroundAnimation: function(){
		var backgroundClass;
		var grayscale = 100;
		var shadow = '#000';

		switch (this.weatherDescription) {
		case "shower rain":
		case "rain":
		case "thunderstorm":
			backgroundClass = "dark-cloud-day";
			grayscale = 100;
			shadow = '#000'
			break;

		case "broken clouds":
		case "scattered clouds":
			backgroundClass = "grey-cloud-day";
			grayscale = 75;
			shadow = '#363636'
			break;

		case "mist":
			backgroundClass = "foggy-day";
			grayscale = 50;
			shadow = '#E8E8E8'
			break;

		case "few clouds":
			backgroundClass = "white-cloud-day";
			grayscale = 25;
			shadow = '#E8E8E8'
				break;

		case "clear sky":
		case "Sky is Clear":
			backgroundClass = "clear-day";
			grayscale = 5;
			shadow = '#FFF'
			break;
		}

		this.filters['grayscale'] = grayscale;
		this.filters['shadow'] = shadow;
		this.loadFilters();
		$('.weather').addClass(backgroundClass);
	},

	loadFilters: function(){
		var webkitFilter = 'grayscale(' + this.filters['grayscale'] + '%) drop-shadow(0px 4px 8px ' + this.filters['shadow'] + ')';
		$('.plates').css('-webkit-filter', webkitFilter);
		$('.board').css('-webkit-filter', webkitFilter);
	},

	loadSunlight: function(){
		var self = this;
		var sunPosition;
		switch (self.weatherDescription) {
		case "few clouds":
		case "clear sky":
		case "Sky is Clear":
			sunPosition = SunCalc.getPosition(new Date(), self.latitude, self.longitude);
			$('#sun').css('top', sunPosition.altitude * -150 + 180);
			break;
		}
	},

	loadExpedient: function(){
		this.expedient = new Date();
		this.expedient.setHours(8, 30, 0, 0);<commit_msg>Calculando rotacao da terra no sol<commit_after>var byejob = {

	KEY_CURRENT_DAY: "byejob.current.day",
	KEY_ENTRY_1: "byejob.entry1",
	KEY_ENTRY_2: "byejob.entry2",
	KEY_LEAVE_1: "byejob.leave1",
	KEY_LAST_WEATHER_CONSULT: "byejob.last.weather.consult",
	KEY_LAST_WEATHER_DESCRIPTION: "byejob.last.weather.description",
	KEY_LAST_TEMPERATURE: "byejob.last.temperature",
	KEY_LAST_CLOUDS: "byejob.last.clouds",

	jEntry1: null,
	jEntry2: null,
	jLeave1: null,
	jLeave2: null,
	jTolerance1: null,
	jTolerance2: null,

	expedient: null,
	temperature: null,
	weatherDescription: null,
	clouds: null,
	filters: {},
	latitude: null,
	longitude: null,

	init : function() {
		this.loadExpedient();
		this.loadJqueryObjects();
		this.loadEvents();
		this.loadCurrentDay();
		this.loadPosition();
	},

	loadPosition: function() {
		var self = this;
		navigator.geolocation.getCurrentPosition(function(position){
			self.latitude = position.coords.latitude;
			self.longitude = position.coords.longitude;
			self.loadWeather();
		});
	},

	loadWeather: function() {
		var self = this;
		if (self.isNeedRefreshWeather() === true) {
			var url = 'http://api.openweathermap.org/data/2.5/weather?lang=en&lat='
				+ self.latitude + '&lon=' + self.longitude
				+ '&APPID=8798ebb0cb4906589ca53da30af6f94e';

			var xhr = new XMLHttpRequest();
			xhr.open("GET", url, true);
			xhr.onreadystatechange = function() {
				if (xhr.readyState == 4) {
					var data = JSON.parse(xhr.response);
					console.log(data);

					var temperature = Math.round(data.main.temp - 273.15);
					var description = data.weather[0].description;
					var clouds = data.clouds.all;

					self.saveKeyLocalSession(self.KEY_LAST_TEMPERATURE, temperature);
					self.temperature = temperature;

					self.saveKeyLocalSession(self.KEY_LAST_WEATHER_DESCRIPTION, description);
					self.weatherDescription = description;

					self.saveKeyLocalSession(self.KEY_LAST_CLOUDS, clouds);
					self.clouds = clouds;

					self.saveKeyLocalSession(self.KEY_LAST_WEATHER_CONSULT, new Date().getTime());
					self.loadWeatherAnimation();
				}
			}
			xhr.send();
		} else {
			self.temperature = self.getKeyLocalSession(self.KEY_LAST_TEMPERATURE);
			self.weatherDescription = self.getKeyLocalSession(self.KEY_LAST_WEATHER_DESCRIPTION);
			self.clouds = self.getKeyLocalSession(self.KEY_LAST_CLOUDS);
			self.loadWeatherAnimation();
		}
	},

	isNeedRefreshWeather: function(){
		var lastConsult = parseInt(this.getKeyLocalSession(this.KEY_LAST_WEATHER_CONSULT));
		if(lastConsult > 0){
			var lastDate = new Date(lastConsult);
			var hours = parseInt(this.timeDifferenceBetween(this.getTimeString(lastDate), this.getTimeString(new Date())).split(":")[0]);
			return lastDate.getDate() != new Date().getDate() || hours > 0;
		}

		return true;
	},

	loadWeatherAnimation: function(){
		this.loadBackgroundAnimation();
		this.loadSunlight();

		$('#first_page').fadeOut(function(){
			$('#content').fadeIn();
		});
	},

	loadBackgroundAnimation: function(){
		var backgroundClass;
		var grayscale = 100;
		var shadow = '#000';

		switch (this.weatherDescription) {
		case "shower rain":
		case "rain":
		case "thunderstorm":
			backgroundClass = "dark-cloud-day";
			grayscale = 100;
			shadow = '#000'
			break;

		case "broken clouds":
		case "scattered clouds":
			backgroundClass = "grey-cloud-day";
			grayscale = 75;
			shadow = '#363636'
			break;

		case "mist":
			backgroundClass = "foggy-day";
			grayscale = 50;
			shadow = '#E8E8E8'
			break;

		case "few clouds":
			backgroundClass = "white-cloud-day";
			grayscale = 25;
			shadow = '#E8E8E8'
				break;

		case "clear sky":
		case "Sky is Clear":
			backgroundClass = "clear-day";
			grayscale = 5;
			shadow = '#FFF'
			break;
		}

		this.filters['grayscale'] = grayscale;
		this.filters['shadow'] = shadow;
		this.loadFilters();
		$('.weather').addClass(backgroundClass);
	},

	loadFilters: function(){
		var webkitFilter = 'grayscale(' + this.filters['grayscale'] + '%) drop-shadow(0px 4px 8px ' + this.filters['shadow'] + ')';
		$('.plates').css('-webkit-filter', webkitFilter);
		$('.board').css('-webkit-filter', webkitFilter);
	},

	loadSunlight: function(){
		var self = this;
		var sunPosition;
		switch (self.weatherDescription) {
		case "few clouds":
		case "clear sky":
		case "Sky is Clear":
			sunPosition = SunCalc.getPosition(new Date(), self.latitude, self.longitude);
			var altitude = sunPosition.altitude * 100;
			var radius = sunPosition.azimuth * 180 / Math.PI;

			if (radius < 0) {
				radius = radius < 0 ? radius * -1 - 60 : radius;
			} else {
				radius = radius > 0 ? 180 - radius + 180 : radius;
			}

			$('#sun').css('top', 160 - (148 / 370 * 6 * altitude))
					.css('left', 420 - (640 / 300 * radius));
			break;
		}
	},

	loadExpedient: function(){
		this.expedient = new Date();
		this.expedient.setHours(8, 30, 0, 0);
{'fraction_non_alphanumeric': 0.14967646122838654, 'fraction_numerical': 0.021958205155404687, 'mean_word_length': 4.098972417522986, 'pattern_counts': {'":': 26, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3892199', 'n_tokens_mistral': 3950, 'n_tokens_neox': 3292, 'n_words': 612}