Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
214 commits
Select commit Hold shift + click to select a range
2e0f267
initial commit
niryariv Jan 7, 2013
5728e6a
rename to index
niryariv Jan 7, 2013
24419c0
init gh-pages
niryariv Jan 7, 2013
eff4c3d
load from /data
niryariv Jan 7, 2013
44f1005
add encoding, IE8 css
niryariv Jan 8, 2013
a9f0c6b
add bootstrap, info window, hover
niryariv Jan 9, 2013
f9795ba
add bootstrap, Alef font
niryariv Jan 9, 2013
e87e0f4
display plan data
niryariv Jan 9, 2013
892a13e
add plan details
niryariv Jan 9, 2013
82019c2
show waiting msg
niryariv Jan 9, 2013
31ec064
add msg, remove locate()
niryariv Jan 9, 2013
898239a
fix alignment
niryariv Jan 9, 2013
dcf817d
fix text
niryariv Jan 9, 2013
ef6d1af
fix text
niryariv Jan 9, 2013
85a8934
some 90s html for y'all
niryariv Jan 10, 2013
b2a082d
polishing plans table, starting to experiment with modal
niryariv Jan 10, 2013
7089884
move libs to /lib
niryariv Jan 10, 2013
0145f89
use PDFObject
niryariv Jan 10, 2013
5310fcc
move libs to /lib
niryariv Jan 10, 2013
7312992
move css to own file
niryariv Jan 10, 2013
29800c4
use /wakeup to wake heroku app
niryariv Jan 10, 2013
dd59474
support download and nispahim links
niryariv Jan 10, 2013
f18f5db
change table items order
niryariv Jan 10, 2013
7e22820
coloring etc
niryariv Jan 10, 2013
9e7ee7f
color fixes
niryariv Jan 12, 2013
d1953ce
support hash URLs with path.js
niryariv Jan 12, 2013
2560f3d
background pattern
niryariv Jan 12, 2013
ddcefb6
white bg for items
niryariv Jan 12, 2013
1467e03
disable clicking on plan
niryariv Jan 12, 2013
244735c
new texture bg
niryariv Jan 13, 2013
8590ae0
add tooltips
niryariv Jan 13, 2013
10cd2f3
fix tooltips
niryariv Jan 13, 2013
579bdb1
fix tooltips, create doc(ready)
niryariv Jan 13, 2013
80a0ed6
move to 8/4 cols, fix popup url behavior
niryariv Jan 14, 2013
6c337c6
add CNAME
niryariv Jan 14, 2013
eba8f78
add GA html
niryariv Jan 15, 2013
caa93e0
fiddling with ga
niryariv Jan 15, 2013
7b9fcf1
the naked domain
niryariv Jan 16, 2013
4919334
cleanup
niryariv Jan 16, 2013
0135f0f
add open in MMI site link
niryariv Jan 16, 2013
0c18f0d
escape plan id link to handle non-numeric chars
niryariv Jan 16, 2013
61f5933
tooltip naming
niryariv Jan 17, 2013
ac1f043
stub
niryariv Jan 17, 2013
03a1568
make h1 link to home
niryariv Jan 17, 2013
da3b7af
add direct link to program in MMI site
niryariv Jan 20, 2013
49506c5
change icons
niryariv Jan 25, 2013
cebd6d5
add faq text
niryariv Jan 26, 2013
aae80a0
separate core js to app.js
niryariv Jan 26, 2013
299fce3
use new heroku url
niryariv Feb 11, 2013
d48f063
use new heroku URL
niryariv Feb 11, 2013
b437d1f
switch to new github URLs
niryariv Feb 11, 2013
b69739e
lame attempts at finding gush without clicking on it
niryariv Feb 26, 2013
b78dd03
add minified gushim.js
niryariv Feb 26, 2013
8b38259
use minified gushim.js
niryariv Feb 26, 2013
6b87bbc
adding gushim as js
niryariv May 7, 2013
6f5e37e
serverless\!\!
niryariv May 7, 2013
a8f4021
fix typo
niryariv May 7, 2013
4803e2e
another typo
niryariv May 7, 2013
39ed377
hopefully all typos now. SERVERLESS
niryariv May 7, 2013
6222416
data update
niryariv May 16, 2013
f8f05c4
use hashbang
niryariv May 26, 2013
2fa6fcd
undo hashbang
niryariv May 26, 2013
e494cf5
add contact info modal
niryariv Jun 1, 2013
e123a0a
use heroku again, to test the new cron
niryariv Jun 3, 2013
663eae6
undeprecate wakeup
niryariv Jun 5, 2013
1ea29cc
handle ? in path
niryariv Jun 5, 2013
45867d9
make sure the map stays at %100 height [contrib: Pini Lichtman]
niryariv Jun 6, 2013
910af9d
enable marking a gush programmatically
niryariv Jun 6, 2013
d229cd2
highlight gush when viewing it
niryariv Jun 6, 2013
a44ea9c
Adding client side support for gush by address
giladgo Jun 12, 2013
6c2fc82
Merge pull request #7 from giladgo/gh-pages
niryariv Jun 12, 2013
021a846
merge gilad's client code
niryariv Jun 12, 2013
4121298
hide search box for now
niryariv Jun 12, 2013
d55f29b
Fixing gush highlight
giladgo Jun 12, 2013
c233daa
Merge pull request #8 from giladgo/gh-pages
niryariv Jun 12, 2013
414e351
hide searchbox text
niryariv Jun 12, 2013
fb6f2ab
remove popup
niryariv Jun 12, 2013
2062185
allow scroll wheel, set min-max zoom boundaries
niryariv Jun 12, 2013
9a93d64
test githubs new geojson rendering
niryariv Jun 14, 2013
b68bd66
remove variable
niryariv Jun 14, 2013
801626c
Adding interface to opentaba-address-db
giladgo Jun 17, 2013
32bd9cb
Merge pull request #9 from giladgo/gh-pages
niryariv Jun 17, 2013
1634cd4
make sure the address entry form stays on the page
niryariv Jun 17, 2013
6dfb738
address popup
niryariv Jun 17, 2013
f6ee560
type lng lon
niryariv Jun 17, 2013
04eb97f
reduce max zoom
niryariv Jun 17, 2013
1f44be1
add credits
niryariv Jun 19, 2013
f7cacdb
fix type
niryariv Jun 19, 2013
c91b3d9
change contact to who are we
niryariv Jun 19, 2013
361ef16
typo
niryariv Jun 19, 2013
74442ac
handle address lookup fail
niryariv Jun 19, 2013
c63681b
Adding loading animation
giladgo Jun 19, 2013
84d04f1
Adding support for going back to 'main' page
giladgo Jun 19, 2013
e842827
Merge pull request #11 from giladgo/gh-pages
niryariv Jun 19, 2013
f050302
move default map center, zoom to constants
niryariv Jun 19, 2013
70fdbf2
Adding Jerusalem as the default city
giladgo Jun 19, 2013
2eb996b
hide scrobber when request ends ; cleanup identation etc
niryariv Jun 19, 2013
0f77c70
fix merge conflicts
niryariv Jun 19, 2013
be9ebae
add city if missing
niryariv Jun 19, 2013
ad262ce
cleanups
niryariv Jun 19, 2013
042572f
remove left padding from map
niryariv Jul 9, 2013
6555cac
add more intro text to homepage
niryariv Aug 19, 2013
7afda63
add commit button
niryariv Aug 19, 2013
af3d436
fix text above input box
niryariv Aug 19, 2013
57e3c7a
add link rel to the feed
niryariv Aug 19, 2013
8274e1d
share buttons, take 1
niryariv Aug 19, 2013
eba86ee
fix extra quote
niryariv Aug 19, 2013
b555638
fix homepage text per maayan's suggestion
niryariv Aug 22, 2013
dc31dca
only one i in maayan
niryariv Aug 24, 2013
601d8ed
add alon nisser to credits
niryariv Sep 6, 2013
11e4f98
seperating inline style from index.html
alonisser Sep 7, 2013
8719570
removing inline style, solving the missing social icons problem
alonisser Sep 7, 2013
b7767a4
added TODO
alonisser Sep 8, 2013
92994ca
Testing gameplan
alonisser Sep 8, 2013
63cd593
basic testing suite for index.html before clicking and moving
alonisser Sep 8, 2013
902d710
add TODO
alonisser Sep 9, 2013
b7bdf07
added more basic tests
alonisser Sep 9, 2013
0676e63
try the gushim Mor scraped
niryariv Sep 10, 2013
0d231b6
add BSD license
niryariv Sep 10, 2013
640fc1e
add new scrape (still need to fix coords)
niryariv Sep 10, 2013
3f23b6c
Converted coords from ITM to WGS84 + added altitude
florpor Sep 11, 2013
63b048f
Merge pull request #21 from florpor/master
niryariv Sep 12, 2013
d15044b
Added Jerusalem's 'gush border' layer data, removed altitude and redu…
florpor Sep 12, 2013
2e4ebce
preparing for travis ci integration
alonisser Sep 12, 2013
2e632a3
minor linting changes: var, semicolon etc
alonisser Sep 12, 2013
5b50aa2
moved into the tests program
alonisser Sep 12, 2013
0ad97cf
an npm/grunt configuration
alonisser Sep 12, 2013
9eb27eb
added a gruntfile
alonisser Sep 12, 2013
45d4f27
making the package.json a single source of truth for jshint
alonisser Sep 13, 2013
84dad92
minor changes, semicolons and vice versa
alonisser Sep 13, 2013
3fbf38d
Merge pull request #23 from florpor/master
niryariv Sep 13, 2013
ddd9d38
deleted and tried again - seperating the testing of the api and addi…
alonisser Sep 13, 2013
74ddf06
removed type
alonisser Sep 13, 2013
e12e631
basics test workflow working
alonisser Sep 13, 2013
4525f2f
stubs for further testings
alonisser Sep 13, 2013
62f8f92
fixed .travis.yml and testing to reflect tests
alonisser Sep 13, 2013
466268f
typo
alonisser Sep 13, 2013
01c8ed9
fixed jshint dependency
alonisser Sep 13, 2013
1f688be
removed explict jshint dependency to fix travis
alonisser Sep 13, 2013
b1200eb
trying to fix the npm installs all problem
alonisser Sep 13, 2013
e0f3d53
fixing npm dependency hell
alonisser Sep 13, 2013
7f069c5
a helper script to extract img for testing and a map image for testin…
alonisser Sep 13, 2013
c92d18a
removed sudo from .travis.yml
alonisser Sep 13, 2013
0c00e64
yet another travis check
alonisser Sep 13, 2013
fd435ce
add build status and reference to testing
alonisser Sep 13, 2013
e068407
added phantomcss for image regression testing
alonisser Sep 13, 2013
0af6336
moved phantomcss testing to a seperate file
alonisser Sep 13, 2013
57ba84d
prepared for phantomcss testing
alonisser Sep 13, 2013
da58c13
added map regression test
alonisser Sep 13, 2013
b93c254
added phantomcss and removed binaries
alonisser Sep 13, 2013
eacd833
added phantomcss and removed binaries
alonisser Sep 13, 2013
a423642
removed unneeded folder creation
alonisser Sep 13, 2013
95924ef
removed --dev from npm install
alonisser Sep 13, 2013
b3b65ac
added my phantomcss fork as submodule, didn't remove casperserver yet
alonisser Sep 13, 2013
ec877ac
added submodule update to travis workflow
alonisser Sep 13, 2013
5859a36
with submodules
alonisser Sep 13, 2013
02cf1aa
changed travis.yml yet again, to work with phantomcss
alonisser Sep 13, 2013
f4b0f5c
changed to https to enable travis installation
alonisser Sep 13, 2013
2c7e60c
whitespace to trigget travis
alonisser Sep 13, 2013
69d6430
triggering travis after playing with the images
alonisser Sep 13, 2013
305b0f6
Merge branch 'master' of github.com:niryariv/opentaba-client
alonisser Sep 13, 2013
3b4828e
updated with our progress
alonisser Sep 14, 2013
ade6d55
added explict waituntil option
alonisser Sep 14, 2013
5a67798
typo
alonisser Sep 14, 2013
f6419bc
again
alonisser Sep 14, 2013
ff0c0e0
phantomcss
alonisser Sep 14, 2013
e780f44
updated readme
alonisser Sep 14, 2013
1bc2ec8
fixed sinon dependency to browser version and added specifc plan test
alonisser Sep 14, 2013
100e7d2
more details in testing.md and added stubs for further testing
alonisser Sep 14, 2013
c94258b
33 new municipalities' data added
florpor Sep 27, 2013
d92eb60
Merge pull request #27 from florpor/master
niryariv Sep 27, 2013
02d29d1
Merge pull request #24 from alonisser/master
niryariv Sep 30, 2013
2ca1b3e
added more tests to get gush
alonisser Sep 30, 2013
e84e789
added engine option
alonisser Sep 30, 2013
b138da4
more advanced testing, still not finished
alonisser Sep 30, 2013
dd2045f
added baseline pictures
alonisser Sep 30, 2013
4c2cd1a
initial commit
alonisser Sep 30, 2013
046c314
Merge branch 'master' of github.com:niryariv/opentaba-client
alonisser Sep 30, 2013
2a6aaff
adding a gitignore
alonisser Oct 1, 2013
9031b7d
added fontawesome icons for twitter and facebook, removed the other s…
alonisser Oct 1, 2013
c38d682
removed underline css for icons
alonisser Oct 1, 2013
601d813
fixing phantomcss test
alonisser Oct 4, 2013
503f088
added specific threshold
alonisser Oct 4, 2013
9ab98c8
seperating different image test
alonisser Oct 4, 2013
a9b40e0
removed not working phantomcss test and added some others
alonisser Oct 7, 2013
0abe27d
remove space
niryariv Oct 7, 2013
25597f7
fix conflict
niryariv Oct 7, 2013
578a71c
style share icons
niryariv Oct 7, 2013
5fab336
stylin
niryariv Oct 7, 2013
3ed15c5
open attachments in new tab instead of modal
niryariv Oct 7, 2013
eb8549f
add a little space above share icons
niryariv Oct 7, 2013
03c1827
use https instead of http in heroku calls, solve #31
niryariv Oct 8, 2013
7be8f3c
Merge branch 'master' into gh-pages
niryariv Oct 8, 2013
52209d0
switch to google api for address search
florpor Nov 5, 2013
cff52ed
remove the weird array comparison for a simple one
florpor Nov 5, 2013
0474feb
fix number of tests
florpor Nov 5, 2013
e5610c8
remove need for heroku address-db, use google api for geocoding. Merg…
niryariv Nov 6, 2013
523e2b0
add mor, shahar to credits
niryariv Nov 6, 2013
cf7f92e
add nir weissman to credits
niryariv Nov 6, 2013
77c7c99
no need for pdfobject.js
niryariv Dec 21, 2013
9324089
remove attribution
niryariv Dec 21, 2013
c2ca411
update to leaflet 0.7.1
niryariv Dec 21, 2013
e7463f4
Adding .json suffix to gush plans URL to support new opentaba-server API
shevron Dec 22, 2013
5768b4a
Changing URL of atom feed to comply with new server API
shevron Dec 22, 2013
04e8ba5
Fixing client-side tests to support new URL scheme
shevron Dec 22, 2013
1c62d88
Merge pull request #44 from shevron/feature/server-type-suffix
niryariv Dec 22, 2013
7ee05aa
Merge branch 'master' of https://github.com/niryariv/opentaba-client
niryariv Dec 22, 2013
bf086c8
kiryat ono gush-helka
niryariv Dec 28, 2013
b347028
123
OrenKishon Jan 4, 2014
6629284
123
OrenKishon Jan 4, 2014
f6ab984
Merge branch 'master' of https://github.com/niryariv/opentaba-client
OrenKishon Jan 4, 2014
a3bfba7
remove
OrenKishon Jan 4, 2014
4b57abe
neighbours
OrenKishon Jan 4, 2014
5a990d0
neighbours script
OrenKishon Jan 4, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*~
tests/node_modules/
tests/img/*.diff.png
7 changes: 7 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[submodule "tests/modules/casperserver"]
path = tests/modules/casperserver
url = https://github.com/casperjs/casperserver.git

[submodule "tests/PhantomCSS"]
path = tests/PhantomCSS
url = https://github.com/alonisser/PhantomCSS.git
20 changes: 20 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
language: node_js


node_js:
- 0.8

before_script:
- git clone -q git://github.com/n1k0/casperjs.git
- cd casperjs; git checkout -q tags/1.1-beta1; cd ../
- export PATH=$PATH:`pwd`/casperjs/bin
- phantomjs --version; casperjs --version

before_install:
- git submodule update --init --recursive

install:
- npm install -g grunt-cli
- cd tests; npm install

script: cd tests;npm test
1 change: 1 addition & 0 deletions CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
opentaba.info
27 changes: 27 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright (c) 2013, Hasadna - Public Knowledge Workshop, Nir Yariv and others.
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

3. Neither the name of Open Knesset nor the names of its contributors may be used
to endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
citymap-client
==============
[![Build Status](https://travis-ci.org/alonisser/opentaba-client.png?branch=master)](https://travis-ci.org/alonisser/opentaba-client)Client code for OpenTaba - details will arrive soon, but the code is pretty simple to understand.If you came looking for the server side of opentaba It's [here](https://github.com/niryariv/opentaba-server).##Testing:see [what's needed](tests/testing.md) with testing.##Want to help?look at the issues. Lots of work here
Expand Down
292 changes: 292 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,292 @@
// deprecating, replacing with serverless mode
var RUNNING_LOCAL = (document.location.host == 'localhost' || document.location.host == '127.0.0.1' || document.location.protocol == 'file:');
var API_URL = RUNNING_LOCAL ? 'http://0.0.0.0:5000/' : 'https://opentaba-server.herokuapp.com/';
var ADDR_DB_API_URL = RUNNING_LOCAL ? 'http://0.0.0.0:5000/' : 'https://opentaba-address-db.herokuapp.com/';

var gushimLayer;
leafletPip.bassackwards = true;

var CITY_NAME = "ירושלים"; //TODO: replace this with something more scalable.

var MAP_CENTER = gushim.features[0].geometry.coordinates[0][0].slice(0,
2).reverse()
var DEFAULT_ZOOM = 13;

// var API_URL = '/'; // serverless, bitches! just store the JSON in the directory and grab it from there.

var highlit = [];

// Utility endsWith function
String.prototype.endsWith = function(suffix) {
return this.indexOf(suffix, this.length - suffix.length) !== -1;
};

function show_data(url){
if (url.indexOf('.pdf', url.length - 4) !== -1) { // endsWith('.pdf')?
new PDFObject({ url: url }).embed("modal-doc");
} else {
$("#modal-doc").html('<iframe src="' + url + '"></iframe>');
}

$("#doc_new_window").attr("href", url);
$("#docModal").modal().css({ width: '90%', height: '80%', 'margin-left': function () { return -($(this).width() / 2); } });
}

function render_plans(plans, gid) {
//TODO: rewrite this DRY
var out = '<h3 style="color: grey;">גוש ' + gid + '</h3>';

// html brought to you courtsey of 1998
out += "<table>";
for (var i = 0 ; i<plans.length ; i++) {
var p = plans[i];

//plan_link = 'http://www.mmi.gov.il/IturTabot/taba2.asp?Gush=' + p.gush_id + '&MisTochnit=' + escape(p.number)
plan_link = 'http://mmi.gov.il/IturTabot/taba4.asp?kod=3000&MsTochnit=' + escape(p.number);

out+='<tr style="vertical-align:top" class="item">' +
' <td><b>' + [p.day, p.month, p.year].join('/') + '</b></td>' +
' <td>' + p.status + '</td>'+
' <td><b>' + p.essence + '</b></td>'+
'</tr>' +
'<tr class="details">' +
' <td colspan="2">' +
' <a href="' + plan_link + '" target="_blank" rel="tooltip" title="פתח באתר ממי">'+
' תוכנית ' + p.number + '</a>' +
' </td>' +
' <td>';
var j;
for (j=0 ; j<p.tasrit_link.length ; j++)
out += '<a href="'+ p.tasrit_link[j] + '" target="_blank" rel="tooltip" title="תשריט"><i class="icon-globe"></i></a>';

for (j=0 ; j<p.takanon_link.length ; j++)
out += '<a href="'+ p.takanon_link[j] + '" target="_blank" rel="tooltip" title="תקנון"><i class="icon-file"></i></a>';

for (j=0 ; j<p.nispahim_link.length ; j++)
out += '<a href="'+ p.nispahim_link[j] + '" target="_blank" rel="tooltip" title="נספחים"><i class="icon-folder-open"></i></a>';

for (j=0 ; j<p.files_link.length ; j++)
out += '<a href="http://mmi.gov.il' + p.files_link[j] +
'" rel="tooltip" title="קבצי ממג"><i class="icon-download-alt"></i></a>';

out+=' </td>' +
'</tr>' +
'<tr style="height: 10px"><td colspan="3">&nbsp;</td></tr>';
}
out += '</table>';

$("#info").html(out);

// activate Boostrap tooltips on attachment icons
$("[rel='tooltip']").tooltip({'placement' : 'bottom'});


$(".item").hover(
function () { $(this).css("background","#fff"); $(this).next(".details").css("background","#fff"); }, //#f7f7f9
function () { $(this).css("background","") ; $(this).next(".details").css("background",""); }
);

$(".details").hover(
function () { $(this).css("background","#fff"); $(this).prev(".item").css("background","#fff"); },
function () { $(this).css("background","") ; $(this).prev(".item").css("background",""); }
);

}

function get_gush(gush_id) {
// console.log("get_gush: " + API_URL + 'gush/' + gush_id + '/plans')
clear_all_highlit();
highlight_gush(gush_id);
location.hash = "#/gush/" + gush_id;

$.getJSON(
API_URL + 'gush/' + gush_id + '/plans.json',
function(d) {
//console.log(d.length);
render_plans(d, gush_id);
}
);

console.log('waiting for json');

}

// find a rendered gush based on ID
function find_gush(gush_id){
g = gushim.features.filter(
function(f){ return (f.properties.Name == gush_id); }
);
return g[0];
}

// get a gush by street address
function get_gush_by_addr(addr) {
if (!addr.endsWith(" " + CITY_NAME)) { //TODO: change to regex with cityname
addr = addr + " " + CITY_NAME;
}

console.log("get_gush_by_addr: " + addr);

// Use Google api to find a gush by address
$.getJSON(
'https://maps.googleapis.com/maps/api/geocode/json?address='+addr+'&sensor=false',
function (r) {
$('#scrobber').hide();
$('#addr-error-p').html('');

if (r['status'] == 'OK' && r['results'].length > 0) {
// Here we have a case when Google api returns without an actual place (even a street),
// so it only has a city. This happens because it didn't find the address, but we
// did append the name of the current city at the end, and Google apparently thinks
// 'better something than nothing'. We're trying to ignore this (should test though)
if (r['results'][0]['types'].length == 2 &&
$.inArray('locality', r['results'][0]['types']) > -1 &&
$.inArray('political', r['results'][0]['types']) > -1) {
$('#addr-error-p').html('כתובת שגויה או שלא נמצאו נתונים');
}
else {
var lat = r['results'][0]['geometry']['location']['lat'];
var lon = r['results'][0]['geometry']['location']['lng'];
console.log('got lon: ' + lon + ', lat: ' + lat);

// Using leafletpip we try to find an object in the gushim layer with the coordinate we got
var gid = leafletPip.pointInLayer([lat, lon], gushimLayer, true);
if (gid && gid.length > 0) {
get_gush(gid[0].gushid);
var pp = L.popup().setLatLng([lat, lon]).setContent('<b>' + addr + '</b>').openOn(map);
} else {
$('#addr-error-p').html('לא נמצא גוש התואם לכתובת'); // TODO: when enabling multiple cities change the message to point users to try a differenct city
}
}
}
else if (r['status'] == 'ZERO_RESULTS') {
$('#addr-error-p').html('כתובת שגויה או שלא נמצאו נתונים');
}
else {
$('#addr-error-p').html('חלה שגיאה בחיפוש הכתובת, אנא נסו שנית מאוחר יותר');
}
}
)
.fail(
function(){
$('#scrobber').hide();
$('#addr-error-p').html('חלה שגיאה בחיפוש הכתובת, אנא נסו שנית מאוחר יותר');
}
);
}


function highlight_gush(id) {
gush = 'gush_' + id;
console.log("highlight_gush ", gush);
map.fitBounds(map._layers[gush].getBounds());
map._layers[gush].setStyle({opacity: 0 , color: "blue"});
highlit.push(id);
}

function clear_highlight(id) {
gush = 'gush_' + id;
map._layers[gush].setStyle({opacity: 0.05 , color: "#777"});
highlit.splice(highlit.indexOf(id), 1);
}

function clear_all_highlit() {
while (highlit.length > 0) {
clear_highlight(highlit[0]);
}
}

function onEachFeature(feature, layer) {
// layer.bindPopup(feature.properties.Name + " גוש ");
layer.on({
'mouseover' : function() {
if (highlit.indexOf(this["gushid"]) < 0) {
this.setStyle({ opacity: 0 , color: "red" })
}
for (var i = 0; i < this["neighbours"].length; i++) {
neighbour = this["neighbours"][i];
if (highlit.indexOf(neighbour) < 0) {
map._layers['gush_' + neighbour].setStyle({ opacity: 0 , color: "blue" })
}
}
} ,
'mouseout' : function() {
if (highlit.indexOf(this["gushid"]) < 0) {
this.setStyle({ opacity: 0.95, color: "#777" })
}
for (var i = 0; i < this["neighbours"].length; i++) {
neighbour = this["neighbours"][i];
if (highlit.indexOf(neighbour) < 0) {
map._layers['gush_' + neighbour].setStyle({ opacity: 0.95, color: "#777" })
}
}
},
'click' : function() {
$("#info").html("עוד מעט...");
location.hash = "#/gush/" + feature.properties.Name;
get_gush(feature.properties.Name);
}
});
layer["gushid"] = feature.properties.Name;
layer["neighbours"] = feature.properties.neighbours;
layer._leaflet_id = 'gush_' + feature.properties.Name;
}

// jQuery startup funcs
$(document).ready(function(){

// comment out for serverless
// wake up possibly-idling heroku dyno to make sure later requests aren't too slow
$.getJSON( API_URL + "wakeup" , function(){
// do nothing
});

// setup a path.js router to allow distinct URLs for each block
Path.map("#/gush/:gush_id").to(
function(){
$("#docModal").modal('hide');
get_gush(this.params['gush_id'].split('?')[0]); // remove '?params' if exists
}
);

Path.map("").to(
function(){
$("#docModal").modal('hide');
$("#info").html("");
clear_all_highlit();
map.setView(MAP_CENTER, DEFAULT_ZOOM);
}
);

Path.listen();

$('#addr-form').submit(
function() {
var addr = $('#addr-text').val();
console.log('Getting gush for address "' + addr + '"');
$('#scrobber').show();
get_gush_by_addr(addr);
return false;
}
);
});


var map = L.map('map', { scrollWheelZoom: true, attributionControl: false }).setView(MAP_CENTER, DEFAULT_ZOOM);

tile_url = 'http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png';
L.tileLayer(tile_url, {
maxZoom: 16,
minZoom: 13
}).addTo(map);

gushimLayer = L.geoJson(gushim,
{
onEachFeature: onEachFeature,
style : {
"color" : "#777",
"weight": 1,
"opacity": 0.9
}
}
).addTo(map);
Binary file added css/ajax-loader.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added css/font/Alef-bold.eot
Binary file not shown.
Loading