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 a7db7f62
authored
2019-11-26 14:20:42 +0000
by
Luciano Barletta
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
generation complete
1 parent
f873b0cc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
18 deletions
Luciano/static/Scripts/construct.js
Luciano/templates/generate.html
Luciano/static/Scripts/construct.js
View file @
a7db7f6
...
...
@@ -13,13 +13,12 @@ var getAncestorByAttribute = (elem,attr,val) => {
}
var
getDescendantByAttribute
=
(
elem
,
attr
,
val
)
=>
{
if
(
elem
.
getAttribute
(
attr
)
==
val
)
return
elem
;
Array
.
from
(
elem
.
children
).
reduce
(
(
a
,
b
)
=>
{
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
?
x
:
y
;
});
return
null
;
return
x
==
null
?
y
:
x
;
},
null
);
}
/**
...
...
@@ -61,28 +60,34 @@ function addTab(t,n){
* 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
));
...
...
@@ -104,6 +109,6 @@ function maxChild(container,number){
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/templates/generate.html
View file @
a7db7f6
...
...
@@ -24,7 +24,7 @@
</button>
</div>
<h3
id=
"ContinuarText"
>
Cuando se encuentre conforme con el formulario presione Continuar
</h3>
<button
id=
"ContinuarButton"
>
Continuar
</button>
<button
id=
"ContinuarButton"
onclick=
"generate(document.getElementById('tabs'))"
>
Continuar
</button>
</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