Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
purr-data
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sanket Bhukan
purr-data
Commits
7c98463e
Commit
7c98463e
authored
7 years ago
by
Jonathan Wilkes
Browse files
Options
Downloads
Patches
Plain Diff
update the external dialog interface, adding input type argument
parent
ff36e03a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pd/nw/dialog_external.html
+53
-34
53 additions, 34 deletions
pd/nw/dialog_external.html
with
53 additions
and
34 deletions
pd/nw/dialog_external.html
+
53
−
34
View file @
7c98463e
...
...
@@ -86,30 +86,33 @@ function ok() {
// value: a value for the input
function
parse_attrs
(
attrs
)
{
var
ret
=
[],
elem
;
attrs
.
forEach
(
function
(
token
,
i
)
{
if
(
i
%
2
===
0
)
{
elem
=
{};
token
=
token
.
split
(
"
_
"
);
if
(
token
.
length
>
1
)
{
elem
.
type
=
token
[
token
.
length
-
1
];
if
(
elem
.
type
!==
"
symbol
"
&&
elem
.
type
!==
"
toggle
"
)
{
// no suffix defaults to "number"
elem
.
type
=
"
number
"
;
elem
,
gate
=
false
;
attrs
.
forEach
(
function
(
attr
,
i
)
{
if
(
i
%
3
===
0
)
{
elem
=
gate
?
elem
:
{};
gate
=
attr
===
"
enum
"
;
elem
.
type
=
attr
;
}
else
if
(
i
%
3
===
1
)
{
elem
.
name
=
attr
;
elem
.
label
=
attr
.
replace
(
"
_
"
,
"
"
);
}
else
{
if
(
elem
.
type
===
"
enum
"
)
{
if
(
elem
.
value
)
{
elem
.
value
.
push
(
attr
);
}
else
{
// remove the type suffix
token
=
token
.
slice
(
0
,
-
1
);
elem
.
value
=
[
attr
];
}
}
else
if
(
elem
.
type
===
"
enum_index
"
)
{
elem
.
index
=
attr
;
}
else
{
elem
.
type
=
"
number
"
;
elem
.
value
=
attr
;
}
elem
.
name
=
token
.
join
(
"
_
"
);
elem
.
label
=
token
.
join
(
"
"
);
}
else
{
elem
.
value
=
token
;
// now push the object onto the array
ret
.
push
(
elem
);
if
(
elem
.
type
!==
"
enum
"
)
{
elem
.
type
=
elem
.
type
===
"
enum_index
"
?
"
enum
"
:
elem
.
type
;
ret
.
push
(
elem
);
}
}
});
return
ret
;
...
...
@@ -134,7 +137,7 @@ function register_window_id(gfxstub, args) {
translate_form
();
build_form
(
external_name
,
array_of_objects
);
fud
=
array_of_objects
;
// We don't turn on rendering of the "container" div until
// We've finished displaying all the spans and populating the
// labels and form elements. That makes it more efficient and
...
...
@@ -160,7 +163,10 @@ function translate_form() {
function
get_input_type
(
t
)
{
return
t
===
"
symbol
"
?
"
text
"
:
t
===
"
number
"
?
"
text
"
:
t
===
"
int
"
?
"
text
"
:
t
===
"
float
"
?
"
text
"
:
t
===
"
color
"
?
"
color
"
:
t
===
"
enum
"
?
"
select
"
:
t
===
"
toggle
"
?
"
checkbox
"
:
"
text
"
;
}
...
...
@@ -168,23 +174,36 @@ function get_input_type(t) {
function
build_form
(
external_name
,
array_of_objects
)
{
var
fieldset
=
document
.
querySelector
(
"
fieldset
"
);
document
.
querySelector
(
"
legend
"
).
textContent
=
external_name
;
array_of_objects
.
forEach
(
function
(
elem
)
{
var
input_elem
=
document
.
createElement
(
"
input
"
),
label
=
document
.
createElement
(
"
label
"
);
input_elem
.
type
=
get_input_type
(
elem
.
type
);
if
(
input_elem
.
type
===
"
checkbox
"
)
{
input_elem
.
checked
=
elem
.
value
!==
0
;
input_elem
.
onchange
=
function
()
{
elem
.
value
=
input_elem
.
checked
?
1
:
0
;
array_of_objects
.
forEach
(
function
(
ob
)
{
var
elem
,
label
,
type
=
get_input_type
(
ob
.
type
);
if
(
type
===
"
select
"
)
{
elem
=
document
.
createElement
(
"
select
"
);
ob
.
value
.
forEach
(
function
(
e
)
{
var
option
=
document
.
createElement
(
"
option
"
);
option
.
textContent
=
e
;
elem
.
appendChild
(
option
);
});
elem
.
selectedIndex
=
ob
.
index
;
}
else
if
(
type
===
"
checkbox
"
)
{
elem
=
document
.
createElement
(
"
input
"
);
elem
.
type
=
"
checkbox
"
;
elem
.
checked
=
ob
.
value
!==
0
;
elem
.
onchange
=
function
()
{
ob
.
value
=
elem
.
checked
?
1
:
0
;
};
}
else
{
input_elem
.
value
=
elem
.
value
;
input_elem
.
onchange
=
function
()
{
elem
.
value
=
input_elem
.
value
;
elem
=
document
.
createElement
(
"
input
"
);
elem
.
type
=
type
;
elem
.
value
=
ob
.
value
;
elem
.
onchange
=
function
()
{
ob
.
value
=
elem
.
value
;
}
}
label
.
textContent
=
elem
.
label
;
label
.
appendChild
(
input_elem
);
label
=
document
.
createElement
(
"
label
"
);
label
.
textContent
=
ob
.
label
;
label
.
appendChild
(
elem
);
fieldset
.
appendChild
(
label
);
// stop-gap until we make this prettier through css: insert a break
fieldset
.
appendChild
(
document
.
createElement
(
"
br
"
));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment