Changeset 250 for binary-improvements/webserver/js
- Timestamp:
- Aug 12, 2015, 6:10:28 PM (9 years ago)
- Location:
- binary-improvements/webserver/js
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/webserver/js/index.js
r245 r250 1 InitializeTabs (); 1 //InitializeTabs (); 2 var tabs = $("#adminmenu").tabbedContent ({ 3 contentdiv: $("#admincontent"), 4 }); 2 5 SetupInventoryDialog (); 3 6 InitPermissions (); -
binary-improvements/webserver/js/inventory_dialog.js
r249 r250 11 11 var cell = $("#" + containerTypeName + "Field"+cellIdent); 12 12 var text = $("#" + containerTypeName + "FieldText"+cellIdent); 13 if (itemdata.count > 0) { 13 var qual = $("#" + containerTypeName + "FieldQuality"+cellIdent); 14 15 cell.attr("style", "background-image: none;"); 16 cell.removeAttr("title"); 17 text.removeClass ("visible"); 18 qual.removeClass ("visible"); 19 20 if (itemdata !== null) { 14 21 cell.attr("style", "background-image: url(" + ITEMICONBASEURL + itemdata.name + ".png);"); 15 cell.attr("title", itemdata.name); 16 text.text(itemdata.count); 17 } else { 18 cell.attr("style", "background-image: none;"); 19 cell.removeAttr("title"); 20 text.text(""); 22 if (itemdata.quality >= 0) { 23 cell.attr("title", itemdata.name + " (quality: " + itemdata.quality + ")"); 24 qual.attr("style", "background-color: #"+ itemdata.qualitycolor); 25 qual.addClass ("visible"); 26 } else { 27 cell.attr("title", itemdata.name); 28 text.text(itemdata.count); 29 text.addClass ("visible"); 30 } 21 31 } 22 32 } … … 24 34 var SetEquipmentItem = function (data, name, cellIdent) { 25 35 if (data.equipment [name] == false) { 26 SetCellItem ("equipment", cellIdent, { count: 0, name: "" });36 SetCellItem ("equipment", cellIdent, null); 27 37 } else { 28 SetCellItem ("equipment", cellIdent, { count: 1, name: data.equipment [name] });38 SetCellItem ("equipment", cellIdent, data.equipment [name] ); 29 39 } 30 40 } … … 77 87 var CreateInvCell = function (containerTypeName, cellIdent) { 78 88 return "<td class=\"invField\" id=\"" + containerTypeName + "Field"+cellIdent+"\">" + 89 "<div class=\"invFieldQuality\" id=\"" + containerTypeName + "FieldQuality" + cellIdent + "\"></div>" + 79 90 "<span class=\"invFieldText\" id=\"" + containerTypeName + "FieldText"+cellIdent+"\"></span>" + 80 91 "</td>"; -
binary-improvements/webserver/js/map.js
r249 r250 131 131 }); 132 132 133 var openedPopup = null; 134 var updatingMarkers = false; 135 136 map.on ("popupopen", function (event) { 137 console.log ("open"); 138 console.log (event.popup._source); 139 openedPopup = event.popup._source; 140 }); 141 map.on ("popupclose", function (event) { 142 if (!updatingMarkers) { 143 console.log ("close"); 144 openedPopup = null; 145 } 146 }); 147 133 148 var setPlayerMarkers = function(data) { 134 149 var online = 0; 135 150 var offline = 0; 151 updatingMarkers = true; 136 152 $.each( data, function( key, val ) { 137 153 var marker; … … 147 163 playersMappingList[val.steamid] = { online: !val.online }; 148 164 } 149 if (playersMappingList[val.steamid].online) { 150 playersOnlineMarkerGroup.removeLayer(marker); 151 } else { 152 playersOfflineMarkerGroup.removeLayer(marker); 153 } 154 marker.setLatLng([val.position.x, val.position.z]); 155 if (val.online) { 156 marker.setOpacity(1.0); 157 playersOnlineMarkerGroup.addLayer(marker); 158 } else { 159 marker.setOpacity(0.5); 160 playersOfflineMarkerGroup.addLayer(marker); 165 166 oldpos = marker.getLatLng (); 167 if ( playersMappingList[val.steamid].online != val.online || oldpos.lat != val.position.x || oldpos.lng != val.position.z ) { 168 if (playersMappingList[val.steamid].online) { 169 playersOnlineMarkerGroup.removeLayer(marker); 170 } else { 171 playersOfflineMarkerGroup.removeLayer(marker); 172 } 173 marker.setLatLng([val.position.x, val.position.z]); 174 if (val.online) { 175 marker.setOpacity(1.0); 176 playersOnlineMarkerGroup.addLayer(marker); 177 } else { 178 marker.setOpacity(0.5); 179 playersOfflineMarkerGroup.addLayer(marker); 180 } 161 181 } 162 182 … … 169 189 offline++; 170 190 }); 191 updatingMarkers = false; 192 if (openedPopup != null) { 193 openedPopup.openPopup (); 194 } 171 195 $( "#mapControlOnlineCount" ).text( online ); 172 196 $( "#mapControlOfflineCount" ).text( offline ); 173 197 } 174 198 199 var updatePlayerTimeout; 175 200 var updatePlayerEvent = function() { 176 201 $.getJSON( "../api/getplayerslocation") … … 180 205 }) 181 206 .always(function() { 182 window.setTimeout(updatePlayerEvent, 2000);207 updatePlayerTimeout = window.setTimeout(updatePlayerEvent, 4000); 183 208 }); 184 209 } 185 210 186 if (HasPermission ("webapi.getplayerslocation")) { 187 window.setTimeout(updatePlayerEvent, 0); 211 tabs.on ("tabbedcontenttabopened", function (event, data) { 212 if (data.newTab === "#tab_map") { 213 if (HasPermission ("webapi.getplayerslocation")) { 214 updatePlayerEvent (); 215 } 216 } else { 217 window.clearTimeout (updatePlayerTimeout); 218 } 219 }); 220 221 if (tabs.tabbedContent ("isTabOpen", "tab_map")) { 222 if (HasPermission ("webapi.getplayerslocation")) { 223 updatePlayerEvent (); 224 } 188 225 } 189 226 -
binary-improvements/webserver/js/permissions.js
r249 r250 21 21 } 22 22 23 ApplyTabPermissions ();24 25 23 if (HasPermission ("web.map")) { 26 24 StartMapModule (); 27 25 } 26 if (HasPermission ("webapi.getlog")) { 27 StartLogModule (); 28 } 28 29 29 if (HasPermission ("webapi.getstats")) { 30 if (HasPermission ("webapi.getwebuiupdates")) { 31 StartUIUpdatesModule (); 32 } else if (HasPermission ("webapi.getstats")) { 30 33 StartStatsModule (); 31 34 } 35 36 tabs.tabbedContent ("applyPermissions"); 32 37 33 38 }) -
binary-improvements/webserver/js/stats.js
r245 r250 25 25 } 26 26 27 function StartUIUpdatesModule () { 28 var updateGameTimeEvent = function() { 29 $.getJSON( "../api/getwebuiupdates?latestLine=" + lastLogLine) 30 .done(function(data) { 31 var time = "Day " + data.gametime.days + ", "; 32 if (data.gametime.hours < 10) 33 time += "0"; 34 time += data.gametime.hours; 35 time += ":"; 36 if (data.gametime.minutes < 10) 37 time += "0"; 38 time += data.gametime.minutes; 39 40 $("#stats_time").html (time); 41 $("#stats_players").html (data.players); 42 $("#newlogcount").html (data.newlogs); 43 if (data.newlogs > 0) { 44 $("#newlogcount").addClass ("visible"); 45 } else { 46 $("#newlogcount").removeClass ("visible"); 47 } 48 }) 49 .fail(function(jqxhr, textStatus, error) { 50 console.log("Error fetching ui updates"); 51 }) 52 .always(function() { 53 }); 54 window.setTimeout(updateGameTimeEvent, 2000); 55 }; 56 updateGameTimeEvent(); 57 } 58 -
binary-improvements/webserver/js/tabs.js
r249 r250 1 var tabElements = {}; 2 var currentTabClass = "current_tab"; 1 $.widget( "7dtd.tabbedContent", { 2 options: { 3 contentdiv: null, 4 currentTabClass: "current_tab", 5 menuButtonClass: "menu_button", 6 allowedMenuButtonClass: "allowed", 7 contentDivClass: "contenttab", 8 }, 9 10 _create: function () { 11 var options = this.options; 12 var self = this; 13 14 if (options.contentdiv == null) { 15 console.log ("contentdiv has to be set!"); 16 } 17 18 this.element.find ("ul > li").addClass (options.menuButtonClass); 3 19 4 function OpenTab () { 5 var menuElement = $(this); 6 var linkElement = menuElement.children ("a"); 7 var linkName = linkElement.attr ("href"); 20 options.contentdiv.children ("div").addClass (options.contentDivClass); 21 this.element.on ('click.action', "ul > li", function (event) { 22 var menuElement = $(this); 23 var linkElement = menuElement.children ("a"); 24 var linkName = linkElement.attr ("href"); 25 self.openTab (linkName); 26 }); 8 27 9 $("*").removeClass (currentTabClass); 10 menuElement.addClass (currentTabClass); 11 $(linkName).addClass (currentTabClass); 12 } 28 self.tabs = {}; 29 this.element.find (".menu_button").each (function () { 30 self.tabs [$(this).children ("a").attr ("href")] = $(this); 31 }); 32 }, 33 34 applyPermissions: function () { 35 var self = this; 36 this.element.find (".menu_button").each (function () { 37 if ($(this).children ("a").data ("permission")) { 38 var perm = $(this).children ("a").data ("permission"); 39 if (HasPermission (perm)) { 40 $(this).addClass (self.options.allowedMenuButtonClass); 41 } 42 } else { 43 $(this).addClass (self.options.allowedMenuButtonClass); 44 } 45 }); 13 46 14 function InitializeTabs () { 15 $("#adminmenu > ul > li").addClass ("menu_button"); 16 $(".admincontent > div").addClass ("contenttab"); 17 $(".menu_button").on ('click.action', null, function (event) { 18 var menuElement = $(this); 19 var linkElement = menuElement.children ("a"); 20 var linkName = linkElement.attr ("href"); 47 this.element.find ("." + self.options.allowedMenuButtonClass).first ().click (); 48 }, 49 50 openTab: function (name) { 51 if (name.indexOf ("#") != 0) 52 name = "#" + name; 21 53 22 $("*").removeClass ("current_tab"); 23 menuElement.addClass ("current_tab"); 24 $(linkName).addClass ("current_tab"); 25 }); 26 } 54 if (!this.tabs.hasOwnProperty(name)) { 55 console.log ("no tab named " + name + " in " + this); 56 return; 57 } 27 58 28 function ApplyTabPermissions () { 29 $("#adminmenu .menu_button").each (function () { 30 if ($(this).children ("a").data ("permission")) { 31 var perm = $(this).children ("a").data ("permission"); 32 if (HasPermission (perm)) { 33 $(this).addClass ("allowed"); 34 } 59 var menuElement = $(".menu_button > a[href=" + name + "]").parent (); 60 61 $("*").removeClass (this.options.currentTabClass); 62 menuElement.addClass (this.options.currentTabClass); 63 $(name).addClass (this.options.currentTabClass); 64 var oldTab = this.currentTab; 65 this.currentTab = name; 66 67 if (oldTab != name) { 68 this._trigger ("tabopened", null, { oldTab: oldTab, newTab: name } ); 35 69 } 36 }); 70 }, 71 72 currentOpenTab: function () { 73 return this.currentTab; 74 }, 75 76 isTabOpen: function (name) { 77 if (name.indexOf ("#") != 0) 78 name = "#" + name; 37 79 38 $("#adminmenu .allowed").first ().click ();39 } 80 return this.currentTab == name; 81 }, 40 82 83 /* 84 value: function (value) { 85 if ( value === undefined ) { 86 return this.options.value; 87 } else { 88 this.options.value = this._constrain( value ); 89 var progress = this.options.value + "%"; 90 this.element.text( progress ); 91 } 92 }, 93 */ 94 });
Note:
See TracChangeset
for help on using the changeset viewer.