Remove support for ancient browsers
authorChris Morgan <me@chrismorgan.info>
committerChris Morgan <me@chrismorgan.info>
OK, so String.prototype.padStart is only 5 years ago, but the rest is
all well over a decade ago, some two.
static/gitweb.js

index e3add4868ea5da8768c5030d6471123d9c491b68..c2d7ecd382cc8c77f3fcc4c963c3c416795c4322 100644 (file)
@@ -8,113 +8,6 @@
  */
 
 
-/* ============================================================ */
-/* ............................................................ */
-/* Padding */
-
-/**
- * pad INPUT on the left with STR that is assumed to have visible
- * width of single character (for example nonbreakable spaces),
- * to WIDTH characters
- *
- * example: padLeftStr(12, 3, '\u00A0') == '\u00A012'
- *          ('\u00A0' is nonbreakable space)
- *
- * @param {Number|String} input: number to pad
- * @param {Number} width: visible width of output
- * @param {String} str: string to prefix to string, defaults to '\u00A0'
- * @returns {String} INPUT prefixed with STR x (WIDTH - INPUT.length)
- */
-function padLeftStr(input, width, str) {
-       var prefix = '';
-       if (typeof str === 'undefined') {
-               ch = '\u00A0'; // using '&nbsp;' doesn't work in all browsers
-       }
-
-       width -= input.toString().length;
-       while (width > 0) {
-               prefix += str;
-               width--;
-       }
-       return prefix + input;
-}
-
-/* ............................................................ */
-/* Handling browser incompatibilities */
-
-/**
- * Create XMLHttpRequest object in cross-browser way
- * @returns XMLHttpRequest object, or null
- */
-function createRequestObject() {
-       try {
-               return new XMLHttpRequest();
-       } catch (e) {}
-       try {
-               return window.createRequest();
-       } catch (e) {}
-       try {
-               return new ActiveXObject("Msxml2.XMLHTTP");
-       } catch (e) {}
-       try {
-               return new ActiveXObject("Microsoft.XMLHTTP");
-       } catch (e) {}
-
-       return null;
-}
-
-
-/* ............................................................ */
-/* Support for legacy browsers */
-
-/**
- * Provides getElementsByClassName method, if there is no native
- * implementation of this method.
- *
- * NOTE that there are limits and differences compared to native
- * getElementsByClassName as defined by e.g.:
- *   https://developer.mozilla.org/en/DOM/document.getElementsByClassName
- *   http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#dom-getelementsbyclassname
- *   http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#dom-document-getelementsbyclassname
- *
- * Namely, this implementation supports only single class name as
- * argument and not set of space-separated tokens representing classes,
- * it returns Array of nodes rather than live NodeList, and has
- * additional optional argument where you can limit search to given tags
- * (via getElementsByTagName).
- *
- * Based on
- *   http://code.google.com/p/getelementsbyclassname/
- *   http://www.dustindiaz.com/getelementsbyclass/
- *   http://stackoverflow.com/questions/1818865/do-we-have-getelementsbyclassname-in-javascript
- *
- * See also http://ejohn.org/blog/getelementsbyclassname-speed-comparison/
- *
- * @param {String} class: name of _single_ class to find
- * @param {String} [taghint] limit search to given tags
- * @returns {Node[]} array of matching elements
- */
-if (!('getElementsByClassName' in document)) {
-       document.getElementsByClassName = function (classname, taghint) {
-               taghint = taghint || "*";
-               var elements = (taghint === "*" && document.all) ?
-                              document.all :
-                              document.getElementsByTagName(taghint);
-               var pattern = new RegExp("(^|\\s)" + classname + "(\\s|$)");
-               var matches= [];
-               for (var i = 0, j = 0, n = elements.length; i < n; i++) {
-                       var el= elements[i];
-                       if (el.className && pattern.test(el.className)) {
-                               // matches.push(el);
-                               matches[j] = el;
-                               j++;
-                       }
-               }
-               return matches;
-       };
-} // end if
-
-
 /* ............................................................ */
 /* unquoting/unescaping filenames */
 
@@ -312,7 +205,7 @@ function updateProgressInfo() {
 
        if (div_progress_info) {
                div_progress_info.firstChild.data  = blamedLines + ' / ' + totalLines +
-                       ' (' + padLeftStr(percentage, 3, '\u00A0') + '%)';
+                       ' (' + (''+percentage).padStart(3, '\u00A0') + '%)';
        }
 
        if (div_progress_bar) {
@@ -873,7 +766,7 @@ function handleResponse(xhr, fromTimer) {
 */
 function startBlame(blamedataUrl, bUrl) {
 
-       var xhr = createRequestObject();
+       var xhr = new XMLHttpRequest();
        if (!xhr) {
                errorInfo('ERROR: XMLHttpRequest not supported');
                return;