Commit 44805a53 by Luciano Barletta

changed scheme

1 parent 532400f7
<html lang="en">
<head>
<script src="./Scripts/construct.js"></script>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="./Style/Templates.css">
<link href="https://fonts.googleapis.com/css?family=Montserrat&display=swap" rel="stylesheet">
<title>Generador de Formularios</title>
<link rel="icon" href="./Assets/ICONO ANACSOFT 48 SIN TRASNSF.png"
type="image/png">
</head>
<body>
<h1> Generador de Formularios</h1>
<h3>Para comenzar por favor cree un nuevo tab</h3>
<br>
<div id="tabs"></div>
<div style="text-align: center;">
<button class="NewTabButton" onclick="addTab(document.getElementById('tabs'))">
+
</button>
</div>
<h3 id="ContinuarText">Cuando se encuentre conforme con el formulario presione Continuar</h3>
<button id="ContinuarButton"> Continuar </button>
</body>
<!-- templates -->
<template id="tabTemplate">
<div class="TabCards">
<input type="number" class="TabNumber">
<input class="TabTitle" placeholder="Titulo del Tab" type="text">
<button class="RemoveTabButton" onclick="removeTab(this)">
X
</button>
<br>
<div style="text-align: center;">
<button class="NewInputButton" onclick="addField(this)">
+
</button>
</div>
</div>
</template>
<template id="fieldTemplate">
<div class="InputContainer">
<input type="number" class="InputNumber">
<input type="text" id="Titulo" class="Input" placeholder="Título">
<select name="input" class="Input">
<option disabled selected value="">Input</option>
<option id="text" value="text">Texto</option>
<option id="number" value="number">Numero</option>
<option id="mail" value="mail">Mail</option>
<option id="password" value="password">Contraseña</option>
<option id="date" value="date">Fecha</option>
<option id="time" value="time">Hora</option>
<option id="textarea" value="textarea">Párrafo</option>
<option id="checkbox" value="checkbox">Selección</option>
</select>
Obligatorio : <input type="checkbox">
<button class="RemoveInputButton" onclick="removeField(this)">
-
</button>
</div>
</template>
</html>
\ No newline at end of file
/**
* Armado de formulario
*/
function removeField(b){
while(b.getAttribute("name") != "Field") b = b.parentElement;
if(b.nodeElement == "body") return;
b.parentElement.removeChild(b);
}
function addField(b){
let newfield = document.createElement("div");
newfield.setAttribute("name","Field");
newfield.innerHTML = document.getElementById("fieldTemplate").innerHTML;
let tab = b.parentElement;
// swap
tab.removeChild(b);
tab.appendChild(newfield);
tab.appendChild(b);
}
function removeTab(b){
while(b.getAttribute("name") != "Tab") b = b.parentElement;
if(b.nodeElement == "body") return;
b.parentElement.removeChild(b);
}
function addTab(t){
document.getElementById("ContinuarText").style.display = 'block';
document.getElementById("ContinuarButton").style.display = 'block';
let newtab = document.createElement("div");
newtab.setAttribute("name","Tab");
newtab.innerHTML = document.getElementById("tabTemplate").innerHTML;
t.appendChild(newtab);
}
/**
* Lectura de información y formateado
*/
function processField(field){
return {
'Title' : field.children[0],
'Input' : field.children[1].selectedOptions[0].value,
'Required' : field.children[2].checked,
};
}
function processTab(tab){
let dict = {};
for(let i = 0; i < tab.children.length; i++){
if (tab.children[i].getAttribute("name") == "Field"){
dict[i] = processField(tab.children[i]);
}
}
return dict;
}
function generate(tabs){
let dict = {};
for(let i = 0; i < tabs.children.length; i++){
if (tabs.children[i].getAttribute("name") == "Tab"){
dict[i] = processTab(tabs.children[i]);
}
}
console.log(JSON.stringify(dict));
}
function sortTabs(){
let tabs = document.getElementById("tabs");
Array.from(tabs.children).sort(
(a,b) => a.children[0].value < b.children[0].value ? -1 : a.children[0].value > b.children[0].value ? 1 : 0
).forEach(
c => tabs.appendChild(c)
)
}
function sortFields(tab){
Array.from(tab.children).sort(
(a,b) => a.children[0].value < b.children[0].value ? -1 : a.children[0].value > b.children[0].value ? 1 : 0
).forEach(
c => tabs.appendChild(c)
)
}
\ No newline at end of file
html{
font-family: 'Montserrat', sans-serif;
}
h1,h3{
text-align: center;
}
h1{
font-size: 40px;
}
body{
background-color: whitesmoke;
}
.TabCards{
background-color: white;
box-shadow: 2px 2px 5px #575757;
margin: 2% auto;
padding: 2%;
border-radius: 2px;
}
.TabTitle, .TabNumber{
color: grey;
margin-bottom: 5%;
font-size: 30px;
width: 84%;
text-align: left;
border:none;
border-bottom: 1px solid grey;
}
.TabNumber{
width: 10%;
}
.InputContainer{
width: 100%;
text-align: center;
}
.InputNumber{
width: 5%;
}
.Input,.InputNumber{
color: grey;
border:none;
border-bottom: 1px solid grey;
width: 25%;
margin: 1%;
}
.InputNumber{
width: 5%;
}
.NewTabButton, .NewInputButton, .RemoveInputButton, .RemoveTabButton{
text-align: center;
margin: auto;
color: whitesmoke;
border-radius: 50%;
}
.NewTabButton{
font-size:45px;
width: 90px;
height: 90px;
border: 3px solid rgb(0, 88, 170);
background-color: rgb(0, 102, 255);
}
.NewInputButton {
font-size: 25px;
width: 40px;
height: 40px;
margin: 1%;
border: 3px solid rgb(1, 194, 120);
background-color: rgb(14, 211, 135);
}
.RemoveInputButton, .RemoveTabButton{
width: 35px;
height: 35px;
margin: 1%;
font-size: 20px;
border: 3px solid rgb(230, 25, 25);
background-color: rgba(211, 14, 14, 0.788);
}
.RemoveTabButton{
width: 40px;
height: 40px;
}
#ContinuarText, #ContinuarButton{
display: none;
}
#ContinuarButton{
font-size: 20px;
border: none;
background-color: rgb(1, 194, 120);
color: rgb(255, 255, 255);
margin: 2%;
text-align: center;
width: 96%;
height: 2.5em;
border-radius: 5px;
}
@media ( max-width: 1050px) {
.TabNumber{
width: 10%;
}
.TabTitle{
width: 80%;
}
}
@media (max-width: 600px) {
.TabNumber{
width: 10%;
}
.TabTitle{
width:75%;
}
.RemoveInputButton{
width: 30px;
height: 30px;
}
.RemoveTabButton{
width: 30px;
height: 30px;
}
.Input{
width: 16%;
margin: none;
}
}
@media ( max-width: 350px) {
.TabNumber{
width: 10%;
}
.TabTitle{
width:70%;
}
.RemoveInputButton{
width: 30px;
height: 30px;
}
.RemoveTabButton{
width: 30px;
height: 30px;
}
.Input{
width: 15%;
margin: 0%;
}
}
\ No newline at end of file
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!