Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: scyclops/fruitdrop
base: 1c24d7dcd7
...
head fork: scyclops/fruitdrop
compare: c794d94fea
  • 2 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
Showing with 73 additions and 34 deletions.
  1. +2 −0  D.min.js
  2. +3 −0  index.html
  3. +66 −34 map.js
  4. +2 −0  settings.js
View
2  D.min.js
@@ -0,0 +1,2 @@
+/* (c) Jonathan Gotti - licence: https://github.com/malko/d.js/LICENCE.txt */
+(function(){"use strict";function n(n){t(function(){throw n})}var t,r=function(n){return n instanceof Function},e=function(n){return!!~[void 0,null,!1].indexOf(n)},u=function(n,t){return[].slice.apply(n,t)},i="undefined",o="length",c="promise",f="resolve",s="reject",l="then";if(typeof process!==i&&process.nextTick)t=process.nextTick;else if(typeof MessageChannel!==i){var a=new MessageChannel,p=[];a.port1.onmessage=function(){p[o]&&p.shift()()},t=function(n){p.push(n),a.port2.postMessage(0)}}else t=function(n){setTimeout(n,0)};var h=function(u){function i(n){n&&n.call(null,v)}function a(){if(0!==d){var n=m,t=0,r=n[o],e=~d?0:1;for(m=[];r>t;t++)i(n[t][e])}}function p(n){return d?this:n&&r(n[l])?(n[l](p,y),this):(v=n,d=1,u?t(a):a(),this)}function y(n){if(0!==d)return this;try{throw n}catch(r){v=r}return d=-1,u?t(a):a(),this}u||(u=h.alwaysAsync);var v,d=0,m=[],g=h.onlyFuncs,w={then:function(n,i){var o=h();return m.push([function(t){try{o[f](e(n)?t:r(n)?n.call(null,t):g?t:n)}catch(u){o[s](u)}},function(n){if((e(i)||!r(i)&&g)&&o[s](n),i)try{o[f](r(i)?i.call(null,n):i)}catch(t){o[s](t)}}]),0!==d&&(u?t(a):a()),o[c]},success:function(n){return this[l](n,null)},error:function(n){return this[l](null,n)},apply:function(n,t){return this[l](function(t){return r(n)?n.apply(null,t):g?t:n},t||null)},rethrow:function(t){return this[l](null,t?function(n){throw t(n),n}:n)},isPending:function(){return 0===d?!0:!1},getStatus:function(){return d}};return w.toSource=w.toString=w.valueOf=function(){return void 0===v?this:v},{promise:w,resolve:p,fulfill:p,reject:y}};h.defer=h,h.nextTick=t,h.alwaysAsync=!0,h.onlyFuncs=!0,h.resolved=h.fulfilled=function(n){return h(!0)[f](n)[c]},h.rejected=function(n){return h(!0)[s](n)[c]},h.wait=function(n){var t=h();return setTimeout(t[f],n||0),t[c]},h.delay=function(n,t){var r=h();return setTimeout(function(){try{r[f](n.apply(null))}catch(t){r[s](t)}},t||0),r[c]},h.promisify=function(n){return n&&r(n[l])?n:d.resolved(n)},h.all=function(){var n=arguments;if(1===n[o]&&n[0]instanceof Array){if(n[0][o])return h.all.apply(h,n[0]);var t=h();return t[f](n[0]),t[c]}var r=[],e=h(),i=u(n),a=i[o];if(a)for(var p=0,y=a;y>p;p++)(function(n){var t=h.promisify(i[n]);t[l](function(t){n in r||(r[n]=t,--a||e[f](r))},function(t){n in r||e[s](t)})})(p);else e[f](r);return e[c]},h.nodeCapsule=function(n,t){return t||(t=n,n=void 0),function(){var r=h(),e=u(arguments);e.push(function(n,t){n?r[s](n):r[f](arguments[o]>2?u(arguments,1):t)});try{t.apply(n,e)}catch(i){r.reject(i)}return r[c]}},typeof window!==i?window.D=h:module.exports=h})();
View
3  index.html
@@ -7,7 +7,10 @@
<script type="text/javascript" src="phonegap.js"></script>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.mobile-1.3.1.min.js"></script>
+ <script type="text/javascript" src="D.min.js"></script>
+ <script type="text/javascript" src="settings.js"></script>
<script type="text/javascript" src="icons.js"></script>
+ <script type="text/javascript" src="api.js"></script>
<script type="text/javascript" src="map.js"></script>
</head>
<body>
View
100 map.js
@@ -1,5 +1,11 @@
-var native_app = (window.location.href.indexOf('localhost') === -1),
- api_url = (native_app ? 'http://fallingfruit.org' : 'http://localhost:8080');
+
+$(document).on('click', 'a', function(){
+ if (this.target === '_blank') {
+ console.log('opening window..');
+ window.open(this.href);
+ return false;
+ }
+});
var FruitDrop = function() {
@@ -90,40 +96,37 @@ FruitDrop.prototype = {
},
getData: function() {
- var bounds = this._map.getBounds();
-
- $.ajax({
- type: 'GET',
- url: api_url + '/locations/markers.json',
- data: {
- muni: 0,
- nelat: bounds.getNorthEast().lat(),
- nelng: bounds.getNorthEast().lng(),
- swlat: bounds.getSouthWest().lat(),
- swlng: bounds.getSouthWest().lng()
- },
- /* -- for clusters --
- url: api_url + '/locations/cluster.json',
- data: {
- method: 'grid',
- grid: this._map.getZoom(),
- nelat: bounds.getNorthEast().lat(),
- nelng: bounds.getNorthEast().lng(),
- swlat: bounds.getSouthWest().lat(),
- swlng: bounds.getSouthWest().lng()
- },
- */
- dataType: 'json',
- success: $.proxy(this.addMarkers, this),
- error: $.proxy(this.error, this)
- });
+ var bounds = this._map.getBounds(),
+ self = this;
+
+ get_markers(
+ bounds.getNorthEast().lat(),
+ bounds.getNorthEast().lng(),
+ bounds.getSouthWest().lat(),
+ bounds.getSouthWest().lng()
+ ).then(
+ $.proxy(this.addMarkers, this),
+ $.proxy(this.error, this)
+ );
+
+ /* -- for clusters --
+ get_clusters(
+ bounds.getNorthEast().lat(),
+ bounds.getNorthEast().lng(),
+ bounds.getSouthWest().lat(),
+ bounds.getSouthWest().lng(),
+ this._map.getZoom(),
+ )
+ */
},
addMarkers: function(data) {
this.removeMarkers();
var dataLength = data.length;
for (var i = 0; i < dataLength; i++)
- this._markers.push(this.placeMarker(new google.maps.LatLng(data[i].lat, data[i].lng), data[i].title));
+ this._markers.push(this.placeMarker(new google.maps.LatLng(data[i].lat, data[i].lng),
+ data[i].title,
+ data[i].location_id));
},
removeMarkers: function() {
@@ -141,7 +144,7 @@ FruitDrop.prototype = {
this._markers = [];
},
- placeMarker: function(location, title) {
+ placeMarker: function(location, title, location_id) {
if ((this._filter) && (title.search(new RegExp(this._filter,"i")) < 0) && (title !== 'You are Here'))
return;
@@ -154,9 +157,38 @@ FruitDrop.prototype = {
var self = this;
google.maps.event.addListener(marker, 'click', function() {
- self._infoWindow.setContent(this.getTitle());
- self._infoWindow.open(self._map, this);
- self._infoWindowMarker = this;
+ var that = this;
+
+ get_info(location_id)
+ .then(function(data){
+ var html = ('<strong>' + title + '</strong><br /><em>by ' +
+ data.author + '</em><br /><br />' + data.description),
+ t;
+
+ for (var i = 0; i < data.types.length; ++i) {
+ t = data.types[i];
+
+ if (!t.wiki_url && !t.usda_url) continue;
+
+ html += '<br /><br />' + title + ' (';
+ if (t.wiki_url) {
+ html += '<a href="'+ t.wiki_url +'" target="_blank">wiki</a>';
+ }
+ if (t.usda_url) {
+ if (t.wiki_url) html += ' | ';
+ html += '<a href="'+ t.usda_url +'" target="_blank">usda</a>';
+ }
+ html += ')';
+ }
+
+ self._infoWindow.setContent(html);
+ self._infoWindow.open(self._map, that);
+ self._infoWindowMarker = that;
+
+ }, function(){
+ console.log("Unable to fetch location data.");
+ });
+
});
return marker;
View
2  settings.js
@@ -0,0 +1,2 @@
+
+var native_app = (window.location.href.indexOf('localhost') === -1);

No commit comments for this range

Something went wrong with that request. Please try again.