Changeset 163 for binary-improvements/webserver/js
- Timestamp:
- Sep 4, 2014, 5:45:22 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/webserver/js/index.js
r157 r163 3 3 var TILESIZE = 128; 4 4 var MAXZOOM = 4; 5 6 var BAG_COLS = 8; 7 var BAG_ROWS = 4; 8 var BELT_COLS = 8; 9 var INV_ITEM_WIDTH = 58; 10 var INV_ITEM_HEIGHT = 40; 5 11 6 12 SDTD_Projection = { … … 148 154 var playersMappingList = {}; 149 155 156 var showInv = function(steamid) { 157 $.getJSON( "../api/getplayerinventory", { steamid: steamid }) 158 .done(function(data) { 159 $("#invPlayerName").text(playersMappingList[steamid].name); 160 for (var y = 0; y < BAG_ROWS; y++) { 161 for (var x = 0; x < BAG_COLS; x++) { 162 if (data.bag[y*BAG_COLS+x].count > 0) { 163 $("#bagField"+x+"_"+y).attr("style", "background-image: url(itemimages/" + data.bag[y*BAG_COLS+x].name + ".png);"); 164 $("#bagFieldText"+x+"_"+y).text(data.bag[y*BAG_COLS+x].count); 165 } else { 166 $("#bagField"+x+"_"+y).attr("style", "background-image: none;"); 167 $("#bagFieldText"+x+"_"+y).text(""); 168 } 169 } 170 } 171 172 for (var x = 0; x < BELT_COLS; x++) { 173 if (data.belt[x].count > 0) { 174 $("#beltField"+x).attr("style", "background-image: url(itemimages/" + data.belt[x].name + ".png);"); 175 $("#beltFieldText"+x).text(data.belt[x].count); 176 } else { 177 $("#beltField"+x).attr("style", "background-image: none;"); 178 $("#beltFieldText"+x).text(""); 179 } 180 } 181 182 $( "#dialog-message" ).dialog({ 183 modal: true, 184 width: BAG_COLS*INV_ITEM_WIDTH + 60, 185 buttons: { 186 Ok: function() { 187 $( this ).dialog( "close" ); 188 } 189 } 190 }); 191 }) 192 .fail(function() { 193 console.log("Error fetching player inventory"); 194 }) 195 .always(function() { 196 }); 197 }; 198 199 for (var y = 0; y < BAG_ROWS; y++) { 200 $("#bagTable").append("<tr id=\"bagRow"+y+"\"></tr>"); 201 for (var x = 0; x < BAG_COLS; x++) { 202 $("#bagRow"+y).append( 203 "<td class=\"invField\" id=\"bagField"+x+"_"+y+"\">" + 204 "<span class=\"invFieldText\" id=\"bagFieldText"+x+"_"+y+"\"></span>" + 205 "</td>"); 206 } 207 } 208 209 $("#beltTable").append("<tr id=\"beltRow0\"></tr>"); 210 for (var x = 0; x < BELT_COLS; x++) { 211 $("#beltRow0").append( 212 "<td class=\"invField\" id=\"beltField"+x+"\">" + 213 "<span class=\"invFieldText\" id=\"beltFieldText"+x+"\"></span>" + 214 "</td>"); 215 } 216 150 217 var setPlayerMarkers = function(data) { 151 218 var online = 0; … … 157 224 marker.setLatLng([val.position.z, val.position.x]); 158 225 } else { 159 marker = L.marker([val.position.z, val.position.x]).bindPopup(val.name); 226 marker = L.marker([val.position.z, val.position.x]).bindPopup( 227 "Player: " + val.name + "<br/>" + 228 "<a onClick='showInv(\""+val.steamid+"\")'>Show inventory</a>" 229 ); 160 230 playersMappingList[val.steamid] = { online: !val.online }; 161 231 }
Note:
See TracChangeset
for help on using the changeset viewer.