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 e8e2302a
authored
2019-11-22 13:37:44 +0000
by
Luciano Barletta
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
generate json
1 parent
edd14dee
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
3 deletions
static/Scripts/construct.js
templates/generate.html
static/Scripts/construct.js
View file @
e8e2302
/**
* Armado de formulario
*/
function
removeField
(
b
){
function
removeField
(
b
){
let
div
=
b
.
parentElement
;
let
div
=
b
.
parentElement
;
let
tab
=
div
.
parentElement
;
let
tab
=
div
.
parentElement
;
...
@@ -5,7 +8,8 @@ function removeField(b){
...
@@ -5,7 +8,8 @@ function removeField(b){
}
}
function
addField
(
b
){
function
addField
(
b
){
let
newfield
=
document
.
createElement
(
"div"
)
let
newfield
=
document
.
createElement
(
"div"
);
newfield
.
setAttribute
(
"name"
,
"Field"
);
newfield
.
innerHTML
=
document
.
getElementById
(
"fieldTemplate"
).
innerHTML
;
newfield
.
innerHTML
=
document
.
getElementById
(
"fieldTemplate"
).
innerHTML
;
b
.
parentElement
.
appendChild
(
newfield
);
b
.
parentElement
.
appendChild
(
newfield
);
}
}
...
@@ -17,7 +21,40 @@ function removeTab(b){
...
@@ -17,7 +21,40 @@ function removeTab(b){
}
}
function
addTab
(
t
){
function
addTab
(
t
){
let
newtab
=
document
.
createElement
(
"div"
)
let
newtab
=
document
.
createElement
(
"div"
);
newtab
.
setAttribute
(
"name"
,
"Tab"
);
newtab
.
innerHTML
=
document
.
getElementById
(
"tabTemplate"
).
innerHTML
;
newtab
.
innerHTML
=
document
.
getElementById
(
"tabTemplate"
).
innerHTML
;
t
.
appendChild
(
newtab
);
t
.
appendChild
(
newtab
);
}
\ No newline at end of file
\ No newline at end of file
}
/**
* 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
));
}
templates/generate.html
View file @
e8e2302
...
@@ -14,6 +14,12 @@
...
@@ -14,6 +14,12 @@
<button
onclick=
"addTab(document.getElementById('tabs'))"
>
<button
onclick=
"addTab(document.getElementById('tabs'))"
>
+
+
</button>
</button>
<br>
<br>
<button
onclick=
"generate(document.getElementById('tabs'))"
>
Generar
</button>
</body>
</body>
<!-- templates -->
<!-- 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