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
Hide 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,38 +45,39 @@ function getFormData(parent) {
...
@@ -45,38 +45,39 @@ function getFormData(parent) {
// we need an id.
// we need an id.
return
;
return
;
}
}
var
node
=
data
;
var
node
=
data
;
// target node
var
keyparts
=
$
(
this
).
prop
(
'
id
'
).
split
(
'
.
'
);
var
sourceNode
=
$
(
this
);
// document node to fetch data from
for
(
var
i
in
keyparts
)
{
var
keyparts
=
sourceNode
.
prop
(
'
id
'
).
split
(
'
.
'
);
if
(
!
(
keyparts
[
i
]
in
node
))
{
$
.
each
(
keyparts
,
function
(
indx
,
keypart
){
node
[
keyparts
[
i
]]
=
{};
if
(
!
(
keypart
in
node
))
{
node
[
keypart
]
=
{};
}
}
if
(
i
<
keyparts
.
length
-
1
)
{
if
(
i
ndx
<
keyparts
.
length
-
1
)
{
node
=
node
[
keypart
s
[
i
]
];
node
=
node
[
keypart
];
}
else
{
}
else
{
if
(
$
(
this
)
.
is
(
"
select
"
))
{
if
(
sourceNode
.
is
(
"
select
"
))
{
// selectbox, collect selected items
// selectbox, collect selected items
var
tmp_str
=
""
;
var
tmp_str
=
""
;
$
(
this
)
.
children
().
each
(
function
(
index
){
sourceNode
.
children
().
each
(
function
(
index
){
if
(
$
(
this
).
prop
(
"
selected
"
)){
if
(
$
(
this
).
prop
(
"
selected
"
)){
if
(
tmp_str
!=
""
)
tmp_str
=
tmp_str
+
"
,
"
;
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
;
node
[
keypart
]
=
tmp_str
;
}
else
if
(
$
(
this
)
.
prop
(
"
type
"
)
==
"
checkbox
"
)
{
}
else
if
(
sourceNode
.
prop
(
"
type
"
)
==
"
checkbox
"
)
{
// checkbox input type
// checkbox input type
if
(
$
(
this
)
.
prop
(
"
checked
"
))
{
if
(
sourceNode
.
prop
(
"
checked
"
))
{
node
[
keypart
s
[
i
]
]
=
1
;
node
[
keypart
]
=
1
;
}
else
{
}
else
{
node
[
keypart
s
[
i
]
]
=
0
;
node
[
keypart
]
=
0
;
}
}
}
else
{
}
else
{
// regular input type
// regular input type
node
[
keypart
s
[
i
]]
=
$
(
this
)
.
val
();
node
[
keypart
]
=
sourceNode
.
val
();
}
}
}
}
}
}
);
});
});
return
data
;
return
data
;
...
@@ -101,38 +102,38 @@ function setFormData(parent,data) {
...
@@ -101,38 +102,38 @@ function setFormData(parent,data) {
return
;
return
;
}
}
var
node
=
data
;
var
node
=
data
;
var
targetNode
=
$
(
this
);
// document node to fetch data to
var
keyparts
=
$
(
this
).
prop
(
'
id
'
).
split
(
'
.
'
);
var
keyparts
=
$
(
this
).
prop
(
'
id
'
).
split
(
'
.
'
);
for
(
var
i
in
keyparts
)
{
$
.
each
(
keyparts
,
function
(
indx
,
keypart
){
if
(
!
(
keyparts
[
i
]
in
node
))
{
if
(
keypart
in
node
)
{
break
;
if
(
indx
<
keyparts
.
length
-
1
)
{
}
node
=
node
[
keypart
];
if
(
i
<
keyparts
.
length
-
1
)
{
}
else
{
node
=
node
[
keyparts
[
i
]];
// data node found, handle per type
}
else
{
if
(
targetNode
.
is
(
"
select
"
))
{
// data node found, handle per type
// handle select boxes
if
(
$
(
this
).
is
(
"
select
"
))
{
targetNode
.
empty
();
// flush
// handle select boxes
$
.
each
(
node
[
keypart
],
function
(
indxItem
,
keyItem
){
$
(
this
).
empty
();
// flush
if
(
keyItem
[
"
selected
"
]
!=
"
0
"
)
{
for
(
var
key
in
node
[
keyparts
[
i
]])
{
targetNode
.
append
(
"
<option value='
"
+
indxItem
+
"
' selected>
"
+
keyItem
[
"
value
"
]
+
"
</option>
"
);
if
(
node
[
keyparts
[
i
]][
key
][
"
selected
"
]
!=
"
0
"
)
{
}
else
{
$
(
this
).
append
(
"
<option value='
"
+
key
+
"
' selected>
"
+
node
[
keyparts
[
i
]][
key
][
"
value
"
]
+
"
</option>
"
);
targetNode
.
append
(
"
<option value='
"
+
indxItem
+
"
'>
"
+
keyItem
[
"
value
"
]
+
"
</option>
"
);
}
});
}
else
if
(
targetNode
.
prop
(
"
type
"
)
==
"
checkbox
"
)
{
// checkbox type
if
(
node
[
keypart
]
!=
0
)
{
targetNode
.
prop
(
"
checked
"
,
true
)
;
}
else
{
}
else
{
$
(
this
).
append
(
"
<option value='
"
+
key
+
"
'>
"
+
node
[
keyparts
[
i
]][
key
][
"
value
"
]
+
"
</option>
"
)
;
targetNode
.
prop
(
"
checked
"
,
false
)
;
}
}
}
}
else
if
(
$
(
this
).
prop
(
"
type
"
)
==
"
checkbox
"
)
{
// checkbox type
if
(
node
[
keyparts
[
i
]]
!=
0
)
{
$
(
this
).
prop
(
"
checked
"
,
true
)
;
}
else
{
}
else
{
$
(
this
).
prop
(
"
checked
"
,
false
)
;
// regular input type
targetNode
.
val
(
node
[
keypart
]);
}
}
}
else
{
// regular input type
$
(
this
).
val
(
node
[
keyparts
[
i
]]);
}
}
}
}
}
}
);
});
});
}
}
...
...
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