CSM:List of Functions

List of Functions for CSM
Before the checking of functions, it is recommended to have an overview of mobile app provided services. This overview could be by running the app and checking this services directly, or by checking its description within related deliverables, such as D 4.6. Used functions within CSM mobile app could be classified based on its purposes and hosted file name, as it appears below. Most of hosted code files, mentioned below, are available in code repository within www/js folder. An example of apps include:
 * settings: Wifi, GPS, ..
 * feedback: feelings, comments,...
 * graphs: heat map, tracking, ...

The detailed list addresses b)	documentReady.js
 * Index.html
 * goToWIFISettings: Asks user to control the Wi-Fi settings of the phone.
 * goToGPSSettings : Asks user to control the GPS settings of the phone.
 * Initialize : Gets the content height in order to adjust the UI components.
 * getRealContentHeight : it is called in the initialize method. This makes the necessary calculations and returns the result back to the initialize method, which helps adjust the UI components of the content.
 * vibrate : creates vibration for 1 sec.
 * capturePhoto : takes picture using device camera and retrieves image as base64-encoded string.
 * feelingsOnReady; Adjusts the visibility of feelings (man icons) on the map.
 * heatMapAQIRelatedOperationsOnReady; Heat map adjustments are set.
 * pollenClickOnDocReady; “onClick” method. Visibility of gears are set.
 * feelingsInfoClickOnDocReady; “onClick” method. Visibility of gears are set.
 * trackRootClickOnDocReady;“onClick” method. informationWindow popup gets closed while tracking_popup opens.
 * reportFeelingRelatedOnDocReady; “onClick” method. informationWindow popup gets closed while reportfeeling_popup1 opens.
 * informationPopupOnDocReady; “onClick” method. informationWindow opens.
 * settingsOnDocReady; “onClick” method. settings_popup opens.
 * feelingsPopupSetOnDocReady; “onClick” method. feelings_popup closes.
 * qualityPopupSetOnDocReady; “onClick” method. quality_popup closes.
 * trackingModesOnDocReady; “onClick” method. When tracking is clicked, the visibility of related UI components are re-configured based on the selected mode (start, stop, pause)
 * trackRouteStartStopOnDocReady; “onClick” method. When trackRoute is clicked, UI components get hidden or visible.
 * trackingStartOnDocReady; “onClick” method. When tracking_start is clicked, UI components get hidden or visible.
 * trackingPauseOnDocReady; “onClick” method. When tracking_pause is clicked, UI components get hidden or visible.
 * trackingStopOnDocReady; “onClick” method. When tracking_stop is clicked, UI components get hidden or visible.
 * trackingSummaryOnDocReady; “onClick” method. When tracking_summary-save is clicked, UI components get hidden or visible.
 * trackingHistorialOnDocReady; “onClick” method. When tracking_historial is clicked, UI components get hidden or visible.
 * deviceReady.js
 * setTrackingTextFieldsNorwegian : Changes the labels of tracking popup based on the language selection.
 * setUserInformationSettings : Generates a unique id, if there is no id generated before. Then it calls the updateUserInformationForms method to keep information popup fields updated.
 * refreshCitySensors : It makes a simple call to getListOfSensorUrls method in order to get the list of sensors URLs, which will be called to fetch the latest measurements from sensors.
 * retrieveCitySensors.js
 * toggleHeatmap : Generates a heatmap layer over the googleMap.
 * loadPollenData : Makes a call to fetch the Pollen data from correspondence server.
 * pollenDataServiceException : It is called, if loadPollenData method fails. It is just to handle the current situation by giving a notice to the user that the service failed at the moment.
 * parsePollenData2 : It is called, if loadPollenData method succeeds. It is to parse the response of the server and make the response ready for the table.
 * mergePollenDataSets : It is used to merge two sets of pollen data.
 * findColorOfPollen : Based on the pollen data measured value, its colour is specified.
 * loadPollenDataIntoTable : The pollen data is now made ready for the preview.
 * loadAnotherWay : Makes the call in the old fashioned way, meaning that the old service is called to get the list of city sensors. It is most probably deprecated due to the availability of new services.
 * Parse : This method is to parse the response of loadAnotherWay method.
 * changeOpacity : It changes the opacity of heatmap on GoogleMap.
 * defineItsWeight : It makes the calculation for pollution in order to define its weight & color. Mostly Deprecated!
 * defineItsColour : It makes the calculation for pollution in order to define its color. Mostly Deprecated!
 * deleteOverlays : It deletes (cleans) the markers or feelings from the map.
 * showAllMarkers : It maps the markers or feelings on the map.
 * showOnlySpecificSensors: it is related to view filtering services, where, It removes all of the markers except the ones which satisfy particular criteria.
 * showOnlySpecificMenFigures : It removes all of the men figures but the specified one.
 * showEverythingOnMap : Show markers and feelings on the map.
 * retrieveCitySensorsVnew.js
 * getListOfSensorUrls : Makes the call to get the list of endpoints of each city sensor location.
 * callCitySensors : it makes the call for each sensor in the city
 * callService : it is the service making the real ajax call
 * parseDoc : It is the success method for callService method, which parses the response and creates the data set for App to use on the map.
 * parseDocOldOne : Deprecated.
 * trackingCitySense.js
 * saveTheTrackingData : Saves the tracking data locally, takes the screenshot of the activity and calls the insertTrackingObject  method from storageMethods.js who pushes the data into the local storage.
 * startTracking : Starts the recording of tracking.
 * pauseTracking : Pauses the recording of tracking, calls the stopTimer method.
 * restartTracking : Restarts the recording of tracking.
 * stopTracking : Stops the recording operation and keeps the necessary data to prepare saving.
 * onSucc : Recording of tracking is conducted with the GPS location data. Thus, the location of the user is retrieved in a timely manner. This method is the success callback of the geolocation method.
 * gps_distance : This is to calculate the distance between two GEOlocation (lat,lon) points.
 * convertTimeStampToTimeString:This is a util method to make the necessary conversation.
 * Getdhm : Formats a timestamp value, returns it in month/day/year format.
 * startTimer : Starts the timer.
 * stopTimer: Stops the timer.
 * Timer : A function that prepares the methods of the “Timer” Object.
 * shareViaFB : It utilizes the “Cordova Plugin” called socialSharing method in order to share data via Facebook.
 * shareViaTwitter : It utilizes the “Cordova Plugin” called socialSharing method in order to share data via Twitter.
 * shareViaMail : It utilizes the “Cordova Plugin” called socialSharing method in order to share data via Mail applications.
 * prepareSharing : It is the actual call to share tracking, which decides by what channel the data should be shared.
 * getTimeDiffPlease : It is a util method to calculate the difference between 2 timestamp values in Sec.
 * timeDiffOfTwo: It takes the difference between two date (milliseconds) values, converts it into second, then the possible distance that can be made during that time duration is calculated. This way, the current calculation is compared with the possible distance he can make. This helps the application understand if there is an erroneous case in tracking logic (if the calculated distance is bigger than the possible metric value then the data is ignored), or not (if the calculated value is equal or smaller than the possible metric value then the app makes the rest of the calculation as designed).
 * storagemethods.js
 * createTag : creates a tag with the given parameters. (Not in use – deprecated)
 * createHrefTag : creates a href tag with the given parameters. (Not in use – deprecated)
 * createIncludeTagXML: creates the questionnaire xml attribute (Not in use – deprecated)
 * saveUserFeedback : Saves the input entered in userFeedback screen.
 * saveQuestionnaire : Saves a questionnaire answered by the user.
 * setLanguagePreferenceIntoDB : When user changes the language setting of the app, the new choice of the user is saved as preference in the local storage.
 * insertTrackingObject : Inserts newly recorded tracking data into the local storage.
 * PopupPic : It is called when the history of tracking is shown in order to set the width & height of the image frame and place the recorded image into it.
 * showHistoryOfTracking : All history of tracking is fetched from the localStorage and then prepared to be previewd in the table.
 * insertObject: It is the put a new object (feeling) into localstorage.
 * deleteKeyStore : It is the delete a key store from local storage entirely.
 * updateTheCommentOfLastFeeling : Updates the last feeling in the feeling collection. It is used when a new feeling is desired to be located on the map but there has already been a feeling object in that zone of the user.
 * updateTheManIconColorOfLastFeeling : Updates the colour of the last feeling in the feeling collection. It is used when a new feeling is desired to be located on the map but there has already been a feeling object in that zone of the user.
 * checkLastTwoManIcons : When the user puts a new man icon, its position will be checked with the last man icon' position and it will be discarded if the current position is in the range of previous one's
 * findSearch : It is to verify that an object exists in the keystore.
 * fetchAllTrackingFromDB : It is to debug all of the tracking objects in the DB (localStorage)
 * fetchAllFromDB: It prints the data of the desired key in the local storage.
 * fetchClicks : It fetches the number of clicks for a specific page (Data is stored in localStorage)
 * findAndUpdate : It finds the data of a specific page in localStorage and updates its pageClick value (increases +1).
 * fetchVisitDurations : It fetches the duration of a visit for a specific page. (Data is stored in localStorage)
 * addVisitIntoPage : It adds a visit object (details, duration amount) for a page.
 * generateUUID : Generates a unique id.
 * firstTimeAfterInstallation : It returns a Boolean value to check if it is the first usage right after the installation of the application.
 * setUserInformationPreferenceIntoDB : It stores the user information preference (gender, yearborn, education) into the db.
 * saveQuestionnaireViaTemplate : It prepares the questionnaire data via template in order to store and send it to the server.
 * printDebug : It is a util method to debug timestamp formats.
 * retrieveMyFeelings.js
 * showMyFeelingsByLocalStorage : It takes the feelings of the user from DB and generates related data, categorizes them by color (red, yellow, orange, green) to put them on the map.
 * createFeeling : It creates a new feeling with the position of pin (for man icon), the comment that user enters, and the icon information.
 * showDetailsOftheClickedMarker : Basically takes and shows a specific marker.
 * onSuccessFeeling: Success callback of putFeeling method.
 * onErrorFeeling: Error callback method of putFeeling method.
 * putFeeling : It puts a feeling icon when user clicks man icon in the application. The geolocation info of the user is attempted to fetch in order to put a man icon on the map.
 * saveFeelingComment : When user enters a comment for a feeling, it is attached to that feeling and stored in DB updateFeelingComment
 * restartFeelingAndItsComments : It sets the location of each marker feeling to NULL so that they are not visible on the map anymore till it is changed back.
 * addZero : It is a util method to make “hour” value readable when timestamp is turned into a mm/dd/yyyy hh:mm format.
 * printNow : It is only for debug purposes, prints timestamp to help measure performance of a specific method.
 * Localization.js
 * This js consists of only one main object called Localization which makes the necessary object settings for the application to set and switch languages.
 * Language.js
 * setLanguage : is the method that acts as a DB table for different languages. It stores the equivalent of each keyword in different languages.
 * saveLanguagePreference : is to switch between languages. It calls the vibrate method to buzz the device to notify the user that the change has been reflected.
 * userInformation.js
 * saveUserinformation : Takes the input from userInformation popup and saves into localStorage.
 * updateUserInformationForms : When user desires to update his info, this method takes place with the new inputs.
 * updateUserInformationFormsGender : Specifically sets the gender input’s status (checked/unchecked).
 * updateUserInformationFormsYearborn: Specifically sets the yearBorn input’s status.
 * updateUserInformationFormsEducation : Specifically sets the gender input’s status.
 * updateUserInformationFormsHidePopUp: Specifically sets the user’s choice (checked/unchecked) on the popup.
 * hideStartPopUp: Sets the visibility of the information popup.
 * wfsstoragemethods.js
 * callback: is to store data in local storage that cannot be sent due to some reason like network connection.
 * createAQAPSensor : Checks if there is a sensor device for this app stored on the WFS, if not creates it before calling the callback function
 * storeSensorDeviceXml : Creates a Sensor Device based on xml template, if successfull calls the callback function
 * storePerceptions : Creates a sensor device then run callback for storing user perception
 * storePerceptionsCallback : Runs a specific method in a time interval, in this case to try calling storePerception method again.
 * storePerception : Gets the template xml file and calls storePerceptionXml method.
 * storePerceptionXml : This prepares the request xml and makes a call to the server for store operation.
 * includeElement : To make an “include” element for XML
 * getOthersPerception : Get others perception from wfs server (only for a specific area), add markers on map
 * getOthersAllPerceptions : gets the data of all of other perceptions from the server.