geo_rails 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a9da787d536b078c0b9670535ecd168a9d79fd4f
4
- data.tar.gz: cd111cf308fe8feb124a887044e01913632e7b3e
3
+ metadata.gz: 1bd9d37eff28688815b2af403402e37022e3f775
4
+ data.tar.gz: 2618076d967d09ec272a47c3556692e8ee20e9dd
5
5
  SHA512:
6
- metadata.gz: 4dd4de49c6a627a4170f8cb08419d830a609023f9cc0bd905fbfc33dbc80a509763e5b5f60e1890804aaebcdff6737ea22e0c3566046d66047c1bd670b9d8bfd
7
- data.tar.gz: 5088d81995cae6054a3416ca2e0a660fd9c54d54c537f38d744579de0203918f2decebccb5f3ab9cb74e751d5a7a47e77caa629ae3a72205ad2250df2c15ad9b
6
+ metadata.gz: 65a11e2e7e0d28059a6e60df1f6f1256a0693cd73f84c20e762fa6590dc3e08cbf9f621d2990eb18c7f8158da1d64f385ede3ee15b98611d76e5901c8e1bfdc6
7
+ data.tar.gz: 7716347b18edc6bf65d4fae1955ffea0b03981efd2b4b2bc96c3caa4a4d3fb2fb14c4329834a39642dbd6a6285d2a0d58e797e9dc5d350b1e5bcc3365d00a396
@@ -1,73 +1,49 @@
1
1
  <%= hidden_field_tag "authenticity_token", form_authenticity_token %>
2
2
  <script>
3
- if( navigator.geolocation )
4
- {
5
- navigator.geolocation.getCurrentPosition(
6
-
7
- function( position )
8
- {
9
- var data = position.coords ;
10
-
11
- var lat = data.latitude ;
12
- var lng = data.longitude ;
13
-
14
- //post geolocation
15
- $.ajax({
16
- type :"POST",
17
- url: "<%= url %>" ,
18
- data: {
19
- lat: lat,
20
- lng: lng,
21
- authenticity_token: $("#authenticity_token").val()
22
- }
23
- });
24
-
25
- },
26
-
27
- function( error )
28
- {
29
- var errorInfo = [
30
- "unknown error" ,
31
- "unauthorized" ,
32
- "cannot get information" ,
33
- "timeout"
34
- ] ;
35
-
36
- var errorNo = error.code ;
37
- var errorMessage = errorInfo[ errorNo ] ;
38
-
39
- //error handling
40
- $.ajax({
41
- type :"POST",
42
- url: "<%= url %>" ,
43
- data: {
44
- error: errorMessage,
45
- authenticity_token: $("#authenticity_token").val()
46
- }
47
- });
48
-
49
- } ,
50
-
51
- {
52
- "enableHighAccuracy": false,
53
- "timeout": 8000,
54
- "maximumAge": 2000,
55
- }
56
-
57
- ) ;
58
- }
59
-
60
- else
61
- {
62
- //error handling
3
+ function geo_params(latitude, longitude, err_msg){
63
4
  $.ajax({
64
5
  type :"POST",
65
6
  url: "<%= url %>" ,
66
7
  data: {
67
- error: "unsupported browser",
8
+ lat: latitude,
9
+ lng: longitude,
10
+ error: err_msg,
68
11
  authenticity_token: $("#authenticity_token").val()
69
12
  }
70
13
  });
71
- }
14
+ };
72
15
 
16
+ if( navigator.geolocation )
17
+ {
18
+ function position(pos){
19
+ var data = pos.coords;
20
+ var lat = data.latitude;
21
+ var lng = data.longitude;
22
+ geo_params(lat, lng, null);
23
+ };
24
+
25
+ function error(err){
26
+ var errorInfo = [
27
+ "unknown error" ,
28
+ "unauthorized" ,
29
+ "cannot get information" ,
30
+ "timeout"
31
+ ];
32
+ var errorNo = err.code ;
33
+ var errorMessage = errorInfo[ errorNo ] ;
34
+ geo_params(null, null, errorMessage);
35
+ };
36
+
37
+ var options = {
38
+ "enableHighAccuracy": false,
39
+ "timeout": 8000,
40
+ "maximumAge": 2000,
41
+ };
42
+
43
+ navigator.geolocation.getCurrentPosition(position, error, options);
44
+
45
+ } else {
46
+ var errorMessage = "unsupported browser";
47
+ geo_params(null, null, errorMessage);
48
+ }
73
49
  </script>
@@ -2,7 +2,7 @@ module GeoRails
2
2
  module GetGeo
3
3
  def render_geo(url = {})
4
4
  render_url = self.controller_name + "/"
5
- render_url += url[:url][:action] unless url[:url][:action].nil?
5
+ render_url += url[:url][:action] unless url[:url][:action].nil?
6
6
  render partial: "/geo/get_geo", locals: {url: render_url}
7
7
  end
8
8
  end
@@ -1,3 +1,3 @@
1
1
  module GeoRails
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geo_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - "末永良太"
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-04 00:00:00.000000000 Z
11
+ date: 2016-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails