(function () {
  'use strict';

  angular.module('DeviceWall').factory('DeviceInfo', function($window, $log) {
    return {
      getPlatformInfo: function(userAgent) {
        var agent = userAgent ? userAgent : $window.navigator.userAgent;
        var matches;
        
        if (/(iPhone|iPad)/.test(agent)) {
          matches = /(iPhone|iPad);.*OS (\d_\d)/.exec(agent);
          $log.debug('iOS matches', matches);
          return {platform: "iOS", version: getVersion(matches).replace('_', '.')};
        }

        if (/Windows Phone/.test(agent)) {
          matches = /Windows Phone (OS )?(\d.\d);/.exec(agent);
          $log.debug('Windows phone matches', matches);
          return {platform: "Windows Phone", version: getVersion(matches)};
        }

        if (/Android/.test(agent)) {
          var re = /Android (\d+(?:\.\d+)+);/;
          matches = re.exec(agent);
          $log.debug('Android', matches);
          return {platform: "Android", version: getVersion(matches)};
        }

        return false;
      }
    };
    function getVersion(matches) {
      return matches[matches.length-1]?matches[matches.length-1]:'';
    }
  });

})();
@@ -354,16 +354,24 @@
 S (%5Cd_%5Cd
+(?:_%5Cd)?
 )/.exec(
@@ -500,16 +500,17 @@
 ace(
-'_', '.'
+/_/g, %22.%22
 )%7D;%0A
@@ -1005,32 +1005,277 @@
 s)%7D;%0A        %7D%0A%0A
+        if (/(Jolla%7CSailfish)/.test(agent)) %7B%0A          matches = /SailfishBrowser%5C/(%5Cd.%5Cd(?:.%5Cd)?)/.exec(agent);%0A          $log.debug('Sailfish', matches);%0A          return %7Bplatform: %22Jolla Sailfish%22, version: getVersion(matches)%7D;%0A        %7D%0A%0A
         return f

add jolla version detector and fix ios version