Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
f4055efd
Commit
f4055efd
authored
May 27, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(mvc) use $.each for array iteration.... (fix for
https://github.com/opnsense/core/issues/195
)
parent
55bee2fd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
42 deletions
+43
-42
opnsense.js
src/opnsense/www/js/opnsense.js
+43
-42
No files found.
src/opnsense/www/js/opnsense.js
View file @
f4055efd
...
...
@@ -45,39 +45,40 @@ function getFormData(parent) {
// we need an id.
return
;
}
var
node
=
data
;
var
keyparts
=
$
(
this
).
prop
(
'
id
'
).
split
(
'
.
'
);
for
(
var
i
in
keyparts
)
{
if
(
!
(
keyparts
[
i
]
in
node
))
{
node
[
keyparts
[
i
]]
=
{};
}
if
(
i
<
keyparts
.
length
-
1
)
{
node
=
node
[
keyparts
[
i
]];
var
node
=
data
;
// target node
var
sourceNode
=
$
(
this
);
// document node to fetch data from
var
keyparts
=
sourceNode
.
prop
(
'
id
'
).
split
(
'
.
'
);
$
.
each
(
keyparts
,
function
(
indx
,
keypart
){
if
(
!
(
keypart
in
node
))
{
node
[
keypart
]
=
{};
}
if
(
indx
<
keyparts
.
length
-
1
)
{
node
=
node
[
keypart
];
}
else
{
if
(
$
(
this
)
.
is
(
"
select
"
))
{
if
(
sourceNode
.
is
(
"
select
"
))
{
// selectbox, collect selected items
var
tmp_str
=
""
;
$
(
this
)
.
children
().
each
(
function
(
index
){
sourceNode
.
children
().
each
(
function
(
index
){
if
(
$
(
this
).
prop
(
"
selected
"
)){
if
(
tmp_str
!=
""
)
tmp_str
=
tmp_str
+
"
,
"
;
tmp_str
=
tmp_str
+
$
(
this
)
.
val
();
tmp_str
=
tmp_str
+
sourceNode
.
val
();
}
});
node
[
keypart
s
[
i
]
]
=
tmp_str
;
}
else
if
(
$
(
this
)
.
prop
(
"
type
"
)
==
"
checkbox
"
)
{
node
[
keypart
]
=
tmp_str
;
}
else
if
(
sourceNode
.
prop
(
"
type
"
)
==
"
checkbox
"
)
{
// checkbox input type
if
(
$
(
this
)
.
prop
(
"
checked
"
))
{
node
[
keypart
s
[
i
]
]
=
1
;
if
(
sourceNode
.
prop
(
"
checked
"
))
{
node
[
keypart
]
=
1
;
}
else
{
node
[
keypart
s
[
i
]
]
=
0
;
node
[
keypart
]
=
0
;
}
}
else
{
// regular input type
node
[
keyparts
[
i
]]
=
$
(
this
).
val
();
}
node
[
keypart
]
=
sourceNode
.
val
();
}
}
});
});
return
data
;
}
...
...
@@ -101,39 +102,39 @@ function setFormData(parent,data) {
return
;
}
var
node
=
data
;
var
targetNode
=
$
(
this
);
// document node to fetch data to
var
keyparts
=
$
(
this
).
prop
(
'
id
'
).
split
(
'
.
'
);
for
(
var
i
in
keyparts
)
{
if
(
!
(
keyparts
[
i
]
in
node
))
{
break
;
}
if
(
i
<
keyparts
.
length
-
1
)
{
node
=
node
[
keyparts
[
i
]];
$
.
each
(
keyparts
,
function
(
indx
,
keypart
){
if
(
keypart
in
node
)
{
if
(
indx
<
keyparts
.
length
-
1
)
{
node
=
node
[
keypart
];
}
else
{
// data node found, handle per type
if
(
$
(
this
)
.
is
(
"
select
"
))
{
if
(
targetNode
.
is
(
"
select
"
))
{
// handle select boxes
$
(
this
)
.
empty
();
// flush
for
(
var
key
in
node
[
keyparts
[
i
]])
{
if
(
node
[
keyparts
[
i
]][
key
]
[
"
selected
"
]
!=
"
0
"
)
{
$
(
this
).
append
(
"
<option value='
"
+
key
+
"
' selected>
"
+
node
[
keyparts
[
i
]][
key
]
[
"
value
"
]
+
"
</option>
"
);
targetNode
.
empty
();
// flush
$
.
each
(
node
[
keypart
],
function
(
indxItem
,
keyItem
)
{
if
(
keyItem
[
"
selected
"
]
!=
"
0
"
)
{
targetNode
.
append
(
"
<option value='
"
+
indxItem
+
"
' selected>
"
+
keyItem
[
"
value
"
]
+
"
</option>
"
);
}
else
{
$
(
this
).
append
(
"
<option value='
"
+
key
+
"
'>
"
+
node
[
keyparts
[
i
]][
key
][
"
value
"
]
+
"
</option>
"
);
}
targetNode
.
append
(
"
<option value='
"
+
indxItem
+
"
'>
"
+
keyItem
[
"
value
"
]
+
"
</option>
"
);
}
}
else
if
(
$
(
this
).
prop
(
"
type
"
)
==
"
checkbox
"
)
{
});
}
else
if
(
targetNode
.
prop
(
"
type
"
)
==
"
checkbox
"
)
{
// checkbox type
if
(
node
[
keyparts
[
i
]
]
!=
0
)
{
$
(
this
)
.
prop
(
"
checked
"
,
true
)
;
if
(
node
[
keypart
]
!=
0
)
{
targetNode
.
prop
(
"
checked
"
,
true
)
;
}
else
{
$
(
this
)
.
prop
(
"
checked
"
,
false
)
;
targetNode
.
prop
(
"
checked
"
,
false
)
;
}
}
else
{
// regular input type
$
(
this
).
val
(
node
[
keyparts
[
i
]
]);
targetNode
.
val
(
node
[
keypart
]);
}
}
}
});
});
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment