//Creado con Ardora - www.webardora.net
//bajo licencia Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)
//para otros usos contacte con el autor
var isFull=false;var isLog=false;
function createBar(){var element = document.createElement("div");element.setAttribute("id", "ardNavBar");$(element).css("position","fixed");$(element).css("z-index", 998);
$(element).css("right",0);$(element).css("bottom",0);
document.getElementById("ardoraMain").appendChild(element);
$(element).html('<p id="startBut" title="Inicio" class="butfont butLe">i</p>');
$("#startBut").on("touchstart click",function(e){   var canSave=true;if (isLog) {$.ajax({data: {"action": "canSave","type": "0"},type: "POST",dataType: "json",url: "php/ardoraXML.php",success: function(data, textStatus, jqXHR) {if (data["status"]!="Ok"){$("#editBut").remove();}}});}
if ($("#ardNB").length>0){$("#ardNB").animate({height:"0px"},100);$("#ardNB").promise().done(function(){$("#ardNB").remove();});$("#startBut").text("i");}else{
$("#startBut").text("E");var NB = document.createElement("div");NB.setAttribute("id", "ardNB");$(NB).css("position","fixed");$(NB).css("z-index", 998);
$(NB).css("right",0);$(NB).css("bottom","40px");$(NB).css("width",35);$(NB).css("height",0);
var codeAud =""
if (!isLog){codeAud='<p id="loginBut" title="Usuaria/o" class="butfont butLe">U</p>';
codeAud = codeAud + '<p id="refreshBut" title="Refrescar" class="butfont butLe">Z</p>';
codeAud = codeAud + '<p id="fullBut" title="Pantalla completa" class="butfont butLe">H</p>';
$(NB).html(codeAud);document.getElementById("ardoraMain").appendChild(NB);
}
if (isLog){codeAud=codeAud+'<p id="pusN"><span id="usN" title="">'+userN+'</span></p>';
codeAud=codeAud+'<p id="editBut" title="Añadir o edita unidad" class="butfont butLe">P</p>';
codeAud=codeAud+'<p id="refreshBut" title="Refrescar" class="butfont butLe">Z</p>';
codeAud=codeAud+'<p id="fullBut" title="Pantalla completa" class="butfont butLe">H</p>';
codeAud = codeAud + '<p id="closeS" title="Cerrar sesión" class="butfont butLe">z</p>';
$(NB).html(codeAud);document.getElementById("ardoraMain").appendChild(NB);}
if (isLog){
var nWidth=($("#pusN").width()+160+40)+"px";
$(NB).animate({height: nWidth}, 500);
}else{$(NB).animate({height: "160px"}, 500);}
$("#fullBut").on("touchstart click",function(v){if (!isFull){var e = document.body;if (e.requestFullscreen) {e.requestFullscreen();} else if (e.mozRequestFullScreen) {e.mozRequestFullScreen();} else if (e.webkitRequestFullScreen) {e.webkitRequestFullScreen();}
document.addEventListener("fullscreenchange", function() {if (!document.fullscreen) {$("#imaFull").remove();}}, false);document.addEventListener("mozfullscreenchange", function() {if (!document.mozFullScreen) {$("#imaFull").remove();}}, false);
document.addEventListener("webkitfullscreenchange", function() {if (!document.webkitIsFullScreen) {$("#imafull").remove();;}}, false);isFull=true;}
else{var docElement, request;docElement = document;request = docElement.cancelFullScreen || docElement.webkitCancelFullScreen || docElement.mozCancelFullScreen || docElement.msCancelFullScreen || docElement.exitFullscreen; if (typeof request != "undefined" && request) {request.call(docElement);} isFull=false;}
});
$("#loginBut").on("touchstart click", function(e) {$("#modal-content").empty();$("#modal-content").css("height", "auto");$("#modal-content").addClass("widthAuto");
var newHtml = '<div id="divLogin"><div id="modalTit">Nombre usuario/a</div>';newHtml = newHtml + '<iframe id="if_login" src="php/ardoraLogin.php" width="640" height="400"></iframe>';newHtml = newHtml + "</div>";
$("#modal-content").append(newHtml);$("#modal-content,#modal-background").toggleClass("active");$("#modal-background, #modal-close, #cancelBut").click(function() {$("#modal-content,#modal-background").toggleClass("active");});
$("#ardNB").animate({height: "0px"}, 100);$("#ardNB").promise().done(function() {$("#ardNB").remove();});$("#startBut").text("i");$("#modal-content").draggable();$("#modal-content").css("left",($("#ardoraMain").width()- $("#modal-content").width()) / 2).toString()+"px";$("#modal-content").css("top","50px");});
$("#editBut").on("touchstart click", function(e) {$("#modal-content").empty();$("#modal-content").css("height","auto");$("#modal-content").css("width", "800px");
var newHtml='<div id="modalTit">Añadir unidad</div>';
newHtml =newHtml+'<div id="area_form" ><form id="entraDatos" class="formLogin" name="entraDatos" method="post" action="" enctype="multipart/form-data">';
newHtml =newHtml+'<div id="traballos"><p>Introduce los datos</p></div>';
newHtml =newHtml+'<div id="datos_form"><label for="titulo">Unidad  </label><input type="text" name="titulo" id="titulo" placeholder="" required value="" maxlength="30"/>';
newHtml =newHtml+'<div id="clear"></div>';newHtml =newHtml+'<label for="descri">Descripción  </label><input type="text" name="descricion" id="descricion" placeholder="" required value=""/>';
newHtml =newHtml+'<div id="clear"></div>';
newHtml =newHtml+'<label for="colorBack">Color de fondo</label><input type="color" value="#FFFF00" name="back_color" id="back_color">';
newHtml =newHtml+'</div></form></div>';newHtml =newHtml+'<div id="clear"></div>';newHtml =newHtml+'<div id="clear"></div>';
newHtml = newHtml + '<div id="modalBar"><p id="cancelBut" class="butfont butLe red" title="Cancelar">E</p><p id="oKBut" class="butfont butRi green" title="Aceptar">g</p></div></div>';
$("#modal-content").append(newHtml);
$("#modal-content").css("left",($("#ardoraMain").width()- $("#modal-content").width()) / 2).toString()+"px";
$("#modal-content").css("top","50px");
$("#modal-content,#modal-background").toggleClass("active");
$("#modal-background, #modal-close, #cancelBut").click(function() {$("#modal-content,#modal-background").toggleClass("active");});
$("#modal-content").draggable();
$("#titulo").on("touchstart click", function(e) {$("#titulo").select();});
$("#descricion").on("touchstart click", function(e) {$("#descricion").select();});
$("#fileinput").on("touchstart click", function(e) {$("#fileinput").select();});
$("#oKBut").on("touchstart click", function(e) {$("#alertDiv").remove();var input_Tit= $("#titulo").val();var input_Des= $("#descricion").val();
var input_cBack= $("#back_color").val();var input_cBorder="#000000";if (input_Tit.length > 0) {
$("#oKBut").hide();$.ajax({data: {"action": "new","tit": input_Tit,"des": input_Des,"cBack": input_cBack,"cBorder": input_cBorder,"type": "0","nameUser": ""},type: "POST",dataType: "json",async: false,url: "php/ardoraXML.php",
success: function(data, textStatus, jqXHR) {if (data["status"] == "Ok") {$("#modal-content,#modal-background").toggleClass("active");}
if (data["status"]=="UpMaxUpload"){$("#modal-content,#modal-background").toggleClass("active");alert("Ya has escrito suficientes unidades.");}
if (data["status"] == "ItemMaxUpload") {$("#modal-content,#modal-background").toggleClass("active");alert("Hemos alcanzado las 50 unidades.");}}
});getJob();if (allJobs.length>50){$("#editBut").remove()}
} else {$("#datos_form").append("<div id='alertDiv'><p id=alertIco>a</p><p id='errorMen'>Debes de escribir el nombre de una unidad</p></div>");}
});
$("#startBut").click();
});
$("#refreshBut").on("touchstart click", function(e) {getJob();});
$("#closeS").on("touchstart click", function(e) {$.ajax({data: {"action": "logout"},type: "POST",dataType: "json",url: "php/ardoraXML.php",success: function(data, textStatus, jqXHR) {if (data["status"]=="logout"){isLog=false;$("#startBut").click();getJob();};}});});
}});}
