MobileESP JavaScript: OOP Beta 1 Released!

Hi, folks —

As MobileESP has added new methods and variables, I’ve been more & more concerned with the potential for API collisions with other JavaScripts that may be present on the page. So I decided to work on converting the standard JavaScript code into an Object Oriented model using the literal notation technique. Since I had to touch each function anyways, I decided it was time for a deep review of the JavaScript code, as well. Simultaneously, I drafted a list of test useragent strings and tested each one against our new UA test list.

Download: OOP JavaScript Beta 1 (July 22, 2012)

REGULAR JAVASCRIPT METHOD

In the normal JavaScript method, this is how you would include and use the code to test for iPhone Tier devices (including Android and Windows Phone 7). Notice how the JS function call is available as if it had been defined on the same page.

//In the Header, load the file:

<script type=”text/javascript” src=”code/mdetect.js”></script>

<script type=”text/javascript” language=”JavaScript”>

if (DetectTierIphone())

//Do something interesting, like redirect to a mobile page

//or promote the link to the iOS app store.

</script>

OOP JAVASCRIPT METHOD

Using this OOP method, all function calls and interesting variables are accessed within a new object called “MobileEsp.” So, only one line needs to change as we add “MobileEsp.” to the function call:

//Do the stuff listed above…

if (MobileEsp.DetectTierIphone())

//Do something interesting

CHANGE LOG

In addition, I made numerous tweaks and updates to the JavaScript code. If the JavaScript switch to the OOP model is well accepted by the community, and any bugs get fixed, then I’ll start porting these tweaks and updates to the other libraries. A few people have sent in a few other requests for coding changes (especially to PHP), which I’ll also try to get in. Here are some highlights of the JavaScript updates:

  • Added global variables for quick access to these very useful Boolean values:¬†IsWebkit, IsMobilePhone, IsIphone, IsAndroid, IsAndroidPhone, IsTierTablet, IsTierIphone, IsTierRichCss, IsTierGenericMobile
  • Simplified OperaMobile().
  • Moved the following from DetectMobileQuick() to DetectMobileLong():¬†DetectDangerHiptop(), DetectMaemoTablet(), DetectGarminNuvifone(), devicePda.
  • Added DetectBada(). Added it to DetectSmartphone & iPhone Tier, too.

BETA TEST FEEDBACK

Please review & test the proposed code for the new OOP JavaScript object and its many tweaks and updates. Please send feedback to me (Anthony) no later than Friday, August 10, 2012. I’d like to be able to incorporate all of the feedback and publish an official switch to OOP by the end of August.

Thank you for your continued support of MobileESP, your energies, and your ideas on how to make it better for the entire community!!!

Anthony

(anthony.hand [at] gmail [dot] com)

Owner of the MobileESP project. For the latest source code downloads, visit: http://code.google.com/p/mobileesp/

Posted in Code Updates, General, MobileESP APIs