window.isSmartphone = function() { // this check is also used in main.js. Note it should not detect // tablets because their display is large enough to use the desktop // version. // The stock intel site allows forcing mobile/full sites with a vp=m or vp=f // parameter - let's support the same. (stock only allows this for some // browsers - e.g. android phone/tablet. let's allow it for all, but // no promises it'll work right) var viewParam = getURLParam('vp'); if (viewParam == 'm') return true; if (viewParam == 'f') return false; return navigator.userAgent.match(/Android.*Mobile/); } window.smartphone = function() {}; window.runOnSmartphonesBeforeBoot = function() { if(!isSmartphone()) return; console.warn('running smartphone pre boot stuff'); // add smartphone stylesheet headHTML = document.getElementsByTagName('head')[0].innerHTML; headHTML += ''; document.getElementsByTagName('head')[0].innerHTML = headHTML; // don’t need many of those window.setupStyles = function() { $('head').append(''); } window.smartphone.mapButton = $('map').click(function() { $('#map').css('visibility', 'visible'); $('#updatestatus').show(); $('#chatcontrols a .active').removeClass('active'); $("#chatcontrols a:contains('map')").addClass('active'); }); window.smartphone.sideButton = $('info').click(function() { $('#scrollwrapper').show(); $('.active').removeClass('active'); $("#chatcontrols a:contains('info')").addClass('active'); }); $('#chatcontrols').append(smartphone.mapButton).append(smartphone.sideButton); window.addHook('portalDetailsUpdated', function(data) { var x = $('.imgpreview img').removeClass('hide'); if(!x.length) { $('.fullimg').remove(); return; } if($('.fullimg').length) { $('.fullimg').replaceWith(x.addClass('fullimg')); } else { x.addClass('fullimg').appendTo('#sidebar'); } }); } window.smartphoneInfo = function(data) { var guid = data.selectedPortalGuid; if(!window.portals[guid]) return; var data = window.portals[selectedPortal].options.data; var details = window.portalDetail.get(guid); var lvl = data.level; if(data.team === "NEUTRAL") var t = 'L0'; else var t = 'L' + lvl + ''; var percentage = data.health; if(details) { var totalEnergy = getTotalPortalEnergy(details); if(getTotalPortalEnergy(details) > 0) { percentage = Math.floor(getCurrentPortalEnergy(details) / totalEnergy * 100); } } t += ' ' + percentage + '% '; t += data.title; if(details) { var l,v,max,perc; var eastAnticlockwiseToNorthClockwise = [2,1,0,7,6,5,4,3]; for(var ind=0;ind<8;ind++) { if (details.resonators.length == 8) { var slot = eastAnticlockwiseToNorthClockwise[ind]; var reso = details.resonators[slot]; } else { var slot = null; var reso = ind < details.resonators.length ? details.resonators[ind] : null; } var className = TEAM_TO_CSS[getTeam(details)]; if(slot !== null && OCTANTS[slot] === 'N') className += ' north' if(reso) { l = parseInt(reso.level); v = parseInt(reso.energy); max = RESO_NRG[l]; perc = v/max*100; } else { l = 0; v = 0; max = 0; perc = 0; } t += '