Mercurial > public > sg101
comparison media/js/membermap.js @ 153:13d052fbe4f1
Fixing #28, cosmetic issues with member map. Also fixed a bug involving the smiley and markdown interactions. Single quotes were getting HTML REMOVED by markdown.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 19 Dec 2009 19:34:16 +0000 |
parents | b43e1288ff80 |
children | 4e1abeb593c2 |
comparison
equal
deleted
inserted
replaced
152:bc657962941e | 153:13d052fbe4f1 |
---|---|
15 mmap.map.setCenter(pt); | 15 mmap.map.setCenter(pt); |
16 mmap.users[name].marker.openInfoWindowHtml(mmap.users[name].message); | 16 mmap.users[name].marker.openInfoWindowHtml(mmap.users[name].message); |
17 }, | 17 }, |
18 clear: function() { | 18 clear: function() { |
19 mmap.users.length = 0; | 19 mmap.users.length = 0; |
20 }, | |
21 resizeUserList: function() { | |
22 var sel = $('#member_map_members'); | |
23 sel[0].size = Math.min(29, sel[0].length); | |
24 $('#member_map_count').html(sel[0].length); | |
25 }, | 20 }, |
26 selectText: "(select)", | 21 selectText: "(select)", |
27 onMapDir: 'You have previously added yourself to the member map. Your information appears below. You may change ' + | 22 onMapDir: 'You have previously added yourself to the member map. Your information appears below. You may change ' + |
28 'the information if you wish. To delete yourself from the map, click the Delete button.', | 23 'the information if you wish. To delete yourself from the map, click the Delete button.', |
29 offMapDir: 'Your location is not on the map. If you would like to appear on the map, please fill out the form below ' + | 24 offMapDir: 'Your location is not on the map. If you would like to appear on the map, please fill out the form below ' + |
45 $.getJSON('/member_map/query/', | 40 $.getJSON('/member_map/query/', |
46 function(data) { | 41 function(data) { |
47 mmap.map.clearOverlays(); | 42 mmap.map.clearOverlays(); |
48 var sel = $('#member_map_members'); | 43 var sel = $('#member_map_members'); |
49 sel[0].length = 0; | 44 sel[0].length = 0; |
45 sel.append($('<option />').html(mmap.selectText)); | |
50 mmap.clear(); | 46 mmap.clear(); |
51 $.each(data.users, function(i, item) { | 47 $.each(data.users, function(i, item) { |
52 sel.append($('<option />').html(item.name)); | 48 sel.append($('<option />').html(item.name)); |
53 var marker = new GMarker(new GLatLng(item.lat, item.lon)); | 49 var marker = new GMarker(new GLatLng(item.lat, item.lon)); |
54 marker.bindInfoWindowHtml(item.message); | 50 marker.bindInfoWindowHtml(item.message); |
58 if (mmapUser.userName == item.name) | 54 if (mmapUser.userName == item.name) |
59 { | 55 { |
60 mmap.userOnMap = true; | 56 mmap.userOnMap = true; |
61 } | 57 } |
62 }); | 58 }); |
63 sel[0].size = Math.min(29, data.users.length); | |
64 $('#member_map_count').html(data.users.length); | 59 $('#member_map_count').html(data.users.length); |
65 | 60 |
66 sel = $('#member_map_recent'); | 61 sel = $('#member_map_recent'); |
67 sel[0].length = 0; | 62 sel[0].length = 0; |
68 sel.append($('<option />').html(mmap.selectText)); | 63 sel.append($('<option />').html(mmap.selectText)); |
101 mmap.map.removeOverlay(mmap.users[mmapUser.userName].marker); | 96 mmap.map.removeOverlay(mmap.users[mmapUser.userName].marker); |
102 } | 97 } |
103 else | 98 else |
104 { | 99 { |
105 $('#member_map_members').append($('<option />').html(data.name)); | 100 $('#member_map_members').append($('<option />').html(data.name)); |
101 $('#member_map_recent').append($('<option />').html(data.name)); | |
106 mmap.userOnMap = true; | 102 mmap.userOnMap = true; |
107 deleteButton.removeAttr('disabled').val('Delete'); | 103 deleteButton.removeAttr('disabled').val('Delete'); |
108 } | 104 } |
109 var marker = new GMarker(new GLatLng(data.lat, data.lon)); | 105 var marker = new GMarker(new GLatLng(data.lat, data.lon)); |
110 marker.bindInfoWindowHtml(data.message); | 106 marker.bindInfoWindowHtml(data.message); |
112 mmap.users[mmapUser.userName] = data; | 108 mmap.users[mmapUser.userName] = data; |
113 mmap.users[mmapUser.userName].marker = marker; | 109 mmap.users[mmapUser.userName].marker = marker; |
114 mmap.clickUser(mmapUser.userName); | 110 mmap.clickUser(mmapUser.userName); |
115 submitButton.removeAttr('disabled').val('Update'); | 111 submitButton.removeAttr('disabled').val('Update'); |
116 $('#member_map_directions').html(mmap.onMapDir); | 112 $('#member_map_directions').html(mmap.onMapDir); |
117 mmap.resizeUserList(); | 113 $('#member_map_count').html($('#member_map_members')[0].length - 1); |
118 alert(wasOnMap ? "Your location has been updated!" : | 114 alert(wasOnMap ? "Your location has been updated!" : |
119 "You've been added to the map!"); | 115 "You've been added to the map!"); |
120 }, | 116 }, |
121 error: function (xhr, textStatus, ex) { | 117 error: function (xhr, textStatus, ex) { |
122 alert('Oops, an error occurred. ' + xhr.statusText + ' - ' + | 118 alert('Oops, an error occurred. ' + xhr.statusText + ' - ' + |
144 mmap.users[mmapUser.userName] = null; | 140 mmap.users[mmapUser.userName] = null; |
145 mmap.userOnMap = false; | 141 mmap.userOnMap = false; |
146 deleteButton.val('Delete'); | 142 deleteButton.val('Delete'); |
147 submitButton.removeAttr('disabled').val('Add'); | 143 submitButton.removeAttr('disabled').val('Add'); |
148 $('#member_map_directions').html(mmap.offMapDir); | 144 $('#member_map_directions').html(mmap.offMapDir); |
149 mmap.resizeUserList(); | 145 $('#member_map_count').html($('#member_map_members')[0].length - 1); |
150 alert("You've been removed from the map."); | 146 alert("You've been removed from the map."); |
151 }, | 147 }, |
152 error: function (xhr, textStatus, ex) { | 148 error: function (xhr, textStatus, ex) { |
153 alert('Oops, an error occurred. ' + xhr.statusText + ' - ' + | 149 alert('Oops, an error occurred. ' + xhr.statusText + ' - ' + |
154 xhr.responseText); | 150 xhr.responseText); |