]> Lady’s Gitweb - Gitweb/blobdiff - gitweb.js
gitweb.js: fix null object exception in initials calculation
[Gitweb] / gitweb.js
index 5ffc6f80f8643b7ee9495d894f1ef0bf568f0fa5c562748bdd527df01d1193fd..1b0d1f98bc41e339031faf94eade3e778b38d6b5a74bb11cb0b136a9ab801300 100644 (file)
--- a/gitweb.js
+++ b/gitweb.js
@@ -7,6 +7,39 @@
  * @license GPLv2 or later
  */
 
  * @license GPLv2 or later
  */
 
+/* ============================================================ */
+/* functions for generic gitweb actions and views */
+
+/**
+ * used to check if link has 'js' query parameter already (at end),
+ * and other reasons to not add 'js=1' param at the end of link
+ * @constant
+ */
+var jsExceptionsRe = /[;?]js=[01]$/;
+
+/**
+ * Add '?js=1' or ';js=1' to the end of every link in the document
+ * that doesn't have 'js' query parameter set already.
+ *
+ * Links with 'js=1' lead to JavaScript version of given action, if it
+ * exists (currently there is only 'blame_incremental' for 'blame')
+ *
+ * @globals jsExceptionsRe
+ */
+function fixLinks() {
+       var allLinks = document.getElementsByTagName("a") || document.links;
+       for (var i = 0, len = allLinks.length; i < len; i++) {
+               var link = allLinks[i];
+               if (!jsExceptionsRe.test(link)) { // =~ /[;?]js=[01]$/;
+                       link.href +=
+                               (link.href.indexOf('?') === -1 ? '?' : ';') + 'js=1';
+               }
+       }
+}
+
+
+/* ============================================================ */
+
 /*
  * This code uses DOM methods instead of (nonstandard) innerHTML
  * to modify page.
 /*
  * This code uses DOM methods instead of (nonstandard) innerHTML
  * to modify page.
@@ -89,6 +122,7 @@ function createRequestObject() {
        return null;
 }
 
        return null;
 }
 
+
 /* ============================================================ */
 /* utility/helper functions (and variables) */
 
 /* ============================================================ */
 /* utility/helper functions (and variables) */
 
@@ -532,8 +566,11 @@ function handleLine(commit, group) {
                        if (group.numlines >= 2) {
                                var fragment = document.createDocumentFragment();
                                var br   = document.createElement("br");
                        if (group.numlines >= 2) {
                                var fragment = document.createDocumentFragment();
                                var br   = document.createElement("br");
-                               var text = document.createTextNode(
-                                       commit.author.match(/\b([A-Z])\B/g).join(''));
+                               var match = commit.author.match(/\b([A-Z])\B/g);
+                               if (match) {
+                                       var text = document.createTextNode(
+                                                       match.join(''));
+                               }
                                if (br && text) {
                                        var elem = fragment || td_sha1;
                                        elem.appendChild(br);
                                if (br && text) {
                                        var elem = fragment || td_sha1;
                                        elem.appendChild(br);
This page took 0.17117 seconds and 4 git commands to generate.