Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
hipchat4 / opt / HipChat4 / share / localweb / preload.js
Size: Mime:
/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};

/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {

/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId])
/******/ 			return installedModules[moduleId].exports;

/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			exports: {},
/******/ 			id: moduleId,
/******/ 			loaded: false
/******/ 		};

/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);

/******/ 		// Flag the module as loaded
/******/ 		module.loaded = true;

/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}


/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;

/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;

/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";

/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {

	'use strict';

	/*global getEvent*/

	/**
	 * A loader screen for the web client.
	 *
	 * This module is responsible for bootstrapping the web client interface.
	 *
	 * Please keep imports into this module to a minimum. i.e. none.
	 */
	(function () {

	  var delay = 20 * 1000;

	  var loadingMessages = __webpack_require__(1),
	      listeners = [],
	      eventQueue = [];

	  var loadingMessage = document.querySelector('.loading-message');

	  /**
	   * Builds a basic analytics event object with some of the expected properties.  Once the analytics object is
	   * initialized, we can populate the rest of properties GAS expects
	   *
	   * @param name the name of the analytics event
	   *
	   * @returns {object} the object containing the minimum expected values
	   */
	  function makeEvent(name) {
	    return {
	      "name": name,
	      "serverTime": new Date().getTime()
	    };
	  }

	  function getRandomNumber(max) {
	    return Math.floor(Math.random() * max);
	  }

	  function getRandomMessage(type) {
	    return loadingMessages[type][getRandomNumber(loadingMessages[type].length)];
	  }

	  function setMessage(message) {
	    loadingMessage.querySelector('p').textContent = message;
	  }

	  function removeMessage() {
	    loadingMessage.removeChild(loadingMessage.querySelector('p'));
	  }

	  function showHappyMessage() {
	    eventQueue.push(makeEvent("hipchat.client.load.timeout.1"));
	    setMessage(getRandomMessage("happy"));
	  }

	  function showNotSoHappyMessage() {
	    eventQueue.push(makeEvent("hipchat.client.load.timeout.2"));
	    setMessage(getRandomMessage("sad"));
	  }

	  function elAppend(el, html) {
	    el.insertAdjacentHTML('beforeend', html);
	  }

	  function elAddClass(el, strClass) {
	    if (el.classList) {
	      el.classList.add(strClass);
	    } else {
	      // for IE9
	      el.className += ' ' + strClass;
	    }
	  }

	  function elRemove(el) {
	    el.parentNode.removeChild(el);
	  }

	  function onDomReady(fn) {
	    if (document.readyState !== 'loading') {
	      fn();
	    } else {
	      document.addEventListener('DOMContentLoaded', fn);
	    }
	  }

	  function cleanup() {
	    listeners = null;
	    delete window.preloaderEvents;
	  }

	  function firePreloaderComplete(queue) {
	    if (listeners) {
	      listeners.forEach(function (listener) {
	        listener(queue);
	      });
	    }
	    cleanup();
	  }

	  window.preloaderEvents = {
	    onComplete: function onComplete(handler) {
	      listeners.push(handler);
	    }
	  };

	  function showBrokenMessage() {
	    eventQueue.push(makeEvent("hipchat.client.load.failed"));
	    firePreloaderComplete(eventQueue);

	    setMessage(loadingMessages.broken_message);

	    elAppend(loadingMessage, '<p><button class=\'aui-button\' id=\'try-again\' type=\'button\'>' + loadingMessages.try_again + '</button></p>');

	    var tryAgainBtn = loadingMessage.querySelector('#try-again');
	    tryAgainBtn.style.marginTop = '5px';
	    tryAgainBtn.onclick = function () {
	      return window.location.reload();
	    };

	    elAddClass(loadingMessage, 'sad');

	    loadingMessage.querySelector('svg > use').setAttribute('xlink:href', '#icon-hipchat-logo-sad');
	  }

	  function showPolicyViolationMessage(_ref) {
	    var web_server = _ref.web_server;

	    eventQueue.push(makeEvent("hipchat.client.load.failed"));
	    firePreloaderComplete(eventQueue);

	    removeMessage();
	    elAppend(loadingMessage, loadingMessages.policy_violation(web_server));

	    elAddClass(loadingMessage, 'sad');

	    loadingMessage.querySelector('svg > use').setAttribute('xlink:href', '#icon-hipchat-logo-sad');
	  }

	  function checkBrowserSupport() {
	    var el = document.querySelector('.unsupported-browser');

	    if (el && el.style.display !== 'none') {
	      eventQueue.push(getEvent("hipchat.client.load.failed.unsupported"));
	      firePreloaderComplete(eventQueue);
	    }
	  }

	  // Push an event that indicates we're beginning the load process
	  eventQueue.push(makeEvent("hipchat.client.load.begin"));

	  // Setup our loading timeouts
	  var timeouts = [setTimeout(showHappyMessage, delay), setTimeout(showNotSoHappyMessage, delay * 2), setTimeout(showBrokenMessage, delay * 3)];

	  onDomReady(checkBrowserSupport);

	  var clearTimeouts = function clearTimeouts() {
	    return timeouts.forEach(function (t) {
	      return clearTimeout(t);
	    });
	  };

	  function onAppReady() {
	    elRemove(loadingMessage);
	    clearTimeouts();
	    eventQueue.push(makeEvent("hipchat.client.load.end"));
	    firePreloaderComplete(eventQueue);

	    // remove jquery event handler
	    delete document['onapp-state-ready'];
	  }

	  function onAppError(evt, data) {
	    clearTimeouts();
	    showPolicyViolationMessage(data);
	    delete document['onapp-error'];
	  }

	  // add handler for jquery event
	  document['onapp-state-ready'] = onAppReady;
	  document['onapp-error'] = onAppError;
	})();

/***/ },
/* 1 */
/***/ function(module, exports, __webpack_require__) {

	'use strict';

	Object.defineProperty(exports, "__esModule", {
	  value: true
	});

	var _common_strings = __webpack_require__(2);

	var _common_strings2 = _interopRequireDefault(_common_strings);

	function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

	exports.default = {
	  /*
	  These two arrays correspond to each other; they must be
	  the same length and the two corresponding messages must be
	  at the same index.
	  */
	  happy: ['Hold tight. Shouldn\'t take too long.', 'Just a sec.', 'One ' + _common_strings2.default.app_name + ', coming right up.', 'Relax. We got this.', 'Here it comes.', 'Let\'s get started.', 'Workin\' on it.'],
	  sad: ['Yikes. This really is taking a while...', 'Looks like a sec wasn\'t enough. Give us a minute...', 'Well... coming up soon...', 'Oh man. Don\'t freak out, we still got this...', 'This hardly ever happens...', 'Looks like we\'ll be starting a little late...', 'Still workin\' here... You sure do look nice today...'],
	  broken_message: 'Something\'s gone wrong.',
	  try_again: 'Try again',
	  policy_violation: function policy_violation(web_server) {
	    return '<p>You currently have 10 active sessions which is the maximum number allowed.</p>\n                                      <p>You can manage your active sessions <a href="https://' + web_server + '/account/sessions">here</a>.</p>';
	  }
	};
	module.exports = exports['default'];

/***/ },
/* 2 */
/***/ function(module, exports) {

	"use strict";

	Object.defineProperty(exports, "__esModule", {
	  value: true
	});
	exports.default = {
	  app_name: "HipChat",
	  filter_label: "Filter rooms and people",
	  filter: "Filter",
	  all: "All",
	  rooms: "Rooms",
	  people: "People",
	  sign_in: "Sign in",
	  lobby: "Lobby",
	  youre_welcome: "you're welcome here",
	  search_results: "Search results",
	  buttons: {
	    create_room: "Create a room",
	    invite_team: "Invite your team",
	    invite_team_in_lobby: "Invite someone to join!"
	  },
	  loud: "Loud",
	  normal: "Normal",
	  quiet: "Quiet"
	};
	module.exports = exports['default'];

/***/ }
/******/ ]);