//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 index=0;var indexList = [];var indexNames=[];var idNum=1;$( document ).ready(function() {initUser();
$("#okDelete").click(function() {$.ajax({data: {"action": "deleteJob","nameUser":indexList[index]},type: "POST",dataType: "json",url: "ardoraXML.php",success: function(data, textStatus, jqXHR) {
var mensa = "";if (data["status"] == "Ok") {$("#men").css("color", "green"); mensa = "Ficha borrada"} else {$("#men").css("color", "red");mensa = "Error"}
$("#men").text(mensa);if (index>0) {index=0;indexList=[];initUser();} else{ window.open("../index.php", "_self");} timer = setTimeout("hideMen()", 3000);}});})
$("#b_close").click(function(){window.open("../index.php", "_self");})
$("#b_fullscreen").click(function (){if (isFull) {isFull=false;fullScreenCancel();}else{isFull=true;fullScreen()}})
$("#b_save").click(function() {$.ajax({data: {"action":"new","type": "1","nameUser":indexList[index],"idNum" : idNum.toString(),
"paragrafo5" : $("#paragrafo5").val(),"paragrafo8" : $("#paragrafo8").val(),"edit1" : $("#edit1").val(),"edit2" : $("#edit2").val(),"edit3" : $("#edit3").val(),
},type: "POST",dataType: "json",url: "../php/ardoraXML.php",
success: function(data, textStatus, jqXHR) {var mensa="";if (data["status"]=="Ok"){$("#men").css("color", "green");$("#buttonUp").css("visibility","visible"); mensa="Ficha de lectura gardada"} else {
$("#men").css("color", "red"); mensa="Error al grabar el archivo"} $("#men").text(mensa);timer = setTimeout("hideMen()", 3000);}
});});
$("#goRightBut").click(function() {index++;goArrows();});
$("#goLeftBut").click(function() {index--;goArrows();});
});
function initUser(){$.ajax({data: {"action": "getUser"},type: "POST",dataType: "json",url: "ardoraXML.php",
success: function(data, textStatus, jqXHR) {
if ($.trim(data["userType"]) == "profe" || $.trim(data["userType"]) == "admin") {$.ajax({data: {"action": "indexUsers"},type: "POST",dataType: "json",async: false,url: "ardoraXML.php",success: function(data, textStatus, jqXHR) {
$.each(data, function(k, v) { if (data[k] != "." && data[k] != "..") {indexList.push(data[k][0].substr(0, data[k][0].length - 4));indexNames.push(data[k][1]);}}); goArrows();}});makeMenu();} else{ $("body").html("");}}});}
function goItem(num) {index = num;goArrows();}
function goArrows() {$("#goRightBut").hide(); $("#goLeftBut").hide(); if (indexList.length > 0) {showItem(indexList[index],indexNames[index]); if (index > 0) {$("#goLeftBut").show()} if (index < indexList.length - 1) {$("#goRightBut").show()}}}
function makeMenu() {$("#buttonUp").html("");if (indexList.length > 0) {var newHtml = "<p id='menuBut' class='butfont butLe'>X</p><ul>";for (i = 0; i < indexList.length; i++) {
newHtml = newHtml + '<li class="submenu"><a href="javascript:goItem(' + i.toString() + ')">' + indexList[i] + '</a></li>';} newHtml = newHtml + "</ul>";$("#buttonUp").html(newHtml);}else{$("#pForm").remove();$("#buttonUpDele").remove();$("#b_save").remove();}}
function showItem(nameUser,nameFull) {$.ajax({data: {"action": "getUserData","nameUser":nameUser}, type: "POST",dataType: "json",url: "ardoraXML.php",
success: function(data, textStatus, jqXHR) {if ($.trim(data["tiUser"])=="1"){$("#d_userName").html("<b>&rArr; "+nameFull+"</b>");
$("#paragrafo5").text(data["paragrafo5"]);
$("#paragrafo8").text(data["paragrafo8"]);
$("#edit1").val(data["edit1"]);
$("#edit2").val(data["edit2"]);
$("#edit3").val(data["edit3"]);
} else{$("#buttonUp").css("visibility","hidden");}}});}
function hideMen(){$("#men").text("");clearTimeout(timer);}
function fullScreen() {var docElement,request;docElement = document.documentElement;request = docElement.requestFullScreen || docElement.webkitRequestFullScreen || docElement.mozRequestFullScreen || docElement.msRequestFullScreen;if(typeof request!="undefined" && request){request.call(docElement);}}
function fullScreenCancel() {var docElement, request;docElement=document;request = docElement.cancelFullScreen|| docElement.webkitCancelFullScreen || docElement.mozCancelFullScreen || docElement.msCancelFullScreen || docElement.exitFullscreen;if(typeof request!="undefined" && request){request.call(docElement);}}
