Run prettier on file so it confirms to a consistent style

Run prettier on file so it confirms to a consistent style

diff --git a/assets/message-bus.js b/assets/message-bus.js
index 8ea3082..7ac115d 100644
--- a/assets/message-bus.js
+++ b/assets/message-bus.js
@@ -1,20 +1,36 @@
 /*jshint bitwise: false*/
 (function(global, document, undefined) {
-  'use strict';
+  "use strict";
   var previousMessageBus = global.MessageBus;
 
   // http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
-  var callbacks, clientId, failCount, shouldLongPoll, queue, responseCallbacks, uniqueId, baseUrl;
-  var me, started, stopped, longPoller, pollTimeout, paused, later, jQuery, interval, chunkedBackoff;
+  var callbacks,
+    clientId,
+    failCount,
+    shouldLongPoll,
+    queue,
+    responseCallbacks,
+    uniqueId,
+    baseUrl;
+  var me,
+    started,
+    stopped,
+    longPoller,
+    pollTimeout,
+    paused,
+    later,
+    jQuery,
+    interval,
+    chunkedBackoff;
   var delayPollTimeout;
 
   var ajaxInProgress = false;
 
   uniqueId = function() {
-    return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
+    return "xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g, function(c) {
       var r, v;
-      r = Math.random() * 16 | 0;
-      v = c === 'x' ? r : (r & 0x3 | 0x8);
+      r = (Math.random() * 16) | 0;
+      v = c === "x" ? r : (r & 0x3) | 0x8;
       return v.toString(16);
     });
   };
@@ -32,19 +48,19 @@
   jQuery = global.jQuery;
   var hiddenProperty;
 
-  (function(){
-    var prefixes = ["","webkit","ms","moz"];
-    for(var i=0; i<prefixes.length; i++) {
+  (function() {
+    var prefixes = ["", "webkit", "ms", "moz"];
+    for (var i = 0; i < prefixes.length; i++) {
       var prefix = prefixes[i];
       var check = prefix + (prefix === "" ? "hidden" : "Hidden");
-      if(document[check] !== undefined ){
+      if (document[check] !== undefined) {
         hiddenProperty = check;
       }
     }
   })();
 
   var isHidden = function() {
-    if (hiddenProperty !== undefined){
+    if (hiddenProperty !== undefined) {
       return document[hiddenProperty];
     } else {
       return !document.hasFocus;
@@ -56,7 +72,7 @@
       localStorage.setItem("mbTestLocalStorage", Date.now());
       localStorage.removeItem("mbTestLocalStorage");
       return true;
-    } catch(e) {
+    } catch (e) {
       return false;
     }
   })();
@@ -65,7 +81,7 @@
     if (hasLocalStorage) {
       localStorage.setItem("__mbLastAjax", Date.now());
     }
-  }
+  };
 
   var hiddenTabShouldWait = function() {
     if (hasLocalStorage && isHidden()) {
@@ -75,10 +91,10 @@
       return deltaAjax >= 0 && deltaAjax < me.minHiddenPollInterval;
     }
     return false;
-  }
+  };
 
-  var hasonprogress = (new XMLHttpRequest()).onprogress === null;
-  var allowChunked = function(){
+  var hasonprogress = new XMLHttpRequest().onprogress === null;
+  var allowChunked = function() {
     return me.enableChunkedEncoding && hasonprogress;
   };
 
@@ -94,19 +110,23 @@
     var gotData = false;
     if (!messages) return false; // server unexpectedly closed connection
 
-    for (var i=0; i<messages.length; i++) {
+    for (var i = 0; i < messages.length; i++) {
       var message = messages[i];
       gotData = true;
-      for (var j=0; j<callbacks.length; j++) {
+      for (var j = 0; j < callbacks.length; j++) {
         var callback = callbacks[j];
         if (callback.channel === message.channel) {
           callback.last_id = message.message_id;
           try {
             callback.func(message.data, message.global_id, message.message_id);
-          }
-          catch(e){
-            if(console.log) {
-              console.log("MESSAGE BUS FAIL: callback " + callback.channel +  " caused exception " + e.stack);
+          } catch (e) {
+            if (console.log) {
+              console.log(
+                "MESSAGE BUS FAIL: callback " +
+                  callback.channel +
+                  " caused exception " +
+                  e.stack
+              );
             }
           }
         }
@@ -125,7 +145,7 @@
     failCount = 0;
     if (paused) {
       if (messages) {
-        for (var i=0; i<messages.length; i++) {
+        for (var i = 0; i < messages.length; i++) {
           later.push(messages[i]);
         }
       }
@@ -136,7 +156,6 @@
   };
 
   longPoller = function(poll, data) {
-
     if (ajaxInProgress) {
       // never allow concurrent ajax reqs
       return;
@@ -156,20 +175,19 @@
     }
 
     var headers = {
-      'X-SILENCE-LOGGER': 'true'
+      "X-SILENCE-LOGGER": "true"
     };
-    for (var name in me.headers){
+    for (var name in me.headers) {
       headers[name] = me.headers[name];
     }
 
-    if (!chunked){
-      headers["Dont-Chunk"] = 'true';
+    if (!chunked) {
+      headers["Dont-Chunk"] = "true";
     }
 
     var dataType = chunked ? "text" : "json";
 
     var handle_progress = function(payload, position) {
-
       var separator = "\r\n|\r\n";
       var endChunk = payload.indexOf(separator, position);
 
@@ -182,7 +200,7 @@
 
       try {
         reqSuccess(JSON.parse(chunk));
-      } catch(e) {
+      } catch (e) {
         if (console.log) {
           console.log("FAILED TO PARSE CHUNKED REPLY");
           console.log(data);
@@ -190,9 +208,9 @@
       }
 
       return handle_progress(payload, endChunk + separator.length);
-    }
+    };
 
-    var disableChunked = function(){
+    var disableChunked = function() {
       if (me.longPoll) {
         me.longPoll.abort();
         chunkedBackoff = 30;
@@ -203,18 +221,21 @@
       var position = 0;
       // if it takes longer than 3000 ms to get first chunk, we have some proxy
       // this is messing with us, so just backoff from using chunked for now
-      var chunkedTimeout = setTimeout(disableChunked,3000);
-      xhr.onprogress = function () {
+      var chunkedTimeout = setTimeout(disableChunked, 3000);
+      xhr.onprogress = function() {
         clearTimeout(chunkedTimeout);
-        if(xhr.getResponseHeader('Content-Type') === 'application/json; charset=utf-8') {
+        if (
+          xhr.getResponseHeader("Content-Type") ===
+          "application/json; charset=utf-8"
+        ) {
           // not chunked we are sending json back
           chunked = false;
           return;
         }
         position = handle_progress(xhr.responseText, position);
-      }
+      };
     };
-    if (!me.ajax){
+    if (!me.ajax) {
       throw new Error("Either jQuery or the ajax adapter must be loaded");
     }
 
@@ -222,12 +243,17 @@
 
     ajaxInProgress = true;
     var req = me.ajax({
-      url: me.baseUrl + "message-bus/" + me.clientId + "/poll" + (!longPoll ? "?dlp=t" : ""),
+      url:
+        me.baseUrl +
+        "message-bus/" +
+        me.clientId +
+        "/poll" +
+        (!longPoll ? "?dlp=t" : ""),
       data: data,
       cache: false,
       async: true,
       dataType: dataType,
-      type: 'POST',
+      type: "POST",
       headers: headers,
       messageBus: {
         chunked: chunked,
@@ -235,15 +261,18 @@
           var position = 0;
           // if it takes longer than 3000 ms to get first chunk, we have some proxy
           // this is messing with us, so just backoff from using chunked for now
-          var chunkedTimeout = setTimeout(disableChunked,3000);
-          return xhr.onprogress = function () {
+          var chunkedTimeout = setTimeout(disableChunked, 3000);
+          return (xhr.onprogress = function() {
             clearTimeout(chunkedTimeout);
-            if(xhr.getResponseHeader('Content-Type') === 'application/json; charset=utf-8') {
+            if (
+              xhr.getResponseHeader("Content-Type") ===
+              "application/json; charset=utf-8"
+            ) {
               chunked = false; // not chunked, we are sending json back
             } else {
               position = handle_progress(xhr.responseText, position);
             }
-          }
+          });
         }
       },
       xhr: function() {
@@ -255,16 +284,16 @@
         return xhr;
       },

[... diff too long, it was truncated ...]

GitHub sha: 895a851f

1 Like