Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eric Duminil
RegionChooser
Commits
9c10c90a
Commit
9c10c90a
authored
2 years ago
by
Eric Duminil
Browse files
Options
Download
Email Patches
Plain Diff
Disable or enable button.
parent
c7cc6053
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/resources/eu/simstadt/regionchooser/website/script/simstadt_openlayers.js
+17
-5
...stadt/regionchooser/website/script/simstadt_openlayers.js
with
17 additions
and
5 deletions
+17
-5
src/main/resources/eu/simstadt/regionchooser/website/script/simstadt_openlayers.js
+
17
-
5
View file @
9c10c90a
var
regionChooser
=
(
function
(){
//TODO: Somehow split in classes. This file is getting too big and mixed
var
publicScope
=
{};
var
fromJavaFX
=
navigator
.
userAgent
.
indexOf
(
'
JavaFX
'
)
!==
-
1
;
var
dataPanel
=
$
(
'
#dataPanel
'
);
...
...
@@ -162,7 +163,7 @@ var regionChooser = (function(){
intersections
.
addFeature
(
intersection
);
var
link
=
'
<li>
'
// TODO: If possible, highlight the corresponding polygon when hovering above a name.
link
+=
'
<input type="checkbox" id="citygml_
'
+
feature
.
getId
()
+
'
" class="select_citygml"><label for="citygml_
'
+
feature
.
getId
()
+
'
">
'
+
feature
[
'
name
'
]
+
'
</label>
'
;
link
+=
'
<input type="checkbox" id="citygml_
'
+
feature
.
getId
()
+
'
" class="select_citygml"
onclick="regionChooser.canDownload();"
><label for="citygml_
'
+
feature
.
getId
()
+
'
">
'
+
feature
[
'
name
'
]
+
'
</label>
'
;
link
+=
"
(
"
+
citygml_percentage
+
"
%
"
;
if
(
sketch_percentage
==
100
)
{
...
...
@@ -171,6 +172,17 @@ var regionChooser = (function(){
dataPanel
.
append
(
link
+
"
)
\n
"
);
}
publicScope
.
canDownload
=
function
(){
var
count
=
0
;
console
.
log
(
"
...
"
);
document
.
querySelectorAll
(
"
input.select_citygml
"
).
forEach
(
c
=>
{
if
(
c
.
checked
){
count
+=
1
;
}
});
document
.
getElementById
(
"
download
"
).
disabled
=
(
count
==
0
);
}
function
findIntersection
(
feature
,
polygon
)
{
try
{
return
turf
.
intersect
(
polygon
,
feature
[
"
geoJSON
"
]);
...
...
@@ -211,8 +223,6 @@ var regionChooser = (function(){
}
publicScope
.
downloadRegionFromCityGMLs
=
function
(
checkbox_ids
)
{
// TODO: Disable all links
// TODO: DRY
var
features
=
checkbox_ids
.
map
(
checkbox_id
=>
{
var
i
=
Number
(
checkbox_id
.
replace
(
"
citygml_
"
,
""
));
return
kml_source
.
getFeatureById
(
i
);
...
...
@@ -238,6 +248,7 @@ var regionChooser = (function(){
var
time
=
end
-
start
;
console
.
log
(
'
Download Execution time:
'
+
(
time
/
1000
).
toFixed
(
3
)
+
'
s
'
);
setTimeout
(
function
()
{
document
.
getElementById
(
"
download
"
).
disabled
=
false
;
document
.
documentElement
.
className
=
''
;
// Stop waiting
},
100
);
}
else
{
...
...
@@ -267,8 +278,7 @@ var regionChooser = (function(){
dataPanel
.
append
(
wgs84_coords
+
"
<br/>
\n
"
);
}
dataPanel
.
append
(
"
<h3 class='clean'>Area :
"
+
(
area
/
10000
).
toFixed
(
1
)
+
"
ha
\n
"
);
//TODO: Hide button if empty
dataPanel
.
append
(
'
<button type="button" onclick="regionChooser.downloadFromSelectedCityGMLs()" id="download" style="visibility:hidden">Download Region</button><br/>
\n
'
);
dataPanel
.
append
(
'
<button type="button" onclick="regionChooser.downloadFromSelectedCityGMLs()" id="download" style="visibility:hidden" disabled>Download Region</button><br/>
\n
'
);
dataPanel
.
append
(
'
<a href="#" onclick="regionChooser.checkCityGMLS(true);">(Select All)</a>
'
);
dataPanel
.
append
(
'
<a href="#" onclick="regionChooser.checkCityGMLS(false);">(Select None)</a>
'
);
dataPanel
.
append
(
'
<br/>
\n
'
);
...
...
@@ -363,12 +373,14 @@ var regionChooser = (function(){
if
(
checkedBoxes
.
length
===
0
){
console
.
log
(
"
You should select at least one citygml, though.
"
);
}
else
{
document
.
getElementById
(
"
download
"
).
disabled
=
true
;
publicScope
.
downloadRegionFromCityGMLs
(
checkedBoxes
.
map
(
c
=>
c
.
id
));
}
}
publicScope
.
checkCityGMLS
=
function
(
allOrNone
)
{
document
.
querySelectorAll
(
"
input.select_citygml
"
).
forEach
(
c
=>
c
.
checked
=
allOrNone
);
publicScope
.
canDownload
();
}
publicScope
.
selectRepository
=
function
()
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment