text: if (!String.prototype.endsWith) {
    String.prototype.endsWith = function(searchString, position) {
        var subjectString = this.toString();
        if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) {
          position = subjectString.length;
        }
        position -= searchString.length;
        var lastIndex = subjectString.indexOf(searchString, position);
        return lastIndex !== -1 && lastIndex === position;
    };
  }
  
  // Define outerHtml method for jQuery since we need to give openlayers plain html
  // http://stackoverflow.com/questions/2419749/get-selected-elements-outer-html
  // Elements outerHtml property only works on IE and chrome
  jQuery.fn.outerHTML = function (arg) {
      var ret;
  
      // If no items in the collection, return
      if (!this.length) {
          return typeof arg === 'undefined' ? this : null;
      }
      // Getter overload (no argument passed)
      if (!arg) {
          return this[0].outerHTML || (ret = this.wrap('<div>').parent().html(), this.unwrap(), ret);
      }
      // Setter overload
      jQuery.each(this, function (i, el) {
          var fnRet,
              pass = el,
              inOrOut = el.outerHTML ? 'outerHTML' : 'innerHTML';
  
          if (!el.outerHTML) {
              el = jQuery(el).wrap('<div>').parent()[0];
          }
  
          if (jQuery.isFunction(arg)) {
              if ((fnRet = arg.call(pass, i, el[inOrOut])) !== false) {
                  el[inOrOut] = fnRet;
              }
          } else {
              el[inOrOut] = arg;
          }
  
          if (!el.outerHTML) {
              jQuery(el).children().unwrap();
          }
      });
  
      return this;
  };
  /*
  // Polymer statsgrid needs this for IE, but there are more problems with it so we don't need to add it yet
  // new Event(); polyfill for IE
  (function () {
    // https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent
    try {
      new Event();
    } catch(err) {
      function CustomEvent ( event, params ) {
        params = params || { bubbles: false, cancelable: false, detail: undefined };
        var evt = document.createEvent( 'CustomEvent' );
        evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail );
        return evt;
       }
  
      CustomEvent.prototype = window.Event.prototype;
  
      window.CustomEvent = CustomEvent;
    }
  })();
  */