summaryrefslogtreecommitdiff
path: root/addons/website_event/static/src/js
diff options
context:
space:
mode:
authorParth Gajjar (Open ERP) <pga@tinyerp.com>2014-02-26 17:01:21 +0530
committerParth Gajjar (Open ERP) <pga@tinyerp.com>2014-02-26 17:01:21 +0530
commitd4e7b18a553e1920548c4cd6de4faa9815c5cb02 (patch)
tree658f9f8a973fd8274f7ceb116e280bcc9668f78c /addons/website_event/static/src/js
parent2ab61cf001fab1d30050598931bfa39956cf4883 (diff)
[ADD] added snippet for country event, script for finding coordinates from brwoser, And display events from users country
bzr revid: pga@tinyerp.com-20140226113121-vni0182v0cc2u3d4
Diffstat (limited to 'addons/website_event/static/src/js')
-rw-r--r--addons/website_event/static/src/js/website_geolocation.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/addons/website_event/static/src/js/website_geolocation.js b/addons/website_event/static/src/js/website_geolocation.js
new file mode 100644
index 00000000000..3d48b042433
--- /dev/null
+++ b/addons/website_event/static/src/js/website_geolocation.js
@@ -0,0 +1,40 @@
+(function() {
+ "use strict";
+ function getLocation()
+ {
+ if (navigator.geolocation)
+ {
+ navigator.geolocation.getCurrentPosition(showPosition);
+ }
+ else{alert("Geolocation is not supported by this browser.");}
+ }
+
+ function showPosition(position)
+ {
+ var latitude = position.coords.latitude;
+ var longitude = position.coords.longitude;
+ $.ajax({
+ url: "https://maps.googleapis.com/maps/api/geocode/json?latlng="+latitude+","+longitude+"&sensor=false",
+ type: 'GET',
+ dataType: 'json',
+ success: function(response, status, xhr, wfe){
+ if(response.status == 'OK'){
+ var last_element = response.results[response.results.length - 1]
+ if( last_element.types.indexOf( "country" ) != -1){
+ var country_obj = last_element.address_components[0];
+ $('img.event_country_flag').attr('src','base/static/img/country_flags/'+country_obj.short_name.toLowerCase()+'.png');
+ $.post( "/event/get_country_event_list/"+country_obj.short_name, function( data ) {
+ $( ".country_events_list" ).replaceWith( data );
+ });
+ }
+ }
+ }
+ });
+ }
+
+ $(document).ready(function () {
+ if($('.country_events').length){
+ getLocation();
+ }
+ });
+})(); \ No newline at end of file