Skip to content

Commit

Permalink
Fix Javascript issues, mostly related to missing variable declarations (
Browse files Browse the repository at this point in the history
  • Loading branch information
josegar74 authored Apr 4, 2024
1 parent 091ad01 commit 8eabfce
Show file tree
Hide file tree
Showing 33 changed files with 67 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@
var encLegends;
var attributions = [];
var layers = this.map.getLayers();
pdfLegendsToDownload = [];
var pdfLegendsToDownload = [];

angular.forEach(layers, function (layer) {
layer.visible = true; // FIXME: was not set by default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
var encLegends = [];
var attributions = [];
var layers = $scope.map.getLayers();
pdfLegendsToDownload = [];
var pdfLegendsToDownload = [];

var sortedZindexLayers = layers.getArray().sort(function (a, b) {
return a.getZIndex() > b.getZIndex();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@
getWFSCapabilities: function (url, version) {
var defer = $q.defer();
if (url) {
defaultVersion = "1.1.0";
var defaultVersion = "1.1.0";
version = version || defaultVersion;
url = mergeDefaultParams(url, {
request: "GetCapabilities",
Expand Down Expand Up @@ -396,7 +396,7 @@
getWCSCapabilities: function (url, version) {
var defer = $q.defer();
if (url) {
defaultVersion = "1.1.0";
var defaultVersion = "1.1.0";
version = version || defaultVersion;
url = mergeDefaultParams(url, {
REQUEST: "GetCapabilities",
Expand Down Expand Up @@ -474,13 +474,13 @@
var layers = capObj.layers || capObj.Layer;

// Layer name may be a list of comma separated layers
layerList = layerName.split(",");
var layerList = layerName.split(",");
var needles = new Array(layerList.length);

layersLoop: for (var j = 0; j < layerList.length; j++) {
var name = layerList[j];
//non namespaced lowercase name
nameNoNamespace = this.getNameWithoutNamespace(name).toLowerCase();
var nameNoNamespace = this.getNameWithoutNamespace(name).toLowerCase();

capabilityLayers: for (var i = 0; i < layers.length; i++) {
//Add Info for Requests:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
scope.spyElems.pop();
}

rootElement = $("#" + scope.id);
var rootElement = $("#" + scope.id);

// Get the number of fieldset above the current element
// to compute depth later.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@
// $(id).tagsinput('add', keyword);
// });

getRecordsAutocompleter = function (config) {
var getRecordsAutocompleter = function (config) {
var recordsAutocompleter = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.whitespace("title"),
queryTokenizer: Bloodhound.tokenizers.whitespace,
Expand Down Expand Up @@ -469,7 +469,7 @@
recordsAutocompleter.initialize();
return recordsAutocompleter;
};
autocompleter = getRecordsAutocompleter({ max: 10 });
var autocompleter = getRecordsAutocompleter({ max: 10 });

// Init typeahead
field
Expand Down Expand Up @@ -558,7 +558,7 @@
urls.forEach(function (url, i) {
// local://srv/api/registries/entries/af8a36bb-ecea-4880-bf83-26b691e7570e?
// transformation=contact-from-iso19139-to-foaf-agent&lang=eng,fre&schema=dcat2
uuid = url.replace(/.*entries\/(.*)\?.*/, "$1");
var uuid = url.replace(/.*entries\/(.*)\?.*/, "$1");
$http
.post(
"../api/search/records/_search",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@
scope.generateThumbnail = function () {
//Added mandatory custom params here to avoid
//changing other printing services
jsonSpec = angular.extend(scope.jsonSpec, {
var jsonSpec = angular.extend(scope.jsonSpec, {
hasNoTitle: true
});

Expand Down Expand Up @@ -869,8 +869,6 @@
} else {
return DEFAULT_CONFIG;
}

return DEFAULT_CONFIG;
}

gnOnlinesrc.register("onlinesrc", function (linkToEditOrType) {
Expand Down Expand Up @@ -2135,7 +2133,7 @@
* Return the index or -1 if not present.
*/
var findObj = function (md) {
for (i = 0; i < scope.selection.length; ++i) {
for (var i = 0; i < scope.selection.length; ++i) {
if (scope.selection[i].md === md) {
return i;
}
Expand Down Expand Up @@ -2183,7 +2181,7 @@
*/
scope.linkToResource = function () {
var uuids = [];
for (i = 0; i < scope.selection.length; ++i) {
for (var i = 0; i < scope.selection.length; ++i) {
var obj = scope.selection[i],
parameter =
obj.md.uuid +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
scope.params = {};
scope.currentSuggestion = gnSuggestion.getCurrent();
scope.processParams = angular.fromJson(scope.currentSuggestion.params);
for (key in scope.processParams) {
for (var key in scope.processParams) {
if (scope.processParams[key].type == "expression") {
scope.params[key] = $interpolate(scope.processParams[key].defaultValue)(
scope
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@
};

scope.restoreHistoryElement = function (statusId) {
confirmMessage = $translate.instant("confirmRestore");
var confirmMessage = $translate.instant("confirmRestore");
if ($window.confirm(confirmMessage)) {
return gnRecordHistoryService.restoreHistoryElement(statusId).then(
function (r) {
message = $translate.instant("recordRestored");
var message = $translate.instant("recordRestored");
scope.$emit("StatusUpdated", {
msg: message,
timeout: 0,
Expand All @@ -154,7 +154,7 @@
$window.location.reload();
},
function (response) {
message = "";
var message = "";
if (response.status === 403) {
message = $translate.instant("notAllowedError");
} else if (response.status === 404) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
scope.$on("beforeSearchReset", function () {
field.typeahead("val", "");
stringValues = [];
for (i = 0; i < prev.length; i++) {
for (var i = 0; i < prev.length; i++) {
$(element).tagsinput("remove", prev[i]);
}
prev = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
}

// Set the route only if not same as before
formatter = gnSearchLocation.getFormatter();
var formatter = gnSearchLocation.getFormatter();

gnUtilityService.scrollTo();

Expand Down Expand Up @@ -341,7 +341,7 @@
var metadata = [];
metadata.push(new Metadata(r.data.hits.hits[i]));

data = { metadata: metadata };
var data = { metadata: metadata };
//Keep the search results (gnMdViewObj.records)
// that.feedMd(0, undefined, data.metadata);
//and the trace of where in the search result we are
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@
};

scope.removeFilter = function (filter) {
removeFacetElement = [];
var removeFacetElement = [];
removeFacetElement.push(filter.key);
var keys = Object.keys(filter.value);
if (angular.isObject(filter.value) && keys[0] != 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
};

var cleanSearchParams = function (params) {
for (v in params) {
for (var v in params) {
if (v !== "sortOrder" && params[v] == "") {
delete params[v];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,11 @@
}

if (gnLangs.langs[currentUILang_3char]) {
v = gnLangs.langs[currentUILang_3char];
var v = gnLangs.langs[currentUILang_3char];
if (!_.includes(result, v)) result.push(v);
}
if (currentUILang2_3char && gnLangs.langs[currentUILang2_3char]) {
v = gnLangs.langs[currentUILang2_3char];
var v = gnLangs.langs[currentUILang2_3char];
if (!_.includes(result, v)) result.push(v);
}
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
this.loadFeaturedUserSearches = function (type, withPortal) {
var deferred = $q.defer(),
usersearches = $http.get("../api/usersearches/featured?type=" + type);
apiCalls = [usersearches];
var apiCalls = [usersearches];
if (withPortal) {
apiCalls.push($http.get("../api/sources/subportal"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@

function setDefault() {
var defaultThesaurus = attrs["default"];
for (t in scope.regionTypes) {
for (var t in scope.regionTypes) {
if (scope.regionTypes[t].name === defaultThesaurus) {
scope.regionType = scope.regionTypes[t];
return;
Expand Down Expand Up @@ -734,7 +734,7 @@
link: function (scope, element, attrs) {
if (attrs["gnRegionType"]) {
gnRegionService.loadList().then(function (data) {
for (i = 0; i < data.length; ++i) {
for (var i = 0; i < data.length; ++i) {
if (attrs["gnRegionType"] == data[i].name) {
scope.regionType = data[i];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
* @param {ol.Feature} feature
* @return {Object} serialized style
*/
getStyleObjFromFeature = function (feature) {
var getStyleObjFromFeature = function (feature) {
var st = feature.get("_style");
var drawType = feature.get("_type");
if (angular.isFunction(st)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@
// Do not densify if shape does not appear to be an extent
if (geom.getType() !== "Polygon" || inCoords.length > 5) return;
for (var i = 0; i < inCoords.length - 1; i++) {
var p0, p1, x0, y0, dX;
var p0, p1, x0, y0, dX, dY;
p0 = inCoords[i];
p1 = inCoords[i + 1];
x0 = p0[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@
var promises = [this.promise, this.dictionary];

return $q.all(promises).then(function (data) {
features = data[0];
dictionary = data[1];
var features = data[0];
var dictionary = data[1];

if (!features || features.length == 0) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,11 @@

this.create = function (map, measureObj, scope) {
// taken from https://openlayers.org/en/v3.15.0/examples/measure.html
getGeodesicLength = function (geometry) {
var getGeodesicLength = function (geometry) {
var sourceProj = map.getView().getProjection();
return formatLength(geometry, sourceProj);
};
getGeodesicArea = function (geometry) {
var getGeodesicArea = function (geometry) {
var sourceProj = map.getView().getProjection();
return formatArea(geometry, sourceProj);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
layerAttributionArray = [];
for (var a = 0; a < layer.vendorExtension.attribution.length; a++) {
var attribution = layer.vendorExtension.attribution[a];
layerAttribution = attribution.title;
var layerAttribution = attribution.title;
// If href exist then make the title a link
if (attribution.onlineResource && attribution.onlineResource[0].href) {
var link = document.createElement("a");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@

scope.featuresInMapExtent = false;

onMoveEnd = function (evt) {
var onMoveEnd = function (evt) {
var extent = scope.map.getView().calculateExtent(map.getSize());
var wgsExtent = ol.extent.applyTransform(
extent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@
var inputs = scope.wpsLink.inputs;
var output = scope.wpsLink.output;

updateStatus = function (statusLocation) {
var updateStatus = function (statusLocation) {
gnWpsService.getStatus(statusLocation).then(
function (response) {
processResponse(response);
Expand All @@ -690,7 +690,7 @@
);
};

processResponse = function (response) {
var processResponse = function (response) {
if (response.TYPE_NAME === "OWS_1_1_0.ExceptionReport") {
scope.executeState = "finished";
scope.running = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
* requests are cancelled
*/
this.describeProcess = function (uri, processId, options) {
url = gnOwsCapabilities.mergeDefaultParams(uri, {
var url = gnOwsCapabilities.mergeDefaultParams(uri, {
service: "WPS",
version: "1.0.0",
request: "DescribeProcess",
Expand Down Expand Up @@ -157,14 +157,16 @@
// create a promise (will be used to cancel request)
this.getCapCanceller = $q.defer();

var that = this;

// send request and decode result
return $http
.get(url, {
cache: true,
timeout: this.getCapCanceller.promise
})
.then(function (response) {
this.getCapCanceller = null;
that.getCapCanceller = null;
if (!response.data) {
return;
}
Expand Down
10 changes: 5 additions & 5 deletions web-ui/src/main/resources/catalog/js/CatController.js
Original file line number Diff line number Diff line change
Expand Up @@ -1378,7 +1378,7 @@
_.set(this.gnCfg, p, o);
}
if (runAllChecks) {
optionInDefaultConfig = _.get(defaultConfig, p);
var optionInDefaultConfig = _.get(defaultConfig, p);
if (optionInDefaultConfig === undefined) {
console.warn(
"Path " +
Expand Down Expand Up @@ -1414,7 +1414,7 @@
option = _.get(config, p);
if (angular.isObject(option) && Object.keys(option).length === 0) {
var key = pathToken.pop();
parent = _.get(config, pathToken.join("."));
var parent = _.get(config, pathToken.join("."));
delete parent[key];
}
}
Expand Down Expand Up @@ -1506,7 +1506,7 @@
return angular.isDefined(this.langs[lang]);
},
isValidIso2Lang: function (lang) {
for (p in this.langs) {
for (var p in this.langs) {
if (this.langs[p] === lang) {
return true;
}
Expand All @@ -1517,7 +1517,7 @@
return this.langs[iso3lang] || "en";
},
getIso3Lang: function (iso2lang) {
for (p in this.langs) {
for (var p in this.langs) {
if (this.langs[p] === iso2lang) {
return p;
}
Expand Down Expand Up @@ -2014,7 +2014,7 @@
.then(function (r) {
$scope.searchInfo = r.data;
var keys = Object.keys(gnGlobalSettings.gnCfg.mods.home.facetConfig);
selectedFacet = keys[0];
var selectedFacet = keys[0];

for (var i = 0; i < keys.length; i++) {
if (
Expand Down
Loading

0 comments on commit 8eabfce

Please sign in to comment.