Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Luciano Barletta
/
mini-web
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit 7f6606ea
authored
2019-11-26 14:50:18 +0000
by
Luciano Barletta
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
merge
1 parent
0bef61b1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
233 additions
and
86 deletions
Geo/Scripts/construct.js
Luciano/static/Scripts/ArmadoDeForm.js
Luciano/static/Style/ArmadoDeForm.css
Luciano/static/Style/Templates.css
Luciano/templates/generate.html
Geo/Scripts/construct.js
View file @
7f6606e
/**
* Lambdas
*/
var
accessNumber
=
e
=>
{
if
(
e
.
childElementCount
==
0
)
return
0
;
if
(
e
.
children
[
0
].
childElementCount
==
0
)
return
0
;
return
e
.
children
[
0
].
children
[
0
];
}
var
getAncestorByAttribute
=
(
elem
,
attr
,
val
)
=>
{
while
(
elem
.
getAttribute
(
attr
)
!=
val
||
elem
==
null
)
elem
=
elem
.
parentElement
;
return
elem
;
}
var
getDescendantByAttribute
=
(
elem
,
attr
,
val
)
=>
{
if
(
elem
==
null
||
elem
.
getAttribute
(
attr
)
==
val
)
return
elem
;
return
Array
.
from
(
elem
.
children
).
reduce
(
(
a
,
b
)
=>
{
let
x
=
getDescendantByAttribute
(
a
,
attr
,
val
);
let
y
=
getDescendantByAttribute
(
b
,
attr
,
val
);
return
x
==
null
?
y
:
x
;
},
null
);
}
/**
* Armado de formulario
*/
function
removeField
(
b
){
while
(
b
.
getAttribute
(
"name"
)
!=
"Field"
)
b
=
b
.
parentElement
;
if
(
b
.
nodeElement
==
"body"
)
return
;
b
.
parentElement
.
removeChild
(
b
);
function
removeTab
(
button
){
let
tabs
=
document
.
getElementById
(
'tabs'
)
tabs
.
removeChild
(
getAncestorByAttribute
(
button
,
'name'
,
'Tab'
)
)
if
(
tabs
.
childElementCount
==
0
){
document
.
getElementById
(
"ContinuarText"
).
style
.
display
=
'none'
;
document
.
getElementById
(
"ContinuarButton"
).
style
.
display
=
'none'
;
}
}
function
addField
(
b
){
function
addField
(
b
,
n
){
let
newfield
=
document
.
createElement
(
"div"
);
newfield
.
setAttribute
(
"name"
,
"Field"
);
newfield
.
innerHTML
=
document
.
getElementById
(
"fieldTemplate"
).
innerHTML
;
let
tab
=
b
.
parentElement
;
accessNumber
(
newfield
).
setAttribute
(
"value"
,
n
)
;
// 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
);
let
container
=
b
.
parentElement
;
container
.
appendChild
(
newfield
);
container
.
appendChild
(
b
);
}
function
addTab
(
t
){
function
addTab
(
t
,
n
){
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
;
accessNumber
(
newtab
).
setAttribute
(
"value"
,
n
);
t
.
appendChild
(
newtab
);
}
/**
* Lectura de información y formateado
*/
function
processField
(
field
){
let
data
=
field
.
children
[
0
];
return
{
'Title'
:
field
.
children
[
0
]
,
'Input'
:
field
.
children
[
1
].
selectedOptions
[
0
].
value
,
'Required'
:
field
.
children
[
2
].
checked
,
'Title'
:
data
.
children
[
1
].
value
,
'Input'
:
data
.
children
[
2
].
selectedOptions
[
0
].
value
,
'Required'
:
data
.
children
[
3
].
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
]);
let
dict
=
[];
let
container
=
getDescendantByAttribute
(
tab
,
"name"
,
"Field"
).
parentElement
;
for
(
let
i
=
0
;
i
<
container
.
children
.
length
;
i
++
){
if
(
container
.
children
[
i
].
getAttribute
(
"name"
)
==
"Field"
)
{
dict
.
push
(
processField
(
container
.
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
]);
let
dict
=
[];
for
(
let
i
=
0
;
i
<
tabs
.
children
.
length
;
i
++
)
{
let
c
=
tabs
.
children
[
i
];
if
(
c
.
getAttribute
(
"name"
)
==
"Tab"
)
{
dict
.
push
({
"Title"
:
getDescendantByAttribute
(
c
,
"class"
,
"TabTitle"
).
value
,
"Fields"
:
processTab
(
c
),
});
}
}
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
function
sortChildren
(
container
,
number
){
let
fixinput
=
a
=>
number
(
a
).
nodeName
==
"INPUT"
&&
number
(
a
).
type
==
"number"
?
parseInt
(
number
(
a
).
value
)
:
Infinity
;
Array
.
from
(
container
.
children
).
sort
(
(
a
,
b
)
=>
fixinput
(
a
)
<
fixinput
(
b
)
?
-
1
:
fixinput
(
a
)
>
fixinput
(
b
)
?
1
:
0
).
forEach
(
c
=>
tabs
.
appendChild
(
c
)
c
=>
container
.
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
)
)
function
maxChild
(
container
,
number
){
let
fixinput
=
a
=>
number
(
a
).
nodeName
==
"INPUT"
&&
number
(
a
).
type
==
"number"
?
parseInt
(
number
(
a
).
value
)
:
0
;
if
(
container
.
childElementCount
==
0
)
return
0
;
let
max
=
Array
.
from
(
container
.
children
).
reduce
(
(
a
,
b
)
=>
fixinput
(
a
)
>
fixinput
(
b
)
?
a
:
b
);
return
fixinput
(
max
);
}
\ No newline at end of file
Luciano/static/Scripts/ArmadoDeForm.js
0 → 100644
View file @
7f6606e
function
ArmarForm
()
{
document
.
getElementById
(
"ArmarFormContainer"
).
style
.
display
=
"none"
;
document
.
getElementById
(
"BotonesContainer"
).
style
.
display
=
"block"
;
document
.
getElementById
(
"TabsContainer"
).
style
.
display
=
"block"
;
let
m
=
document
.
getElementById
(
"CantBotones"
).
value
;
let
n
;
for
(
n
=
0
;
n
<
m
;
n
++
)
{
let
padreBotones
=
document
.
getElementById
(
"BotonesContainer"
);
let
padreTabs
=
document
.
getElementById
(
"TabsContainer"
);
let
boton
=
document
.
createElement
(
"Button"
);
padreBotones
.
appendChild
(
boton
);
boton
.
setAttribute
(
"id"
,
"Boton"
+
n
);
boton
.
setAttribute
(
"value"
,
n
);
boton
.
setAttribute
(
"class"
,
"Botones"
);
boton
.
addEventListener
(
"click"
,
HabilitarTab
);
let
ancho
=
((
100
-
(
0.2
*
m
))
/
m
)
+
"%"
;
boton
.
style
.
width
=
ancho
;
let
tab
=
document
.
createElement
(
"div"
);
padreTabs
.
appendChild
(
tab
);
tab
.
style
.
width
=
ancho
*
m
;
tab
.
setAttribute
(
"id"
,
"Tab"
+
n
);
tab
.
setAttribute
(
"class"
,
"Tabs"
);
}
document
.
getElementById
(
"Tab0"
).
style
.
display
=
"block"
;
}
function
HabilitarTab
()
{
for
(
n
=
0
;
n
<
m
;
n
++
)
{
document
.
getElementById
(
"Tab"
+
n
).
style
.
display
=
"none"
if
(
doc
){}
}
}
\ No newline at end of file
Luciano/static/Style/ArmadoDeForm.css
0 → 100644
View file @
7f6606e
html
{
--Color
:
rgb
(
122
,
230
,
163
);
}
#BotonesContainer
{
width
:
100%
;
height
:
5%
;
}
#TabsContainer
{
width
:
100%
;
height
:
95%
;
}
.Botones
{
border-radius
:
5px
5px
0px
0px
;
background-color
:
rgb
(
168
,
168
,
168
);
border
:
none
;
height
:
100%
;
margin
:
0.1%
;
}
.Botones
:active
{
background-color
:
var
(
--Color
);
border-bottom
:
none
;
height
:
6%
;
border-bottom
:
none
;
}
.Botones
:hover
{
background-color
:
rgb
(
53
,
53
,
53
),
0.5
;
}
.Tabs
{
display
:
none
;
height
:
100%
;
border
:
3px
solid
var
(
--Color
);
}
\ No newline at end of file
Luciano/static/Style/Templates.css
View file @
7f6606e
html
{
html
{
font-family
:
'Montserrat'
,
sans-serif
;
}
h1
,
h3
{
h1
,
h3
{
text-align
:
center
;
}
h1
{
h1
{
font-size
:
40px
;
}
body
{
body
{
background-color
:
whitesmoke
;
}
.TabCards
{
.TabCards
{
background-color
:
white
;
box-shadow
:
2px
2px
5px
#575757
;
margin
:
2%
auto
;
padding
:
2%
;
border-radius
:
2px
;
}
.TabTitle
,
.TabNumber
{
.TabTitle
,
.TabNumber
{
color
:
grey
;
margin-bottom
:
5%
;
font-size
:
30px
;
width
:
84%
;
text-align
:
left
;
border
:
none
;
border
:
none
;
border-bottom
:
1px
solid
grey
;
}
.TabNumber
{
.TabNumber
{
width
:
10%
;
}
.InputContainer
{
.InputContainer
{
width
:
100%
;
text-align
:
center
;
}
.InputNumber
{
.InputNumber
{
width
:
5%
;
}
.Input
,
.InputNumber
{
.Input
,
.InputNumber
{
color
:
grey
;
border
:
none
;
border
:
none
;
border-bottom
:
1px
solid
grey
;
width
:
25%
;
margin
:
1%
;
font-size
:
15px
;
}
.InputNumber
{
.InputNumber
{
width
:
5%
;
}
.NewTabButton
,
.NewInputButton
,
.RemoveInputButton
,
.RemoveTabButton
{
.NewTabButton
,
.NewInputButton
,
.RemoveInputButton
,
.RemoveTabButton
{
text-align
:
center
;
margin
:
auto
;
color
:
whitesmoke
;
border-radius
:
50%
;
}
.NewTabButton
{
font-size
:
45px
;
width
:
90px
;
height
:
90px
;
.NewTabButton
{
font-size
:
45px
;
width
:
70px
;
height
:
70px
;
border
:
3px
solid
rgb
(
0
,
88
,
170
);
background-color
:
rgb
(
0
,
102
,
255
);
}
.NewInputButton
{
font-size
:
25px
;
width
:
40px
;
...
...
@@ -70,7 +90,9 @@ body{
border
:
3px
solid
rgb
(
1
,
194
,
120
);
background-color
:
rgb
(
14
,
211
,
135
);
}
.RemoveInputButton
,
.RemoveTabButton
{
.RemoveInputButton
,
.RemoveTabButton
{
width
:
35px
;
height
:
35px
;
margin
:
1%
;
...
...
@@ -78,15 +100,18 @@ body{
border
:
3px
solid
rgb
(
230
,
25
,
25
);
background-color
:
rgba
(
211
,
14
,
14
,
0.788
);
}
.RemoveTabButton
{
.RemoveTabButton
{
width
:
40px
;
height
:
40px
;
}
#ContinuarText
,
#ContinuarButton
{
}
#ContinuarText
,
#ContinuarButton
{
display
:
none
;
}
#ContinuarButton
{
#ContinuarButton
{
font-size
:
20px
;
border
:
none
;
background-color
:
rgb
(
1
,
194
,
120
);
...
...
@@ -98,53 +123,63 @@ body{
border-radius
:
5px
;
}
@media
(
max-width
:
1050px
)
{
.TabNumber
{
@media
(
max-width
:
1050px
)
{
.TabNumber
{
width
:
10%
;
}
.TabTitle
{
.TabTitle
{
width
:
80%
;
}
}
@media
(
max-width
:
600px
)
{
.TabNumber
{
@media
(
max-width
:
600px
)
{
.TabNumber
{
width
:
10%
;
}
.TabTitle
{
width
:
75%
;
.TabTitle
{
width
:
75%
;
}
.RemoveInputButton
{
.RemoveInputButton
{
width
:
30px
;
height
:
30px
;
}
.RemoveTabButton
{
.RemoveTabButton
{
width
:
30px
;
height
:
30px
;
}
.Input
{
.Input
{
width
:
16%
;
margin
:
none
;
}
}
@media
(
max-width
:
350px
)
{
.TabNumber
{
@media
(
max-width
:
400px
)
{
.TabNumber
{
width
:
10%
;
}
.TabTitle
{
width
:
70%
;
.TabTitle
{
width
:
70%
;
}
.RemoveInputButton
{
width
:
30px
;
height
:
30px
;
.RemoveInputButton
{
width
:
25px
;
height
:
25px
;
font-size
:
15px
;
}
.RemoveTabButton
{
.RemoveTabButton
{
width
:
30px
;
height
:
30px
;
}
.Input
{
.Input
{
width
:
15%
;
margin
:
0%
;
}
...
...
Luciano/templates/generate.html
View file @
7f6606e
...
...
@@ -13,6 +13,7 @@
</head>
<body>
<section
id=
"ArmarFormContainer"
>
<h1>
Generador de Formularios
</h1>
<h3>
Para comenzar por favor cree un nuevo tab
</h3>
<br>
...
...
@@ -25,6 +26,11 @@
</div>
<h3
id=
"ContinuarText"
>
Cuando se encuentre conforme con el formulario presione Continuar
</h3>
<button
id=
"ContinuarButton"
onclick=
"generate(document.getElementById('tabs'))"
>
Continuar
</button>
</section>
<section
id=
"BotonesContainer"
style=
"display: none;"
>
</section>
<section
id=
"TabsContainer"
style=
"display: none;"
>
</section>
</body>
<!-- templates -->
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment