<?php 
	/*$token = $_GET['token'];
	
	if(!empty($token)){
		
	}else{
		header("Location: https://artefeitoscrap.com.br/admin");
	} */
?>
<!DOCTYPE html>
<html lang="pt-br">
<head>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Importação</title>
	<link rel="stylesheet" href="./assets/style.css">
	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
	<div class="content">
		<form id="frm" enctype="multipart/form-data">
			<small>(Adicione um arquivo para importação clicando na caixa.)</small>
			<label id="thumbnail" title="Clique aqui para adicionar um arquivo.">
				<input type="file" name="file_arquivo" id="file_arquivo"  onchange="getFileExtension2(this.value);"  required>
				<input type="hidden" name="token" value="<?= $token; ?>" required>
			</label>
			<button type="button" name="BTNINPORT" id="BTNINPORT" onclick="upar();" ><i class="fa fa-upload"></i> IMPORTAR AGORA</button>
			<button id="BTNINPORT10" disabled style="display: none" ><i class="fa fa-refresh fa-spin fa-3x fa-fw"></i></button>
		</form>
	</div>
	<script>
		function getFileExtension2(filename) {
		  var ab = filename.split('.').pop();
		  
		  if(ab == "xml"){
			  
		  }else{
			  document.getElementById('file_arquivo').value = "";
			  alert("Arquivo Invalido, insira um arquivo no formato XML.");
		  }		  
		}
		function clickteste(){
			   var formData = document.getElementById('file_arquivo');
alert(formData);
		//	document.getElementById("BTNINPORT").style.display = "none";
			//document.getElementById("BTNINPORT10").style.display = "block";
			
			
		}
		
	</script>
	<script>
		function upar(){
			var e = $("#frm");
			e.preventDefault();
		  var formulario = new FormData(this);

		  var files = $(":file");
			console.log(files[0].value);	
			console.log(files[1].value);
		
			if (window.XMLHttpRequest){
				xmlhttp = new XMLHttpRequest();
			} else {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			xmlhttp.open("GET", "wew.xml", false);
			xmlhttp.send();
			xmlDoc = xmlhttp.responseXML;
			document.write("<table border='1'>");
			let x = xmlDoc.getElementsByTagName("Row");
				alert(x.length);

			
			for (let i = 0; i < x.length; i++){
				document.write("<tr><td>");
				document.write("Artista: " + x[i].getElementsByTagName("Data")[0].childNodes[0].nodeValue);
				document.write("</br>")
				document.write("Disco: " + x[i].getElementsByTagName("Data")[0].childNodes[0].nodeValue);
				document.write("</td></tr>");
			}
			document.write("</table>");
		}
	</script>
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

	
</body>
</html>