File tree Expand file tree Collapse file tree 5 files changed +116
-42
lines changed
Expand file tree Collapse file tree 5 files changed +116
-42
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1212 < script type ="text/javascript " src ="js/MainController.js " > </ script >
1313 < script type ="text/javascript ">
1414 var controller = new ew . MainController ( ) ;
15-
1615 </ script >
16+ < script type ="text/javascript " src ="http://code.jquery.com/jquery-2.1.0.min.js "> </ script >
17+ < script type ="text/javascript " src ="js/ControllPanel.js "> </ script >
18+ < style >
19+ div # control-panel {
20+ height : 120px ;
21+ padding : 10px ;
22+ box-sizing : border-box;
23+ }
24+ h1 {
25+ margin : 4px 0 4px 0 ;
26+ }
27+ input # message {
28+ width : calc (100% - 120px );
29+ font-size : 1.4em ;
30+ border-radius : 5px ;
31+ vertical-align : middle;
32+ }
33+ div # publish_button {
34+ font-family : 'Lucida Grande' , 'Hiragino Kaku Gothic ProN' ;
35+ display : inline-block;
36+ height : 25px ;
37+ width : 80px ;
38+ border : 1px solid # 000 ;
39+ vertical-align : middle;
40+ text-align : center;
41+ border-radius : 5px ;
42+ padding-top : 6px ;
43+ font-weight : bold;
44+ color : # FFF ;
45+ background-color : # 2c2 ;
46+ border-color : # 2a2 ;
47+ cursor : pointer;
48+ }
49+ </ style >
1750</ head >
1851< body >
19- < div id ="map-canvas " style ="width:100%; height:100% "> </ div >
52+ < div id ="control-panel ">
53+ < h1 > Publish Warning</ h1 >
54+ < div style ="font-size:10px ">
55+ Latitude: < span id ="lat "> </ span > / Longitude: < span id ="lon "> </ span > (Radius: < span id ="radius "> </ span > km)< br >
56+ </ div >
57+ < input type ="text " value ="" placeholder ="Input warning message " size ="40 " id ="message "/> < div id ="publish_button "> Publish</ div >
58+ </ div >
59+ < div id ="map-canvas " style ="width:100; height:calc(100% - 100px); "> </ div >
2060</ body >
21- </ html >
61+ </ html >
Original file line number Diff line number Diff line change 1+ jQuery ( function ( $ ) {
2+ var sending = false ;
3+ $ ( '#publish_button' ) . on ( 'click' , function ( ) {
4+ if ( sending ) {
5+ return ;
6+ }
7+ sending = true ;
8+ $ ( '#publish_button' ) . text ( 'Wait...' ) ;
9+
10+ var circle = window . controller . circle ;
11+ var xhr = $ . ajax ( {
12+ method : 'POST' ,
13+ url : '/publish' ,
14+ headers : {
15+ 'Content-Type' : 'application/json' ,
16+ } ,
17+ data : JSON . stringify ( {
18+ lat : Number ( circle . center . d ) ,
19+ lon : Number ( circle . center . e ) ,
20+ radius : Number ( circle . radius ) ,
21+ message : $ ( '#message' ) . val ( )
22+ } )
23+ } ) ;
24+ xhr . done ( function ( ) {
25+ alert ( 'Message succesfully published' ) ;
26+ $ ( '#publish_button' ) . text ( 'Publish' ) ;
27+ sending = false ;
28+ } ) ;
29+ xhr . error ( function ( ) {
30+ $ ( '#publish_button' ) . text ( 'Publish' ) ;
31+ sending = false ;
32+ } ) ;
33+ } ) ;
34+
35+ function update_latlon ( loc ) {
36+ $ ( '#lat' ) . text ( Math . floor ( loc . lat * 100 ) / 100 ) ;
37+ $ ( '#lon' ) . text ( Math . floor ( loc . lon * 100 ) / 100 ) ;
38+ }
39+
40+ function update_radius ( val ) {
41+ $ ( '#radius' ) . text ( Math . floor ( val / 1000 ) ) ;
42+ }
43+
44+ window . controller . on_center_changed = function ( loc ) {
45+ update_latlon ( {
46+ lat : loc . d ,
47+ lon : loc . e
48+ } ) ;
49+ } ;
50+ window . controller . on_radius_changed = function ( radius ) {
51+ update_radius ( radius ) ;
52+ } ;
53+
54+ // Initial
55+ update_latlon ( {
56+ lat : 22.74 ,
57+ lon : 90.75
58+ } ) ;
59+ update_radius ( 100000 ) ;
60+
61+ } ) ;
Original file line number Diff line number Diff line change @@ -43,9 +43,20 @@ var ew;
4343
4444 this . map = new google . maps . Map ( document . getElementById ( 'map-canvas' ) , mapOptions ) ;
4545 _this . getLatLng ( "Bangladesh mosque" ) ;
46- _this . circle . setMap ( _this . map ) ;
4746
4847 this . circle = this . createCircle ( this . map . getCenter ( ) , 100000 ) ;
48+ _this . circle . setMap ( _this . map ) ;
49+ this . circle . addListener ( 'center_changed' , ( function ( ) {
50+ if ( this . on_center_changed ) {
51+ this . on_center_changed ( this . circle . center ) ;
52+ }
53+ } ) . bind ( this ) ) ;
54+
55+ this . circle . addListener ( 'radius_changed' , ( function ( ) {
56+ if ( this . on_radius_changed ) {
57+ this . on_radius_changed ( this . circle . radius ) ;
58+ }
59+ } ) . bind ( this ) ) ;
4960 } ;
5061
5162 MainController . prototype . getLatLng = function ( place ) {
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments