/**
 * alarma.js:  Maneja alarma.html que avisa de las alarmas vencidas
 */


$(document).ready(function(){ 
	var	datos = localStorage.getItem("information-alarm");

	var alarm_de = document.querySelector("#alarma-de");
	alarm_de.setAttribute("margin-left", "6rem");
	var texto_titulo = document.querySelector("#texto-titulo");

	var text1 = "Alarma de "+datos;
	text1 = text1.toUpperCase();
	text1 = text1.bold();
	text1 = text1.fontsize(6);
	text1 = text1.fontcolor("#FF4E00");

	texto_titulo.innerHTML = text1;
	texto_titulo.setAttribute("color", "rgb(255, 78, 0)");

	var alarm_img = document.querySelector("#alarma-img");
	var volver = document.querySelector("#button-volver");

	if (datos == "riego"){  
		alarm_img.setAttribute("src","images/alarms/riego.png");
		alarm_img.setAttribute("width", "100%");
		alarm_img.setAttribute("height", "100%");

		if(volver){
			volver.addEventListener("click", function(){
				window.location.assign("content.html");
			});			
		}
	}
	else if (datos == "cosecha"){ 
		alarm_img.setAttribute("src","images/alarms/cosecha.png");
		alarm_img.setAttribute("width", "100%");
		alarm_img.setAttribute("height", "100%");

		if(volver){
			volver.addEventListener("click", function(){
				if(localStorage.getItem("experiencia") < 5)
					window.location.assign("experiencia.html");
				else 
					window.location.assign("content.html");
			});
		}
	}

});