<commit_before>/**
* @license Apache-2.0
*
* Copyright (c) 2018 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*    http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

/*
* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.
*/

// MODULES //

var setReadOnly = require( '@stdlib/utils/define-read-only-property' );

// MAIN //

/**
* Top-level namespace.
*
* @namespace ns
*/
var ns = {};

/**
* @name assert
* @memberof ns
* @readonly
* @type {Namespace}
* @see {@link module:@stdlib/ndarray/base/assert}
*/
setReadOnly( ns, 'assert', require( '@stdlib/ndarray/base/assert' ) );

/**
* @name bind2vind
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/bind2vind}
*/
setReadOnly( ns, 'bind2vind', require( '@stdlib/ndarray/base/bind2vind' ) );

/**
* @name broadcastArray
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/broadcast-array}
*/
setReadOnly( ns, 'broadcastArray', require( '@stdlib/ndarray/base/broadcast-array' ) );

/**
* @name broadcastShapes
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/broadcast-shapes}
*/
setReadOnly( ns, 'broadcastShapes', require( '@stdlib/ndarray/base/broadcast-shapes' ) );

/**
* @name buffer
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/buffer}
*/
setReadOnly( ns, 'buffer', require( '@stdlib/ndarray/base/buffer' ) );

/**
* @name bufferCtors
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/buffer-ctors}
*/
setReadOnly( ns, 'bufferCtors', require( '@stdlib/ndarray/base/buffer-ctors' ) );

/**
* @name bufferDataType
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/buffer-dtype}
*/
setReadOnly( ns, 'bufferDataType', require( '@stdlib/ndarray/base/buffer-dtype' ) );

/**
* @name bufferDataTypeEnum
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/buffer-dtype-enum}
*/
setReadOnly( ns, 'bufferDataTypeEnum', require( '@stdlib/ndarray/base/buffer-dtype-enum' ) );

/**
* @name bytesPerElement
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/bytes-per-element}
*/
setReadOnly( ns, 'bytesPerElement', require( '@stdlib/ndarray/base/bytes-per-element' ) );

/**
* @name char2dtype
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/char2dtype}
*/
setReadOnly( ns, 'char2dtype', require( '@stdlib/ndarray/base/char2dtype' ) );

/**
* @name clampIndex
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/clamp-index}
*/
setReadOnly( ns, 'clampIndex', require( '@stdlib/ndarray/base/clamp-index' ) );

/**
* @name ndarray
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/ctor}
*/
setReadOnly( ns, 'ndarray', require( '@stdlib/ndarray/base/ctor' ) );

/**
* @name dtypeChar
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/dtype-char}
*/
setReadOnly( ns, 'dtypeChar', require( '@stdlib/ndarray/base/dtype-char' ) );

/**
* @name dtypeDesc
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/dtype-desc}
*/
setReadOnly( ns, 'dtypeDesc', require( '@stdlib/ndarray/base/dtype-desc' ) );

/**
* @name dtypeEnum2Str
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/dtype-enum2str}
*/
setReadOnly( ns, 'dtypeEnum2Str', require( '@stdlib/ndarray/base/dtype-enum2str' ) );

/**
* @name dtypeResolveEnum
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/dtype-resolve-enum}
*/
setReadOnly( ns, 'dtypeResolveEnum', require( '@stdlib/ndarray/base/dtype-resolve-enum' ) );

/**
* @name dtypeResolveStr
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/dtype-resolve-str}
*/
setReadOnly( ns, 'dtypeResolveStr', require( '@stdlib/ndarray/base/dtype-resolve-str' ) );

/**
* @name dtypeStr2Enum
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/dtype-str2enum}
*/
setReadOnly( ns, 'dtypeStr2Enum', require( '@stdlib/ndarray/base/dtype-str2enum' ) );

/**
* @name dtype2c
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/dtype2c}
*/
setReadOnly( ns, 'dtype2c', require( '@stdlib/ndarray/base/dtype2c' ) );

/**
* @name dtypes2signatures
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/dtypes2signatures}
*/
setReadOnly( ns, 'dtypes2signatures', require( '@stdlib/ndarray/base/dtypes2signatures' ) );

/**
* @name ind
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/ind}
*/
setReadOnly( ns, 'ind', require( '@stdlib/ndarray/base/ind' ) );

/**
* @name ind2sub
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/ind2sub}
*/
setReadOnly( ns, 'ind2sub', require( '@stdlib/ndarray/base/ind2sub' ) );

/**
* @name iterationOrder
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/iteration-order}
*/
setReadOnly( ns, 'iterationOrder', require( '@stdlib/ndarray/base/iteration-order' ) );

/**
* @name maxViewBufferIndex
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/max-view-buffer-index}
*/
setReadOnly( ns, 'maxViewBufferIndex', require( '@stdlib/ndarray/base/max-view-buffer-index' ) );

/**
* @name metaDataProps
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/meta-data-props}
*/
setReadOnly( ns, 'metaDataProps', require( '@stdlib/ndarray/base/meta-data-props' ) );

/**
* @name minViewBufferIndex
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/min-view-buffer-index}
*/
setReadOnly( ns, 'minViewBufferIndex', require( '@stdlib/ndarray/base/min-view-buffer-index' ) );

/**
* @name minmaxViewBufferIndex
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/minmax-view-buffer-index}
*/
setReadOnly( ns, 'minmaxViewBufferIndex', require( '@stdlib/ndarray/base/minmax-view-buffer-index' ) );

/**
* @name ndarraylike2object
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/ndarraylike2object}
*/
setReadOnly( ns, 'ndarraylike2object', require( '@stdlib/ndarray/base/ndarraylike2object' ) );

/**
* @name nonsingletonDimensions
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/nonsingleton-dimensions}
*/
setReadOnly( ns, 'nonsingletonDimensions', require( '@stdlib/ndarray/base/nonsingleton-dimensions' ) );

/**
* @name numel
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/numel}
*/
setReadOnly( ns, 'numel', require( '@stdlib/ndarray/base/numel' ) );

/**
* @name serializeMetaData
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/serialize-meta-data}
*/
setReadOnly( ns, 'serializeMetaData', require( '@stdlib/ndarray/base/serialize-meta-data' ) );

/**
* @name shape2strides
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/shape2strides}
*/
setReadOnly( ns, 'shape2strides', require( '@stdlib/ndarray/base/shape2strides' ) );

/**
* @name singletonDimensions
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/singleton-dimensions}
*/
setReadOnly( ns, 'singletonDimensions', require( '@stdlib/ndarray/base/singleton-dimensions' ) );

/**
* @name strides2offset
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/strides2offset}
*/
setReadOnly( ns, 'strides2offset', require( '@stdlib/ndarray/base/strides2offset' ) );

/**
* @name strides2order
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/strides2order}
*/
setReadOnly( ns, 'strides2order', require( '@stdlib/ndarray/base/strides2order' ) );

/**
* @name sub2ind
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/sub2ind}
*/
setReadOnly( ns, 'sub2ind', require( '@stdlib/ndarray/base/sub2ind' ) );

/**
* @name ndarray2array
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/to-array}
*/
setReadOnly( ns, 'ndarray2array', require( '@stdlib/ndarray/base/to-array' ) );

/**
* @name vind2bind
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/vind2bind}
*/
setReadOnly( ns, 'vind2bind', require( '@stdlib/ndarray/base/vind2bind' ) );

/**
* @name wrapIndex
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/wrap-index}
*/
setReadOnly( ns, 'wrapIndex', require( '@stdlib/ndarray/base/wrap-index' ) );

// EXPORTS //

module.exports = ns;
<commit_msg>Update namespace<commit_after>/**
* @license Apache-2.0
*
* Copyright (c) 2018 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*    http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

/*
* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.
*/

// MODULES //

var setReadOnly = require( '@stdlib/utils/define-read-only-property' );

// MAIN //

/**
* Top-level namespace.
*
* @namespace ns
*/
var ns = {};

/**
* @name assert
* @memberof ns
* @readonly
* @type {Namespace}
* @see {@link module:@stdlib/ndarray/base/assert}
*/
setReadOnly( ns, 'assert', require( '@stdlib/ndarray/base/assert' ) );

/**
* @name bind2vind
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/bind2vind}
*/
setReadOnly( ns, 'bind2vind', require( '@stdlib/ndarray/base/bind2vind' ) );

/**
* @name broadcastArray
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/broadcast-array}
*/
setReadOnly( ns, 'broadcastArray', require( '@stdlib/ndarray/base/broadcast-array' ) );

/**
* @name broadcastShapes
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/broadcast-shapes}
*/
setReadOnly( ns, 'broadcastShapes', require( '@stdlib/ndarray/base/broadcast-shapes' ) );

/**
* @name buffer
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/buffer}
*/
setReadOnly( ns, 'buffer', require( '@stdlib/ndarray/base/buffer' ) );

/**
* @name bufferCtors
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/buffer-ctors}
*/
setReadOnly( ns, 'bufferCtors', require( '@stdlib/ndarray/base/buffer-ctors' ) );

/**
* @name bufferDataType
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/buffer-dtype}
*/
setReadOnly( ns, 'bufferDataType', require( '@stdlib/ndarray/base/buffer-dtype' ) );

/**
* @name bufferDataTypeEnum
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/buffer-dtype-enum}
*/
setReadOnly( ns, 'bufferDataTypeEnum', require( '@stdlib/ndarray/base/buffer-dtype-enum' ) );

/**
* @name bytesPerElement
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/bytes-per-element}
*/
setReadOnly( ns, 'bytesPerElement', require( '@stdlib/ndarray/base/bytes-per-element' ) );

/**
* @name char2dtype
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/char2dtype}
*/
setReadOnly( ns, 'char2dtype', require( '@stdlib/ndarray/base/char2dtype' ) );

/**
* @name clampIndex
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/clamp-index}
*/
setReadOnly( ns, 'clampIndex', require( '@stdlib/ndarray/base/clamp-index' ) );

/**
* @name ndarray
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/ctor}
*/
setReadOnly( ns, 'ndarray', require( '@stdlib/ndarray/base/ctor' ) );

/**
* @name dtypeChar
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/dtype-char}
*/
setReadOnly( ns, 'dtypeChar', require( '@stdlib/ndarray/base/dtype-char' ) );

/**
* @name dtypeDesc
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/dtype-desc}
*/
setReadOnly( ns, 'dtypeDesc', require( '@stdlib/ndarray/base/dtype-desc' ) );

/**
* @name dtypeEnum2Str
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/dtype-enum2str}
*/
setReadOnly( ns, 'dtypeEnum2Str', require( '@stdlib/ndarray/base/dtype-enum2str' ) );

/**
* @name dtypeResolveEnum
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/dtype-resolve-enum}
*/
setReadOnly( ns, 'dtypeResolveEnum', require( '@stdlib/ndarray/base/dtype-resolve-enum' ) );

/**
* @name dtypeResolveStr
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/dtype-resolve-str}
*/
setReadOnly( ns, 'dtypeResolveStr', require( '@stdlib/ndarray/base/dtype-resolve-str' ) );

/**
* @name dtypeStr2Enum
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/dtype-str2enum}
*/
setReadOnly( ns, 'dtypeStr2Enum', require( '@stdlib/ndarray/base/dtype-str2enum' ) );

/**
* @name dtype2c
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/dtype2c}
*/
setReadOnly( ns, 'dtype2c', require( '@stdlib/ndarray/base/dtype2c' ) );

/**
* @name dtypes2signatures
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/dtypes2signatures}
*/
setReadOnly( ns, 'dtypes2signatures', require( '@stdlib/ndarray/base/dtypes2signatures' ) );

/**
* @name ind
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/ind}
*/
setReadOnly( ns, 'ind', require( '@stdlib/ndarray/base/ind' ) );

/**
* @name ind2sub
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/ind2sub}
*/
setReadOnly( ns, 'ind2sub', require( '@stdlib/ndarray/base/ind2sub' ) );

/**
* @name iterationOrder
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/iteration-order}
*/
setReadOnly( ns, 'iterationOrder', require( '@stdlib/ndarray/base/iteration-order' ) );

/**
* @name maxViewBufferIndex
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/max-view-buffer-index}
*/
setReadOnly( ns, 'maxViewBufferIndex', require( '@stdlib/ndarray/base/max-view-buffer-index' ) );

/**
* @name metaDataProps
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/meta-data-props}
*/
setReadOnly( ns, 'metaDataProps', require( '@stdlib/ndarray/base/meta-data-props' ) );

/**
* @name minViewBufferIndex
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/min-view-buffer-index}
*/
setReadOnly( ns, 'minViewBufferIndex', require( '@stdlib/ndarray/base/min-view-buffer-index' ) );

/**
* @name minmaxViewBufferIndex
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/minmax-view-buffer-index}
*/
setReadOnly( ns, 'minmaxViewBufferIndex', require( '@stdlib/ndarray/base/minmax-view-buffer-index' ) );

/**
* @name ndarraylike2object
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/ndarraylike2object}
*/
setReadOnly( ns, 'ndarraylike2object', require( '@stdlib/ndarray/base/ndarraylike2object' ) );

/**
* @name nonsingletonDimensions
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/nonsingleton-dimensions}
*/
setReadOnly( ns, 'nonsingletonDimensions', require( '@stdlib/ndarray/base/nonsingleton-dimensions' ) );

/**
* @name numel
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/numel}
*/
setReadOnly( ns, 'numel', require( '@stdlib/ndarray/base/numel' ) );

/**
* @name serializeMetaData
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/serialize-meta-data}
*/
setReadOnly( ns, 'serializeMetaData', require( '@stdlib/ndarray/base/serialize-meta-data' ) );

/**
* @name shape2strides
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/shape2strides}
*/
setReadOnly( ns, 'shape2strides', require( '@stdlib/ndarray/base/shape2strides' ) );

/**
* @name singletonDimensions
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/singleton-dimensions}
*/
setReadOnly( ns, 'singletonDimensions', require( '@stdlib/ndarray/base/singleton-dimensions' ) );

/**
* @name strides2offset
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/strides2offset}
*/
setReadOnly( ns, 'strides2offset', require( '@stdlib/ndarray/base/strides2offset' ) );

/**
* @name strides2order
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/strides2order}
*/
setReadOnly( ns, 'strides2order', require( '@stdlib/ndarray/base/strides2order' ) );

/**
* @name sub2ind
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/sub2ind}
*/
setReadOnly( ns, 'sub2ind', require( '@stdlib/ndarray/base/sub2ind' ) );

/**
* @name ndarray2array
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/to-array}
*/
setReadOnly( ns, 'ndarray2array', require( '@stdlib/ndarray/base/to-array' ) );

/**
* @name vind2bind
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/vind2bind}
*/
setReadOnly( ns, 'vind2bind', require( '@stdlib/ndarray/base/vind2bind' ) );

/**
* @name wrapIndex
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/wrap-index}
*/
setReadOnly( ns, 'wrapIndex', require( '@stdlib/ndarray/base/wrap-index' ) );

/**
* @name zeros
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/ndarray/base/zeros}
*/
setReadOnly( ns, 'zeros', require( '@stdlib/ndarray/base/zeros' ) );

// EXPORTS //

module.exports = ns;
<|endoftext|>


<commit_before>'use strict';

import slack from 'slack';
import Storage from 'electron-json-storage';
import FirableTimer from './firable-timer.js';

const ChannelCache = 'channel_cache';
const UserCache = 'user_cache';
const AppConfig = require('../assets/conf.json');
const MIN_IN_SEC = 60;
const HOUR_IN_SEC = MIN_IN_SEC * 60;
const DAY_IN_SEC = HOUR_IN_SEC * 24;
const CHANNEL_UPDATE_IN_MSEC = 2000;
const TEAM_UPDATE_IN_MSEC = 60 * CHANNEL_UPDATE_IN_MSEC;
const MAX_REFRESH_WAIT_IN_MSEC = 5000;

export default class SlackHandler {

  constructor() {
    this.onRefresh = null;
    this._sortedChannelIds = [];
    this._channels = {};
    this._users = {};
    this._teams = {};
    this._tokens = AppConfig['tokens'];
    this._updatedTime = new Date();
    this._reserves = {};
    this._loadCache(() => {
      this._updateTeam();
    });
  }

  getChannels() {
    return this._sortedChannelIds.map((channelId) => {
      const channel = this._channels[channelId];
      return {
        id: channel.id,
        team: channel.team,
        channel: channel.name,
        is_new: channel.is_new,
        link: this._deeplink(channel.team,channel.id),
        date: this._formatedDate(channel.last_message.post_time),
        userName: this.getUser(channel.last_message.user_id),
        lastMessage: channel.last_message.text,
      };
    });
  }

  updateChannel(channelId) {
    const runner = this._reserves[channelId];
    if (runner) {
      // force to update after 0.5 sec
      runner.run(500);
    }
  }

  getSize() {
    return this._sortedChannelIds.length;
  }

  getUser(userId) {
    return this._users[userId];
  }

  _loadCache(callback) {
    Promise
      .resolve()
      .then(() => {
        Storage.get(ChannelCache,(error, data) => {
          if (error) {
            console.log(error);
          }
          else {
            this._channels = data;
            this._sortData();
          }
          return Promise.resolve();
        });
      })
      .then(() => {
        Storage.get(UserCache,(error, data) => {
          if (error) {
            console.log(error);
          }
          else {
            this._users = data;
            this._handleRefresh(true);
          }
          return Promise.resolve();
        });
      })
      .then(callback);
  }

  _cacheChannels() {
    Storage.set(ChannelCache,this._channels,(error, data) => {
      if (error) console.log(error);
    });
  }

  _cacheUsers() {
    Storage.set(UserCache,this._users,(error, data) => {
      if (error) console.log(error);
    });
  }

  _formatedDate(date) {
    if (!date) return '';
    const base = Math.round(this._updatedTime.getTime() / 1000);
    const diff = base - date;
    if (diff > DAY_IN_SEC) {
      const day = Math.floor( diff / DAY_IN_SEC );
      if (day > 1) {
        return day + ' days ago';
      }
      return 'Yesterday';
    }
    if (diff > HOUR_IN_SEC) {
      const hour = Math.floor( diff / HOUR_IN_SEC );
      if (hour > 1) {
        return hour + ' hours ago';
      }
      return '1 hour ago';
    }
    const min = Math.floor( diff / MIN_IN_SEC );
    if (min > 1) {
      return min + ' mins ago';
    }
    return min + ' min ago';
  }

  _deeplink(team,channel) {
    if (!this._teams[team]) return 'slack://open';
    return 'slack://channel?team=' + this._teams[team] + '&id=' + channel;
  }

  _handleRefresh(forceRefresh) {
    const now = new Date();
    if (forceRefresh || this._updatedTime.getTime() + MAX_REFRESH_WAIT_IN_MSEC < now.getTime()) {
      this._updatedTime = now;
      if (this.onRefresh) {
        this.onRefresh();
      }
    }
  }

  _sortData() {
    let channelIds = Object.keys(this._channels);
    channelIds = channelIds.filter((id) => {
      return !this._channels[id].is_ignored;
    });
    channelIds.sort((idA, idB) => {
      const dateA = this._channels[idA].last_message.post_time;
      const dateB = this._channels[idB].last_message.post_time;
      return dateB - dateA;
    });
    this._sortedChannelIds = channelIds;
    this._handleRefresh(true);
  }

  _updateTeam() {
    Object.keys(this._tokens).forEach((key) => {
      this._getTeamInfo(key);
      this._updateChannels(key);
    });
  }

  _updateChannels(team) {
    slack.groups.list({token: this._tokens[team]}, (error, data) => {
      if (error) {
        console.log(error);
        this._sortData();
        return;
      }
      data.groups.forEach((channelInfo, index, array) => {
        this._getChannelInfo(team, channelInfo.id);
        if (index == array.length - 1) {
          this._reserveNextListUpdate(team);
        }
      });
    });
  }

  _reserveNextListUpdate(team) {
    setTimeout(() => {
      this._updateChannels(team);
    }, TEAM_UPDATE_IN_MSEC);
  }

  _getChannelInfo(team, channelId) {
    const param = {
      token: this._tokens[team],
      channel: channelId,
    };
    slack.groups.info(param, (error, data) => {
      if (error) {
        console.log(error);
        return;
      }
      const channel = {
        id: data.group.id,
        team: team,
        name: data.group.name,
        is_new: data.group.unread_count_display > 0,
        is_ignored: SlackHandler.shouldIgnoreChannel(data.group),
        last_message: SlackHandler.convertMessage(data.group.latest),
      };
      const cache = this._channels[channel.id];
      this._channels[channel.id] = channel;
      if (!cache || cache.last_message.post_time != channel.last_message.post_time) {
        this._cacheChannels();
        this._sortData();
      }
      else {
        this._handleRefresh(false);
      }
      if (!this._users[channel.last_message.user_id]) {
        this._getUserInfo(team, channel.last_message.user_id);
      }
      if (!channel.is_ignored) {
        this._reserveNextChannelUpdate(team, channel.id);
      }
    });
  }

  _reserveNextChannelUpdate(team, channelId) {
    const runner = new FirableTimer(() => {
      this._reserves[channelId] = null;
      this._getChannelInfo(team, channelId);
    });
    this._reserves[channelId] = runner;
    // making delay randomized so that we do fetch channel info inconsistently.
    runner.run(CHANNEL_UPDATE_IN_MSEC + (Math.random() - 0.5) * 500);
  }

  _getTeamInfo(team) {
    slack.team.info({token: this._tokens[team]}, (error, data) => {
      if (error) {
        console.log(error);
        return;
      }
      this._teams[team] = data.team.id;
    });
  }

  _getUserInfo(team, userId) {
    const updateName = (name) => {
      this._users[userId] = name;
      this._cacheUsers();
      this._handleRefresh(true);
    };
    let param = { token: this._tokens[team] };
    if (userId.startsWith('user_')) {
      param.user = userId.replace(/^user_/,'');
      slack.users.info(param, (error, data) => {
        if (error) {
          console.log(error);
          return;
        }
        updateName(data.user.name);
      });
    }
    else if (userId.startsWith('bot_')) {
      param.bot = userId.replace(/^bot_/,'');
      slack.bots.info(param, (error, data) => {
        if (error) {
          console.log(error);
          return;
        }
        updateName(data.bot.name);
      });
    }
  }

  static convertMessage(info) {
    let userId = info.user ? 'user_' + info.user : undefined;
    if (!userId && info.bot_id) {
      userId = 'bot_' + info.bot_id;
    }
    return {
      user_id: userId,
      post_time: info.ts,
      text: info.text.replace(/\n/,' '),
    };
  }

  static shouldIgnoreChannel(info) {
    if (info.is_archived) return true;
    const ignore = AppConfig['ignore'];
    for (let i=0,n=ignore.length;i<n;i++) {
      if (info.name.indexOf(ignore[i]) > -1) return true;
    }
    return false;
  }

}
<commit_msg>change how to update channel info at first<commit_after>'use strict';

import slack from 'slack';
import Storage from 'electron-json-storage';
import FirableTimer from './firable-timer.js';

const ChannelCache = 'channel_cache';
const UserCache = 'user_cache';
const AppConfig = require('../assets/conf.json');
const MIN_IN_SEC = 60;
const HOUR_IN_SEC = MIN_IN_SEC * 60;
const DAY_IN_SEC = HOUR_IN_SEC * 24;
const CHANNEL_UPDATE_IN_MSEC = 2000;
const TEAM_UPDATE_IN_MSEC = 60 * CHANNEL_UPDATE_IN_MSEC;
const MAX_REFRESH_WAIT_IN_MSEC = 5000;

export default class SlackHandler {

  constructor() {
    this.onRefresh = null;
    this._sortedChannelIds = [];
    this._channels = {};
    this._users = {};
    this._teams = {};
    this._tokens = AppConfig['tokens'];
    this._updatedTime = new Date();
    this._reserves = {};
    this._loadCache(() => {
      this._updateTeam();
    });
  }

  getChannels() {
    return this._sortedChannelIds.map((channelId) => {
      const channel = this._channels[channelId];
      return {
        id: channel.id,
        team: channel.team,
        channel: channel.name,
        is_new: channel.is_new,
        link: this._deeplink(channel.team,channel.id),
        date: this._formatedDate(channel.last_message.post_time),
        userName: this.getUser(channel.last_message.user_id),
        lastMessage: channel.last_message.text,
      };
    });
  }

  updateChannel(channelId) {
    const runner = this._reserves[channelId];
    if (runner) {
      // force to update after 0.5 sec
      runner.run(500);
    }
  }

  getSize() {
    return this._sortedChannelIds.length;
  }

  getUser(userId) {
    return this._users[userId];
  }

  _loadCache(callback) {
    Promise
      .resolve()
      .then(() => {
        Storage.get(ChannelCache,(error, data) => {
          if (error) {
            console.log(error);
          }
          else {
            this._channels = data;
            this._sortData();
          }
          return Promise.resolve();
        });
      })
      .then(() => {
        Storage.get(UserCache,(error, data) => {
          if (error) {
            console.log(error);
          }
          else {
            this._users = data;
            this._handleRefresh(true);
          }
          return Promise.resolve();
        });
      })
      .then(callback);
  }

  _cacheChannels() {
    Storage.set(ChannelCache,this._channels,(error, data) => {
      if (error) console.log(error);
    });
  }

  _cacheUsers() {
    Storage.set(UserCache,this._users,(error, data) => {
      if (error) console.log(error);
    });
  }

  _formatedDate(date) {
    if (!date) return '';
    const base = Math.round(this._updatedTime.getTime() / 1000);
    const diff = base - date;
    if (diff > DAY_IN_SEC) {
      const day = Math.floor( diff / DAY_IN_SEC );
      if (day > 1) {
        return day + ' days ago';
      }
      return 'Yesterday';
    }
    if (diff > HOUR_IN_SEC) {
      const hour = Math.floor( diff / HOUR_IN_SEC );
      if (hour > 1) {
        return hour + ' hours ago';
      }
      return '1 hour ago';
    }
    const min = Math.floor( diff / MIN_IN_SEC );
    if (min > 1) {
      return min + ' mins ago';
    }
    return min + ' min ago';
  }

  _deeplink(team,channel) {
    if (!this._teams[team]) return 'slack://open';
    return 'slack://channel?team=' + this._teams[team] + '&id=' + channel;
  }

  _handleRefresh(forceRefresh) {
    const now = new Date();
    if (forceRefresh || this._updatedTime.getTime() + MAX_REFRESH_WAIT_IN_MSEC < now.getTime()) {
      this._updatedTime = now;
      if (this.onRefresh) {
        this.onRefresh();
      }
    }
  }

  _sortData() {
    let channelIds = Object.keys(this._channels);
    channelIds = channelIds.filter((id) => {
      return !this._channels[id].is_ignored;
    });
    channelIds.sort((idA, idB) => {
      const dateA = this._channels[idA].last_message.post_time;
      const dateB = this._channels[idB].last_message.post_time;
      return dateB - dateA;
    });
    this._sortedChannelIds = channelIds;
    this._handleRefresh(true);
  }

  _updateTeam() {
    Object.keys(this._tokens).forEach((key) => {
      this._getTeamInfo(key);
      this._updateChannels(key);
    });
  }

  _updateChannels(team) {
    slack.groups.list({token: this._tokens[team]}, (error, data) => {
      if (error) {
        console.log(error);
        this._sortData();
        return;
      }
      data.groups.forEach((channelInfo) => {
        if (this._channels[channelInfo.id]) {
          this._reserveNextChannelUpdate(team, channelInfo.id);
        }
        else {
          this._getChannelInfo(team, channelInfo.id);
        }
      });
      this._reserveNextListUpdate(team);
    });
  }

  _reserveNextListUpdate(team) {
    setTimeout(() => {
      this._updateChannels(team);
    }, TEAM_UPDATE_IN_MSEC);
  }

  _getChannelInfo(team, channelId) {
    const param = {
      token: this._tokens[team],
      channel: channelId,
    };
    slack.groups.info(param, (error, data) => {
      if (error) {
        console.log(error);
        return;
      }
      const channel = {
        id: data.group.id,
        team: team,
        name: data.group.name,
        is_new: data.group.unread_count_display > 0,
        is_ignored: SlackHandler.shouldIgnoreChannel(data.group),
        last_message: SlackHandler.convertMessage(data.group.latest),
      };
      const cache = this._channels[channel.id];
      this._channels[channel.id] = channel;
      if (!cache || cache.last_message.post_time != channel.last_message.post_time) {
        this._cacheChannels();
        this._sortData();
      }
      else {
        this._handleRefresh(false);
      }
      if (!this._users[channel.last_message.user_id]) {
        this._getUserInfo(team, channel.last_message.user_id);
      }
      if (!channel.is_ignored) {
        this._reserveNextChannelUpdate(team, channel.id);
      }
    });
  }

  _reserveNextChannelUpdate(team, channelId) {
    const runner = new FirableTimer(() => {
      this._reserves[channelId] = null;
      this._getChannelInfo(team, channelId);
    });
    this._reserves[channelId] = runner;
    // making delay randomized so that we do fetch channel info inconsistently.
    runner.run(CHANNEL_UPDATE_IN_MSEC + (Math.random() - 0.5) * 500);
  }

  _getTeamInfo(team) {
    slack.team.info({token: this._tokens[team]}, (error, data) => {
      if (error) {
        console.log(error);
        return;
      }
      this._teams[team] = data.team.id;
    });
  }

  _getUserInfo(team, userId) {
    const updateName = (name) => {
      this._users[userId] = name;
      this._cacheUsers();
      this._handleRefresh(true);
    };
    let param = { token: this._tokens[team] };
    if (userId.startsWith('user_')) {
      param.user = userId.replace(/^user_/,'');
      slack.users.info(param, (error, data) => {
        if (error) {
          console.log(error);
          return;
        }
        updateName(data.user.name);
      });
    }
    else if (userId.startsWith('bot_')) {
      param.bot = userId.replace(/^bot_/,'');
      slack.bots.info(param, (error, data) => {
        if (error) {
          console.log(error);
          return;
        }
        updateName(data.bot.name);
      });
    }
  }

  static convertMessage(info) {
    let userId = info.user ? 'user_' + info.user : undefined;
    if (!userId && info.bot_id) {
      userId = 'bot_' + info.bot_id;
    }
    return {
      user_id: userId,
      post_time: info.ts,
      text: info.text.replace(/\n/,' '),
    };
  }

  static shouldIgnoreChannel(info) {
    if (info.is_archived) return true;
    const ignore = AppConfig['ignore'];
    for (let i=0,n=ignore.length;i<n;i++) {
      if (info.name.indexOf(ignore[i]) > -1) return true;
    }
    return false;
  }

}
<|endoftext|>


<commit_before>///////////////////////// menu /////////////////////////
function makeMenu() {
	$("#nexl-main-menu").jqxMenu({
		width: '400px',
		height: '30px',
		animationShowDuration: 300,
		animationHideDuration: 200,
		animationShowDelay: 200,
		enableHover: true,
		autoOpen: true,
		showTopLevelArrows: true
	});

	$("#nexl-main-menu").css('visibility', 'visible');

	$("#nexl-logo a").on('click', function () {
		alert('About nexl');
	});

	$("#nexl-login-menu").jqxMenu({
		width: '90px',
		height: '30px',
		animationShowDuration: 300,
		animationHideDuration: 200,
		animationShowDelay: 200,
		enableHover: true,
		autoOpen: true,
		showTopLevelArrows: true
	});
	$("#nexl-login-menu").jqxMenu('setItemOpenDirection', 'login', 'left', 'down');

	$('#login').on('click', function () {
		alert('Login !');
	});

	$('#settings').on('click', function () {
		alert('Settings !');
	});
}

////////////////////////////// nexl sources tree /////////////////////////
function makeNexlSourcesTree() {
	$('#nexl-sources').jqxTree(
		{
			height: '100%',
			width: '100%',
			source: nexlSourceSample,
			allowDrag: true,
			allowDrop: true
		}
	);
	$('#nexl-sources').css('visibility', 'visible');

	var contextMenu = $("#popup-menu").jqxMenu({
		width: '160px',
		height: '110px',
		autoOpenPopup: false,
		mode: 'popup'
	});
	var clickedItem = null;

	var attachContextMenu = function () {
		// open the context menu when the user presses the mouse right button.
		$("#nexl-sources li").on('mousedown', function (event) {
			var target = $(event.target).parents('li:first')[0];
			var rightClick = isRightClick(event);
			if (rightClick && target != null) {
				$("#nexl-sources").jqxTree('selectItem', target);
				var scrollTop = $(window).scrollTop();
				var scrollLeft = $(window).scrollLeft();
				contextMenu.jqxMenu('open', parseInt(event.clientX) + 5 + scrollLeft, parseInt(event.clientY) + 5 + scrollTop);
				return false;
			}
		});
	};

	$('#nexl-sources').on("dragEnd", function (event) {
		attachContextMenu();
	});

	$('#nexl-sources').on('select', function (event) {
		console.log(event.args.element.id);
	});

	attachContextMenu();
	$("#popup-menu").on('itemclick', function (event) {
		var item = $.trim($(event.args).text());
		switch (item) {
			case "Add Item":
				var selectedItem = $('#nexl-sources').jqxTree('selectedItem');
				if (selectedItem != null) {
					$('#nexl-sources').jqxTree('addTo', {label: 'Item'}, selectedItem.element);
					attachContextMenu();
				}
				break;
			case "Remove Item":
				var selectedItem = $('#nexl-sources').jqxTree('selectedItem');
				if (selectedItem != null) {
					$('#nexl-sources').jqxTree('removeItem', selectedItem.element);
					attachContextMenu();
				}
				break;
		}
	});
	// disable the default browser's context menu.
	$(document).on('contextmenu', function (e) {
		if ($(e.target).parents('.jqx-tree').length > 0) {
			return false;
		}
		return true;
	});
	function isRightClick(event) {
		var rightclick;
		if (!event) var event = window.event;
		if (event.which) rightclick = (event.which == 3);
		else if (event.button) rightclick = (event.button == 2);
		return rightclick;
	}
}

////////////////////////////// editor tabs /////////////////////////
function makeEditorTabs() {
	var addButton, addButtonWidth = 29, index = 0;
	$('#tabbed-editor').jqxTabs(
		{
			height: '100%',
			width: '100%',
			showCloseButtons: true,
			reorder: true
		}
	);
}

////////////////////////////// splitters /////////////////////////
function calcMainAreaHeight() {
	return $(window).height() - $('#nexl-main-menu').height() - 45;
}

function makeSplitters() {
	$('#main-area').jqxSplitter({
		width: '100%',
		height: calcMainAreaHeight(),
		orientation: 'horizontal',
		panels: [{size: '65%', collapsible: false}, {size: '35%'}]
	});

	$('#nexl-sources-and-tabs-area').jqxSplitter({
		width: '100%',
		height: '100%',
		orientation: 'vertical',
		panels: [{size: '20%'}, {size: '80%'}]
	});

	$(window).resize(function () {
		$('#main-area').jqxSplitter({
			height: calcMainAreaHeight()
		});
	});
}

function makeArgsWindow() {
	$('#window').jqxWindow({
		position: {x: 250, y: 250},
		showCollapseButton: true,
		maxHeight: 400,
		maxWidth: 700,
		minHeight: 200,
		minWidth: 200,
		height: 300,
		width: 500,
		draggable: true
	});
}

function makeOutputArea() {
	$("#expression-area").jqxInput({
		placeHolder: "Enter nexl expression",
		height: 25,
		width: '90%',
		minLength: 1
	});

	$("#expression-and-url-expander").jqxExpander(
		{
			width: '100%',
			animationType: 'slide',
			toggleMode: "none"
		}
	);
	$("#output-expander").jqxExpander({
		width: '100%',
		toggleMode: "none"

	});
}

function assignEvents() {
	$('#args-button,#menu-view-args').on('click', function () {
		$('#window').jqxWindow('focus');
		$('#window').jqxWindow('show');
	});
}

function init() {
	makeMenu();
	makeNexlSourcesTree();
	makeEditorTabs();
	makeSplitters();
	makeArgsWindow();
	makeOutputArea();
	assignEvents();
}<commit_msg>developing UI<commit_after>///////////////////////// menu /////////////////////////
function makeMenu() {
	$("#nexl-main-menu").jqxMenu({
		width: '400px',
		height: '30px',
		animationShowDuration: 300,
		animationHideDuration: 200,
		animationShowDelay: 200,
		enableHover: true,
		autoOpen: true,
		showTopLevelArrows: true
	});

	$("#nexl-main-menu").css('visibility', 'visible');

	$("#nexl-logo a").on('click', function () {
		alert('About nexl');
	});

	$("#nexl-login-menu").jqxMenu({
		width: '90px',
		height: '30px',
		animationShowDuration: 300,
		animationHideDuration: 200,
		animationShowDelay: 200,
		enableHover: true,
		autoOpen: true,
		showTopLevelArrows: true
	});
	$("#nexl-login-menu").jqxMenu('setItemOpenDirection', 'login', 'left', 'down');

	$('#login').on('click', function () {
		alert('Login !');
	});

	$('#settings').on('click', function () {
		alert('Settings !');
	});
}

////////////////////////////// nexl sources tree /////////////////////////
function makeNexlSourcesTree() {
	$('#nexl-sources').jqxTree(
		{
			height: '100%',
			width: '100%',
			source: nexlSourceSample,
			allowDrag: true,
			allowDrop: true
		}
	);
	$('#nexl-sources').css('visibility', 'visible');

	var contextMenu = $("#popup-menu").jqxMenu({
		width: '160px',
		height: '110px',
		autoOpenPopup: false,
		mode: 'popup'
	});
	var clickedItem = null;

	var attachContextMenu = function () {
		// open the context menu when the user presses the mouse right button.
		$("#nexl-sources li").on('mousedown', function (event) {
			var target = $(event.target).parents('li:first')[0];
			var rightClick = isRightClick(event);
			if (rightClick && target != null) {
				$("#nexl-sources").jqxTree('selectItem', target);
				var scrollTop = $(window).scrollTop();
				var scrollLeft = $(window).scrollLeft();
				contextMenu.jqxMenu('open', parseInt(event.clientX) + 5 + scrollLeft, parseInt(event.clientY) + 5 + scrollTop);
				return false;
			}
		});
	};

	$('#nexl-sources').on("dragEnd", function (event) {
		attachContextMenu();
	});

	$('#nexl-sources').on('select', function (event) {
		console.log(event.args.element.id);
	});

	attachContextMenu();
	$("#popup-menu").on('itemclick', function (event) {
		var item = $.trim($(event.args).text());
		switch (item) {
			case "Add Item":
				var selectedItem = $('#nexl-sources').jqxTree('selectedItem');
				if (selectedItem != null) {
					$('#nexl-sources').jqxTree('addTo', {label: 'Item'}, selectedItem.element);
					attachContextMenu();
				}
				break;
			case "Remove Item":
				var selectedItem = $('#nexl-sources').jqxTree('selectedItem');
				if (selectedItem != null) {
					$('#nexl-sources').jqxTree('removeItem', selectedItem.element);
					attachContextMenu();
				}
				break;
		}
	});
	// disable the default browser's context menu.
	$(document).on('contextmenu', function (e) {
		if ($(e.target).parents('.jqx-tree').length > 0) {
			return false;
		}
		return true;
	});
	function isRightClick(event) {
		var rightclick;
		if (!event) var event = window.event;
		if (event.which) rightclick = (event.which == 3);
		else if (event.button) rightclick = (event.button == 2);
		return rightclick;
	}
}

////////////////////////////// editor tabs /////////////////////////
function makeEditorTabs() {
	var addButton, addButtonWidth = 29, index = 0;
	$('#tabbed-editor').jqxTabs(
		{
			height: '100%',
			width: '100%',
			showCloseButtons: true,
			reorder: true
		}
	);
}

////////////////////////////// splitters /////////////////////////
function calcMainAreaHeight() {
	return $(window).height() - $('#nexl-main-menu').height() - 45;
}

function makeSplitters() {
	$('#main-area').jqxSplitter({
		width: '100%',
		height: calcMainAreaHeight(),
		orientation: 'horizontal',
		panels: [{size: '65%', collapsible: false}, {size: '35%'}]
	});

	$('#nexl-sources-and-tabs-area').jqxSplitter({
		width: '100%',
		height: '100%',
		orientation: 'vertical',
		panels: [{size: '20%'}, {size: '80%'}]
	});

	$(window).resize(function () {
		$('#main-area').jqxSplitter({
			height: calcMainAreaHeight()
		});
	});
}

function makeArgsWindow() {
	$('#window').jqxWindow({
		position: {x: 250, y: 250},
		showCollapseButton: true,
		maxHeight: 400,
		maxWidth: 700,
		minHeight: 200,
		minWidth: 200,
		height: 300,
		width: 500,
		draggable: true
	});
}

function makeOutputArea() {
	$("#expression-area").jqxInput({
		placeHolder: "Enter nexl expression",
		height: 25,
		width: '90%',
		minLength: 1
	});

	$("#expression-and-url-expander").jqxExpander(
		{
			width: '100%',
			animationType: 'slide',
			toggleMode: "none",
			showArrow: false
		}
	);
	$("#output-expander").jqxExpander({
		width: '100%',
		toggleMode: "none",
		showArrow: false
	});
}

function assignEvents() {
	$('#args-button,#menu-view-args').on('click', function () {
		$('#window').jqxWindow('focus');
		$('#window').jqxWindow('show');
	});
}

function init() {
	makeMenu();
	makeNexlSourcesTree();
	makeEditorTabs();
	makeSplitters();
	makeArgsWindow();
	makeOutputArea();
	assignEvents();
}<|endoftext|>


<commit_before>/**
* @license Apache-2.0
*
* Copyright (c) 2020 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*    http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

/*
* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.
*/

// MODULES //

var setReadOnly = require( '@stdlib/utils/define-read-only-property' );

// MAIN //

/**
* Top-level namespace.
*
* @namespace ns
*/
var ns = {};

/**
* @name binary
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/binary}
*/
setReadOnly( ns, 'binary', require( '@stdlib/strided/base/binary' ) );

/**
* @name binaryAddonDispatch
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/binary-addon-dispatch}
*/
setReadOnly( ns, 'binaryAddonDispatch', require( '@stdlib/strided/base/binary-addon-dispatch' ) );

/**
* @name cmap
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/cmap}
*/
setReadOnly( ns, 'cmap', require( '@stdlib/strided/base/cmap' ) );

/**
* @name dmap
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/dmap}
*/
setReadOnly( ns, 'dmap', require( '@stdlib/strided/base/dmap' ) );

/**
* @name dmap2
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/dmap2}
*/
setReadOnly( ns, 'dmap2', require( '@stdlib/strided/base/dmap2' ) );

/**
* @name dmskmap
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/dmskmap}
*/
setReadOnly( ns, 'dmskmap', require( '@stdlib/strided/base/dmskmap' ) );

/**
* @name dmskmap2
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/dmskmap2}
*/
setReadOnly( ns, 'dmskmap2', require( '@stdlib/strided/base/dmskmap2' ) );

/**
* @name dtypeEnum2Str
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/dtype-enum2str}
*/
setReadOnly( ns, 'dtypeEnum2Str', require( '@stdlib/strided/base/dtype-enum2str' ) );

/**
* @name dtypeResolveEnum
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/dtype-resolve-enum}
*/
setReadOnly( ns, 'dtypeResolveEnum', require( '@stdlib/strided/base/dtype-resolve-enum' ) );

/**
* @name dtypeStr2Enum
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/dtype-str2enum}
*/
setReadOnly( ns, 'dtypeStr2Enum', require( '@stdlib/strided/base/dtype-str2enum' ) );

/**
* @name mapBy
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/map-by}
*/
setReadOnly( ns, 'mapBy', require( '@stdlib/strided/base/map-by' ) );

/**
* @name mapBy2
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/map-by2}
*/
setReadOnly( ns, 'mapBy2', require( '@stdlib/strided/base/map-by2' ) );

/**
* @name maxViewBufferIndex
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/max-view-buffer-index}
*/
setReadOnly( ns, 'maxViewBufferIndex', require( '@stdlib/strided/base/max-view-buffer-index' ) );

/**
* @name metaDataProps
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/meta-data-props}
*/
setReadOnly( ns, 'metaDataProps', require( '@stdlib/strided/base/meta-data-props' ) );

/**
* @name minViewBufferIndex
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/min-view-buffer-index}
*/
setReadOnly( ns, 'minViewBufferIndex', require( '@stdlib/strided/base/min-view-buffer-index' ) );

/**
* @name mskunary
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/mskunary}
*/
setReadOnly( ns, 'mskunary', require( '@stdlib/strided/base/mskunary' ) );

/**
* @name nullary
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/nullary}
*/
setReadOnly( ns, 'nullary', require( '@stdlib/strided/base/nullary' ) );

/**
* @name offsetView
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/offset-view}
*/
setReadOnly( ns, 'offsetView', require( '@stdlib/strided/base/offset-view' ) );

/**
* @name quaternary
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/quaternary}
*/
setReadOnly( ns, 'quaternary', require( '@stdlib/strided/base/quaternary' ) );

/**
* @name quinary
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/quinary}
*/
setReadOnly( ns, 'quinary', require( '@stdlib/strided/base/quinary' ) );

/**
* @name reinterpretComplex64
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/reinterpret-complex64}
*/
setReadOnly( ns, 'reinterpretComplex64', require( '@stdlib/strided/base/reinterpret-complex64' ) );

/**
* @name reinterpretComplex128
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/reinterpret-complex128}
*/
setReadOnly( ns, 'reinterpretComplex128', require( '@stdlib/strided/base/reinterpret-complex128' ) );

/**
* @name smap
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/smap}
*/
setReadOnly( ns, 'smap', require( '@stdlib/strided/base/smap' ) );

/**
* @name smap2
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/smap2}
*/
setReadOnly( ns, 'smap2', require( '@stdlib/strided/base/smap2' ) );

/**
* @name smskmap
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/smskmap}
*/
setReadOnly( ns, 'smskmap', require( '@stdlib/strided/base/smskmap' ) );

/**
* @name smskmap2
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/smskmap2}
*/
setReadOnly( ns, 'smskmap2', require( '@stdlib/strided/base/smskmap2' ) );

/**
* @name ternary
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/ternary}
*/
setReadOnly( ns, 'ternary', require( '@stdlib/strided/base/ternary' ) );

/**
* @name unary
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/unary}
*/
setReadOnly( ns, 'unary', require( '@stdlib/strided/base/unary' ) );

/**
* @name unaryAddonDispatch
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/unary-addon-dispatch}
*/
setReadOnly( ns, 'unaryAddonDispatch', require( '@stdlib/strided/base/unary-addon-dispatch' ) );

// EXPORTS //

module.exports = ns;
<commit_msg>Update namespace<commit_after>/**
* @license Apache-2.0
*
* Copyright (c) 2020 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*    http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

/*
* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.
*/

// MODULES //

var setReadOnly = require( '@stdlib/utils/define-read-only-property' );

// MAIN //

/**
* Top-level namespace.
*
* @namespace ns
*/
var ns = {};

/**
* @name binary
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/binary}
*/
setReadOnly( ns, 'binary', require( '@stdlib/strided/base/binary' ) );

/**
* @name binaryAddonDispatch
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/binary-addon-dispatch}
*/
setReadOnly( ns, 'binaryAddonDispatch', require( '@stdlib/strided/base/binary-addon-dispatch' ) );

/**
* @name cmap
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/cmap}
*/
setReadOnly( ns, 'cmap', require( '@stdlib/strided/base/cmap' ) );

/**
* @name dmap
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/dmap}
*/
setReadOnly( ns, 'dmap', require( '@stdlib/strided/base/dmap' ) );

/**
* @name dmap2
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/dmap2}
*/
setReadOnly( ns, 'dmap2', require( '@stdlib/strided/base/dmap2' ) );

/**
* @name dmskmap
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/dmskmap}
*/
setReadOnly( ns, 'dmskmap', require( '@stdlib/strided/base/dmskmap' ) );

/**
* @name dmskmap2
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/dmskmap2}
*/
setReadOnly( ns, 'dmskmap2', require( '@stdlib/strided/base/dmskmap2' ) );

/**
* @name dtypeEnum2Str
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/dtype-enum2str}
*/
setReadOnly( ns, 'dtypeEnum2Str', require( '@stdlib/strided/base/dtype-enum2str' ) );

/**
* @name dtypeResolveEnum
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/dtype-resolve-enum}
*/
setReadOnly( ns, 'dtypeResolveEnum', require( '@stdlib/strided/base/dtype-resolve-enum' ) );

/**
* @name dtypeStr2Enum
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/dtype-str2enum}
*/
setReadOnly( ns, 'dtypeStr2Enum', require( '@stdlib/strided/base/dtype-str2enum' ) );

/**
* @name mapBy
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/map-by}
*/
setReadOnly( ns, 'mapBy', require( '@stdlib/strided/base/map-by' ) );

/**
* @name mapBy2
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/map-by2}
*/
setReadOnly( ns, 'mapBy2', require( '@stdlib/strided/base/map-by2' ) );

/**
* @name maxViewBufferIndex
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/max-view-buffer-index}
*/
setReadOnly( ns, 'maxViewBufferIndex', require( '@stdlib/strided/base/max-view-buffer-index' ) );

/**
* @name metaDataProps
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/meta-data-props}
*/
setReadOnly( ns, 'metaDataProps', require( '@stdlib/strided/base/meta-data-props' ) );

/**
* @name minViewBufferIndex
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/min-view-buffer-index}
*/
setReadOnly( ns, 'minViewBufferIndex', require( '@stdlib/strided/base/min-view-buffer-index' ) );

/**
* @name mskunary
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/mskunary}
*/
setReadOnly( ns, 'mskunary', require( '@stdlib/strided/base/mskunary' ) );

/**
* @name nullary
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/nullary}
*/
setReadOnly( ns, 'nullary', require( '@stdlib/strided/base/nullary' ) );

/**
* @name offsetView
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/offset-view}
*/
setReadOnly( ns, 'offsetView', require( '@stdlib/strided/base/offset-view' ) );

/**
* @name quaternary
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/quaternary}
*/
setReadOnly( ns, 'quaternary', require( '@stdlib/strided/base/quaternary' ) );

/**
* @name quinary
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/quinary}
*/
setReadOnly( ns, 'quinary', require( '@stdlib/strided/base/quinary' ) );

/**
* @name reinterpretComplex64
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/reinterpret-complex64}
*/
setReadOnly( ns, 'reinterpretComplex64', require( '@stdlib/strided/base/reinterpret-complex64' ) );

/**
* @name reinterpretComplex128
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/reinterpret-complex128}
*/
setReadOnly( ns, 'reinterpretComplex128', require( '@stdlib/strided/base/reinterpret-complex128' ) );

/**
* @name smap
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/smap}
*/
setReadOnly( ns, 'smap', require( '@stdlib/strided/base/smap' ) );

/**
* @name smap2
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/smap2}
*/
setReadOnly( ns, 'smap2', require( '@stdlib/strided/base/smap2' ) );

/**
* @name smskmap
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/smskmap}
*/
setReadOnly( ns, 'smskmap', require( '@stdlib/strided/base/smskmap' ) );

/**
* @name smskmap2
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/smskmap2}
*/
setReadOnly( ns, 'smskmap2', require( '@stdlib/strided/base/smskmap2' ) );

/**
* @name ternary
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/ternary}
*/
setReadOnly( ns, 'ternary', require( '@stdlib/strided/base/ternary' ) );

/**
* @name unary
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/unary}
*/
setReadOnly( ns, 'unary', require( '@stdlib/strided/base/unary' ) );

/**
* @name unaryAddonDispatch
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/unary-addon-dispatch}
*/
setReadOnly( ns, 'unaryAddonDispatch', require( '@stdlib/strided/base/unary-addon-dispatch' ) );

/**
* @name zmap
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/strided/base/zmap}
*/
setReadOnly( ns, 'zmap', require( '@stdlib/strided/base/zmap' ) );

// EXPORTS //

module.exports = ns;
<|endoftext|>


<commit_before>$(function() {
  $('a.widgy-fancybox').fancybox({
    width: 700,
    type: 'iframe',
    onComplete: function() {
      $.fancybox.showActivity();
      $('#fancybox-frame').load(function(){
        $.fancybox.hideActivity();
      });
    }
  });
  window.closeFancybox = $.fancybox.close;
});
<commit_msg>Fixed showActivity bug.<commit_after>jQuery(function($) {
  $('a.widgy-fancybox').fancybox({
    width: 700,
    type: 'iframe',
    onComplete: function() {
      $.fancybox.showActivity();
      $('#fancybox-frame').load(function(){
        $.fancybox.hideActivity();
      });
    }
  });
  window.closeFancybox = $.fancybox.close;
});
<|endoftext|>


<commit_before>const Helper = require('../../shared');
const wsServer = require('websocket').server;
const http = require('http');

class websocketController extends Helper{
	constructor(){
		super('Web Socket Controller');
		this._config = this.setConfigs();
		this.server = this.initServer();
	}

	broadcast(type, data){
		msg = JSON.stringify({type, data});
		return this.server.broadcast(msg);
	}

	/**
	 * Set Default Configurations
	 */
	setConfigs(){
		this.log('setConfigs');
		let configs = {};

		configs.port = process.env.WS_PORT;
		configs.allowedProtocol = 'cec-protocol';

		configs.ws = {};
		// You should not use autoAcceptConnections for production
		// applications, as it defeats all standard cross-origin protection
		// facilities built into the protocol and the browser.  You should
		// *always* verify the connection's origin and decide whether or not
		// to accept it.
		configs.ws.autoAcceptConnections = false
		configs.ws.httpServer = this.makeHttpServer(configs.port)

		return configs;
	}

	/**
	 * Make Https server, needed by Websocket
	 * @param  {Number} port Set via .env
	 * @return http Server
	 */
	makeHttpServer(port){
		this.log('makeHttpServer on', port);
		const server = http.createServer(this.handleHttpResponse);
		server.listen(port, ()=>this.log(`listening ws://localhost:${port}`));
		return server
	}

	/**
	 * Handle http connection to port
	 * @param  {Object} request
	 * @param  {Object} response
	 * @return {Response.end}
	 */
	handleHttpResponse(request, response){
		this.log('handleHttpResponse', `Received ${request.url}`)
		response.writeHead(404);
		return response.end();
	}

	initServer(){
		this.log('initServer');
		this.server =  new wsServer(this._config.ws);
		return this.server.on('request', (request)=>this.wsRequest(request))
	}

	wsRequest(request){
		if (!this.originIsAllowed(request.origin)) {
		  return this.rejectRequest(request);
		}

		let connection = request.accept(this._config.allowedProtocol, request.origin);
		this.log(`${request.origin} accepted.`);
		this.emit('onConnectionAccept')

		// Handle connection message
		connection.on('message', (message) => this.emit('onConnectionMessage', message));

		// handle when connection disconnected
		connection.on('close', (reasonCode, description) => this.onClose(reasonCode, description, connection));
	}

	originIsAllowed(origin){
		this.log('wsRequest');
		// put logic here to detect whether the specified origin is allowed.
		return true;
	}

	rejectRequest(request){
		this.log(`Connection ${request.origin} rejected.`)
		// Make sure we only accept requests from an allowed origin
		return request.reject();
	}

	onClose(reasonCode, description, connection){
		this.log(`disconnected: ${connection.remoteAddress}`);
	}
}

module.exports = new websocketController();<commit_msg>define msg<commit_after>const Helper = require('../../shared');
const wsServer = require('websocket').server;
const http = require('http');

class websocketController extends Helper{
	constructor(){
		super('Web Socket Controller');
		this._config = this.setConfigs();
		this.server = this.initServer();
	}

	broadcast(type, data){
		let msg = JSON.stringify({type, data});
		return this.server.broadcast(msg);
	}

	/**
	 * Set Default Configurations
	 */
	setConfigs(){
		this.log('setConfigs');
		let configs = {};

		configs.port = process.env.WS_PORT;
		configs.allowedProtocol = 'cec-protocol';

		configs.ws = {};
		// You should not use autoAcceptConnections for production
		// applications, as it defeats all standard cross-origin protection
		// facilities built into the protocol and the browser.  You should
		// *always* verify the connection's origin and decide whether or not
		// to accept it.
		configs.ws.autoAcceptConnections = false
		configs.ws.httpServer = this.makeHttpServer(configs.port)

		return configs;
	}

	/**
	 * Make Https server, needed by Websocket
	 * @param  {Number} port Set via .env
	 * @return http Server
	 */
	makeHttpServer(port){
		this.log('makeHttpServer on', port);
		const server = http.createServer(this.handleHttpResponse);
		server.listen(port, ()=>this.log(`listening ws://localhost:${port}`));
		return server
	}

	/**
	 * Handle http connection to port
	 * @param  {Object} request
	 * @param  {Object} response
	 * @return {Response.end}
	 */
	handleHttpResponse(request, response){
		this.log('handleHttpResponse', `Received ${request.url}`)
		response.writeHead(404);
		return response.end();
	}

	initServer(){
		this.log('initServer');
		this.server =  new wsServer(this._config.ws);
		return this.server.on('request', (request)=>this.wsRequest(request))
	}

	wsRequest(request){
		if (!this.originIsAllowed(request.origin)) {
		  return this.rejectRequest(request);
		}

		let connection = request.accept(this._config.allowedProtocol, request.origin);
		this.log(`${request.origin} accepted.`);
		this.emit('onConnectionAccept')

		// Handle connection message
		connection.on('message', (message) => this.emit('onConnectionMessage', message));

		// handle when connection disconnected
		connection.on('close', (reasonCode, description) => this.onClose(reasonCode, description, connection));
	}

	originIsAllowed(origin){
		this.log('wsRequest');
		// put logic here to detect whether the specified origin is allowed.
		return true;
	}

	rejectRequest(request){
		this.log(`Connection ${request.origin} rejected.`)
		// Make sure we only accept requests from an allowed origin
		return request.reject();
	}

	onClose(reasonCode, description, connection){
		this.log(`disconnected: ${connection.remoteAddress}`);
	}
}

module.exports = new websocketController();<|endoftext|>


<commit_before>////////////////////////////////////////////////////////////////////////////////////////////////
// Mobius Unit Detail Component
////////////////////////////////////////////////////////////////////////////////////////////////

mobiusEngine.unit.dtlController = function($scope,_data) {
	var $ctrl = this;
	$ctrl.unit = _data.getUnit($ctrl.uuid);
	$ctrl.link = "http://rokhos82.github.io/mobius/#/unit/import/" + btoa(angular.toJson($ctrl.unit));

	$ctrl.sectionFilter = function(value,index,arr) {
		return _.omit($ctrl.unit,["direct-fire","packet-fire","uuid"]);
	};

	$ctrl.addAttribute = function(section,attribute) {
		var key = attribute.toLowerCase();
		section[key] = 0;
	};

	$ctrl.addSection = function(section) {
		var key = section.toLowerCase();
		$ctrl.unit[key] = {};
	};

	$ctrl.removeAttribute = function(section,key) {
		delete section[key];
	};
};

mobiusEngine.app.component("unitDetail",{
	templateUrl: 'app/component/unit.detail.html',
	controller: ["$scope","mobius.data.unit",mobiusEngine.unit.dtlController],
	bindings: {
		uuid: "<"
	}
});<commit_msg>Added alerts for section creation and deletion.<commit_after>////////////////////////////////////////////////////////////////////////////////////////////////
// Mobius Unit Detail Component
////////////////////////////////////////////////////////////////////////////////////////////////

mobiusEngine.unit.dtlController = function($scope,_data) {
	var $ctrl = this;
	$ctrl.unit = _data.getUnit($ctrl.uuid);
	$ctrl.link = "http://rokhos82.github.io/mobius/#/unit/import/" + btoa(angular.toJson($ctrl.unit));
	$ctrl.alerts = [];

	$ctrl.sectionFilter = function(value,index,arr) {
		return _.omit($ctrl.unit,["direct-fire","packet-fire","uuid"]);
	};

	$ctrl.addAttribute = function(section,attribute) {
		var key = attribute.toLowerCase();
		section[key] = 0;
	};

	$ctrl.addSection = function(section) {
		var key = section.toLowerCase();
		if($ctrl.unit[key]) {
			$ctrl.alerts.push(new mobiusEngine.pageAlerts.alert(section + " already exists!","warning",2000));
		}
		else {
			$ctrl.unit[key] = {};
			$ctrl.alerts.push(new mobiusEngine.pageAlerts.alert("Created section: " + section,"success",1500));
		}
	};

	$ctrl.removeAttribute = function(section,key) {
		delete section[key];
	};

	$ctrl.removeSection = function(section) {
		delete $ctrl.unit[section];
	};
};

mobiusEngine.app.component("unitDetail",{
	templateUrl: 'app/component/unit.detail.html',
	controller: ["$scope","mobius.data.unit",mobiusEngine.unit.dtlController],
	bindings: {
		uuid: "<"
	}
});<|endoftext|>


<commit_before>/**
* Plymedia close caption module loader
*
* @Description of plymedia module goes here
* @author plymedia authored by
*/
( function( mw ) {
	// List named resource paths
	mw.addResourcePaths({
		"plyMediaPlayer" : "plyMedia/Your_PlyMedia_HTML5_Lib_Could_Go_Here.js",
		"plyMedia.style" :  "plyMedia/Your_Css_File_Could_Go_Here_.css",
		"mw.plyMediaConfig" : "mw.plyMediaConfig.js"
	});

	mw.addModuleLoader( 'plyMedia', function(){
		// load any files needed for plyMedia player ( ie plyMediaPlayer and plyMedia.style )
		return ['mw.plyMediaConfig' ];
	});

	// Bind the plyMedia player where the uiconf includes the plymedia plugin
	$j( mw ).bind( 'newEmbedPlayerEvent', function( event, embedPlayer ){

		$j( embedPlayer ).bind( 'KalturaSupport_CheckUiConf', function( event, $uiConf , callback){
			// Check for plyMedia in kaltura uiConf
			if( kWidgetSupport.getPluginConfig( embedPlayer, $uiConf, 'plymedia', 'plugin' ) ){
				// Load the plyMeida module:
			    mw.load( 'plyMedia', function(){
			    	mw.plyMediaConfig.bindPlayer( embedPlayer );
			    });
			}
			// Don't block player display on plyMedia plugin loading ( directly issue the callback )
			callback();
		});
	});

} )( window.mw );<commit_msg>alert entry id<commit_after>/**
* Plymedia close caption module loader
*
* @Description of plymedia module goes here
* @author plymedia authored by
*/
( function( mw ) {
	// List named resource paths
	mw.addResourcePaths({
		"plyMediaPlayer" : "plyMedia/Your_PlyMedia_HTML5_Lib_Could_Go_Here.js",
		"plyMedia.style" :  "plyMedia/Your_Css_File_Could_Go_Here_.css",
		"mw.plyMediaConfig" : "mw.plyMediaConfig.js"
	});

	mw.addModuleLoader( 'plyMedia', function(){
		// load any files needed for plyMedia player ( ie plyMediaPlayer and plyMedia.style )
		return ['mw.plyMediaConfig' ];
	});

	// Bind the plyMedia player where the uiconf includes the plymedia plugin
	$j( mw ).bind( 'newEmbedPlayerEvent', function( event, embedPlayer ){

		$j( embedPlayer ).bind( 'KalturaSupport_CheckUiConf', function( event, $uiConf , callback){
			// Check for plyMedia in kaltura uiConf
			if( kWidgetSupport.getPluginConfig( embedPlayer, $uiConf, 'plymedia', 'plugin' ) ){
				alert( embedPlayer.kentryid );
				// Load the plyMeida module:
			    mw.load( 'plyMedia', function(){
			    	mw.plyMediaConfig.bindPlayer( embedPlayer );
			    });
			}
			// Don't block player display on plyMedia plugin loading ( directly issue the callback )
			callback();
		});
	});

} )( window.mw );<|endoftext|>


<commit_before>import React from 'react';
import guessBestIcon from "../utils/helpers";
import numeral from 'numeral';

function BudgetItem(props) {
    var iconClass = "circular " + guessBestIcon(props.budgetItem.category) + " icon blue";
    return

Edit

                {props.budgetItem.category}

            {numeral(props.budgetItem.budget).format('$ 0,0.00')}

}

export default BudgetItem;
<commit_msg>added placeholder for remaining budget<commit_after>import React from 'react';
import guessBestIcon from "../utils/helpers";
import numeral from 'numeral';

function BudgetItem(props) {
    var iconClass = "circular " + guessBestIcon(props.budgetItem.category) + " icon blue";
    return

Edit

                {props.budgetItem.category}

            {numeral(15).format('$ 0,0.00')} / {numeral(props.budgetItem.budget).format('$ 0,0.00')}

}

export default BudgetItem;
<|endoftext|>


<commit_before>/**
 * TagSpaces - universal file and folder organizer
 * Copyright (C) 2017-present TagSpaces UG (haftungsbeschraenkt)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License (version 3) as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *
 * @flow
 */

import React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import IconButton from '@material-ui/core/IconButton';
import { Pro } from '../pro';
import TextLogoIcon from '../assets/images/text-logo.svg';
// import CustomLogoIcon from '../assets/images/custom-logo.svg';
import { actions as AppActions } from '../reducers/app';

type Props = {
  toggleAboutDialog: () => void
};

const CustomLogo = (props: Props) => (
  <IconButton
    style={{ height: 50, padding: 0, marginBottom: 15 }}
    data-tid="aboutTagSpaces"
    onClick={props.toggleAboutDialog}
  >

    {/*  */}
  </IconButton>
);

function mapActionCreatorsToProps(dispatch) {
  return bindActionCreators({
    toggleAboutDialog: AppActions.toggleAboutDialog,
  }, dispatch);
}

export default connect(undefined, mapActionCreatorsToProps)(CustomLogo);
<commit_msg>adjusting custom logo functionality<commit_after>/**
 * TagSpaces - universal file and folder organizer
 * Copyright (C) 2017-present TagSpaces UG (haftungsbeschraenkt)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License (version 3) as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *
 * @flow
 */

import React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import IconButton from '@material-ui/core/IconButton';
import { Pro } from '../pro';
import TextLogoIcon from '../assets/images/text-logo.svg';
import { actions as AppActions } from '../reducers/app';

type Props = {
  toggleAboutDialog: () => void
};

let logo = Pro ? Pro.TextLogoIcon : TextLogoIcon;
// logo = 'assets/images/custom-logo.svg';
const externalLogo = window.ExtLogoURL || false;
if (externalLogo) {
  logo = externalLogo;
}

const CustomLogo = (props: Props) => (
  <IconButton
    style={{ height: 50, padding: 0, marginBottom: 15 }}
    data-tid="aboutTagSpaces"
    onClick={props.toggleAboutDialog}
  >

  </IconButton>
);

function mapActionCreatorsToProps(dispatch) {
  return bindActionCreators({
    toggleAboutDialog: AppActions.toggleAboutDialog,
  }, dispatch);
}

export default connect(undefined, mapActionCreatorsToProps)(CustomLogo);
<|endoftext|>


<commit_before>/*!
 * Abricos Platform (http://abricos.org)
 * Copyright 2008-2016 Alexander Kuzmin <roosit@abricos.org>
 * Licensed under the MIT license
 */

var Component = new Brick.Component();
Component.requires = {
    yui: ['io', 'json']
};
Component.entryPoint = function(NS){
    var Y = Brick.YUI,
        LNG = new Abricos.ComponentLanguage(this);

    var queryCounter = 0;
    var uniqueURL = function(){
        return (queryCounter++) + (new Date().getTime());
    };

    var AJAX = function(){
    };
    AJAX.HTTP_TIMEOUT = 30000;
    AJAX.CSRF_TOKEN = YUI.Env.CSRF_TOKEN;
    AJAX.HTTP_HEADERS = {
        // 'Accept': 'application/json',
        // 'Content-Type': 'application/json'
    };
    AJAX.ATTRS = {
        moduleName: {
            value: ''
        },
        errorTemplate: {
            value: '{v#title}: {v#msg}'
        }
    };
    AJAX.prototype = {
        initializer: function(){
            this.publish('AJAXError', {
                defaultFn: this.onAJAXError
            });
        },
        onAJAXError: function(){
        },
        getAJAXURL: function(){
            var moduleName = this.get('moduleName') || 'undefined';

            return '/tajax/' + moduleName + '/' + uniqueURL() + '/';
        },
        ajax: function(data, callback, options){
            options || (options = {})

            options.arguments = options.arguments || {};

            if (!options.arguments['action'] && data && data['do']){
                options.arguments['action'] = data['do'];
            }

            var url = this.getAJAXURL(),
                headers = Y.merge(AJAX.HTTP_HEADERS, options.header),
                csrfToken = options.csrfToken || AJAX.CSRF_TOKEN;

            if (csrfToken){
                headers['X-CSRF-Token'] = csrfToken;
            }

            var entity = Y.JSON.stringify(data);
            entity = encodeURIComponent(entity);

            this._sendAJAXIORequest({
                callback: callback,
                arguments: options.arguments,
                context: options.context || this,
                entity: 'data=' + entity,
                headers: headers,
                method: 'POST',
                timeout: options.timeout || AJAX.HTTP_TIMEOUT,
                url: url
            });
        },
        _sendAJAXIORequest: function(config){
            return Y.io(config.url, {
                arguments: {
                    callback: config.callback,
                    context: config.context,
                    arguments: config.arguments,
                    url: config.url
                },

                context: config.context,
                data: config.entity,
                headers: config.headers,
                method: config.method,
                timeout: config.timeout,

                on: {
                    start: this._onAJAXIOStart,
                    failure: this._onAJAXIOFailure,
                    success: this._onAJAXIOSuccess,
                    end: this._onAJAXIOEnd
                }
            });
        },
        _parseIOResponse: function(res){
            return Y.JSON.parse(res.responseText);
        },
        _onAJAXIOEnd: function(txId, details){
        },
        _treatAJAXError: function(err, details){
            if (!err){
                return;
            }

            var msg = LNG.get('ajax.error.' + err.code);
            if (msg === '' && this.language && details.action){
                msg = this.language.get('ajax.' + details.action + '.error.' + err.code);
            }

            if (msg && msg !== ''){
                if (this.language){
                    var errTitle = this.language.get('ajax.' + details.action + '.error.title'),
                        errTemplate = this.get('errorTemplate');

                    if (errTitle !== ''){
                        msg = errTemplate.replace("{v#msg}", msg);
                        msg = msg.replace('{v#title}', errTitle);
                    }
                }
                err.msg = msg;
            }

            this.fire('AJAXError', err, details);
        },
        _onAJAXIOFailure: function(txId, res, details){
            var callback = details.callback,
                context = details.context,
                err = {
                    code: res.status,
                    msg: res.statusText,
                    request: res
                };

            this._treatAJAXError(err, details.arguments);
            if (callback){
                callback.apply(context, [err, null, details.arguments]);
            }
        },
        _onAJAXIOSuccess: function(txId, res, details){
            var callback = details.callback,
                context = details.context,
                request = new NS.AJAXRequest({
                    request: res
                });

            var err = null, data = request.data || {};
            if (res && data && data.err > 0){
                err = {code: data.err, msg: ''};
            }

            this._treatAJAXError(err, details.arguments);

            if (callback){
                callback.apply(context, [err, request, details.arguments]);
            }
        },
        _onAJAXIOStart: function(txId, details){
        }
    };
    NS.AJAX = AJAX;

    var AJAXRequest = function(config){
        this._init(config);
    };
    AJAXRequest.prototype = {

        request: null,

        data: {},

        userid: Brick.env.user.id | 0,

        _init: function(config){
            config || (config || {});

            this.request = config.request;

            var o = Y.JSON.parse(this.request.responseText);
            if (o){
                if (o.data){
                    this.data = o.data;
                }
                this.userid = o.userid | 0;
            }
        }
    };
    NS.AJAXRequest = AJAXRequest;
};<commit_msg>added subcode notice message<commit_after>var Component = new Brick.Component();
Component.requires = {
    yui: ['io', 'json']
};
Component.entryPoint = function(NS){
    var Y = Brick.YUI,
        LNG = new Abricos.ComponentLanguage(this);

    var queryCounter = 0;
    var uniqueURL = function(){
        return (queryCounter++) + (new Date().getTime());
    };

    var AJAX = function(){
    };
    AJAX.HTTP_TIMEOUT = 30000;
    AJAX.CSRF_TOKEN = YUI.Env.CSRF_TOKEN;
    AJAX.HTTP_HEADERS = {
        // 'Accept': 'application/json',
        // 'Content-Type': 'application/json'
    };
    AJAX.ATTRS = {
        moduleName: {
            value: ''
        },
        errorTemplate: {
            value: '{v#title}: {v#msg}'
        }
    };
    AJAX.prototype = {
        initializer: function(){
            this.publish('AJAXError', {
                defaultFn: this.onAJAXError
            });
        },
        onAJAXError: function(){
        },
        getAJAXURL: function(){
            var moduleName = this.get('moduleName') || 'undefined';

            return '/tajax/' + moduleName + '/' + uniqueURL() + '/';
        },
        ajax: function(data, callback, options){
            options || (options = {});

            options.arguments = options.arguments || {};

            if (!options.arguments['action'] && data && data['do']){
                options.arguments['action'] = data['do'];
            }

            var url = this.getAJAXURL(),
                headers = Y.merge(AJAX.HTTP_HEADERS, options.header),
                csrfToken = options.csrfToken || AJAX.CSRF_TOKEN;

            if (csrfToken){
                headers['X-CSRF-Token'] = csrfToken;
            }

            var entity = Y.JSON.stringify(data);
            entity = encodeURIComponent(entity);

            this._sendAJAXIORequest({
                callback: callback,
                arguments: options.arguments,
                context: options.context || this,
                entity: 'data=' + entity,
                headers: headers,
                method: 'POST',
                timeout: options.timeout || AJAX.HTTP_TIMEOUT,
                url: url
            });
        },
        _sendAJAXIORequest: function(config){
            return Y.io(config.url, {
                arguments: {
                    callback: config.callback,
                    context: config.context,
                    arguments: config.arguments,
                    url: config.url
                },

                context: config.context,
                data: config.entity,
                headers: config.headers,
                method: config.method,
                timeout: config.timeout,

                on: {
                    start: this._onAJAXIOStart,
                    failure: this._onAJAXIOFailure,
                    success: this._onAJAXIOSuccess,
                    end: this._onAJAXIOEnd
                }
            });
        },
        _parseIOResponse: function(res){
            return Y.JSON.parse(res.responseText);
        },
        _onAJAXIOEnd: function(txId, details){
        },
        _treatAJAXError: function(err, details){
            if (!err){
                return;
            }

            var msg = LNG.get('ajax.error.' + err.code),
                lng = this.language,
                action = details.action || '',
                errTemplate = this.get('errorTemplate'),
                ovrMsg;

            if (lng && action){
                ovrMsg = lng.get('ajax.' + action + '.error.' + err.code);
                if (!ovrMsg){
                    ovrMsg = lng.get('ajax.' + action + '.error.' + err.code + '.default');
                }

                var cName = this.get('component').name,
                    extLang = this.get('component').language[cName],
                    subCode = err.subCode | 0;

                if (subCode > 0
                    && extLang['ajax']
                    && extLang['ajax'][action]
                    && extLang['ajax'][action]['error']
                    && Y.Lang.isObject(extLang['ajax'][action]['error'][err.code])){

                    extLang = extLang['ajax'][action]['error'][err.code];

                    var iCode;
                    for (var name in extLang){
                        if (!extLang.hasOwnProperty(name)){
                            continue;
                        }
                        iCode = name | 0;
                        if (iCode === 0){
                            continue;
                        }
                        if ((subCode & iCode) > 0){
                            ovrMsg = extLang[name] + '';
                        }
                    }
                }
            }
            msg = ovrMsg || msg;

            if (msg && msg !== ''){
                if (lng){
                    var errTitle = lng.get('ajax.' + details.action + '.error.title');

                    if (errTitle !== ''){
                        msg = errTemplate.replace("{v#msg}", msg);
                        msg = msg.replace('{v#title}', errTitle);
                    }
                }
                err.msg = msg;
            }

            this.fire('AJAXError', err, details);
        },
        _onAJAXIOFailure: function(txId, res, details){
            var callback = details.callback,
                context = details.context,
                err = {
                    code: res.status,
                    msg: res.statusText,
                    request: res
                };

            this._treatAJAXError(err, details.arguments);
            if (callback){
                callback.apply(context, [err, null, details.arguments]);
            }
        },
        _onAJAXIOSuccess: function(txId, res, details){
            var callback = details.callback,
                context = details.context,
                detArgs = details.arguments,
                action = detArgs.action,
                request = new NS.AJAXRequest({
                    request: res
                }),
                err = null,
                data = request.data || {};

            if (res && data && data.err > 0){
                err = {code: data.err, msg: ''};
                if (data[action] && data[action].code){
                    err.subCode = data[action].code;
                }
            }

            this._treatAJAXError(err, details.arguments);

            if (callback){
                callback.apply(context, [err, request, details.arguments]);
            }
        },
        _onAJAXIOStart: function(txId, details){
        }
    };
    NS.AJAX = AJAX;

    var AJAXRequest = function(config){
        this._init(config);
    };
    AJAXRequest.prototype = {

        request: null,

        data: {},

        userid: Brick.env.user.id | 0,

        _init: function(config){
            config || (config || {});

            this.request = config.request;

            var o = Y.JSON.parse(this.request.responseText);
            if (o){
                if (o.data){
                    this.data = o.data;
                }
                this.userid = o.userid | 0;
            }
        }
    };
    NS.AJAXRequest = AJAXRequest;
};<|endoftext|>


<commit_before>import React, {Component} from 'react';
import { View,
         Text,
         ActivityIndicator,
         StyleSheet} from 'react-native';
import githubService from '../services/githubService'

export default class User extends Component {
  constructor(props) {
    super(props)
    this.state = {
        user: {}
    }
  }

  //-----------------------------------
  // RENDERING
  //-----------------------------------

  render() {
    if(!(Object.keys(this.state.user).length === 0)) {
      return (
        <View>
          <Text>TEst</Text>
        </View>
      )
    }
    return (
      <ActivityIndicator
        animating={this.state.animating}
        style={[styles.centering, {height: 80}]}
        size="large"
      />
    );
  }

  //-----------------------------------
  // PRIVATE METHODS
  //-----------------------------------
  //
  //
  componentDidMount() {
    githubService.getUser(this.props.user.login)
      .then(response => {
        debugger
        this.setState({
            user: response
        })
      })
  }
}

const styles = StyleSheet.create({
  centering: {
    alignItems: 'center',
    justifyContent: 'center',
    padding: 8,
  },
});
<commit_msg>Rendering UserView data to screen -- needs style and repo views<commit_after>import React, {Component} from 'react';
import { View,
         Image,
         Text,
         ActivityIndicator,
         StyleSheet} from 'react-native';
import githubService from '../services/githubService'

export default class User extends Component {
  constructor(props) {
    super(props)
    this.state = {
        user: {}
    }
  }

  //-----------------------------------
  // RENDERING
  //-----------------------------------

  // avatar_url, bio, email, name, created_at, location
  render() {
    if(!(Object.keys(this.state.user).length === 0)) {
      return (
        <View>
            <Image source={{uri: this.state.user.avatar_url}}
                   style={{width: 40, height: 40}}/>
            <Text>User: {this.state.user.name}</Text>
            <Text>Email: {this.state.user.email}</Text>
            <Text>Created: {this.state.user.created_at}</Text>
            <Text>Location: {this.state.user.location}</Text>
        </View>
      )
    }
    return (
      <ActivityIndicator
        animating={this.state.animating}
        style={[styles.centering, {height: 80}]}
        size="large"
      />
    );
  }

  //-----------------------------------
  // PRIVATE METHODS
  //-----------------------------------
  //
  //
  componentDidMount() {
    githubService.getUser(this.props.user.login)
      .then(response => {
        this.setState({
            user: response
        })
      })
  }
}

const styles = StyleSheet.create({
  centering: {
    alignItems: 'center',
    justifyContent: 'center',
    padding: 8,
  },
});
<|endoftext|>