// *********************************************************
function fetch_from_api(endpoint_name, params, callback) {
- // `&a=&b=&c=1` => '&c='
- for (var k in params) {
- if (typeof (params[k]) === 'undefined' || params[k] === '' || params[k] === null) {
- delete params[k];
+ // `&a=&b=&c=1` => '&c=1'
+
+ var param_names = Object.keys(params);
+ for (var i = 0; i < param_names.length; i += 1) {
+ var val = param_names[keys[i]];
+ if (typeof (val) === 'undefined' || val === '' || val === null) {
+ delete param_names[keys[i]];
}
}
+'use strict';
+
function formatOSMType(sType, bExcludeExternal) {
if (sType === 'N') return 'node';
if (sType === 'W') return 'way';
}
Handlebars.registerHelper({
- shortOSMType: function(sType) {
+ shortOSMType: function (sType) {
if (sType === 'node') return 'N';
if (sType === 'way') return 'W';
if (sType === 'relation') return 'R';
return (iLevel < 15 ? iLevel : '');
},
formatMapIcon: function (sIcon) {
- if (!sIcon) return;
+ if (!sIcon) return '';
var url = sIcon;
if (!url.match(/^http/)) url = get_config_value('Images_Base_Url') + url;
if (aPlace.type && aPlace.type === 'yes' && aPlace.class) {
return capitalize(aPlace.class.replace(/_/g, ' '));
- } else if (aPlace.type) {
+ }
+ if (aPlace.type) {
return capitalize(aPlace.type.replace(/_/g, ' '));
}
return '';
return 'other: ' + iRank;
},
tooManyHierarchyLinesWarning: function (aPlace) {
- if (!aPlace.hierarchy) return;
+ if (!aPlace.hierarchy) return '';
- var c = 0;
- for (var type in aPlace.hierarchy) {
- c = c + type.length + 1;
- }
- if (c < 500) return;
+ var c = Object.keys(aPlace.hierarchy);
+ if (c < 500) return '';
return new Handlebars.SafeString(
'<p>There are more child objects which are not shown.</p>'
var select = $('<select>');
var option = jQuery('<option>', { value: '', text: '--' });
- if (typeof (iSelectedZoom) === 'undefined') option.attr('selected', 'selected');
+ if (typeof (iSelectedZoom) === 'undefined') {
+ option.attr('selected', 'selected');
+ }
option.appendTo(select);
jQuery.each(aZoomLevels, function (i, title) {