Skip to content

Commit

Permalink
#5, #7 polygon & mapping entitied for a project
Browse files Browse the repository at this point in the history
  • Loading branch information
ramyaragupathy committed Mar 28, 2018
1 parent 964b52a commit 84ba5f3
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 20 deletions.
29 changes: 19 additions & 10 deletions dist/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -987,23 +987,33 @@ function errorNotice (message, time) {
}

/**
* Event listener for project selection
* Construct URL to request a particular project details
*
**/

document.getElementById('projects').addEventListener('change', function (e) {
let projectID = this.value
projDetails(projectID)
})
function getProjQuery () {
let projectID = document.getElementById('projects').value
let url = 'https://tasks.hotosm.org/api/v1/project/' + projectID + '?as_file=false'
return url
}

/**
* Fetches complete details of a particular HOTOSM project
*
* @param {number} projectID - Unique ID of a HOTOSM project
**/

function projDetails (projectID) {
console.log('From projDetails: ', projectID)
function getProjDetails () {
let url = getProjQuery()
console.log('From projDetails: ', url)
$.ajax(url)
.done(function (data) {
let polygon = data.areaOfInterest
let entities = data.mappingTypes
console.log(entities)
console.log(polygon)
})
.fail(function () {
})
}

// Fetch Data on Click
Expand All @@ -1017,8 +1027,7 @@ $('#submit').on('click', function () {
'fromDate': moment($('#fromdate').val()).utc().toISOString(),
'toDate': moment($('#todate').val()).utc().toISOString()
}
let url = getQuery()
console.log('from submit before fetching ', url)
getProjDetails()
getData()
} else {
errorNotice('Zoom in further to fetch results')
Expand Down
29 changes: 19 additions & 10 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,23 +178,33 @@ function errorNotice (message, time) {
}

/**
* Event listener for project selection
* Construct URL to request a particular project details
*
**/

document.getElementById('projects').addEventListener('change', function (e) {
let projectID = this.value
projDetails(projectID)
})
function getProjQuery () {
let projectID = document.getElementById('projects').value
let url = 'https://tasks.hotosm.org/api/v1/project/' + projectID + '?as_file=false'
return url
}

/**
* Fetches complete details of a particular HOTOSM project
*
* @param {number} projectID - Unique ID of a HOTOSM project
**/

function projDetails (projectID) {
console.log('From projDetails: ', projectID)
function getProjDetails () {
let url = getProjQuery()
console.log('From projDetails: ', url)
$.ajax(url)
.done(function (data) {
let polygon = data.areaOfInterest
let entities = data.mappingTypes
console.log(entities)
console.log(polygon)
})
.fail(function () {
})
}

// Fetch Data on Click
Expand All @@ -208,8 +218,7 @@ $('#submit').on('click', function () {
'fromDate': moment($('#fromdate').val()).utc().toISOString(),
'toDate': moment($('#todate').val()).utc().toISOString()
}
let url = getQuery()
console.log('from submit before fetching ', url)
getProjDetails()
getData()
} else {
errorNotice('Zoom in further to fetch results')
Expand Down

0 comments on commit 84ba5f3

Please sign in to comment.