iitc-project / ingress-intel-total-conversion

ingress.com/intel total conversion user script with some new features. Should allow easier extension of the intel map.
http://iitc.jonatkins.com/
ISC License
991 stars 552 forks source link

Forcing mobile IITC on non-mobile browsers #88

Closed jonatkins closed 11 years ago

jonatkins commented 11 years ago

I thought it'd be useful to have the option of forcing the mobile version of the IITC site on non-mobile browsers.

As an attempt at doing this I added code that checked for a URL parameter, and overrode the user-agent based detection.

The URL parameter is an optional ?vp=m (for mobile) - and ?vp=f (to force desktop on mobile browsers) - this parameter is the same as used by the stock intel sites on phones/tablets to force the site style.

However, it doesn't work very well. The site does change, but not as intended. Obviously I'm missing something, but I'm not sure what.

Additionally, I did a brief test with the IITC Mobile app passing this parameter to force the mobile version on my tablet - this gives the same poor appearance as on Chrome desktop.

Can anyone point out what I've missed?

breunigs commented 11 years ago

you need to overwrite the user agent detection in both main.js and smartphone.js. Start in latter file, it should be near the top, in a separate function. This function is duplicated in main.js because IITC is not yet booted.

jonatkins commented 11 years ago

Ah, I see it now. Thanks. I'd grepped through the code multiple times and not seen that. I'd also misunderstood the comment - thought it meant that the function was also called from main.js - not that the user-agent check was duplicated.

It'd make more sense just to have it in one place. Moving the function from code/smartphone.js into main.js, before the point it's needed, should do it - yes?

jonatkins commented 11 years ago

@breunigs any thoughts on code of the form

  headHTML = document.getElementsByTagName('head')[0].innerHTML;
  headHTML += '<style>@@INCLUDESTRING:mobile/smartphone.css@@</style>';
  document.getElementsByTagName('head')[0].innerHTML = headHTML;

in window.runOnSmartphonesBeforeBoot - avoiding the need for the smartphone test in main.js?

jonatkins commented 11 years ago

seems fine. will commit. can revert if issues...