Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
VIPSLogic
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
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
VIPS
VIPSLogic
Commits
bcca20a4
Commit
bcca20a4
authored
8 months ago
by
Tor-Einar Skog
Browse files
Options
Downloads
Patches
Plain Diff
fix: latin name for black alder (alnus glutinosa)
parent
4171101b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/webapp/map_applications/phytophthora/js/map.js
+202
-259
202 additions, 259 deletions
src/main/webapp/map_applications/phytophthora/js/map.js
with
202 additions
and
259 deletions
src/main/webapp/map_applications/phytophthora/js/map.js
+
202
−
259
View file @
bcca20a4
...
@@ -36,8 +36,7 @@ var geolocation;
...
@@ -36,8 +36,7 @@ var geolocation;
* Initializes the map with all its layers
* Initializes the map with all its layers
* @returns {undefined}
* @returns {undefined}
*/
*/
async
function
initMap
()
async
function
initMap
()
{
{
var
features
=
new
ol
.
Collection
();
var
features
=
new
ol
.
Collection
();
// Icon styling for the observations layer
// Icon styling for the observations layer
...
@@ -45,52 +44,52 @@ async function initMap()
...
@@ -45,52 +44,52 @@ async function initMap()
var
styles
=
{
var
styles
=
{
// Bøk = rød
// Bøk = rød
'
fagus sylvatica
'
:
[
new
ol
.
style
.
Style
({
'
fagus sylvatica
'
:
[
new
ol
.
style
.
Style
({
image
:
new
ol
.
style
.
Circle
({
image
:
new
ol
.
style
.
Circle
({
fill
:
new
ol
.
style
.
Fill
({
color
:
[
255
,
0
,
0
,
1
]}),
fill
:
new
ol
.
style
.
Fill
({
color
:
[
255
,
0
,
0
,
1
]
}),
stroke
:
new
ol
.
style
.
Stroke
({
width
:
1
,
color
:
[
0
,
0
,
0
,
1
]}),
stroke
:
new
ol
.
style
.
Stroke
({
width
:
1
,
color
:
[
0
,
0
,
0
,
1
]
}),
radius
:
iconRadius
radius
:
iconRadius
})
})
})],
})],
// Gråor = dyp oransje
// Gråor = dyp oransje
'
alnus incana
'
:
[
new
ol
.
style
.
Style
({
'
alnus incana
'
:
[
new
ol
.
style
.
Style
({
image
:
new
ol
.
style
.
Circle
({
image
:
new
ol
.
style
.
Circle
({
fill
:
new
ol
.
style
.
Fill
({
color
:
[
239
,
133
,
19
,
1
]}),
fill
:
new
ol
.
style
.
Fill
({
color
:
[
239
,
133
,
19
,
1
]
}),
stroke
:
new
ol
.
style
.
Stroke
({
width
:
1
,
color
:
[
0
,
0
,
0
,
1
]}),
stroke
:
new
ol
.
style
.
Stroke
({
width
:
1
,
color
:
[
0
,
0
,
0
,
1
]
}),
radius
:
iconRadius
radius
:
iconRadius
})
})
})],
})],
// Eik = gul
// Eik = gul
'
quercus
'
:
[
new
ol
.
style
.
Style
({
'
quercus
'
:
[
new
ol
.
style
.
Style
({
image
:
new
ol
.
style
.
Circle
({
image
:
new
ol
.
style
.
Circle
({
fill
:
new
ol
.
style
.
Fill
({
color
:
[
239
,
236
,
19
,
1
]}),
fill
:
new
ol
.
style
.
Fill
({
color
:
[
239
,
236
,
19
,
1
]
}),
stroke
:
new
ol
.
style
.
Stroke
({
width
:
1
,
color
:
[
0
,
0
,
0
,
1
]}),
stroke
:
new
ol
.
style
.
Stroke
({
width
:
1
,
color
:
[
0
,
0
,
0
,
1
]
}),
radius
:
iconRadius
radius
:
iconRadius
})
})
})],
})],
// Lønn = grønn
// Lønn = grønn
'
acer
'
:
[
new
ol
.
style
.
Style
({
'
acer
'
:
[
new
ol
.
style
.
Style
({
image
:
new
ol
.
style
.
Circle
({
image
:
new
ol
.
style
.
Circle
({
fill
:
new
ol
.
style
.
Fill
({
color
:
[
0
,
255
,
0
,
1
]}),
fill
:
new
ol
.
style
.
Fill
({
color
:
[
0
,
255
,
0
,
1
]
}),
stroke
:
new
ol
.
style
.
Stroke
({
width
:
1
,
color
:
[
0
,
0
,
0
,
1
]}),
stroke
:
new
ol
.
style
.
Stroke
({
width
:
1
,
color
:
[
0
,
0
,
0
,
1
]
}),
radius
:
iconRadius
radius
:
iconRadius
})
})
})],
})],
// Svartor = grågrønn
// Svartor = grågrønn
'
svartor
'
:
[
new
ol
.
style
.
Style
({
'
alnus glutinosa
'
:
[
new
ol
.
style
.
Style
({
image
:
new
ol
.
style
.
Circle
({
image
:
new
ol
.
style
.
Circle
({
fill
:
new
ol
.
style
.
Fill
({
color
:
[
122
,
175
,
131
,
1
]}),
fill
:
new
ol
.
style
.
Fill
({
color
:
[
122
,
175
,
131
,
1
]
}),
stroke
:
new
ol
.
style
.
Stroke
({
width
:
1
,
color
:
[
0
,
0
,
0
,
1
]}),
stroke
:
new
ol
.
style
.
Stroke
({
width
:
1
,
color
:
[
0
,
0
,
0
,
1
]
}),
radius
:
iconRadius
radius
:
iconRadius
})
})
})],
})],
// Planteriket = blå
// Planteriket = blå
'
plantae
'
:
[
new
ol
.
style
.
Style
({
'
plantae
'
:
[
new
ol
.
style
.
Style
({
image
:
new
ol
.
style
.
Circle
({
image
:
new
ol
.
style
.
Circle
({
fill
:
new
ol
.
style
.
Fill
({
color
:
[
0
,
0
,
255
,
1
]}),
fill
:
new
ol
.
style
.
Fill
({
color
:
[
0
,
0
,
255
,
1
]
}),
stroke
:
new
ol
.
style
.
Stroke
({
width
:
1
,
color
:
[
0
,
0
,
0
,
1
]}),
stroke
:
new
ol
.
style
.
Stroke
({
width
:
1
,
color
:
[
0
,
0
,
0
,
1
]
}),
radius
:
iconRadius
radius
:
iconRadius
})
})
})
})
]
]
};
};
...
@@ -102,24 +101,21 @@ async function initMap()
...
@@ -102,24 +101,21 @@ async function initMap()
style
:
function
(
feature
,
resolution
)
{
style
:
function
(
feature
,
resolution
)
{
// Site that has been cleared is all black
// Site that has been cleared is all black
var
observationData
=
JSON
.
parse
(
feature
.
get
(
"
observationData
"
));
var
observationData
=
JSON
.
parse
(
feature
.
get
(
"
observationData
"
));
var
retVal
=
null
;
var
retVal
=
null
;
if
(
feature
.
get
(
"
cropOrganism
"
)
!=
null
&&
feature
.
get
(
"
cropOrganism
"
)[
"
latinName
"
]
!=
null
)
if
(
feature
.
get
(
"
cropOrganism
"
)
!=
null
&&
feature
.
get
(
"
cropOrganism
"
)[
"
latinName
"
]
!=
null
)
{
{
retVal
=
styles
[
feature
.
get
(
"
cropOrganism
"
)[
"
latinName
"
].
toLowerCase
()];
retVal
=
styles
[
feature
.
get
(
"
cropOrganism
"
)[
"
latinName
"
].
toLowerCase
()];
}
else
}
else
{
{
retVal
=
styles
[
"
plantae
"
];
retVal
=
styles
[
"
plantae
"
];
}
}
//console.info(retVal[0].getImage().getStroke().getWidth());
//console.info(retVal[0].getImage().getStroke().getWidth());
// If symptom has been registered, mark with inner black dot
// If symptom has been registered, mark with inner black dot
if
(
observationData
[
"
symptom
"
]
!=
"
Ikke symptom
"
&&
observationData
[
"
symptom
"
]
!=
"
Irrelevant
"
)
if
(
observationData
[
"
symptom
"
]
!=
"
Ikke symptom
"
&&
observationData
[
"
symptom
"
]
!=
"
Irrelevant
"
)
{
{
retVal
=
[
retVal
=
[
new
ol
.
style
.
Style
({
new
ol
.
style
.
Style
({
image
:
new
ol
.
style
.
Circle
({
image
:
new
ol
.
style
.
Circle
({
fill
:
new
ol
.
style
.
Fill
({
color
:
[
0
,
0
,
0
,
1
]}),
fill
:
new
ol
.
style
.
Fill
({
color
:
[
0
,
0
,
0
,
1
]
}),
stroke
:
new
ol
.
style
.
Stroke
({
width
:
8
,
color
:
retVal
[
0
].
getImage
().
getFill
().
getColor
()}),
stroke
:
new
ol
.
style
.
Stroke
({
width
:
8
,
color
:
retVal
[
0
].
getImage
().
getFill
().
getColor
()
}),
radius
:
iconRadius
radius
:
iconRadius
})
})
})
})
...
@@ -136,12 +132,12 @@ async function initMap()
...
@@ -136,12 +132,12 @@ async function initMap()
features
:
new
ol
.
Collection
()
features
:
new
ol
.
Collection
()
}),
}),
style
:
[
new
ol
.
style
.
Style
({
style
:
[
new
ol
.
style
.
Style
({
image
:
new
ol
.
style
.
Circle
({
image
:
new
ol
.
style
.
Circle
({
fill
:
new
ol
.
style
.
Fill
({
color
:
[
255
,
255
,
255
,
1
]}),
fill
:
new
ol
.
style
.
Fill
({
color
:
[
255
,
255
,
255
,
1
]
}),
stroke
:
new
ol
.
style
.
Stroke
({
color
:
[
0
,
0
,
0
,
1
],
width
:
3
,
lineDash
:
[
2
,
2
]}),
stroke
:
new
ol
.
style
.
Stroke
({
color
:
[
0
,
0
,
0
,
1
],
width
:
3
,
lineDash
:
[
2
,
2
]
}),
radius
:
10
radius
:
10
})
})
})]
})]
});
});
...
@@ -157,15 +153,15 @@ async function initMap()
...
@@ -157,15 +153,15 @@ async function initMap()
});
});
var
topo
=
var
topo
=
new
ol
.
layer
.
Tile
({
new
ol
.
layer
.
Tile
({
opacity
:
1
,
opacity
:
1
,
source
:
new
ol
.
source
.
WMTS
(
/** @type {!olx.source.WMTSOptions} */
(
options
))
source
:
new
ol
.
source
.
WMTS
(
/** @type {!olx.source.WMTSOptions} */
(
options
))
});
});
map
=
new
ol
.
Map
({
map
=
new
ol
.
Map
({
target
:
'
map
'
,
target
:
'
map
'
,
controls
:
ol
.
control
.
defaults
({
attribution
:
false
}),
// Hide the attribution
controls
:
ol
.
control
.
defaults
({
attribution
:
false
}),
// Hide the attribution
layers
:
[
layers
:
[
topo
,
topo
,
featureOverlay
,
featureOverlay
,
...
@@ -186,19 +182,19 @@ async function initMap()
...
@@ -186,19 +182,19 @@ async function initMap()
});
});
var
positionFeature
=
new
ol
.
Feature
();
var
positionFeature
=
new
ol
.
Feature
();
positionFeature
.
setStyle
(
positionFeature
.
setStyle
(
new
ol
.
style
.
Style
({
new
ol
.
style
.
Style
({
image
:
new
ol
.
style
.
Circle
({
image
:
new
ol
.
style
.
Circle
({
radius
:
6
,
radius
:
6
,
fill
:
new
ol
.
style
.
Fill
({
fill
:
new
ol
.
style
.
Fill
({
color
:
'
#3399CC
'
,
color
:
'
#3399CC
'
,
}),
stroke
:
new
ol
.
style
.
Stroke
({
color
:
'
#fff
'
,
width
:
2
,
}),
}),
}),
})
stroke
:
new
ol
.
style
.
Stroke
({
);
color
:
'
#fff
'
,
width
:
2
,
}),
}),
})
);
geolocation
.
on
(
'
change:position
'
,
function
()
{
geolocation
.
on
(
'
change:position
'
,
function
()
{
var
coordinates
=
geolocation
.
getPosition
();
var
coordinates
=
geolocation
.
getPosition
();
...
@@ -223,9 +219,9 @@ async function initMap()
...
@@ -223,9 +219,9 @@ async function initMap()
map
.
on
(
'
click
'
,
function
(
evt
)
{
map
.
on
(
'
click
'
,
function
(
evt
)
{
//features = []
//features = []
var
feature
=
map
.
forEachFeatureAtPixel
(
var
feature
=
map
.
forEachFeatureAtPixel
(
evt
.
pixel
,
function
(
ft
,
l
)
{
evt
.
pixel
,
function
(
ft
,
l
)
{
return
ft
;
return
ft
;
}
}
);
);
var
vectorSource
=
newFeatureOverlay
.
getSource
();
var
vectorSource
=
newFeatureOverlay
.
getSource
();
...
@@ -237,8 +233,7 @@ async function initMap()
...
@@ -237,8 +233,7 @@ async function initMap()
var
fakeFeature
=
createFeature
(
feature
.
getGeometry
().
getCoordinates
());
var
fakeFeature
=
createFeature
(
feature
.
getGeometry
().
getCoordinates
());
vectorSource
.
addFeature
(
fakeFeature
);
vectorSource
.
addFeature
(
fakeFeature
);
displayFeature
(
feature
);
displayFeature
(
feature
);
}
else
if
(
registration
)
}
else
if
(
registration
)
{
{
var
newFeature
=
createFeature
(
map
.
getCoordinateFromPixel
(
evt
.
pixel
));
var
newFeature
=
createFeature
(
map
.
getCoordinateFromPixel
(
evt
.
pixel
));
vectorSource
.
addFeature
(
newFeature
);
vectorSource
.
addFeature
(
newFeature
);
editFeature
(
newFeature
.
getId
());
editFeature
(
newFeature
.
getId
());
...
@@ -251,10 +246,8 @@ async function initMap()
...
@@ -251,10 +246,8 @@ async function initMap()
let
openLayersDefaultStyle
=
undefined
;
let
openLayersDefaultStyle
=
undefined
;
function
getOpenLayersDefaultStyle
()
function
getOpenLayersDefaultStyle
()
{
{
if
(
openLayersDefaultStyle
==
undefined
)
{
if
(
openLayersDefaultStyle
==
undefined
)
{
var
fill
=
new
ol
.
style
.
Fill
({
var
fill
=
new
ol
.
style
.
Fill
({
color
:
'
rgba(255,255,255,0.4)
'
color
:
'
rgba(255,255,255,0.4)
'
});
});
...
@@ -284,8 +277,7 @@ function getOpenLayersDefaultStyle()
...
@@ -284,8 +277,7 @@ function getOpenLayersDefaultStyle()
* @param {type} fromSeason
* @param {type} fromSeason
* @returns {undefined}
* @returns {undefined}
*/
*/
function
getAndRenderObservations
(
fromSeason
)
function
getAndRenderObservations
(
fromSeason
)
{
{
//console.info("getAndRenderObservations(" + season + ")");
//console.info("getAndRenderObservations(" + season + ")");
$
.
getJSON
(
"
/rest/observation/filter/1/geoJSON?from=
"
+
fromSeason
+
"
-01-01&pestId=
"
+
phytophthora
.
organismId
,
function
(
geoData
)
{
$
.
getJSON
(
"
/rest/observation/filter/1/geoJSON?from=
"
+
fromSeason
+
"
-01-01&pestId=
"
+
phytophthora
.
organismId
,
function
(
geoData
)
{
//console.info(geoData)
//console.info(geoData)
...
@@ -308,66 +300,58 @@ function getAndRenderObservations(fromSeason)
...
@@ -308,66 +300,58 @@ function getAndRenderObservations(fromSeason)
* @param {type} countyNo
* @param {type} countyNo
* @returns {undefined}
* @returns {undefined}
*/
*/
function
getAndRenderObservationsForReport
(
fromSeason
,
countyNo
=
"
-1
"
)
function
getAndRenderObservationsForReport
(
fromSeason
,
countyNo
=
"
-1
"
)
{
{
//console.info("getAndRenderObservations(" + season + ")");
//console.info("getAndRenderObservations(" + season + ")");
$
.
getJSON
(
"
/rest/observation/filter/1/geoJSON?from=
"
+
fromSeason
+
"
-01-01&pestId=
"
+
phytophthora
.
organismId
,
function
(
geoData
)
{
$
.
getJSON
(
"
/rest/observation/filter/1/geoJSON?from=
"
+
fromSeason
+
"
-01-01&pestId=
"
+
phytophthora
.
organismId
,
function
(
geoData
)
{
//console.info(geoData)
//console.info(geoData)
// Filter by county
// Filter by county
$
.
getJSON
(
"
/corsproxy/https://ws.geonorge.no/kommuneinfo/v1/fylker/
"
+
countyNo
+
"
/omrade
"
)
$
.
getJSON
(
"
/corsproxy/https://ws.geonorge.no/kommuneinfo/v1/fylker/
"
+
countyNo
+
"
/omrade
"
)
.
always
(
function
(
serviceResponse
)
{
.
always
(
function
(
serviceResponse
)
{
//console.info(geoData);
//console.info(geoData);
//console.info(serviceResponse);
//console.info(serviceResponse);
if
(
parseInt
(
countyNo
)
>
0
)
if
(
parseInt
(
countyNo
)
>
0
)
{
{
var
filteredFeatures
=
[];
var
filteredFeatures
=
[];
for
(
var
i
=
0
;
i
<
geoData
.
features
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
geoData
.
features
.
length
;
i
++
)
var
featureToBeFiltered
=
geoData
.
features
[
i
];
{
coordinate
=
proj4
(
"
EPSG:4326
"
,
"
EPSG:4258
"
,
[
featureToBeFiltered
.
geometry
.
coordinates
[
0
],
featureToBeFiltered
.
geometry
.
coordinates
[
1
]]);
var
featureToBeFiltered
=
geoData
.
features
[
i
];
// For some weird reason, d3 returns NOT contains in our case
coordinate
=
proj4
(
"
EPSG:4326
"
,
"
EPSG:4258
"
,
[
featureToBeFiltered
.
geometry
.
coordinates
[
0
],
featureToBeFiltered
.
geometry
.
coordinates
[
1
]]);
if
(
!
d3
.
geoContains
(
serviceResponse
.
omrade
,
coordinate
))
{
// For some weird reason, d3 returns NOT contains in our case
if
(
!
d3
.
geoContains
(
serviceResponse
.
omrade
,
coordinate
))
{
//console.info(featureToBeFiltered);
filteredFeatures
.
push
(
featureToBeFiltered
);
}
//console.info(featureToBeFiltered);
//console.info(featureToBeFiltered);
filteredFeatures
.
push
(
featureToBeFiltered
);
}
}
//console.info(filteredFeatures);
//console.info(featureToBeFiltered);
geoData
.
features
=
filteredFeatures
;
}
}
//console.info(filteredFeatures);
geoData
.
features
=
filteredFeatures
;
}
var
format
=
new
ol
.
format
.
GeoJSON
();
var
format
=
new
ol
.
format
.
GeoJSON
();
var
drawnfeatures
=
format
.
readFeatures
(
geoData
,
{
var
drawnfeatures
=
format
.
readFeatures
(
geoData
,
{
//dataProjection: "EPSG:32633",
//dataProjection: "EPSG:32633",
dataProjection
:
"
EPSG:4326
"
,
dataProjection
:
"
EPSG:4326
"
,
featureProjection
:
map
.
getView
().
getProjection
().
getCode
()
featureProjection
:
map
.
getView
().
getProjection
().
getCode
()
});
});
featureOverlay
.
getSource
().
clear
();
featureOverlay
.
getSource
().
clear
();
featureOverlay
.
getSource
().
addFeatures
(
drawnfeatures
);
featureOverlay
.
getSource
().
addFeatures
(
drawnfeatures
);
}
}
);
);
});
});
}
}
function
toggleRegistration
(
theButton
)
function
toggleRegistration
(
theButton
)
{
{
if
(
registration
)
{
if
(
registration
)
{
theButton
.
title
=
"
Registrering er AV
"
;
theButton
.
title
=
"
Registrering er AV
"
;
theButton
.
style
.
color
=
"
white
"
;
theButton
.
style
.
color
=
"
white
"
;
}
else
}
else
{
{
theButton
.
title
=
"
Registrering er PÅ
"
;
theButton
.
title
=
"
Registrering er PÅ
"
;
theButton
.
style
.
color
=
"
red
"
;
theButton
.
style
.
color
=
"
red
"
;
}
}
registration
=
!
registration
;
registration
=
!
registration
;
}
}
function
toggleTracking
(
theButton
)
function
toggleTracking
(
theButton
)
{
{
geolocation
.
setTracking
(
!
geolocation
.
getTracking
());
geolocation
.
setTracking
(
!
geolocation
.
getTracking
());
theButton
.
style
.
backgroundColor
=
geolocation
.
getTracking
()
?
"
green
"
:
"
rgba(0,60,136,.5)
"
;
theButton
.
style
.
backgroundColor
=
geolocation
.
getTracking
()
?
"
green
"
:
"
rgba(0,60,136,.5)
"
;
theButton
.
title
=
geolocation
.
getTracking
()
?
"
Vis min posisjon er PÅ
"
:
"
Vis min posisjon er AV
"
;
theButton
.
title
=
geolocation
.
getTracking
()
?
"
Vis min posisjon er PÅ
"
:
"
Vis min posisjon er AV
"
;
...
@@ -378,10 +362,8 @@ function toggleTracking(theButton)
...
@@ -378,10 +362,8 @@ function toggleTracking(theButton)
* @param {type} coordinate
* @param {type} coordinate
* @returns {createFeature.newFeature|ol.Feature}
* @returns {createFeature.newFeature|ol.Feature}
*/
*/
var
createFeature
=
function
(
coordinate
)
var
createFeature
=
function
(
coordinate
)
{
{
if
(
coordinate
.
length
==
2
)
{
if
(
coordinate
.
length
==
2
)
{
coordinate
=
[
coordinate
[
0
],
coordinate
[
1
],
0
];
coordinate
=
[
coordinate
[
0
],
coordinate
[
1
],
0
];
}
}
var
point
=
new
ol
.
geom
.
Point
(
coordinate
);
var
point
=
new
ol
.
geom
.
Point
(
coordinate
);
...
@@ -401,8 +383,7 @@ var createFeature = function (coordinate)
...
@@ -401,8 +383,7 @@ var createFeature = function (coordinate)
return
newFeature
;
return
newFeature
;
}
}
var
displayFeature
=
function
(
feature
)
var
displayFeature
=
function
(
feature
)
{
{
var
featureForm
=
document
.
getElementById
(
"
featureForm
"
);
var
featureForm
=
document
.
getElementById
(
"
featureForm
"
);
var
observationData
=
JSON
.
parse
(
feature
.
get
(
"
observationData
"
));
var
observationData
=
JSON
.
parse
(
feature
.
get
(
"
observationData
"
));
...
@@ -440,8 +421,7 @@ var forekomsttypeLatinskeNavn = [
...
@@ -440,8 +421,7 @@ var forekomsttypeLatinskeNavn = [
var
forekomsttyper
=
[];
var
forekomsttyper
=
[];
var
phytophthora
=
{};
var
phytophthora
=
{};
function
initForekomsttyper
()
function
initForekomsttyper
()
{
{
$
.
getJSON
(
"
/rest/organism/search/latinnames?keywords=
"
+
forekomsttypeLatinskeNavn
.
join
(
"
,
"
),
function
(
data
)
{
$
.
getJSON
(
"
/rest/organism/search/latinnames?keywords=
"
+
forekomsttypeLatinskeNavn
.
join
(
"
,
"
),
function
(
data
)
{
forekomsttyper
=
data
;
forekomsttyper
=
data
;
});
});
...
@@ -449,70 +429,65 @@ function initForekomsttyper()
...
@@ -449,70 +429,65 @@ function initForekomsttyper()
function
initPhytophthora
()
{
function
initPhytophthora
()
{
$
.
getJSON
(
"
/rest/organism/search/latinnames?keywords=Phytophthora sp
"
,
function
(
data
)
{
$
.
getJSON
(
"
/rest/organism/search/latinnames?keywords=Phytophthora sp
"
,
function
(
data
)
{
if
(
data
.
length
==
1
)
if
(
data
.
length
==
1
)
{
{
phytophthora
=
data
[
0
];
phytophthora
=
data
[
0
];
initMap
();
initMap
();
}
}
});
});
}
}
var
getCropOrganism
=
function
(
organismId
)
var
getCropOrganism
=
function
(
organismId
)
{
{
for
(
var
i
=
0
;
i
<
forekomsttyper
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
forekomsttyper
.
length
;
i
++
)
if
(
forekomsttyper
[
i
].
organismId
==
organismId
)
{
{
if
(
forekomsttyper
[
i
].
organismId
==
organismId
)
{
return
forekomsttyper
[
i
];
return
forekomsttyper
[
i
];
}
}
}
}
}
}
var
symptoms
=
[
"
Flekker
"
,
"
Glisne kroner
"
,
"
Oppsprekking
"
,
"
Død
"
,
"
Andre symptom
"
,
"
Andre skader
"
,
"
Ikke symptom
"
,
"
Irrelevant
"
];
var
symptoms
=
[
"
Flekker
"
,
"
Glisne kroner
"
,
"
Oppsprekking
"
,
"
Død
"
,
"
Andre symptom
"
,
"
Andre skader
"
,
"
Ikke symptom
"
,
"
Irrelevant
"
];
var
funns
=
[
"
[Ukjent]
"
,
"
Phytophthora gonapodyides
"
,
"
Phytophthora lacustris
"
,
"
Phytophthora plurivora
"
,
"
Phytophthora cambivora
"
,
"
Phytophthora cactorum
"
,
"
Phytophthora sp
"
]
var
funns
=
[
"
[Ukjent]
"
,
"
Phytophthora gonapodyides
"
,
"
Phytophthora lacustris
"
,
"
Phytophthora plurivora
"
,
"
Phytophthora cambivora
"
,
"
Phytophthora cactorum
"
,
"
Phytophthora sp
"
]
var
provetypes
=
[
"
[Ikke prøve]
"
,
"
Jord
"
,
"
Vev
"
,
"
Vann
"
,
"
Blad
"
,
"
Bait
"
];
var
provetypes
=
[
"
[Ikke prøve]
"
,
"
Jord
"
,
"
Vev
"
,
"
Vann
"
,
"
Blad
"
,
"
Bait
"
];
var
editFeature
=
function
(
featureId
)
var
editFeature
=
function
(
featureId
)
{
{
var
feature
=
featureId
>
0
?
featureOverlay
.
getSource
().
getFeatureById
(
featureId
)
var
feature
=
featureId
>
0
?
featureOverlay
.
getSource
().
getFeatureById
(
featureId
)
:
newFeatureOverlay
.
getSource
().
getFeatureById
(
featureId
);
:
newFeatureOverlay
.
getSource
().
getFeatureById
(
featureId
);
var
observationData
=
JSON
.
parse
(
feature
.
get
(
"
observationData
"
));
var
observationData
=
JSON
.
parse
(
feature
.
get
(
"
observationData
"
));
var
timeOfObservation
=
new
moment
(
feature
.
get
(
"
timeOfObservation
"
));
var
timeOfObservation
=
new
moment
(
feature
.
get
(
"
timeOfObservation
"
));
var
featureForm
=
document
.
getElementById
(
"
featureForm
"
);
var
featureForm
=
document
.
getElementById
(
"
featureForm
"
);
var
html
=
var
html
=
'
<button type="button" onclick="unFocusForm()" title="Avbryt">X</button>
'
+
'
<button type="button" onclick="unFocusForm()" title="Avbryt">X</button>
'
+
(
featureId
>
0
?
'
<button type="button" onclick="deleteFeature(
'
+
featureId
+
'
)">Delete</button>
'
:
''
)
+
(
featureId
>
0
?
'
<button type="button" onclick="deleteFeature(
'
+
featureId
+
'
)">Delete</button>
'
:
''
)
+
'
<h3>
'
+
(
featureId
>
0
?
"
R
"
:
"
Ny r
"
)
+
'
egistrering</h3>
'
+
'
<h3>
'
+
(
featureId
>
0
?
"
R
"
:
"
Ny r
"
)
+
'
egistrering</h3>
'
+
'
<table>
'
+
'
<table>
'
+
'
<tr><td>Plante</td><td>
'
+
'
<tr><td>Plante</td><td>
'
+
generateCropSelect
(
"
forekomsttype
"
,
forekomsttyper
,
feature
.
get
(
"
cropOrganism
"
)[
"
organismId
"
])
+
generateCropSelect
(
"
forekomsttype
"
,
forekomsttyper
,
feature
.
get
(
"
cropOrganism
"
)[
"
organismId
"
])
+
'
</td></tr>
'
+
'
</td></tr>
'
+
'
<tr><td>Plante spes.</td><td>
'
+
'
<tr><td>Plante spes.</td><td>
'
+
'
<input type="text" id="plantespes" name="plantespes" size="15" value="
'
+
(
observationData
[
"
plantespes
"
]
!=
null
?
observationData
[
"
plantespes
"
]
:
""
)
+
'
"/></td></tr>
'
+
'
<input type="text" id="plantespes" name="plantespes" size="15" value="
'
+
(
observationData
[
"
plantespes
"
]
!=
null
?
observationData
[
"
plantespes
"
]
:
""
)
+
'
"/></td></tr>
'
+
'
<tr><td>Symptom</td><td>
'
+
'
<tr><td>Symptom</td><td>
'
+
generateSelect
(
"
symptom
"
,
symptoms
,
observationData
[
"
symptom
"
])
+
generateSelect
(
"
symptom
"
,
symptoms
,
observationData
[
"
symptom
"
])
+
'
</td></tr>
'
+
'
</td></tr>
'
+
'
<tr><td>Sym spes.</td><td>
'
+
'
<tr><td>Sym spes.</td><td>
'
+
'
<input type="text" id="symspes" name="symspes" size="15" value="
'
+
(
observationData
[
"
symspes
"
]
!=
null
?
observationData
[
"
symspes
"
]
:
""
)
+
'
"/></td></tr>
'
+
'
<input type="text" id="symspes" name="symspes" size="15" value="
'
+
(
observationData
[
"
symspes
"
]
!=
null
?
observationData
[
"
symspes
"
]
:
""
)
+
'
"/></td></tr>
'
+
'
<tr><td>Prøvetype</td><td>
'
+
'
<tr><td>Prøvetype</td><td>
'
+
generateSelect
(
"
provetype
"
,
provetypes
,
observationData
[
"
provetype
"
])
+
generateSelect
(
"
provetype
"
,
provetypes
,
observationData
[
"
provetype
"
])
+
'
</td></tr>
'
+
'
</td></tr>
'
+
'
<tr><td>Prøvenummer</td><td>
'
+
'
<tr><td>Prøvenummer</td><td>
'
+
'
<input type="text" id="provenummer" name="provenummer" size="15" value="
'
+
(
observationData
[
"
provenummer
"
]
!=
null
?
observationData
[
"
provenummer
"
]
:
""
)
+
'
"/></td></tr>
'
+
'
<input type="text" id="provenummer" name="provenummer" size="15" value="
'
+
(
observationData
[
"
provenummer
"
]
!=
null
?
observationData
[
"
provenummer
"
]
:
""
)
+
'
"/></td></tr>
'
+
'
<tr><td>Funn</td><td>
'
+
'
<tr><td>Funn</td><td>
'
+
generateSelect
(
"
funn
"
,
funns
,
observationData
[
"
funn
"
])
+
generateSelect
(
"
funn
"
,
funns
,
observationData
[
"
funn
"
])
+
'
</td></tr>
'
+
'
</td></tr>
'
+
'
<tr><td>Mer info</td><td>
'
+
'
<tr><td>Mer info</td><td>
'
+
'
<textarea id="beskrivelse" name="beskrivelse">
'
+
(
feature
.
get
(
"
observationText
"
)
!=
null
?
feature
.
get
(
"
observationText
"
)
:
""
)
+
'
</textarea>
'
+
'
<textarea id="beskrivelse" name="beskrivelse">
'
+
(
feature
.
get
(
"
observationText
"
)
!=
null
?
feature
.
get
(
"
observationText
"
)
:
""
)
+
'
</textarea>
'
+
'
</td></tr>
'
+
'
</td></tr>
'
+
'
<tr><td>Dato</td><td>
'
+
'
<tr><td>Dato</td><td>
'
+
'
<input type="text" id="dato" name="dato" size="10" value="
'
+
timeOfObservation
.
format
(
"
DD.MM.YYYY
"
)
+
'
"/></td></tr>
'
+
'
<input type="text" id="dato" name="dato" size="10" value="
'
+
timeOfObservation
.
format
(
"
DD.MM.YYYY
"
)
+
'
"/></td></tr>
'
+
'
<tr><td></td><td>
'
+
'
<tr><td></td><td>
'
+
'
<input type="submit" value="Lagre" onclick="storeFeature(
'
+
feature
.
getId
()
+
'
);"/></td></tr>
'
+
'
<input type="submit" value="Lagre" onclick="storeFeature(
'
+
feature
.
getId
()
+
'
);"/></td></tr>
'
+
'
</table>
'
;
'
</table>
'
;
featureForm
.
innerHTML
=
html
;
featureForm
.
innerHTML
=
html
;
...
@@ -520,10 +495,9 @@ var editFeature = function (featureId)
...
@@ -520,10 +495,9 @@ var editFeature = function (featureId)
//console.info(feature);
//console.info(feature);
};
};
var
storeFeature
=
function
(
featureId
)
var
storeFeature
=
function
(
featureId
)
{
{
var
feature
=
featureId
>
0
?
featureOverlay
.
getSource
().
getFeatureById
(
featureId
)
var
feature
=
featureId
>
0
?
featureOverlay
.
getSource
().
getFeatureById
(
featureId
)
:
newFeatureOverlay
.
getSource
().
getFeatureById
(
featureId
);
:
newFeatureOverlay
.
getSource
().
getFeatureById
(
featureId
);
// Store, clear newFeature layer
// Store, clear newFeature layer
// Need to add feature as payload
// Need to add feature as payload
...
@@ -541,8 +515,7 @@ var storeFeature = function (featureId)
...
@@ -541,8 +515,7 @@ var storeFeature = function (featureId)
var
observationText
=
document
.
getElementById
(
"
beskrivelse
"
).
value
;
var
observationText
=
document
.
getElementById
(
"
beskrivelse
"
).
value
;
var
observationHeading
=
"
Registrering av phytophthora
"
;
var
observationHeading
=
"
Registrering av phytophthora
"
;
var
timeOfObservation
=
moment
(
document
.
getElementById
(
"
dato
"
).
value
+
"
+0200
"
,
"
DD.MM.YYYYZ
"
);
var
timeOfObservation
=
moment
(
document
.
getElementById
(
"
dato
"
).
value
+
"
+0200
"
,
"
DD.MM.YYYYZ
"
);
if
(
timeOfObservation
.
year
()
<
2000
)
if
(
timeOfObservation
.
year
()
<
2000
)
{
{
alert
(
"
Feil dato (før år 2000). Datoformat er DD.MM.ÅÅÅÅ
"
);
alert
(
"
Feil dato (før år 2000). Datoformat er DD.MM.ÅÅÅÅ
"
);
return
;
return
;
}
}
...
@@ -585,22 +558,18 @@ var storeFeature = function (featureId)
...
@@ -585,22 +558,18 @@ var storeFeature = function (featureId)
// If storing an existing feature, remove the one
// If storing an existing feature, remove the one
// that was there before storing, since the returned
// that was there before storing, since the returned
// one has a new gisId (featureId)
// one has a new gisId (featureId)
if
(
featureId
>
0
)
if
(
featureId
>
0
)
{
{
featureOverlay
.
getSource
().
removeFeature
(
feature
);
featureOverlay
.
getSource
().
removeFeature
(
feature
);
}
}
featureOverlay
.
getSource
().
addFeatures
(
drawnfeatures
);
featureOverlay
.
getSource
().
addFeatures
(
drawnfeatures
);
unFocusForm
();
unFocusForm
();
},
},
error
:
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
error
:
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
if
(
jqXHR
.
status
==
401
)
if
(
jqXHR
.
status
==
401
)
{
{
if
(
confirm
(
"
Kan ikke lagre fordi du er logget ut av applikasjonen. Klikk OK for å logge inn.
"
))
{
if
(
confirm
(
"
Kan ikke lagre fordi du er logget ut av applikasjonen. Klikk OK for å logge inn.
"
))
{
window
.
location
.
reload
();
window
.
location
.
reload
();
}
}
}
else
}
else
{
{
alert
(
"
Beklager, en feil oppsto. Status =
"
+
jqXHR
.
status
+
"
, eventuell feilmelding:
"
+
textStatus
);
alert
(
"
Beklager, en feil oppsto. Status =
"
+
jqXHR
.
status
+
"
, eventuell feilmelding:
"
+
textStatus
);
}
}
}
}
...
@@ -614,10 +583,8 @@ var storeFeature = function (featureId)
...
@@ -614,10 +583,8 @@ var storeFeature = function (featureId)
* @param {type} featureId
* @param {type} featureId
* @returns {undefined}
* @returns {undefined}
*/
*/
var
deleteFeature
=
function
(
featureId
)
var
deleteFeature
=
function
(
featureId
)
{
{
if
(
!
confirm
(
"
Er du sikker på at du vil slette?
"
))
{
if
(
!
confirm
(
"
Er du sikker på at du vil slette?
"
))
{
return
;
return
;
}
}
...
@@ -631,51 +598,41 @@ var deleteFeature = function (featureId)
...
@@ -631,51 +598,41 @@ var deleteFeature = function (featureId)
// If storing an existing feature, remove the one
// If storing an existing feature, remove the one
// that was there before storing, since the returned
// that was there before storing, since the returned
// one has a new gisId (featureId)
// one has a new gisId (featureId)
if
(
featureId
>
0
)
if
(
featureId
>
0
)
{
{
featureOverlay
.
getSource
().
removeFeature
(
feature
);
featureOverlay
.
getSource
().
removeFeature
(
feature
);
}
}
unFocusForm
();
unFocusForm
();
},
},
error
:
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
error
:
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
if
(
jqXHR
.
status
==
401
)
if
(
jqXHR
.
status
==
401
)
{
{
if
(
confirm
(
"
Kan ikke slette fordi du er logget ut av applikasjonen. Klikk OK for å logge inn.
"
))
{
if
(
confirm
(
"
Kan ikke slette fordi du er logget ut av applikasjonen. Klikk OK for å logge inn.
"
))
{
window
.
location
.
reload
();
window
.
location
.
reload
();
}
}
}
else
}
else
{
{
alert
(
"
Beklager, en feil oppsto. Status =
"
+
jqXHR
.
status
+
"
, eventuell feilmelding:
"
+
textStatus
);
alert
(
"
Beklager, en feil oppsto. Status =
"
+
jqXHR
.
status
+
"
, eventuell feilmelding:
"
+
textStatus
);
}
}
}
}
});
});
}
}
var
generateSelect
=
function
(
selectName
,
options
,
preselect
)
var
generateSelect
=
function
(
selectName
,
options
,
preselect
)
{
{
var
retVal
=
'
<select id="
'
+
selectName
+
'
" name="
'
+
selectName
+
'
">
'
;
var
retVal
=
'
<select id="
'
+
selectName
+
'
" name="
'
+
selectName
+
'
">
'
;
for
(
var
i
=
0
;
i
<
options
.
length
;
i
++
)
for
(
var
i
=
0
;
i
<
options
.
length
;
i
++
)
{
{
retVal
+=
'
<option value="
'
+
options
[
i
]
+
'
"
'
+
(
options
[
i
]
==
preselect
?
"
selected=
\"
selected
\"
"
:
""
)
+
'
">
'
+
options
[
i
]
+
'
</option>
'
;
retVal
+=
'
<option value="
'
+
options
[
i
]
+
'
"
'
+
(
options
[
i
]
==
preselect
?
"
selected=
\"
selected
\"
"
:
""
)
+
'
">
'
+
options
[
i
]
+
'
</option>
'
;
}
}
retVal
+=
'
</select>
'
;
retVal
+=
'
</select>
'
;
return
retVal
;
return
retVal
;
}
}
var
generateCropSelect
=
function
(
selectName
,
cropOrganisms
,
preselect
)
var
generateCropSelect
=
function
(
selectName
,
cropOrganisms
,
preselect
)
{
{
var
retVal
=
'
<select id="
'
+
selectName
+
'
" name="
'
+
selectName
+
'
">
'
;
var
retVal
=
'
<select id="
'
+
selectName
+
'
" name="
'
+
selectName
+
'
">
'
;
for
(
var
c
=
0
;
c
<
forekomsttypeLatinskeNavn
.
length
;
c
++
)
for
(
var
c
=
0
;
c
<
forekomsttypeLatinskeNavn
.
length
;
c
++
)
{
{
currentLatinName
=
forekomsttypeLatinskeNavn
[
c
];
currentLatinName
=
forekomsttypeLatinskeNavn
[
c
];
for
(
var
i
=
0
;
i
<
cropOrganisms
.
length
;
i
++
)
for
(
var
i
=
0
;
i
<
cropOrganisms
.
length
;
i
++
)
{
{
if
(
cropOrganisms
[
i
].
latinName
==
currentLatinName
)
{
if
(
cropOrganisms
[
i
].
latinName
==
currentLatinName
)
{
retVal
+=
'
<option value="
'
+
cropOrganisms
[
i
].
organismId
+
'
"
'
+
(
cropOrganisms
[
i
].
organismId
==
preselect
?
"
selected=
\"
selected
\"
"
:
""
)
+
'
">
'
+
retVal
+=
'
<option value="
'
+
cropOrganisms
[
i
].
organismId
+
'
"
'
+
(
cropOrganisms
[
i
].
organismId
==
preselect
?
"
selected=
\"
selected
\"
"
:
""
)
+
'
">
'
+
(
currentLatinName
==
"
Plantae
"
?
"
Annet
"
:
getLocalizedOrganismName
(
cropOrganisms
[
i
],
hardcodedLanguage
))
(
currentLatinName
==
"
Plantae
"
?
"
Annet
"
:
getLocalizedOrganismName
(
cropOrganisms
[
i
],
hardcodedLanguage
))
+
'
</option>
'
;
+
'
</option>
'
;
}
}
}
}
}
}
...
@@ -683,22 +640,19 @@ var generateCropSelect = function (selectName, cropOrganisms, preselect)
...
@@ -683,22 +640,19 @@ var generateCropSelect = function (selectName, cropOrganisms, preselect)
return
retVal
;
return
retVal
;
}
}
var
focusForm
=
function
()
var
focusForm
=
function
()
{
{
var
featureForm
=
document
.
getElementById
(
"
featureForm
"
);
var
featureForm
=
document
.
getElementById
(
"
featureForm
"
);
featureForm
.
style
.
display
=
"
block
"
;
featureForm
.
style
.
display
=
"
block
"
;
}
}
var
unFocusForm
=
function
()
var
unFocusForm
=
function
()
{
{
var
featureForm
=
document
.
getElementById
(
"
featureForm
"
);
var
featureForm
=
document
.
getElementById
(
"
featureForm
"
);
featureForm
.
style
.
display
=
"
none
"
;
featureForm
.
style
.
display
=
"
none
"
;
// Also remove feature (if one) on the New feature overlay
// Also remove feature (if one) on the New feature overlay
newFeatureOverlay
.
getSource
().
clear
();
newFeatureOverlay
.
getSource
().
clear
();
}
}
var
navigateTo
=
function
(
center
)
var
navigateTo
=
function
(
center
)
{
{
var
centerPosition
=
ol
.
proj
.
transform
(
center
,
'
EPSG:4326
'
,
'
EPSG:3857
'
);
var
centerPosition
=
ol
.
proj
.
transform
(
center
,
'
EPSG:4326
'
,
'
EPSG:3857
'
);
view
=
new
ol
.
View
({
view
=
new
ol
.
View
({
center
:
centerPosition
,
center
:
centerPosition
,
...
@@ -717,16 +671,13 @@ var navigateTo = function (center)
...
@@ -717,16 +671,13 @@ var navigateTo = function (center)
*/
*/
function
showLocation
()
{
function
showLocation
()
{
if
(
navigator
.
geolocation
)
{
if
(
navigator
.
geolocation
)
{
if
(
window
.
location
.
protocol
===
"
http:
"
)
if
(
window
.
location
.
protocol
===
"
http:
"
)
{
{
navigator
.
geolocation
.
getCurrentPosition
(
function
(
geopositionObj
)
{
navigator
.
geolocation
.
getCurrentPosition
(
function
(
geopositionObj
)
{
// TODO: position and display location icon
// TODO: position and display location icon
}
}
);
);
}
else
}
else
{
{
if
(
confirm
(
"
Lokalisering fungerer bare over https (sikker tilkobling mellom nettleser og tjener). Klikk OK for å gå til sikker tilkobling.
"
))
{
if
(
confirm
(
"
Lokalisering fungerer bare over https (sikker tilkobling mellom nettleser og tjener). Klikk OK for å gå til sikker tilkobling.
"
))
{
window
.
location
=
"
https:
"
+
window
.
location
.
href
.
substring
(
window
.
location
.
protocol
.
length
);
window
.
location
=
"
https:
"
+
window
.
location
.
href
.
substring
(
window
.
location
.
protocol
.
length
);
}
}
}
}
...
@@ -737,16 +688,13 @@ function showLocation() {
...
@@ -737,16 +688,13 @@ function showLocation() {
function
navToLocation
()
{
function
navToLocation
()
{
if
(
navigator
.
geolocation
)
{
if
(
navigator
.
geolocation
)
{
if
(
window
.
location
.
protocol
===
"
https:
"
)
if
(
window
.
location
.
protocol
===
"
https:
"
)
{
{
navigator
.
geolocation
.
getCurrentPosition
(
function
(
geopositionObj
)
{
navigator
.
geolocation
.
getCurrentPosition
(
function
(
geopositionObj
)
{
navigateTo
([
geopositionObj
.
coords
.
longitude
,
geopositionObj
.
coords
.
latitude
]);
navigateTo
([
geopositionObj
.
coords
.
longitude
,
geopositionObj
.
coords
.
latitude
]);
}
}
);
);
}
else
}
else
{
{
if
(
confirm
(
"
Lokalisering fungerer bare over https (sikker tilkobling mellom nettleser og tjener). Klikk OK for å gå til sikker tilkobling.
"
))
{
if
(
confirm
(
"
Lokalisering fungerer bare over https (sikker tilkobling mellom nettleser og tjener). Klikk OK for å gå til sikker tilkobling.
"
))
{
window
.
location
=
"
https:
"
+
window
.
location
.
href
.
substring
(
window
.
location
.
protocol
.
length
);
window
.
location
=
"
https:
"
+
window
.
location
.
href
.
substring
(
window
.
location
.
protocol
.
length
);
}
}
}
}
...
@@ -760,41 +708,36 @@ function navToLocation() {
...
@@ -760,41 +708,36 @@ function navToLocation() {
* @param {type} selectedSeason
* @param {type} selectedSeason
* @returns {undefined}
* @returns {undefined}
*/
*/
function
initSeasonSelectList
(
selectedSeason
)
function
initSeasonSelectList
(
selectedSeason
)
{
{
// What's the current year?
// What's the current year?
var
thisYear
=
new
Date
().
getFullYear
();
var
thisYear
=
new
Date
().
getFullYear
();
// How many years do we go back?
// How many years do we go back?
$
.
ajax
({
$
.
ajax
({
url
:
"
/rest/observation/first/
"
+
phytophthora
.
organismId
url
:
"
/rest/observation/first/
"
+
phytophthora
.
organismId
})
})
.
done
(
function
(
data
)
{
.
done
(
function
(
data
)
{
var
time
=
moment
(
data
);
var
time
=
moment
(
data
);
var
firstYear
=
time
.
toDate
().
getFullYear
();
var
firstYear
=
time
.
toDate
().
getFullYear
();
// Loop gjennom år, lag valgliste :-)
// Loop gjennom år, lag valgliste :-)
var
startSeasonList
=
document
.
getElementById
(
"
startSeason
"
);
var
startSeasonList
=
document
.
getElementById
(
"
startSeason
"
);
for
(
var
i
=
firstYear
;
i
<=
thisYear
;
i
++
)
for
(
var
i
=
firstYear
;
i
<=
thisYear
;
i
++
)
{
{
var
yearOpt
=
new
Option
(
""
,
i
);
var
yearOpt
=
new
Option
(
""
,
i
);
yearOpt
.
innerHTML
=
i
+
"
→
"
yearOpt
.
innerHTML
=
i
+
"
→
"
if
(
i
==
selectedSeason
)
{
if
(
i
==
selectedSeason
)
yearOpt
.
selected
=
true
;
{
yearOpt
.
selected
=
true
;
}
startSeasonList
.
options
[
startSeasonList
.
options
.
length
]
=
yearOpt
;
}
})
.
fail
(
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
if
(
jqXHR
.
status
==
404
)
{
alert
(
"
Could not find any observations of organism with id=
"
+
phytophthora
.
organismId
);
document
.
getElementById
(
"
startSeason
"
).
options
[
0
]
=
new
Option
(
""
+
thisYear
,
thisYear
);
}
else
{
alert
(
textStatus
+
"
:
"
+
errorThrown
);
}
}
});
startSeasonList
.
options
[
startSeasonList
.
options
.
length
]
=
yearOpt
;
}
})
.
fail
(
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
if
(
jqXHR
.
status
==
404
)
{
alert
(
"
Could not find any observations of organism with id=
"
+
phytophthora
.
organismId
);
document
.
getElementById
(
"
startSeason
"
).
options
[
0
]
=
new
Option
(
""
+
thisYear
,
thisYear
);
}
else
{
alert
(
textStatus
+
"
:
"
+
errorThrown
);
}
});
}
}
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