-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Place tag detection and replacing "-" with "" #2734
Changes from 4 commits
80c3e44
1a30611
2dc5cfe
4660cc4
6be9dbc
2e3eeb6
690027c
dddb402
d6e18c7
3dfc1ef
48435fa
cbf8132
9cc2c0c
c5ba0ab
c13dd2c
abc8b5e
719b598
6f0bd4c
794fa11
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,14 @@ function addTag(tagname, selector) { | |
|
||
selector = selector || '#tagform'; | ||
|
||
if (tagname.indexOf("place") != -1) { | ||
place = tagname.split(":")[1]; | ||
place.replace("-", " "); | ||
geocodeStringAndPan(place); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need to put the prompt code into a callback so it executes /after/ the geocode is complete? Or does this just work? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, perhaps in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I copied this code from blurred-location library, how do I test all of it? |
||
var choice = prompt("This looks like a location: A) Geocode B) Leave"); | ||
while(choice == NULL) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Awesome |
||
|
||
var el = $(selector); | ||
|
||
el.find('.tag-input').val(tagname); | ||
|
@@ -80,3 +88,18 @@ function initTagForm(deletion_path, selector) { | |
return el; | ||
|
||
} | ||
|
||
function geocodeStringAndPan(string, onComplete) { | ||
var url = "https://maps.googleapis.com/maps/api/geocode/json?address=" + string.split(" ").join("+"); | ||
var Blurred = $.ajax({ | ||
async: false, | ||
url: url | ||
}); | ||
onComplete = onComplete || function onComplete(geometry) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Plus, I believe you'll have to assign the onComplete function to run once this Ajax call is complete. See jQuery docs to see how to attach this so it's run on the response only. Make sense? |
||
lat = geometry.lat; | ||
lng = geometry.lng; | ||
|
||
return [lat, lng]; | ||
} | ||
onComplete(Blurred.responseJSON.results[0].geometry.location); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great but let's attach this to the Ajax call so it runs when they call completes; you'll have to look up how this is done in the jQuery Ajax docs! |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -289,8 +289,6 @@ def create | |
uid: current_user.uid, | ||
body: " @#{current_user.username} has marked #{tagname.split(':')[1]} as a co-author. ") | ||
|
||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a stray deletion? Maybe re-adding the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, on it!! |
||
|
||
if saved | ||
@tags << tag | ||
@output[:saved] << [tag.name, tag.id] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, @mridulnagpal -- are these gems used in your code, or was this added by mistake? I guess we can upgrade the versions without a problem, though!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I am not using these gems, must be by mistake
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just remember to remove this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done