diff --git a/Gruntfile.js b/Gruntfile.js index 1fb52134f7c2b89dbc812346060402b360f15950..f8897d8a0b87784ebfe30031624b99ecfe93ba01 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -5,7 +5,7 @@ module.exports = function(grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), jshint: { - files: ['Gruntfile.js', 'src/main/webapp/js/**/*.js', '!src/main/webapp/js/lib/**/*.js'], + all: ['Gruntfile.js', 'src/main/webapp/js/**/*.js', '!src/main/webapp/js/lib/**/*.js'], options: { browser: true, expr: true, @@ -31,9 +31,12 @@ module.exports = function(grunt) { } }, jsdoc: { - dist: { - src: ['src/main/webapp/js/**/*.js', '!src/main/webapp/js/lib/**/*.js'], - dest: 'build/docs/jsdoc' + all: { + src: ['src/main/webapp/js/**/*.js', '!src/main/webapp/js/lib/**/*.js', 'JsDoc.md'], + dest: 'build/docs/jsdoc', + options: { + private: false + } } } }); diff --git a/JsDoc.md b/JsDoc.md new file mode 100644 index 0000000000000000000000000000000000000000..8910da82bc3c56c7970ff8f04cf8589d3082a1a6 --- /dev/null +++ b/JsDoc.md @@ -0,0 +1,2 @@ +This is the technical javascript documentation for the isochrone project. +It contains all the classes which are needed to bring the isochrone web frontend to live. diff --git a/build.gradle b/build.gradle index c32c83ede9540f98ed44163831d46314d71e2d7f..9c84258c6a2c63cbc90d8deac367038c1b3272f2 100644 --- a/build.gradle +++ b/build.gradle @@ -254,6 +254,14 @@ eclipse { Node matcherVagrant = filterVagrant.appendNode('matcher') matcherVagrant.appendNode('id', 'org.eclipse.ui.ide.multiFilter') matcherVagrant.appendNode('arguments', '1.0-name-matches-false-false-.vagrant') + + Node filterNodeModules = filteredResources.appendNode('filter') + filterNodeModules.appendNode('id', 1396275587572) + filterNodeModules.appendNode('name', '') + filterNodeModules.appendNode('type', 14) + Node matcherNodeModules = filterNodeModules.appendNode('matcher') + matcherNodeModules.appendNode('id', 'org.eclipse.ui.ide.multiFilter') + matcherNodeModules.appendNode('arguments', '1.0-name-matches-false-false-node_modules') } } } diff --git a/package.json b/package.json index 6ec45011cb707d9ffdde379fcb86bd9bb290631f..d4de58853a6aba04f11e7aa5a0e78baa5740ff14 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,6 @@ }, "devDependencies": { "grunt-contrib-jshint": "~0.9.2", - "grunt-jsdoc": "~0.5.0" + "grunt-jsdoc": "~0.5.4" } } \ No newline at end of file diff --git a/src/main/webapp/js/isochrone/configuration.js b/src/main/webapp/js/isochrone/configuration.js index 0c3fc4c728296c405ac0c86f14dfea03e6255980..e65b6a0a63f55f06d555a22096232495da064f0f 100644 --- a/src/main/webapp/js/isochrone/configuration.js +++ b/src/main/webapp/js/isochrone/configuration.js @@ -1,6 +1,8 @@ /** - * Singleton class configuration. - * This is used to store the client's configuration + * Used to store the client's configuration + * + * @singleton + * @class Configuration */ define(['console'], function(logger) { var instance = null; @@ -9,6 +11,10 @@ define(['console'], function(logger) { var datasetConfigMap = {}; var mapserverUrl = null; + /** + * @private + * @method Configuration#addDatasetConfig + */ this.addDatasetConfig = function(dSetConfig) { if (!dSetConfig || !dSetConfig.datasetName) { logger.warn('Not adding invalid dataset configuration to client configuration singleton'); @@ -19,18 +25,34 @@ define(['console'], function(logger) { datasetConfigMap[dSetConfig.datasetName] = dSetConfig; }; + /** + * @private + * @method Configuration#getDatasetConfigMap + */ this.getDatasetConfigMap = function() { return datasetConfigMap; }; + /** + * @private + * @method Configuration#getDatasetConfig + */ this.getDatasetConfig = function(datasetName) { return datasetConfigMap[datasetName]; }; + /** + * @private + * @method Configuration#getMapserverUrl + */ this.getMapserverUrl = function() { return mapserverUrl; }; + /** + * @private + * @method Configuration#setMapserverUrl + */ this.setMapserverUrl = function(url) { var i = url.indexOf('://'); if (i <= 0) { @@ -44,6 +66,10 @@ define(['console'], function(logger) { } return { + /** + * @public + * @method Configuration.getInstance + */ getInstance: function() { if (instance === null) { instance = new Configuration(); diff --git a/src/main/webapp/js/isochrone/initHelper.js b/src/main/webapp/js/isochrone/initHelper.js index 6122f2a321265c2e81d36a2cdf40d4ca96971f40..6ef6662dcf0bdebdf6d9e20af76872fc0bad51fa 100644 --- a/src/main/webapp/js/isochrone/initHelper.js +++ b/src/main/webapp/js/isochrone/initHelper.js @@ -1,3 +1,6 @@ +/** + * @class InitHelper + */ define(['jQuery', 'console', 'isochrone/isoMap', 'service/websocket', 'service/serviceIsochrone', 'service/serviceConfiguration', 'isochrone/searchExtender', 'jQueryUI', 'jQueryUI-timepicker'], function($, logger, IsoMap, Websocket, ServiceIsochrone, ServiceConfiguration, SearchExtender) { function InitHelper() { var serviceConfig = null; @@ -7,6 +10,10 @@ define(['jQuery', 'console', 'isochrone/isoMap', 'service/websocket', 'service/s // Public methods + /** + * @public + * @method InitHelper#initMap + */ this.initMap = function() { logger.debug('Initializing map'); @@ -21,6 +28,10 @@ define(['jQuery', 'console', 'isochrone/isoMap', 'service/websocket', 'service/s $(document).on('isomap_draw', extendSearch.bind(this)); }; + /** + * @public + * @method InitHelper#initPreferences + */ this.initPreferences = function() { $('#help-dialog').dialog({ autoOpen: false, @@ -48,6 +59,10 @@ define(['jQuery', 'console', 'isochrone/isoMap', 'service/websocket', 'service/s // Private methods + /** + * @private + * @method InitHelper#extendSearch + */ function extendSearch() { var searchExtender = new SearchExtender(isoMap.getMap(), function() { serviceIsochrone.sentRequest.apply(this, arguments); diff --git a/src/main/webapp/js/isochrone/isoMap.js b/src/main/webapp/js/isochrone/isoMap.js index a5f24e4b9f49d2a9d62d5060cb165c3e8c2d0237..84a5c04fca2af7fcdb7cc791771b25d7b55e0a3f 100644 --- a/src/main/webapp/js/isochrone/isoMap.js +++ b/src/main/webapp/js/isochrone/isoMap.js @@ -1,9 +1,13 @@ +/** + * @class IsoMap + */ define(['jQuery', 'leaflet', 'console', 'map/layer/bing','map/layer/google', 'map/control/help', 'map/control/settings', 'map/control/wswarning', 'map/control/geosearch', 'map/control/geosearchProvider/osm', 'map/ipLocator/ipProvider', 'map/ipLocator/ipLocator'], function($, L, logger, BingLayer, GoogleLayer, HelpControl, SettingsControl, WsWarningControl, GeoSearch, OSMProvider, IpProvider, IpLocator) { // Private static fields var INNSBRUCK = [47.265718, 11.391342]; // var VIENNA = [48.186312, 16.317615]; // Class function (a.k.a. constructor) + function IsoMap(div) { // self has to be used instead of this in private methods to refer to public vars/mathods // var self = this; @@ -32,12 +36,20 @@ define(['jQuery', 'leaflet', 'console', 'map/layer/bing','map/layer/google', 'ma * Gets the internal map object. * This is only useful after the map has been drawn * - * @return the map object. Null if the map has not been drawn. + * @public + * @method IsoMap#getMap + * @return {Object} the map object. Null if the map has not been drawn. */ this.getMap = function() { return map; }; + /** + * Draws the map into the div container referenced by the mDiv class attribute. + * + * @public + * @method IsoMap#draw + */ this.draw = function() { logger.log('Drawing map'); logger.debug(' - options:', mapOptions); @@ -75,10 +87,21 @@ define(['jQuery', 'leaflet', 'console', 'map/layer/bing','map/layer/google', 'ma }); }; + /** + * @public + * @method IsoMap#getLayerControl + */ this.getLayerControl = function() { return layerControl; }; + /** + * Draws the map into the div container referenced by the mDiv class attribute after getting the user's location. + * The estimated user location is used as an initial center of the map shown. + * + * @public + * @method IsoMap#locateAndDraw + */ this.locateAndDraw = function() { var locator = new IpLocator(); locator.locateByIp(mapOptions.ipProvider, onLocationSuccess.bind(this), onLocationError.bind(this)); @@ -86,6 +109,10 @@ define(['jQuery', 'leaflet', 'console', 'map/layer/bing','map/layer/google', 'ma // Private methods + /** + * @private + * @method IsoMap#addBingLayers + */ function addBingLayers() { var apiKey = 'AqTGBsziZHIJYYxgivLBf0hVdrAk9mWO5cQcb8Yux8sW5M8c8opEC2lZqKR1ZZXf', bAerial, @@ -110,6 +137,10 @@ define(['jQuery', 'leaflet', 'console', 'map/layer/bing','map/layer/google', 'ma return bAerial; } + /** + * @private + * @method IsoMap#addBlueMarbleLayers + */ function addBlueMarbleLayers() { if (!L.tileLayer) { return; @@ -142,6 +173,10 @@ define(['jQuery', 'leaflet', 'console', 'map/layer/bing','map/layer/google', 'ma return openGeoOSM; } + /** + * @private + * @method IsoMap#addGoogleLayers + */ function addGoogleLayers() { var gPhysical, gStreet, @@ -168,6 +203,10 @@ define(['jQuery', 'leaflet', 'console', 'map/layer/bing','map/layer/google', 'ma return gSatellite; } + /** + * @private + * @method IsoMap#addOsmLayer + */ function addOsmLayer() { if (!L.tileLayer) { return; @@ -183,6 +222,10 @@ define(['jQuery', 'leaflet', 'console', 'map/layer/bing','map/layer/google', 'ma return layerOsm; } + /** + * @private + * @method IsoMap#addStamenLayer + */ function addStamenLayer() { if (!L.StamenTileLayer) { return; @@ -196,6 +239,10 @@ define(['jQuery', 'leaflet', 'console', 'map/layer/bing','map/layer/google', 'ma return layerStamen; } + /** + * @private + * @method IsoMap#onLocationError + */ function onLocationError(message) { logger.info('Could not get GeoLocation', message); logger.debug(' - will continue with default location'); @@ -203,6 +250,10 @@ define(['jQuery', 'leaflet', 'console', 'map/layer/bing','map/layer/google', 'ma this.draw(); } + /** + * @private + * @method IsoMap#onLocationSuccess + */ function onLocationSuccess(location) { if (!location || !location.coords) { logger.debug('Invalid geoLocation found... no coordinates returned!'); @@ -217,6 +268,10 @@ define(['jQuery', 'leaflet', 'console', 'map/layer/bing','map/layer/google', 'ma this.draw(); } + /** + * @private + * @method IsoMap#warningIndicatorHide + */ function warningIndicatorHide() { if (wsWarningControl !== null) { map.removeControl(wsWarningControl); @@ -224,6 +279,10 @@ define(['jQuery', 'leaflet', 'console', 'map/layer/bing','map/layer/google', 'ma } } + /** + * @private + * @method IsoMap#warningIndicatorShow + */ function warningIndicatorShow() { if (wsWarningControl === null) { wsWarningControl = new WsWarningControl(); diff --git a/src/main/webapp/js/isochrone/isochrone.js b/src/main/webapp/js/isochrone/isochrone.js index da85524879b5a1a8154285c964d030fa5c9f459f..439dfc7e11d4334b660445f80b30c867ceab9bab 100644 --- a/src/main/webapp/js/isochrone/isochrone.js +++ b/src/main/webapp/js/isochrone/isochrone.js @@ -1,3 +1,6 @@ +/** + * @class Isochrone + */ define(['jQuery', 'leaflet', 'console', 'isochrone/configuration', 'util/stringUtils'], function($, L, logger, Configuration, StringUtils) { function Isochrone(iMap) { var isoMap = null; @@ -9,6 +12,10 @@ define(['jQuery', 'leaflet', 'console', 'isochrone/configuration', 'util/stringU // Public methods + /** + * @public + * @method Isochrone#showLayers + */ this.showLayers = function(requestData, bBoxLatLng) { var config = Configuration.getInstance(); if (layerMap === null) { @@ -24,6 +31,10 @@ define(['jQuery', 'leaflet', 'console', 'isochrone/configuration', 'util/stringU // Private methods + /** + * @private + * @method Isochrone#addLayers + */ function addLayers(requestData, clientConfig, baseUrl) { var layerCoverage = null, layerEdge = null, @@ -80,6 +91,10 @@ define(['jQuery', 'leaflet', 'console', 'isochrone/configuration', 'util/stringU updateLayers(requestData); } + /** + * @private + * @method Isochrone#fitMap + */ function fitMap(bBoxLatLng) { var map = null; @@ -90,6 +105,10 @@ define(['jQuery', 'leaflet', 'console', 'isochrone/configuration', 'util/stringU } } + /** + * @private + * @method Isochrone#updateLayers + */ function updateLayers(requestData) { if (layerMap === null) { logger.warn('Can not update layers... no layers available (call addLayers first!)'); diff --git a/src/main/webapp/js/isochrone/searchExtender.js b/src/main/webapp/js/isochrone/searchExtender.js index e9d2ef6b24523ad20e4824b2809d1844e40d297b..dc4408b8d0f4ec1edfd96d8e9c46a5e88067889a 100644 --- a/src/main/webapp/js/isochrone/searchExtender.js +++ b/src/main/webapp/js/isochrone/searchExtender.js @@ -1,3 +1,6 @@ +/** + * @class SearchExtender + */ define(['jQueryUI', 'console', 'isochrone/configuration', 'util/stringUtils'], function($, logger, Configuration, StringUtils) { function SearchExtender(m, callback) { var callbackFn = null; @@ -16,11 +19,19 @@ define(['jQueryUI', 'console', 'isochrone/configuration', 'util/stringUtils'], f // Public methods + /** + * @public + * @method SearchExtender#extendResult + */ this.extendResult = function() { appendMapListener(); - appendSListeners(); + appendStateListeners(); }; + /** + * @public + * @method SearchExtender#setState + */ this.setState = function(state) { isActive = state; @@ -35,6 +46,10 @@ define(['jQueryUI', 'console', 'isochrone/configuration', 'util/stringUtils'], f // Private methods + /** + * @private + * @method SearchExtender#appendIconListener + */ function appendIconListener(geosearchResultEl, datasetConfigs, pointArr) { logger.debug('Appending icon listeners for searchExtender'); @@ -48,13 +63,21 @@ define(['jQueryUI', 'console', 'isochrone/configuration', 'util/stringUtils'], f }); } + /** + * @private + * @method SearchExtender#appendMapListener + */ function appendMapListener() { logger.debug('Appending map listeners for searchExtender'); map.on(geosearchEventName, onSearchResult.bind(this)); } - function appendSListeners() { + /** + * @private + * @method SearchExtender#appendStateListeners + */ + function appendStateListeners() { var fnDisable = self.setState.bind(this, false), fnEnable = self.setState.bind(this, true); @@ -64,6 +87,10 @@ define(['jQueryUI', 'console', 'isochrone/configuration', 'util/stringUtils'], f $(document).on('websocket_open', fnEnable); } + /** + * @private + * @method SearchExtender#clearDatasetConfigTab + */ function clearDatasetConfigTab() { if (configIsochroneDiv === null) { return; @@ -73,6 +100,10 @@ define(['jQueryUI', 'console', 'isochrone/configuration', 'util/stringUtils'], f configIsochroneDiv = null; } + /** + * @private + * @method SearchExtender#createDatasetConfigTab + */ function createDatasetConfigTab(cfg) { var a = document.createElement('a'), container1 = document.createElement('div'), @@ -144,6 +175,10 @@ define(['jQueryUI', 'console', 'isochrone/configuration', 'util/stringUtils'], f }; } + /** + * @private + * @method SearchExtender#getDmaxSliderSteps + */ function getDmaxSliderSteps() { return [{ display: '1min', @@ -181,6 +216,10 @@ define(['jQueryUI', 'console', 'isochrone/configuration', 'util/stringUtils'], f }]; } + /** + * @private + * @method SearchExtender#getDSetConfigs + */ function getDSetConfigs(point) { var config = Configuration.getInstance(), configCandidates = [], @@ -207,6 +246,10 @@ define(['jQueryUI', 'console', 'isochrone/configuration', 'util/stringUtils'], f return configCandidates; } + /** + * @private + * @method SearchExtender#onSearchResult + */ function onSearchResult(data) { var dSetConfigs = null, liFirstChild, @@ -237,6 +280,10 @@ define(['jQueryUI', 'console', 'isochrone/configuration', 'util/stringUtils'], f appendIconListener(geosearchResultEl, dSetConfigs, [data.point]); } + /** + * @private + * @method SearchExtender#showIsochroneConfig + */ function showIsochroneConfig(geosearchResultEl, datasetConfigs, pointArr) { // we write the datasetconfigs to a map while creating the config tabs, so // that they can easily be retrieved on start button click @@ -290,6 +337,10 @@ define(['jQueryUI', 'console', 'isochrone/configuration', 'util/stringUtils'], f }); } + /** + * @private + * @method SearchExtender#sortDatasetFn + */ function sortDatasetFn(d0, d1) { var s0 = d0.bBox.getSize(), s1 = d1.bBox.getSize(); diff --git a/src/main/webapp/js/map/control/geosearch.js b/src/main/webapp/js/map/control/geosearch.js index a94ce192f93913414c56f0b48fc7af4cede8a92c..cea471c529595d6ad009744d9eb09a8fd8bc0e10 100644 --- a/src/main/webapp/js/map/control/geosearch.js +++ b/src/main/webapp/js/map/control/geosearch.js @@ -1,5 +1,5 @@ /** - * GeoSearch - search for an address and zoom to its location + * GeoSearch - search for an address and zoom to its location. * * @see https://github.com/smeijer/leaflet.control.geosearch */ diff --git a/src/main/webapp/js/map/control/geosearchProvider/osm.js b/src/main/webapp/js/map/control/geosearchProvider/osm.js index f588c230e20e0aa250fd11f4199bde7edcd07805..e0e08885fab4dff4c61dbfa810d95170e483dcef 100644 --- a/src/main/webapp/js/map/control/geosearchProvider/osm.js +++ b/src/main/webapp/js/map/control/geosearchProvider/osm.js @@ -1,5 +1,5 @@ /** - * Uses openstreetmap geocoding service for providing geosearch + * Uses openstreetmap geocoding service for providing geosearch. * * @see https://github.com/smeijer/leaflet.control.geosearch */ diff --git a/src/main/webapp/js/service/serviceConfiguration.js b/src/main/webapp/js/service/serviceConfiguration.js index 379b53a80d15910f43f1c50134b6f23c299f7007..25687b3586a3b9fd5a8a22849e0e7a81b7598afc 100644 --- a/src/main/webapp/js/service/serviceConfiguration.js +++ b/src/main/webapp/js/service/serviceConfiguration.js @@ -1,3 +1,6 @@ +/** + * @class ServiceConfiguration + */ define(['jQuery', 'leaflet', 'console', 'isochrone/configuration', 'util/geoUtils'], function($, L, logger, Configuration, GeoUtils) { function ServiceConfiguration(ws) { var actionName = 'getConfiguration'; @@ -9,6 +12,10 @@ define(['jQuery', 'leaflet', 'console', 'isochrone/configuration', 'util/geoUtil // Public methods + /** + * @public + * @method ServiceConfiguration#initFromServer + */ this.initFromServer = function() { // if (!$._data(document, 'events')[actionName]) { $(document).on(actionName, onServerResponse.bind(this)); @@ -29,6 +36,9 @@ define(['jQuery', 'leaflet', 'console', 'isochrone/configuration', 'util/geoUtil * <li>queryNode the a 2D-coordinate of the query point</li> * <li>time the arrival or departure time of the query point</li> * </ul> + * + * @private + * @method ServiceConfiguration#onServerResponse */ function onServerResponse(data) { var config = Configuration.getInstance(), diff --git a/src/main/webapp/js/service/serviceIsochrone.js b/src/main/webapp/js/service/serviceIsochrone.js index e707fff70149b86917f7f76104782d398f77214e..12a8053b7ad6cd58a837b1a2c127c0f937950240 100644 --- a/src/main/webapp/js/service/serviceIsochrone.js +++ b/src/main/webapp/js/service/serviceIsochrone.js @@ -1,3 +1,6 @@ +/** + * @class ServiceIsochrone + */ define(['jQuery', 'leaflet', 'console', 'spinner', 'isochrone/isochrone', 'util/geoUtils'], function($, L, logger, Spinner, Isochrone, GeoUtils) { function ServiceIsochrone(ws, iMap) { var actionName = 'getIsochrone'; @@ -11,6 +14,11 @@ define(['jQuery', 'leaflet', 'console', 'spinner', 'isochrone/isochrone', 'util/ websocket = ws; // Public methods + + /** + * @public + * @method ServiceIsochrone#sentRequest + */ this.sentRequest = function(datasetConfig, points, options) { var msg = null, settings = $('#settings-fields'), @@ -56,6 +64,10 @@ define(['jQuery', 'leaflet', 'console', 'spinner', 'isochrone/isochrone', 'util/ // Private methods + /** + * @private + * @method ServiceIsochrone#onServerResponse + */ function onServerResponse(requestData, responseData) { logger.debug('Handling event "' + actionName + '":', responseData); logger.debug('Isochrone timings are: ', responseData.logging); @@ -84,6 +96,10 @@ define(['jQuery', 'leaflet', 'console', 'spinner', 'isochrone/isochrone', 'util/ $(document).off(actionName); } + /** + * @private + * @method ServiceIsochrone#pointsToQueryNodes + */ function pointsToQueryNodes(points) { var i = 0, nodes = []; diff --git a/src/main/webapp/js/service/websocket.js b/src/main/webapp/js/service/websocket.js index affb36d5e53405a042eb3cd31df4dd4a852c0fbb..af2b1fb533669c6d81804b82f16284fbfbe4b5dc 100644 --- a/src/main/webapp/js/service/websocket.js +++ b/src/main/webapp/js/service/websocket.js @@ -1,3 +1,6 @@ +/** + * @class Websocket + */ define(['jQuery', 'console'], function($, logger) { // Static fields var currentUrl = window.location.href, @@ -8,11 +11,11 @@ define(['jQuery', 'console'], function($, logger) { /** - * This class is used to communicate with the server + * Used to communicate with the server. */ function Websocket() { /** - * The websocket object that holds the connection and to which the callback listeners are applied + * The websocket object that holds the connection and to which the callback listeners are applied. */ var websocket = null; @@ -27,9 +30,11 @@ define(['jQuery', 'console'], function($, logger) { // Public methods /** - * Sends the specified message to the server + * Sends the specified message to the server. * - * @param msg {String/Object} message to send + * @public + * @method Websocket#sendWsMessage + * @param {String/Object} msg message to send */ this.sendWsMessage = function(/* {String/Object} */msg) { if (websocket.readyState === websocket.OPEN) { @@ -51,6 +56,10 @@ define(['jQuery', 'console'], function($, logger) { // Private methods + /** + * @private + * @method Websocket#onOpen + */ function onOpen(evt) { var e = null; @@ -60,6 +69,10 @@ define(['jQuery', 'console'], function($, logger) { $(document).trigger(e); } + /** + * @private + * @method Websocket#onClose + */ function onClose(evt) { var e = null; @@ -69,6 +82,10 @@ define(['jQuery', 'console'], function($, logger) { $(document).trigger(e); } + /** + * @private + * @method Websocket#onMessage + */ function onMessage(evt) { var e1 = null, e2 = null, @@ -99,6 +116,10 @@ define(['jQuery', 'console'], function($, logger) { $(document).trigger(e2); } + /** + * @private + * @method Websocket#onError + */ function onError(evt) { var e = null; diff --git a/src/main/webapp/js/util/geoUtils.js b/src/main/webapp/js/util/geoUtils.js index 21ec6756485d7ece2daef355ecfd6e7f55af7bdf..30cb33b1d535809b3f2fc75332f35300c2868a1d 100644 --- a/src/main/webapp/js/util/geoUtils.js +++ b/src/main/webapp/js/util/geoUtils.js @@ -1,25 +1,36 @@ +/** + * @class GeoUtils + */ define(['leaflet'], function(L) { + /** + * @private + * @constructor + */ function GeoUtils() { } // Public static method /** - * Converts from a LatLng (EPSG:4326) to a point from projection EPSG:3857 + * Converts from a LatLng (EPSG:4326) to a point from projection EPSG:3857. * - * @param L.latLng the matching L.latLng object (coordinates in EPSG:4326) - * @return L.Point the point to convert (containing EPSG:3857 x and y) + * @public + * @method GeoUtils.convertFromLatLng + * @param {L.latLng} latLng the matching L.latLng object (coordinates in EPSG:4326) + * @return {L.Point} the point to convert (containing EPSG:3857 x and y) */ GeoUtils.convertFromLatLng = function(latLng) { return L.CRS.EPSG3857.project(latLng); }; /** - * Converts a point from projection EPSG:3857 to LatLng (EPSG:4326) + * Converts a point from projection EPSG:3857 to LatLng (EPSG:4326). * + * @public + * @method GeoUtils.convertToLatLng + * @param {L.Point} point the point to convert (containing EPSG:3857 x and y) + * @return {L.latLng} the matching L.latLng object (coordinates in EPSG:4326) * @see http://developer.tomtom.com/docs/read/map_toolkit/javascript_sdk_2_0/Migration_Guide - * @param L.Point the point to convert (containing EPSG:3857 x and y) - * @return L.latLng the matching L.latLng object (coordinates in EPSG:4326) */ GeoUtils.convertToLatLng = function(point) { var earthRadius = 6378137; diff --git a/src/main/webapp/js/util/stringUtils.js b/src/main/webapp/js/util/stringUtils.js index 9b8fc9460a73f933d03f991baf7f7813e6793aa3..d90a87b74d1e9eab43e2d6de7a6816c87aa3faff 100644 --- a/src/main/webapp/js/util/stringUtils.js +++ b/src/main/webapp/js/util/stringUtils.js @@ -1,4 +1,11 @@ +/** + * @class StringUtils + */ define([], function() { + /** + * @private + * @constructor + */ function StringUtils() { } @@ -7,13 +14,23 @@ define([], function() { /** * Takes a string and returns it with the first char in upper case and all the rest in lower case. * - * @param str string to capitalize - * @returns same as the input, but with first letter in uppercase (and rest in lower case) + * @public + * @method StringUtils.capitalize + * @param {String} str string to capitalize + * @return {String} same as the input, but with first letter in uppercase (and rest in lower case) */ StringUtils.capitalize = function(str) { return str.substring(0, 1).toUpperCase() + str.substring(1).toLowerCase(); }; + /** + * Converts a given date to a string (using pattern dd.mm.yyyy). + * + * @public + * @method StringUtils.dateToString + * @param {Date} the date to convert + * @return {String} the given date as string (using pattern dd.mm.yyyy) + */ StringUtils.dateToString = function(date) { var dateStr = ('0' + date.getDate()).slice(-2) + '.' + ('0' + (date.getMonth() + 1)).slice(-2) + '.' + date.getFullYear(), timeStr = ('0' + date.getHours()).slice(-2) + ':' + ('0' + date.getMinutes()).slice(-2);