<commit_before>import PortMixin from 'mixins/port_mixin';
import PromiseAssembler from 'libs/promise_assembler';

var PromiseDebug = Ember.Object.extend(PortMixin, {
  namespace: null,
  port: Ember.computed.alias('namespace.port'),
  objectInspector: Ember.computed.alias('namespace.objectInspector'),
  adapter: Ember.computed.alias('namespace.adapter'),
  portNamespace: 'promise',

  existingEvents: Ember.computed.alias('namespace.existingEvents'),
  existingCallbacks: Ember.computed.alias('namespace.existingCallbacks'),

  // created on init
  promiseAssembler: null,

  releaseMethods: Ember.computed(function() { return Ember.A(); }),

  init: function() {
    this._super();
    if (PromiseAssembler.supported()) {
      this.set('promiseAssembler', PromiseAssembler.create());
      this.get('promiseAssembler').set('promiseDebug', this);
      this.get('promiseAssembler').start();
    }
  },

  delay: 100,

  willDestroy: function() {
    this.releaseAll();
    this.get('promiseAssembler').destroy();
    this.set('promiseAssembler', null);
    this._super();
  },

  messages: {
    getAndObservePromises: function() {
      this.getAndObservePromises();
    },

    supported: function() {
      this.sendMessage('supported', {
        supported: PromiseAssembler.supported()
      });
    },

    releasePromises: function() {
      this.releaseAll();
    },

    sendValueToConsole: function(message) {
      var promiseId = message.promiseId;
      var promise = this.get('promiseAssembler').find(promiseId);
      var value = promise.get('value');
      if (value === undefined) {
        value = promise.get('reason');
      }
      this.get('objectInspector').sendValueToConsole(value);
    },

    tracePromise: function(message) {
      var id = message.promiseId;
      var promise = this.get('promiseAssembler').find(id);
      // Remove first two lines and add label
      var stack = promise.get('stack');
      if (stack) {
        stack = stack.split("\n");
        stack.splice(0, 2, ['Ember Inspector (Promise Trace): ' + (promise.get('label') || '')]);
        this.get("adapter").log(stack.join("\n"));
      }
    }
  },

  releaseAll: function() {
    this.get('releaseMethods').forEach(function(fn) {
      fn();
    });
    this.set('releaseMethods', Ember.A());
  },

  getAndObservePromises: function() {
    this.get('promiseAssembler').on('created', this, this.promiseUpdated);
    this.get('promiseAssembler').on('fulfilled', this, this.promiseUpdated);
    this.get('promiseAssembler').on('rejected', this, this.promiseUpdated);
    this.get('promiseAssembler').on('chained', this, this.promiseChained);

    this.get('releaseMethods').pushObject(function() {

      this.get('promiseAssembler').off('created', this, this.promiseUpdated);
      this.get('promiseAssembler').off('fulfilled', this, this.promiseUpdated);
      this.get('promiseAssembler').off('rejected', this, this.promiseUpdated);
      this.get('promiseAssembler').off('fulfilled', this, this.promiseChained);

    }.bind(this));

    this.promisesUpdated(this.get('promiseAssembler').find());
  },

  updatedPromises: Ember.computed(function() { return Ember.A(); }),

  promisesUpdated: function(uniquePromises) {
    if (!uniquePromises) {
      uniquePromises = Ember.A();
      this.get('updatedPromises').forEach(function(promise) {
        if (uniquePromises.indexOf(promise) === -1) {
          uniquePromises.pushObject(promise);
        }
      });
    }
    var serialized = this.serializeArray(uniquePromises);
    this.sendMessage('promisesUpdated', {
      promises: serialized
    });
    this.set('updatedPromises', Ember.A());
  },

  promiseUpdated: function(event) {
    this.get('updatedPromises').pushObject(event.promise);
    Ember.run.debounce(this, 'promisesUpdated', this.delay);
  },

  promiseChained: function(event) {
    this.get('updatedPromises').pushObject(event.promise);
    this.get('updatedPromises').pushObject(event.child);
    Ember.run.debounce(this, 'promisesUpdated', this.delay);
  },

  serializeArray: function(promises) {
    return promises.map(function(item) {
      return this.serialize(item);
    }.bind(this));
  },

  serialize: function(promise) {
    var serialized = {};
    serialized.guid = promise.get('guid');
    serialized.state = promise.get('state');
    serialized.label = promise.get('label');
    if (promise.get('children')) {
      serialized.children = this.promiseIds(promise.get('children'));
    }
    serialized.parent = promise.get('parent.guid');
    serialized.value = this.inspectValue(promise.get('value'));
    serialized.reason = this.inspectValue(promise.get('reason'));
    if (promise.get('createdAt')) {
      serialized.createdAt = promise.get('createdAt').getTime();
    }
    if (promise.get('settledAt')) {
      serialized.settledAt = promise.get('settledAt').getTime();
    }
    return serialized;
  },

  promiseIds: function(promises) {
    return promises.map(function(promise) {
      return promise.get('guid');
    });
  },

  inspectValue: function(value) {
    var objectInspector = this.get('objectInspector'),
        inspected = objectInspector.inspectValue(value);

    if (inspected.type === 'type-ember-object' || inspected.type === "type-array") {
      inspected.objectId = objectInspector.retainObject(value);
      this.get('releaseMethods').pushObject(function() {
        objectInspector.releaseObject(inspected.objectId);
      });
    }
    return inspected;
  }

});

export default PromiseDebug;
<commit_msg>Use `addObject` instead of checking if unique<commit_after>import PortMixin from 'mixins/port_mixin';
import PromiseAssembler from 'libs/promise_assembler';

var PromiseDebug = Ember.Object.extend(PortMixin, {
  namespace: null,
  port: Ember.computed.alias('namespace.port'),
  objectInspector: Ember.computed.alias('namespace.objectInspector'),
  adapter: Ember.computed.alias('namespace.adapter'),
  portNamespace: 'promise',

  existingEvents: Ember.computed.alias('namespace.existingEvents'),
  existingCallbacks: Ember.computed.alias('namespace.existingCallbacks'),

  // created on init
  promiseAssembler: null,

  releaseMethods: Ember.computed(function() { return Ember.A(); }),

  init: function() {
    this._super();
    if (PromiseAssembler.supported()) {
      this.set('promiseAssembler', PromiseAssembler.create());
      this.get('promiseAssembler').set('promiseDebug', this);
      this.get('promiseAssembler').start();
    }
  },

  delay: 100,

  willDestroy: function() {
    this.releaseAll();
    this.get('promiseAssembler').destroy();
    this.set('promiseAssembler', null);
    this._super();
  },

  messages: {
    getAndObservePromises: function() {
      this.getAndObservePromises();
    },

    supported: function() {
      this.sendMessage('supported', {
        supported: PromiseAssembler.supported()
      });
    },

    releasePromises: function() {
      this.releaseAll();
    },

    sendValueToConsole: function(message) {
      var promiseId = message.promiseId;
      var promise = this.get('promiseAssembler').find(promiseId);
      var value = promise.get('value');
      if (value === undefined) {
        value = promise.get('reason');
      }
      this.get('objectInspector').sendValueToConsole(value);
    },

    tracePromise: function(message) {
      var id = message.promiseId;
      var promise = this.get('promiseAssembler').find(id);
      // Remove first two lines and add label
      var stack = promise.get('stack');
      if (stack) {
        stack = stack.split("\n");
        stack.splice(0, 2, ['Ember Inspector (Promise Trace): ' + (promise.get('label') || '')]);
        this.get("adapter").log(stack.join("\n"));
      }
    }
  },

  releaseAll: function() {
    this.get('releaseMethods').forEach(function(fn) {
      fn();
    });
    this.set('releaseMethods', Ember.A());
  },

  getAndObservePromises: function() {
    this.get('promiseAssembler').on('created', this, this.promiseUpdated);
    this.get('promiseAssembler').on('fulfilled', this, this.promiseUpdated);
    this.get('promiseAssembler').on('rejected', this, this.promiseUpdated);
    this.get('promiseAssembler').on('chained', this, this.promiseChained);

    this.get('releaseMethods').pushObject(function() {

      this.get('promiseAssembler').off('created', this, this.promiseUpdated);
      this.get('promiseAssembler').off('fulfilled', this, this.promiseUpdated);
      this.get('promiseAssembler').off('rejected', this, this.promiseUpdated);
      this.get('promiseAssembler').off('fulfilled', this, this.promiseChained);

    }.bind(this));

    this.promisesUpdated(this.get('promiseAssembler').find());
  },

  updatedPromises: Ember.computed(function() { return Ember.A(); }),

  promisesUpdated: function(uniquePromises) {
    if (!uniquePromises) {
      uniquePromises = Ember.A();
      this.get('updatedPromises').forEach(function(promise) {
        uniquePromises.addObject(promise);
      });
    }
    var serialized = this.serializeArray(uniquePromises);
    this.sendMessage('promisesUpdated', {
      promises: serialized
    });
    this.set('updatedPromises', Ember.A());
  },

  promiseUpdated: function(event) {
    this.get('updatedPromises').pushObject(event.promise);
    Ember.run.debounce(this, 'promisesUpdated', this.delay);
  },

  promiseChained: function(event) {
    this.get('updatedPromises').pushObject(event.promise);
    this.get('updatedPromises').pushObject(event.child);
    Ember.run.debounce(this, 'promisesUpdated', this.delay);
  },

  serializeArray: function(promises) {
    return promises.map(function(item) {
      return this.serialize(item);
    }.bind(this));
  },

  serialize: function(promise) {
    var serialized = {};
    serialized.guid = promise.get('guid');
    serialized.state = promise.get('state');
    serialized.label = promise.get('label');
    if (promise.get('children')) {
      serialized.children = this.promiseIds(promise.get('children'));
    }
    serialized.parent = promise.get('parent.guid');
    serialized.value = this.inspectValue(promise.get('value'));
    serialized.reason = this.inspectValue(promise.get('reason'));
    if (promise.get('createdAt')) {
      serialized.createdAt = promise.get('createdAt').getTime();
    }
    if (promise.get('settledAt')) {
      serialized.settledAt = promise.get('settledAt').getTime();
    }
    return serialized;
  },

  promiseIds: function(promises) {
    return promises.map(function(promise) {
      return promise.get('guid');
    });
  },

  inspectValue: function(value) {
    var objectInspector = this.get('objectInspector'),
        inspected = objectInspector.inspectValue(value);

    if (inspected.type === 'type-ember-object' || inspected.type === "type-array") {
      inspected.objectId = objectInspector.retainObject(value);
      this.get('releaseMethods').pushObject(function() {
        objectInspector.releaseObject(inspected.objectId);
      });
    }
    return inspected;
  }

});

export default PromiseDebug;
<|endoftext|>


<commit_before>var gateway = require(__dirname+'/../../../../');

module.exports = function(req, res){

  gateway.config.set('KEY', req.body.key);
  res.send({ 'KEY': gateway.config.get('KEY') });

};
<commit_msg>[BUG] send json response on config save callback<commit_after>var gateway = require(__dirname+'/../../../../');

module.exports = function(req, res){
  gateway.config.set('KEY', req.body.key);
  gateway.config.save(function(err){
    if(err){
      res.send(500, {error: err});
    } else {
      res.send({ 'KEY': gateway.config.get('KEY') });
    }
  })

};
<|endoftext|>


<commit_before>/*
Copyright 2015, 2016 OpenMarket Ltd

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.
*/

/*
 * THIS FILE IS AUTO-GENERATED
 * You can edit it you like, but your changes will be overwritten,
 * so you'd just be trying to swim upstream like a salmon.
 * You are not a salmon.
 */

module.exports.components = require('matrix-react-sdk/lib/component-index').components;

import structures$BottomLeftMenu from './components/structures/BottomLeftMenu';
structures$BottomLeftMenu && (module.exports.components['structures.BottomLeftMenu'] = structures$BottomLeftMenu);
import structures$CompatibilityPage from './components/structures/CompatibilityPage';
structures$CompatibilityPage && (module.exports.components['structures.CompatibilityPage'] = structures$CompatibilityPage);
import structures$HomePage from './components/structures/HomePage';
structures$HomePage && (module.exports.components['structures.HomePage'] = structures$HomePage);
import structures$LeftPanel from './components/structures/LeftPanel';
structures$LeftPanel && (module.exports.components['structures.LeftPanel'] = structures$LeftPanel);
import structures$RightPanel from './components/structures/RightPanel';
structures$RightPanel && (module.exports.components['structures.RightPanel'] = structures$RightPanel);
import structures$RoomDirectory from './components/structures/RoomDirectory';
structures$RoomDirectory && (module.exports.components['structures.RoomDirectory'] = structures$RoomDirectory);
import structures$RoomSubList from './components/structures/RoomSubList';
structures$RoomSubList && (module.exports.components['structures.RoomSubList'] = structures$RoomSubList);
import structures$RoomSubListHeader from './components/structures/RoomSubListHeader';
structures$RoomSubListHeader && (module.exports.components['structures.RoomSubListHeader'] = structures$RoomSubListHeader);
import structures$SearchBox from './components/structures/SearchBox';
structures$SearchBox && (module.exports.components['structures.SearchBox'] = structures$SearchBox);
import structures$ViewSource from './components/structures/ViewSource';
structures$ViewSource && (module.exports.components['structures.ViewSource'] = structures$ViewSource);
import views$context_menus$MessageContextMenu from './components/views/context_menus/MessageContextMenu';
views$context_menus$MessageContextMenu && (module.exports.components['views.context_menus.MessageContextMenu'] = views$context_menus$MessageContextMenu);
import views$context_menus$RoomTileContextMenu from './components/views/context_menus/RoomTileContextMenu';
views$context_menus$RoomTileContextMenu && (module.exports.components['views.context_menus.RoomTileContextMenu'] = views$context_menus$RoomTileContextMenu);
import views$dialogs$BugReportDialog from './components/views/dialogs/BugReportDialog';
views$dialogs$BugReportDialog && (module.exports.components['views.dialogs.BugReportDialog'] = views$dialogs$BugReportDialog);
import views$dialogs$ChangelogDialog from './components/views/dialogs/ChangelogDialog';
views$dialogs$ChangelogDialog && (module.exports.components['views.dialogs.ChangelogDialog'] = views$dialogs$ChangelogDialog);
import views$directory$NetworkDropdown from './components/views/directory/NetworkDropdown';
views$directory$NetworkDropdown && (module.exports.components['views.directory.NetworkDropdown'] = views$directory$NetworkDropdown);
import views$elements$ImageView from './components/views/elements/ImageView';
views$elements$ImageView && (module.exports.components['views.elements.ImageView'] = views$elements$ImageView);
import views$elements$Spinner from './components/views/elements/Spinner';
views$elements$Spinner && (module.exports.components['views.elements.Spinner'] = views$elements$Spinner);
import views$globals$GuestWarningBar from './components/views/globals/GuestWarningBar';
views$globals$GuestWarningBar && (module.exports.components['views.globals.GuestWarningBar'] = views$globals$GuestWarningBar);
import views$globals$MatrixToolbar from './components/views/globals/MatrixToolbar';
views$globals$MatrixToolbar && (module.exports.components['views.globals.MatrixToolbar'] = views$globals$MatrixToolbar);
import views$globals$NewVersionBar from './components/views/globals/NewVersionBar';
views$globals$NewVersionBar && (module.exports.components['views.globals.NewVersionBar'] = views$globals$NewVersionBar);
import views$globals$PasswordNagBar from './components/views/globals/PasswordNagBar';
views$globals$PasswordNagBar && (module.exports.components['views.globals.PasswordNagBar'] = views$globals$PasswordNagBar);
import views$login$VectorCustomServerDialog from './components/views/login/VectorCustomServerDialog';
views$login$VectorCustomServerDialog && (module.exports.components['views.login.VectorCustomServerDialog'] = views$login$VectorCustomServerDialog);
import views$login$VectorLoginFooter from './components/views/login/VectorLoginFooter';
views$login$VectorLoginFooter && (module.exports.components['views.login.VectorLoginFooter'] = views$login$VectorLoginFooter);
import views$login$VectorLoginHeader from './components/views/login/VectorLoginHeader';
views$login$VectorLoginHeader && (module.exports.components['views.login.VectorLoginHeader'] = views$login$VectorLoginHeader);
import views$messages$DateSeparator from './components/views/messages/DateSeparator';
views$messages$DateSeparator && (module.exports.components['views.messages.DateSeparator'] = views$messages$DateSeparator);
import views$messages$MessageTimestamp from './components/views/messages/MessageTimestamp';
views$messages$MessageTimestamp && (module.exports.components['views.messages.MessageTimestamp'] = views$messages$MessageTimestamp);
import views$rooms$DNDRoomTile from './components/views/rooms/DNDRoomTile';
views$rooms$DNDRoomTile && (module.exports.components['views.rooms.DNDRoomTile'] = views$rooms$DNDRoomTile);
import views$rooms$RoomDropTarget from './components/views/rooms/RoomDropTarget';
views$rooms$RoomDropTarget && (module.exports.components['views.rooms.RoomDropTarget'] = views$rooms$RoomDropTarget);
import views$rooms$RoomTooltip from './components/views/rooms/RoomTooltip';
views$rooms$RoomTooltip && (module.exports.components['views.rooms.RoomTooltip'] = views$rooms$RoomTooltip);
import views$rooms$SearchBar from './components/views/rooms/SearchBar';
views$rooms$SearchBar && (module.exports.components['views.rooms.SearchBar'] = views$rooms$SearchBar);
import views$settings$IntegrationsManager from './components/views/settings/IntegrationsManager';
views$settings$IntegrationsManager && (module.exports.components['views.settings.IntegrationsManager'] = views$settings$IntegrationsManager);
import views$settings$Notifications from './components/views/settings/Notifications';
views$settings$Notifications && (module.exports.components['views.settings.Notifications'] = views$settings$Notifications);
<commit_msg>Unmuddle the component-index header<commit_after>/*
Copyright 2015, 2016 OpenMarket Ltd

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.
*/

/*
 * THIS FILE IS AUTO-GENERATED
 * You can edit it you like, but your changes will be overwritten,
 * so you'd just be trying to swim upstream like a salmon.
 * You are not a salmon.
 *
 * To update it, run:
 *    ./reskindex.js -h header
 */

module.exports.components = require('matrix-react-sdk/lib/component-index').components;

import structures$BottomLeftMenu from './components/structures/BottomLeftMenu';
structures$BottomLeftMenu && (module.exports.components['structures.BottomLeftMenu'] = structures$BottomLeftMenu);
import structures$CompatibilityPage from './components/structures/CompatibilityPage';
structures$CompatibilityPage && (module.exports.components['structures.CompatibilityPage'] = structures$CompatibilityPage);
import structures$HomePage from './components/structures/HomePage';
structures$HomePage && (module.exports.components['structures.HomePage'] = structures$HomePage);
import structures$LeftPanel from './components/structures/LeftPanel';
structures$LeftPanel && (module.exports.components['structures.LeftPanel'] = structures$LeftPanel);
import structures$RightPanel from './components/structures/RightPanel';
structures$RightPanel && (module.exports.components['structures.RightPanel'] = structures$RightPanel);
import structures$RoomDirectory from './components/structures/RoomDirectory';
structures$RoomDirectory && (module.exports.components['structures.RoomDirectory'] = structures$RoomDirectory);
import structures$RoomSubList from './components/structures/RoomSubList';
structures$RoomSubList && (module.exports.components['structures.RoomSubList'] = structures$RoomSubList);
import structures$RoomSubListHeader from './components/structures/RoomSubListHeader';
structures$RoomSubListHeader && (module.exports.components['structures.RoomSubListHeader'] = structures$RoomSubListHeader);
import structures$SearchBox from './components/structures/SearchBox';
structures$SearchBox && (module.exports.components['structures.SearchBox'] = structures$SearchBox);
import structures$ViewSource from './components/structures/ViewSource';
structures$ViewSource && (module.exports.components['structures.ViewSource'] = structures$ViewSource);
import views$context_menus$MessageContextMenu from './components/views/context_menus/MessageContextMenu';
views$context_menus$MessageContextMenu && (module.exports.components['views.context_menus.MessageContextMenu'] = views$context_menus$MessageContextMenu);
import views$context_menus$RoomTileContextMenu from './components/views/context_menus/RoomTileContextMenu';
views$context_menus$RoomTileContextMenu && (module.exports.components['views.context_menus.RoomTileContextMenu'] = views$context_menus$RoomTileContextMenu);
import views$dialogs$BugReportDialog from './components/views/dialogs/BugReportDialog';
views$dialogs$BugReportDialog && (module.exports.components['views.dialogs.BugReportDialog'] = views$dialogs$BugReportDialog);
import views$dialogs$ChangelogDialog from './components/views/dialogs/ChangelogDialog';
views$dialogs$ChangelogDialog && (module.exports.components['views.dialogs.ChangelogDialog'] = views$dialogs$ChangelogDialog);
import views$directory$NetworkDropdown from './components/views/directory/NetworkDropdown';
views$directory$NetworkDropdown && (module.exports.components['views.directory.NetworkDropdown'] = views$directory$NetworkDropdown);
import views$elements$ImageView from './components/views/elements/ImageView';
views$elements$ImageView && (module.exports.components['views.elements.ImageView'] = views$elements$ImageView);
import views$elements$Spinner from './components/views/elements/Spinner';
views$elements$Spinner && (module.exports.components['views.elements.Spinner'] = views$elements$Spinner);
import views$globals$GuestWarningBar from './components/views/globals/GuestWarningBar';
views$globals$GuestWarningBar && (module.exports.components['views.globals.GuestWarningBar'] = views$globals$GuestWarningBar);
import views$globals$MatrixToolbar from './components/views/globals/MatrixToolbar';
views$globals$MatrixToolbar && (module.exports.components['views.globals.MatrixToolbar'] = views$globals$MatrixToolbar);
import views$globals$NewVersionBar from './components/views/globals/NewVersionBar';
views$globals$NewVersionBar && (module.exports.components['views.globals.NewVersionBar'] = views$globals$NewVersionBar);
import views$globals$PasswordNagBar from './components/views/globals/PasswordNagBar';
views$globals$PasswordNagBar && (module.exports.components['views.globals.PasswordNagBar'] = views$globals$PasswordNagBar);
import views$login$VectorCustomServerDialog from './components/views/login/VectorCustomServerDialog';
views$login$VectorCustomServerDialog && (module.exports.components['views.login.VectorCustomServerDialog'] = views$login$VectorCustomServerDialog);
import views$login$VectorLoginFooter from './components/views/login/VectorLoginFooter';
views$login$VectorLoginFooter && (module.exports.components['views.login.VectorLoginFooter'] = views$login$VectorLoginFooter);
import views$login$VectorLoginHeader from './components/views/login/VectorLoginHeader';
views$login$VectorLoginHeader && (module.exports.components['views.login.VectorLoginHeader'] = views$login$VectorLoginHeader);
import views$messages$DateSeparator from './components/views/messages/DateSeparator';
views$messages$DateSeparator && (module.exports.components['views.messages.DateSeparator'] = views$messages$DateSeparator);
import views$messages$MessageTimestamp from './components/views/messages/MessageTimestamp';
views$messages$MessageTimestamp && (module.exports.components['views.messages.MessageTimestamp'] = views$messages$MessageTimestamp);
import views$rooms$DNDRoomTile from './components/views/rooms/DNDRoomTile';
views$rooms$DNDRoomTile && (module.exports.components['views.rooms.DNDRoomTile'] = views$rooms$DNDRoomTile);
import views$rooms$RoomDropTarget from './components/views/rooms/RoomDropTarget';
views$rooms$RoomDropTarget && (module.exports.components['views.rooms.RoomDropTarget'] = views$rooms$RoomDropTarget);
import views$rooms$RoomTooltip from './components/views/rooms/RoomTooltip';
views$rooms$RoomTooltip && (module.exports.components['views.rooms.RoomTooltip'] = views$rooms$RoomTooltip);
import views$rooms$SearchBar from './components/views/rooms/SearchBar';
views$rooms$SearchBar && (module.exports.components['views.rooms.SearchBar'] = views$rooms$SearchBar);
import views$settings$IntegrationsManager from './components/views/settings/IntegrationsManager';
views$settings$IntegrationsManager && (module.exports.components['views.settings.IntegrationsManager'] = views$settings$IntegrationsManager);
import views$settings$Notifications from './components/views/settings/Notifications';
views$settings$Notifications && (module.exports.components['views.settings.Notifications'] = views$settings$Notifications);
<|endoftext|>


<commit_before>/**
@license
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
import '../utils/boot.js';

import '../utils/settings.js';
import { FlattenedNodesObserver } from '../utils/flattened-nodes-observer.js';
export { flush, enqueueDebouncer as addDebouncer } from '../utils/flush.js';
/* eslint-disable no-unused-vars */
import { Debouncer } from '../utils/debounce.js';  // used in type annotations
/* eslint-enable no-unused-vars */

const p = Element.prototype;
/**
 * @const {function(this:Node, string): boolean}
 */
const normalizedMatchesSelector = p.matches || p.matchesSelector ||
  p.mozMatchesSelector || p.msMatchesSelector ||
  p.oMatchesSelector || p.webkitMatchesSelector;

/**
 * Cross-platform `element.matches` shim.
 *
 * @function matchesSelector
 * @param {!Node} node Node to check selector against
 * @param {string} selector Selector to match
 * @return {boolean} True if node matched selector
 */
export const matchesSelector = function(node, selector) {
  return normalizedMatchesSelector.call(node, selector);
};

/**
 * Node API wrapper class returned from `Polymer.dom.(target)` when
 * `target` is a `Node`.
 *
 */
export class DomApi {

  /**
   * @param {Node} node Node for which to create a Polymer.dom helper object.
   */
  constructor(node) {
    this.node = node;
  }

  /**
   * Returns an instance of `FlattenedNodesObserver` that
   * listens for node changes on this element.
   *
   * @param {function(this:HTMLElement, { target: !HTMLElement, addedNodes: !Array<!Element>, removedNodes: !Array<!Element> }):void} callback Called when direct or distributed children
   *   of this element changes
   * @return {!FlattenedNodesObserver} Observer instance
   */
  observeNodes(callback) {
    return new FlattenedNodesObserver(
        /** @type {!HTMLElement} */(this.node), callback);
  }

  /**
   * Disconnects an observer previously created via `observeNodes`
   *
   * @param {!FlattenedNodesObserver} observerHandle Observer instance
   *   to disconnect.
   * @return {void}
   */
  unobserveNodes(observerHandle) {
    observerHandle.disconnect();
  }

  /**
   * Provided as a backwards-compatible API only.  This method does nothing.
   * @return {void}
   */
  notifyObserver() {}

  /**
   * Returns true if the provided node is contained with this element's
   * light-DOM children or shadow root, including any nested shadow roots
   * of children therein.
   *
   * @param {Node} node Node to test
   * @return {boolean} Returns true if the given `node` is contained within
   *   this element's light or shadow DOM.
   */
  deepContains(node) {
    if (this.node.contains(node)) {
      return true;
    }
    let n = node;
    let doc = node.ownerDocument;
    // walk from node to `this` or `document`
    while (n && n !== doc && n !== this.node) {
      // use logical parentnode, or native ShadowRoot host
      n = n.parentNode || n.host;
    }
    return n === this.node;
  }

  /**
   * Returns the root node of this node.  Equivalent to `getRootNode()`.
   *
   * @return {Node} Top most element in the dom tree in which the node
   * exists. If the node is connected to a document this is either a
   * shadowRoot or the document; otherwise, it may be the node
   * itself or a node or document fragment containing it.
   */
  getOwnerRoot() {
    return this.node.getRootNode();
  }

  /**
   * For slot elements, returns the nodes assigned to the slot; otherwise
   * an empty array. It is equivalent to `<slot>.addignedNodes({flatten:true})`.
   *
   * @return {!Array<!Node>} Array of assigned nodes
   */
  getDistributedNodes() {
    return (this.node.localName === 'slot') ?
      this.node.assignedNodes({flatten: true}) :
      [];
  }

  /**
   * Returns an array of all slots this element was distributed to.
   *
   * @return {!Array<!HTMLSlotElement>} Description
   */
  getDestinationInsertionPoints() {
    let ip$ = [];
    let n = this.node.assignedSlot;
    while (n) {
      ip$.push(n);
      n = n.assignedSlot;
    }
    return ip$;
  }

  /**
   * Calls `importNode` on the `ownerDocument` for this node.
   *
   * @param {!Node} node Node to import
   * @param {boolean} deep True if the node should be cloned deeply during
   *   import
   * @return {Node} Clone of given node imported to this owner document
   */
  importNode(node, deep) {
    let doc = this.node instanceof Document ? this.node :
      this.node.ownerDocument;
    return doc.importNode(node, deep);
  }

  /**
   * @return {!Array<!Node>} Returns a flattened list of all child nodes and
   * nodes assigned to child slots.
   */
  getEffectiveChildNodes() {
    return FlattenedNodesObserver.getFlattenedNodes(
        /** @type {!HTMLElement} */ (this.node));
  }

  /**
   * Returns a filtered list of flattened child elements for this element based
   * on the given selector.
   *
   * @param {string} selector Selector to filter nodes against
   * @return {!Array<!HTMLElement>} List of flattened child elements
   */
  queryDistributedElements(selector) {
    let c$ = this.getEffectiveChildNodes();
    let list = [];
    for (let i=0, l=c$.length, c; (i<l) && (c=c$[i]); i++) {
      if ((c.nodeType === Node.ELEMENT_NODE) &&
          matchesSelector(c, selector)) {
        list.push(c);
      }
    }
    return list;
  }

  /**
   * For shadow roots, returns the currently focused element within this
   * shadow root.
   *
   * @return {Node|undefined} Currently focused element
   */
  get activeElement() {
    let node = this.node;
    return node._activeElement !== undefined ? node._activeElement : node.activeElement;
  }
}

function forwardMethods(proto, methods) {
  for (let i=0; i < methods.length; i++) {
    let method = methods[i];
    /* eslint-disable valid-jsdoc */
    proto[method] = /** @this {DomApi} */ function() {
      return this.node[method].apply(this.node, arguments);
    };
    /* eslint-enable */
  }
}

function forwardReadOnlyProperties(proto, properties) {
  for (let i=0; i < properties.length; i++) {
    let name = properties[i];
    Object.defineProperty(proto, name, {
      get: function() {
        const domApi = /** @type {DomApi} */(this);
        return domApi.node[name];
      },
      configurable: true
    });
  }
}

function forwardProperties(proto, properties) {
  for (let i=0; i < properties.length; i++) {
    let name = properties[i];
    Object.defineProperty(proto, name, {
      /**
       * @this {DomApi}
       * @return {*} .
       */
      get: function() {
        return this.node[name];
      },
      /**
       * @this {DomApi}
       * @param {*} value .
       */
      set: function(value) {
        this.node[name] = value;
      },
      configurable: true
    });
  }
}

/**
 * Event API wrapper class returned from `dom.(target)` when
 * `target` is an `Event`.
 */
export class EventApi {
  constructor(event) {
    this.event = event;
  }

  /**
   * Returns the first node on the `composedPath` of this event.
   *
   * @return {!EventTarget} The node this event was dispatched to
   */
  get rootTarget() {
    return this.event.composedPath()[0];
  }

  /**
   * Returns the local (re-targeted) target for this event.
   *
   * @return {!EventTarget} The local (re-targeted) target for this event.
   */
  get localTarget() {
    return this.event.target;
  }

  /**
   * Returns the `composedPath` for this event.
   * @return {!Array<!EventTarget>} The nodes this event propagated through
   */
  get path() {
    return this.event.composedPath();
  }
}

/**
 * @function
 * @param {boolean=} deep
 * @return {!Node}
 */
DomApi.prototype.cloneNode;
/**
 * @function
 * @param {!Node} node
 * @return {!Node}
 */
DomApi.prototype.appendChild;
/**
 * @function
 * @param {!Node} newChild
 * @param {Node} refChild
 * @return {!Node}
 */
DomApi.prototype.insertBefore;
/**
 * @function
 * @param {!Node} node
 * @return {!Node}
 */
DomApi.prototype.removeChild;
/**
 * @function
 * @param {!Node} oldChild
 * @param {!Node} newChild
 * @return {!Node}
 */
DomApi.prototype.replaceChild;
/**
 * @function
 * @param {string} name
 * @param {string} value
 * @return {void}
 */
DomApi.prototype.setAttribute;
/**
 * @function
 * @param {string} name
 * @return {void}
 */
DomApi.prototype.removeAttribute;
/**
 * @function
 * @param {string} selector
 * @return {?Element}
 */
DomApi.prototype.querySelector;
/**
 * @function
 * @param {string} selector
 * @return {!NodeList<!Element>}
 */
DomApi.prototype.querySelectorAll;

/** @type {?Node} */
DomApi.prototype.parentNode;
/** @type {?Node} */
DomApi.prototype.firstChild;
/** @type {?Node} */
DomApi.prototype.lastChild;
/** @type {?Node} */
DomApi.prototype.nextSibling;
/** @type {?Node} */
DomApi.prototype.previousSibling;
/** @type {?HTMLElement} */
DomApi.prototype.firstElementChild;
/** @type {?HTMLElement} */
DomApi.prototype.lastElementChild;
/** @type {?HTMLElement} */
DomApi.prototype.nextElementSibling;
/** @type {?HTMLElement} */
DomApi.prototype.previousElementSibling;
/** @type {!Array<!Node>} */
DomApi.prototype.childNodes;
/** @type {!Array<!HTMLElement>} */
DomApi.prototype.children;
/** @type {?DOMTokenList} */
DomApi.prototype.classList;

/** @type {string} */
DomApi.prototype.textContent;
/** @type {string} */
DomApi.prototype.innerHTML;

forwardMethods(DomApi.prototype, [
  'cloneNode', 'appendChild', 'insertBefore', 'removeChild',
  'replaceChild', 'setAttribute', 'removeAttribute',
  'querySelector', 'querySelectorAll'
]);

forwardReadOnlyProperties(DomApi.prototype, [
  'parentNode', 'firstChild', 'lastChild',
  'nextSibling', 'previousSibling', 'firstElementChild',
  'lastElementChild', 'nextElementSibling', 'previousElementSibling',
  'childNodes', 'children', 'classList'
]);

forwardProperties(DomApi.prototype, [
  'textContent', 'innerHTML'
]);

/**
 * Legacy DOM and Event manipulation API wrapper factory used to abstract
 * differences between native Shadow DOM and "Shady DOM" when polyfilling on
 * older browsers.
 *
 * Note that in Polymer 2.x use of `Polymer.dom` is no longer required and
 * in the majority of cases simply facades directly to the standard native
 * API.
 *
 * @summary Legacy DOM and Event manipulation API wrapper factory used to
 * abstract differences between native Shadow DOM and "Shady DOM."
 * @param {(Node|Event)=} obj Node or event to operate on
 * @return {!DomApi|!EventApi} Wrapper providing either node API or event API
 */
export const dom = function(obj) {
  obj = obj || document;
  if (!obj.__domApi) {
    let helper;
    if (obj instanceof Event) {
      helper = new EventApi(obj);
    } else {
      helper = new DomApi(obj);
    }
    obj.__domApi = helper;
  }
  return obj.__domApi;
};
<commit_msg>Fix another unsafe property assignment in Polymer.<commit_after>/**
@license
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
import '../utils/boot.js';

import '../utils/settings.js';
import { FlattenedNodesObserver } from '../utils/flattened-nodes-observer.js';
export { flush, enqueueDebouncer as addDebouncer } from '../utils/flush.js';
/* eslint-disable no-unused-vars */
import { Debouncer } from '../utils/debounce.js';  // used in type annotations
/* eslint-enable no-unused-vars */

const p = Element.prototype;
/**
 * @const {function(this:Node, string): boolean}
 */
const normalizedMatchesSelector = p.matches || p.matchesSelector ||
  p.mozMatchesSelector || p.msMatchesSelector ||
  p.oMatchesSelector || p.webkitMatchesSelector;

/**
 * Cross-platform `element.matches` shim.
 *
 * @function matchesSelector
 * @param {!Node} node Node to check selector against
 * @param {string} selector Selector to match
 * @return {boolean} True if node matched selector
 */
export const matchesSelector = function(node, selector) {
  return normalizedMatchesSelector.call(node, selector);
};

/**
 * Node API wrapper class returned from `Polymer.dom.(target)` when
 * `target` is a `Node`.
 *
 */
export class DomApi {

  /**
   * @param {Node} node Node for which to create a Polymer.dom helper object.
   */
  constructor(node) {
    this.node = node;
  }

  /**
   * Returns an instance of `FlattenedNodesObserver` that
   * listens for node changes on this element.
   *
   * @param {function(this:HTMLElement, { target: !HTMLElement, addedNodes: !Array<!Element>, removedNodes: !Array<!Element> }):void} callback Called when direct or distributed children
   *   of this element changes
   * @return {!FlattenedNodesObserver} Observer instance
   */
  observeNodes(callback) {
    return new FlattenedNodesObserver(
        /** @type {!HTMLElement} */(this.node), callback);
  }

  /**
   * Disconnects an observer previously created via `observeNodes`
   *
   * @param {!FlattenedNodesObserver} observerHandle Observer instance
   *   to disconnect.
   * @return {void}
   */
  unobserveNodes(observerHandle) {
    observerHandle.disconnect();
  }

  /**
   * Provided as a backwards-compatible API only.  This method does nothing.
   * @return {void}
   */
  notifyObserver() {}

  /**
   * Returns true if the provided node is contained with this element's
   * light-DOM children or shadow root, including any nested shadow roots
   * of children therein.
   *
   * @param {Node} node Node to test
   * @return {boolean} Returns true if the given `node` is contained within
   *   this element's light or shadow DOM.
   */
  deepContains(node) {
    if (this.node.contains(node)) {
      return true;
    }
    let n = node;
    let doc = node.ownerDocument;
    // walk from node to `this` or `document`
    while (n && n !== doc && n !== this.node) {
      // use logical parentnode, or native ShadowRoot host
      n = n.parentNode || n.host;
    }
    return n === this.node;
  }

  /**
   * Returns the root node of this node.  Equivalent to `getRootNode()`.
   *
   * @return {Node} Top most element in the dom tree in which the node
   * exists. If the node is connected to a document this is either a
   * shadowRoot or the document; otherwise, it may be the node
   * itself or a node or document fragment containing it.
   */
  getOwnerRoot() {
    return this.node.getRootNode();
  }

  /**
   * For slot elements, returns the nodes assigned to the slot; otherwise
   * an empty array. It is equivalent to `<slot>.addignedNodes({flatten:true})`.
   *
   * @return {!Array<!Node>} Array of assigned nodes
   */
  getDistributedNodes() {
    return (this.node.localName === 'slot') ?
      this.node.assignedNodes({flatten: true}) :
      [];
  }

  /**
   * Returns an array of all slots this element was distributed to.
   *
   * @return {!Array<!HTMLSlotElement>} Description
   */
  getDestinationInsertionPoints() {
    let ip$ = [];
    let n = this.node.assignedSlot;
    while (n) {
      ip$.push(n);
      n = n.assignedSlot;
    }
    return ip$;
  }

  /**
   * Calls `importNode` on the `ownerDocument` for this node.
   *
   * @param {!Node} node Node to import
   * @param {boolean} deep True if the node should be cloned deeply during
   *   import
   * @return {Node} Clone of given node imported to this owner document
   */
  importNode(node, deep) {
    let doc = this.node instanceof Document ? this.node :
      this.node.ownerDocument;
    return doc.importNode(node, deep);
  }

  /**
   * @return {!Array<!Node>} Returns a flattened list of all child nodes and
   * nodes assigned to child slots.
   */
  getEffectiveChildNodes() {
    return FlattenedNodesObserver.getFlattenedNodes(
        /** @type {!HTMLElement} */ (this.node));
  }

  /**
   * Returns a filtered list of flattened child elements for this element based
   * on the given selector.
   *
   * @param {string} selector Selector to filter nodes against
   * @return {!Array<!HTMLElement>} List of flattened child elements
   */
  queryDistributedElements(selector) {
    let c$ = this.getEffectiveChildNodes();
    let list = [];
    for (let i=0, l=c$.length, c; (i<l) && (c=c$[i]); i++) {
      if ((c.nodeType === Node.ELEMENT_NODE) &&
          matchesSelector(c, selector)) {
        list.push(c);
      }
    }
    return list;
  }

  /**
   * For shadow roots, returns the currently focused element within this
   * shadow root.
   *
   * @return {Node|undefined} Currently focused element
   */
  get activeElement() {
    let node = this.node;
    return node._activeElement !== undefined ? node._activeElement : node.activeElement;
  }
}

function forwardMethods(proto, methods) {
  for (let i=0; i < methods.length; i++) {
    let method = methods[i];
    /* eslint-disable valid-jsdoc */
    proto[method] = /** @this {DomApi} */ function() {
      return this.node[method].apply(this.node, arguments);
    };
    /* eslint-enable */
  }
}

function forwardReadOnlyProperties(proto, properties) {
  for (let i=0; i < properties.length; i++) {
    let name = properties[i];
    Object.defineProperty(proto, name, {
      get: function() {
        const domApi = /** @type {DomApi} */(this);
        return domApi.node[name];
      },
      configurable: true
    });
  }
}

function forwardProperties(proto, properties) {
  for (let i=0; i < properties.length; i++) {
    let name = properties[i];
    Object.defineProperty(proto, name, {
      /**
       * @this {DomApi}
       * @return {*} .
       */
      get: function() {
        return this.node[name];
      },
      /**
       * @this {DomApi}
       * @param {*} value .
       */
      set: function(value) {
        this.node[name] = value;
      },
      configurable: true
    });
  }
}

/**
 * Event API wrapper class returned from `dom.(target)` when
 * `target` is an `Event`.
 */
export class EventApi {
  constructor(event) {
    this.event = event;
  }

  /**
   * Returns the first node on the `composedPath` of this event.
   *
   * @return {!EventTarget} The node this event was dispatched to
   */
  get rootTarget() {
    return this.event.composedPath()[0];
  }

  /**
   * Returns the local (re-targeted) target for this event.
   *
   * @return {!EventTarget} The local (re-targeted) target for this event.
   */
  get localTarget() {
    return this.event.target;
  }

  /**
   * Returns the `composedPath` for this event.
   * @return {!Array<!EventTarget>} The nodes this event propagated through
   */
  get path() {
    return this.event.composedPath();
  }
}

/**
 * @function
 * @param {boolean=} deep
 * @return {!Node}
 */
DomApi.prototype.cloneNode;
/**
 * @function
 * @param {!Node} node
 * @return {!Node}
 */
DomApi.prototype.appendChild;
/**
 * @function
 * @param {!Node} newChild
 * @param {Node} refChild
 * @return {!Node}
 */
DomApi.prototype.insertBefore;
/**
 * @function
 * @param {!Node} node
 * @return {!Node}
 */
DomApi.prototype.removeChild;
/**
 * @function
 * @param {!Node} oldChild
 * @param {!Node} newChild
 * @return {!Node}
 */
DomApi.prototype.replaceChild;
/**
 * @function
 * @param {string} name
 * @param {string} value
 * @return {void}
 */
DomApi.prototype.setAttribute;
/**
 * @function
 * @param {string} name
 * @return {void}
 */
DomApi.prototype.removeAttribute;
/**
 * @function
 * @param {string} selector
 * @return {?Element}
 */
DomApi.prototype.querySelector;
/**
 * @function
 * @param {string} selector
 * @return {!NodeList<!Element>}
 */
DomApi.prototype.querySelectorAll;

/** @type {?Node} */
DomApi.prototype.parentNode;
/** @type {?Node} */
DomApi.prototype.firstChild;
/** @type {?Node} */
DomApi.prototype.lastChild;
/** @type {?Node} */
DomApi.prototype.nextSibling;
/** @type {?Node} */
DomApi.prototype.previousSibling;
/** @type {?HTMLElement} */
DomApi.prototype.firstElementChild;
/** @type {?HTMLElement} */
DomApi.prototype.lastElementChild;
/** @type {?HTMLElement} */
DomApi.prototype.nextElementSibling;
/** @type {?HTMLElement} */
DomApi.prototype.previousElementSibling;
/** @type {!Array<!Node>} */
DomApi.prototype.childNodes;
/** @type {!Array<!HTMLElement>} */
DomApi.prototype.children;
/** @type {?DOMTokenList} */
DomApi.prototype.classList;

/** @type {string} */
DomApi.prototype.textContent;
/** @type {string} */
DomApi.prototype.innerHTML;

forwardMethods(DomApi.prototype, [
  'cloneNode', 'appendChild', 'insertBefore', 'removeChild',
  'replaceChild', 'setAttribute', 'removeAttribute',
  'querySelector', 'querySelectorAll'
]);

forwardReadOnlyProperties(DomApi.prototype, [
  'parentNode', 'firstChild', 'lastChild',
  'nextSibling', 'previousSibling', 'firstElementChild',
  'lastElementChild', 'nextElementSibling', 'previousElementSibling',
  'childNodes', 'children', 'classList'
]);

forwardProperties(DomApi.prototype, [
  'textContent', 'innerHTML'
]);

/**
 * Legacy DOM and Event manipulation API wrapper factory used to abstract
 * differences between native Shadow DOM and "Shady DOM" when polyfilling on
 * older browsers.
 *
 * Note that in Polymer 2.x use of `Polymer.dom` is no longer required and
 * in the majority of cases simply facades directly to the standard native
 * API.
 *
 * @summary Legacy DOM and Event manipulation API wrapper factory used to
 * abstract differences between native Shadow DOM and "Shady DOM."
 * @param {(Node|Event)=} obj Node or event to operate on
 * @return {!DomApi|!EventApi} Wrapper providing either node API or event API
 */
export const dom = function(obj) {
  obj = obj || document;
  if (!obj['__domApi']) {
    let helper;
    if (obj instanceof Event) {
      helper = new EventApi(obj);
    } else {
      helper = new DomApi(obj);
    }
    obj['__domApi'] = helper;
  }
  return obj['__domApi'];
};
<|endoftext|>


<commit_before>(function(angular, $fh) {
    'use strict';

    // Ensure FH module is defined
    try {
        angular.module('FH');
    } catch (e) {
        angular.module('FH', ['ng']);
    }

    angular.module('FH').service('FH.Act', ['$rootScope', '$q', '$timeout', '$window', 'FH.Network'
        function($rootScope, $q, $timeout, $window, Network) {

            // Error strings used for error type detection
            var ACT_ERRORS = {
                PARSE_ERROR: 'parseerror',
                NO_ACTNAME: 'act_no_action',
                UNKNOWN_ACT: 'no such function',
                INTERNAL_ERROR: 'internal error in',
                TIMEOUT: 'timeout'
            };

            // Expose error types for checks by user
            var ERRORS = this.ERRORS = {
                NO_ACTNAME_PROVIDED: 'NO_ACTNAME_PROVIDED',
                UNKNOWN_ERROR: 'UNKNOWN_ERROR',
                UNKNOWN_ACT: 'UNKNOWN_ACT',
                CLOUD_ERROR: 'CLOUD_ERROR',
                TIMEOUT: 'TIMEOUT',
                PARSE_ERROR: 'PARSE_ERROR',
                NO_NETWORK: 'NO_NETWORK'
            };

            // Controls whether debug logging is enabled
            var printLogs = true;
            // Default time to wait for response
            var defaultTimeout = 20 * 1000;

            /**
             * Log debug output for this module.
             * @param {String}  str
             */
            function debug() {
                if (printLogs === true) {
                    var args = Array.prototype.slice.call(arguments);
                    args[0] = '$fh.act ' + new Date().toISOString() + ': ' + args[0];
                    console.debug.apply(console, args);
                }
            }

            /**
             * Called on a successful act call (when main.js callback is called with a null error param)
             * It is assumed if a request could not be fulfilled res.errors will be defined.
             * @param {String}      actname
             * @param {Object}      res
             * @param {Function}    callback
             */
            function parseSuccess(actname, res) {
                debug('Called "' + actname + '" successfully.');

                return res;
            }

            /**
             * Called when an act call has failed.
             * Tries to create a meaningful error string.
             * @param {String}      actname
             * @param {String}      err
             * @param {Object}      details
             * @param {Function}    callback
             */
            function parseFail(actname, err, details) {
                var ERR = null;

                if (err === ACT_ERRORS.NO_ACTNAME) {
                    ERR = ERRORS.NO_ACTNAME_PROVIDED;
                } else if (err !== 'error_ajaxfail') {
                    ERR = ERRORS.UKNOWN_ERROR;
                } else if (err === ERRORS.NO_ACTNAME_PROVIDED) {
                    ERR = ERRORS.NO_ACTNAME_PROVIDED;
                } else if (details.error.toLowerCase().indexOf(ACT_ERRORS.UNKNOWN_ACT) >= 0) {
                    ERR = ERRORS.UNKNOWN_ACT;
                } else if (details.message.toLowerCase().indexOf(ACT_ERRORS.TIMEOUT) >= 0) {
                    ERR = ERRORS.TIMEOUT;
                } else if (details.message === ACT_ERRORS.PARSE_ERROR) {
                    ERR = ERRORS.PARSE_ERROR;
                } else {
                    // Cloud code sent error to it's callback
                    debug('"%s" encountered an error in it\'s cloud code. Error String: %s, Error Object: %o', actname, err, details);
                    ERR = ERRORS.CLOUD_ERROR;
                }

                debug('"%s" failed with error %s', actname, ERR);

                return {
                    type: ERR,
                    err: err,
                    msg: details
                };
            }

            function safeApply(fn) {
                var phase = $rootScope.$$phase;
                if (phase === '$apply' || phase === '$digest') {
                    if (fn && (typeof(fn) === 'function')) {
                        fn();
                    }
                } else {
                    $rootScope.$apply(fn);
                }
            }

            /**
             * Returns a successful act call.
             * @param {Mixed} res
             * @param {Promise} [promise]
             * @param {Function} [callback]
             */
            function resolve(res, promise, callback) {
                safeApply(function() {
                    if (callback) {
                        callback(null, res);
                    } else {
                        promise.resolve(res);
                    }
                });
            }

            /**
             * Returns a failed act call.
             * @param {Mixed} res
             * @param {Promise} [promise]
             * @param {Function} [callback]
             */
            function reject(err, promise, callback) {
                safeApply(function() {
                    if (callback) {
                        callback(err, null);
                    } else {
                        promise.reject(err);
                    }
                });
            }

            /**
             * Call an action on the cloud.
             * @param {String}      actname
             * @param {Object}      [params]
             * @param {Function}    [callback]
             * @param {Number}      [timeout]
             */
            this.callFn = function(actname, params, cb, timeout) {
                var promise = null,
                    callback = null,
                    args = Array.prototype.slice.call(arguments)

                    // Find a callback if one exists
                    for (var i in args) {
                        if (typeof args[i] === 'function') {
                            // User provided a callback
                            callback = args[i];
                        }
                    }

                if (callback) {
                    // Ensure we don't provde a function to req of $fh.act
                    if (params === callback) {
                        params = null;
                    }
                } else {
                    promise = $q.defer();
                }

                // $fh.act parameters object
                var opts = {
                    act: actname,
                    req: params,
                    timeout: timeout || defaultTimeout
                };

                // Wait a bit before calling so we can return the promise
                $timeout(function() {
                    // Check are we online before trying the request
                    // For unit tests simply assume we have a connection
                    if (Network.isAvailable() === true || window.mochaPhantomJS) {
                        debug('Calling "' + actname + '" cloud side function.');

                        $fh.act(opts, function(res) {
                            resolve(parseSuccess(actname, res), promise, callback);
                        }, function(err, msg) {
                            reject(parseFail(actname, err, msg), promise, callback);
                        });
                    } else {
                        debug('Could not call "' + actname + '". No network connection.');

                        reject({
                            type: ERRORS.NO_NETWORK,
                            err: null,
                            msg: null
                        }, promise, callback);
                    }
                }, 0);

                if (promise !== null) {
                    return promise.promise;
                }
            };

            this.setDefaultTimeout = function(timeout) {
                defaultTimeout = timeout;
            };

            // Disable internal logging by this service.
            this.disableLogging = function() {
                printLogs = false;
            };

            // Disable internal logging by this service.
            this.enableLogging = function() {
                printLogs = true;
            };
        }
    ]);

})(window.angular, window.$fh);
<commit_msg>Update for release<commit_after>(function(angular, $fh) {
    'use strict';

    // Ensure FH module is defined
    try {
        angular.module('FH');
    } catch (e) {
        angular.module('FH', ['ng']);
    }

    angular.module('FH').service('FH.Act', ['$rootScope', '$q', '$timeout', '$window',
        function($rootScope, $q, $timeout, $window) {

            // Error strings used for error type detection
            var ACT_ERRORS = {
                PARSE_ERROR: 'parseerror',
                NO_ACTNAME: 'act_no_action',
                UNKNOWN_ACT: 'no such function',
                INTERNAL_ERROR: 'internal error in',
                TIMEOUT: 'timeout'
            };

            // Expose error types for checks by user
            var ERRORS = this.ERRORS = {
                NO_ACTNAME_PROVIDED: 'NO_ACTNAME_PROVIDED',
                UNKNOWN_ERROR: 'UNKNOWN_ERROR',
                UNKNOWN_ACT: 'UNKNOWN_ACT',
                CLOUD_ERROR: 'CLOUD_ERROR',
                TIMEOUT: 'TIMEOUT',
                PARSE_ERROR: 'PARSE_ERROR',
                NO_NETWORK: 'NO_NETWORK'
            };

            // Controls whether debug logging is enabled
            var printLogs = true;
            // Default time to wait for response
            var defaultTimeout = 20 * 1000;

            /**
             * Log debug output for this module.
             * @param {String}  str
             */
            function debug() {
                if (printLogs === true) {
                    var args = Array.prototype.slice.call(arguments);
                    args[0] = '$fh.act ' + new Date().toISOString() + ': ' + args[0];
                    console.debug.apply(console, args);
                }
            }

            /**
             * Called on a successful act call (when main.js callback is called with a null error param)
             * It is assumed if a request could not be fulfilled res.errors will be defined.
             * @param {String}      actname
             * @param {Object}      res
             * @param {Function}    callback
             */
            function parseSuccess(actname, res) {
                debug('Called "' + actname + '" successfully.');

                return res;
            }

            /**
             * Called when an act call has failed.
             * Tries to create a meaningful error string.
             * @param {String}      actname
             * @param {String}      err
             * @param {Object}      details
             * @param {Function}    callback
             */
            function parseFail(actname, err, details) {
                var ERR = null;

                if (err === ACT_ERRORS.NO_ACTNAME) {
                    ERR = ERRORS.NO_ACTNAME_PROVIDED;
                } else if (err !== 'error_ajaxfail') {
                    ERR = ERRORS.UKNOWN_ERROR;
                } else if (err === ERRORS.NO_ACTNAME_PROVIDED) {
                    ERR = ERRORS.NO_ACTNAME_PROVIDED;
                } else if (details.error.toLowerCase().indexOf(ACT_ERRORS.UNKNOWN_ACT) >= 0) {
                    ERR = ERRORS.UNKNOWN_ACT;
                } else if (details.message.toLowerCase().indexOf(ACT_ERRORS.TIMEOUT) >= 0) {
                    ERR = ERRORS.TIMEOUT;
                } else if (details.message === ACT_ERRORS.PARSE_ERROR) {
                    ERR = ERRORS.PARSE_ERROR;
                } else {
                    // Cloud code sent error to it's callback
                    debug('"%s" encountered an error in it\'s cloud code. Error String: %s, Error Object: %o', actname, err, details);
                    ERR = ERRORS.CLOUD_ERROR;
                }

                debug('"%s" failed with error %s', actname, ERR);

                return {
                    type: ERR,
                    err: err,
                    msg: details
                };
            }

            function safeApply(fn) {
                var phase = $rootScope.$$phase;
                if (phase === '$apply' || phase === '$digest') {
                    if (fn && (typeof(fn) === 'function')) {
                        fn();
                    }
                } else {
                    $rootScope.$apply(fn);
                }
            }

            /**
             * Returns a successful act call.
             * @param {Mixed} res
             * @param {Promise} [promise]
             * @param {Function} [callback]
             */
            function resolve(res, promise, callback) {
                safeApply(function() {
                    if (callback) {
                        callback(null, res);
                    } else {
                        promise.resolve(res);
                    }
                });
            }

            /**
             * Returns a failed act call.
             * @param {Mixed} res
             * @param {Promise} [promise]
             * @param {Function} [callback]
             */
            function reject(err, promise, callback) {
                safeApply(function() {
                    if (callback) {
                        callback(err, null);
                    } else {
                        promise.reject(err);
                    }
                });
            }

            /**
             * Call an action on the cloud.
             * @param {String}      actname
             * @param {Object}      [params]
             * @param {Function}    [callback]
             * @param {Number}      [timeout]
             */
            this.callFn = function(actname, params, cb, timeout) {
                var promise = null,
                    callback = null,
                    args = Array.prototype.slice.call(arguments);

                // Find a callback if one exists
                for (var i in args) {
                    if (typeof args[i] === 'function') {
                        // User provided a callback
                        callback = args[i];
                    }
                }

                if (callback) {
                    // Ensure we don't provde a function to req of $fh.act
                    if (params === callback) {
                        params = null;
                    }
                } else {
                    promise = $q.defer();
                }

                // $fh.act parameters object
                var opts = {
                    act: actname,
                    req: params,
                    timeout: timeout || defaultTimeout
                };

                // Wait a bit before calling so we can return the promise
                $timeout(function() {
                    // Check are we online before trying the request
                    // For unit tests simply assume we have a connection
                    if ($window.navigator.onLine === true || window.mochaPhantomJS) {
                        debug('Calling "' + actname + '" cloud side function.');

                        $fh.act(opts, function(res) {
                            resolve(parseSuccess(actname, res), promise, callback);
                        }, function(err, msg) {
                            reject(parseFail(actname, err, msg), promise, callback);
                        });
                    } else {
                        debug('Could not call "' + actname + '". No network connection.');

                        reject({
                            type: ERRORS.NO_NETWORK,
                            err: null,
                            msg: null
                        }, promise, callback);
                    }
                }, 0);

                if (promise !== null) {
                    return promise.promise;
                }
            };

            this.setDefaultTimeout = function(timeout) {
                defaultTimeout = timeout;
            };

            // Disable internal logging by this service.
            this.disableLogging = function() {
                printLogs = false;
            };

            // Disable internal logging by this service.
            this.enableLogging = function() {
                printLogs = true;
            };
        }
    ]);

})(window.angular, window.$fh);
<|endoftext|>


<commit_before>/**
 * Created by 国正 on 2014/7/11.
 */
var request = require('request');
var iconv = require('iconv-lite');
var cheerio = require('cheerio');

var session;

module.exports = function getRent(session, callback) {
    if (session == '' || session == null) {
        callback('Not Login');
    }
    request
    (
        {
            uri: 'http://222.24.3.7:8080/opac_two/reader/jieshuxinxi.jsp',
            encoding: null,
            headers: {
                Cookie: session
            }
        }, function (err, res, body) {
            if (err) {
                callback(err);
            }
            var rawHtml = (iconv.decode(body, "GB2312")).replace(/td_color_2/g, 'td_color_1');

            var $ = cheerio.load(rawHtml);

            if ($('#no_text').html() != null) {
                callback('null');
            }

            var rentData = [];
            $('TR[class="td_color_1"]').each(function (i) {
                var temp = $(this).children();
                var canRenew = true;
                if (RTrim($(temp[5]).text()) == '本馆续借')
                    canRenew = false;
                var jsRaw = temp[7].children[0].attribs['onclick'];
                jsRaw = jsRaw.substr(jsRaw.indexOf('Renew') + 6).replace(/\);/g, '').replace(/\'/g, '');
                var jsInfo = jsRaw.split(',');
                rentData[i] =
                {
                    'Title': RTrim($(temp[2]).text()),
                    'Barcode': RTrim($(temp[3]).text()),
                    'Department': RTrim($(temp[4]).text()),
                    'State': RTrim($(temp[5]).text()),
                    'Date': RTrim($(temp[6]).text().replace(/\//g, '')),
                    'CanRenew': canRenew,
                    'Depaertment_id': jsInfo[1],
                    'Library_id': jsInfo[2]
                };

            });

            callback(rentData);
        }
    )
};

function RTrim(str) {
    return str.replace(/(\s*$)/g, "");
}<commit_msg>Fix rentState bug<commit_after>/**
 * Created by 国正 on 2014/7/11.
 */
var request = require('request');
var iconv = require('iconv-lite');
var cheerio = require('cheerio');

var session;

module.exports = function getRent(session, callback) {
    if (session == '' || session == null) {
        callback('Not Login');
    }
    request
    (
        {
            uri: 'http://222.24.3.7:8080/opac_two/reader/jieshuxinxi.jsp',
            encoding: null,
            headers: {
                Cookie: session
            }
        }, function (err, res, body) {
            if (err) {
                callback(err);
            }
            var rawHtml = (iconv.decode(body, "GB2312")).replace(/td_color_2/g, 'td_color_1');

            var $ = cheerio.load(rawHtml);

            if ($('#no_text').html() != null) {
                callback('null');
            }

            var rentData = [];
            var department_id, library_id, state;

            $('TR[class="td_color_1"]').each(function (i) {
                var temp = $(this).children();
                state = RTrim($(temp[5]).text());
                var canRenew = true;
                if (RTrim($(temp[5]).text()) == '本馆续借')
                    canRenew = false;
                var jsRaw = temp[7].children[0].attribs['onclick'];
                if (jsRaw == undefined) {
                    jsRaw = temp[7].children[0].children[0].data;
                    if (jsRaw == '过期暂停') {
                        canRenew = false;
                        department_id = null;
                        library_id = null;
                        state = '过期暂停';
                    }
                } else {
                    jsRaw = jsRaw.substr(jsRaw.indexOf('Renew') + 6).replace(/\);/g, '').replace(/\'/g, '');
                    var jsInfo = jsRaw.split(',');
                    department_id = jsInfo[1];
                    library_id = jsInfo[2];
                }
                rentData[i] =
                {
                    'Title': RTrim($(temp[2]).text()),
                    'Barcode': RTrim($(temp[3]).text()),
                    'Department': RTrim($(temp[4]).text()),
                    'State': state,
                    'Date': RTrim($(temp[6]).text().replace(/\//g, '')),
                    'CanRenew': canRenew,
                    'Depaertment_id': department_id,
                    'Library_id': library_id
                };

            });

            callback(rentData);
        }
    )
};

function RTrim(str) {
    return str.replace(/(\s*$)/g, "");
}<|endoftext|>


<commit_before>module.exports = function(grunt) {
  grunt.initConfig({

    pkg: grunt.file.readJSON('package.json'),

    concat: {
      options: {
        separator: ';'
      },
      bundle: {
        src: [
          'cronenberg/static/js/jquery-1.11.0.min.js',
          'cronenberg/static/js/moment.min.js',
          'cronenberg/static/js/markdown.min.js',
          'cronenberg/static/js/bean.min.js',
          'cronenberg/static/js/URI.min.js',
          'cronenberg/static/js/handlebars.min.js',
          'cronenberg/static/js/bootstrap.min.js',
          'cronenberg/static/js/bootbox.min.js',
          'cronenberg/static/js/d3.min.js',
          'cronenberg/static/js/nv.d3.min.js',
          'cronenberg/static/js/tagmanager.js',
          'cronenberg/static/js/bootstrap-editable.min.js'
        ],
        dest: 'cronenberg/static/bundle.js'
      },
      app: {
        src: [
          'js/app/cronenberg.js',
          'js/app/cronenberg-queries.js',
          'js/app/cronenberg-charts.js',
          'js/app/cronenberg-dashboards.js',
          'js/app/cronenberg-templates.js',
          'js/core.js',
          'js/models/item.js',
          'js/models/container.js',
          'js/models/factory.js',
          'js/models/thresholds.js',
          'js/models/tag.js',
          'js/models/dashboard.js',
          'js/models/dashboard-definition.js',
          'js/models/presentations/chart.js',
          'js/models/presentations/singlestat.js',
          'js/models/presentations/jumbotron-singlestat.js',
          'js/models/presentations/summation-table.js',
          'js/models/presentations/simple-time-series.js',
          'js/models/presentations/standard-time-series.js',
          'js/models/presentations/stacked-area-chart.js',
          'js/models/presentations/donut-chart.js',
          'js/models/presentations/single-graph.js',
          'js/models/layouts/heading.js',
          'js/models/layouts/markdown.js',
          'js/models/layouts/cell.js',
          'js/models/layouts/row.js',
          'js/models/layouts/separator.js',
          'js/models/layouts/section.js',
          'js/models/layouts/dashboard-definition.js',
        ],
        dest: 'cronenberg/static/app.js'
      }
    },
    handlebars: {
    },
    watch: {
      files: [
        'cronenberg/static/cron*.js',
        'cronenberg/static/js/**/*.js'
      ],
      tasks: ['concat']
    }
  });

  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-handlebars');

  grunt.registerTask('default', ['handlebars', 'concat']);
}
<commit_msg>Update filenames<commit_after>module.exports = function(grunt) {
  grunt.initConfig({

    pkg: grunt.file.readJSON('package.json'),

    concat: {
      options: {
        separator: ';'
      },
      bundle: {
        src: [
          'cronenberg/static/js/jquery-1.11.0.min.js',
          'cronenberg/static/js/moment.min.js',
          'cronenberg/static/js/markdown.min.js',
          'cronenberg/static/js/bean.min.js',
          'cronenberg/static/js/URI.min.js',
          'cronenberg/static/js/handlebars.min.js',
          'cronenberg/static/js/bootstrap.min.js',
          'cronenberg/static/js/bootbox.min.js',
          'cronenberg/static/js/d3.min.js',
          'cronenberg/static/js/nv.d3.min.js',
          'cronenberg/static/js/tagmanager.js',
          'cronenberg/static/js/bootstrap-editable.min.js'
        ],
        dest: 'cronenberg/static/bundle.js'
      },
      app: {
        src: [
          'js/app/cronenberg.js',
          'js/app/cronenberg-queries.js',
          'js/app/cronenberg-charts.js',
          'js/app/cronenberg-dashboards.js',
          'js/app/cronenberg-templates.js',
          'js/core.js',
          'js/models/item.js',
          'js/models/container.js',
          'js/models/factory.js',
          'js/models/thresholds.js',
          'js/models/tag.js',
          'js/models/dashboard.js',
          'js/models/dashboard_definition.js',
          'js/models/presentations/chart.js',
          'js/models/presentations/singlestat.js',
          'js/models/presentations/jumbotron_singlestat.js',
          'js/models/presentations/summation_table.js',
          'js/models/presentations/simple_time_series.js',
          'js/models/presentations/standard_time_series.js',
          'js/models/presentations/stacked_area_chart.js',
          'js/models/presentations/donut_chart.js',
          'js/models/presentations/single_graph.js',
          'js/models/layouts/heading.js',
          'js/models/layouts/markdown.js',
          'js/models/layouts/cell.js',
          'js/models/layouts/row.js',
          'js/models/layouts/separator.js',
          'js/models/layouts/section.js',
          'js/models/layouts/dashboard_definition.js'
        ],
        dest: 'cronenberg/static/app.js'
      }
    },
    handlebars: {
    },
    watch: {
      files: [
        'cronenberg/static/cron*.js',
        'cronenberg/static/js/**/*.js'
      ],
      tasks: ['concat']
    }
  });

  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-handlebars');

  grunt.registerTask('default', ['handlebars', 'concat']);
}
<|endoftext|>


<commit_before>var ce = require('cloneextend');

function battleUnitData() {
    var that = {};
    var unitData = {};

    (function(){
        unitData['granBraver'] = {
            name: 'グランブレイバー',
            pictName: 'GranBraver.PNG',
            hp: 3200,
            defense : 1000,
            speed: 230,
            active: 0,
            battery: 5,
            overHeatFlag : false,
            skillPoint : 1,
            weapons: {
                1: {name: 'バスターナックル', power: 800},
                2: {name: 'バスターナックル', power: 1100},
                3: {name: 'バスターナックル', power: 1600},
                4: {name: 'バスターナックル', power: 2100},
                5: {name: 'バスターナックル', power: 2800}
            },
            pilot : {
                type : 'quickCharge',
                battery : 3,
                hp : 0,
                power : 0,
                defense : 0,
                speed : 0
            },
            ability: {
                type: 'none'
            }
        };

        unitData['granBraverSpeed1000'] = ce.clone(unitData['granBraver']);
        unitData['granBraverSpeed1000'].speed = 1000;

        unitData['granBraverQuickCharge'] = ce.clone(unitData['granBraver']);
        unitData['granBraverQuickCharge'].pilot =
        {
            type : 'quickCharge',
            battery : 3,
            hp : 0,
            power : 0,
            defense : 0,
            speed : 0
        };

        unitData['granBraverStunAttack'] = ce.clone(unitData['granBraver']);
        unitData['granBraverStunAttack'].pilot =
        {
            type : 'stunAttack',
            hp : 0,
            power : 0,
            defense : 0,
            speed : 0
        }

        unitData['granBraverGuardBreak'] = ce.clone(unitData['granBraver']);
        unitData['granBraverGuardBreak'].pilot =
        {
            type : 'guardBreak',
            value : 300,
            hp : 0,
            power : 0,
            defense : 0,
            speed : 0
        }

        unitData['granBraverSuperGuard'] = ce.clone(unitData['granBraver']);
        unitData['granBraverSuperGuard'].pilot =
        {
            type : 'superGuard',
            value : 0.5,
            hp : 0,
            power : 0,
            defense : 0,
            speed : 0
        }

        unitData['granBraverBoostBattery'] = ce.clone(unitData['granBraver']);
        unitData['granBraverBoostBattery'].ability =
        {
            type : 'boostBattery',
            battery: 5,
            threshold: 0.3
        }

        unitData['granBraverBoostActive'] = ce.clone(unitData['granBraver']);
        unitData['granBraverBoostActive'].ability =
        {
            type : 'boostActive',
            active : 0.3,
            threshold: 0.3
        }

        unitData['granBraverBoostPower'] = ce.clone(unitData['granBraver']);
        unitData['granBraverBoostPower'].ability =
        {
            type : 'boostPower',
            power : 100,
            threshold: 0.3
        }

        unitData['landozer'] = {
            name: 'ランドーザ',
            pictName: 'Landozer.PNG',
            hp: 4700,
            defense : 1000,
            speed: 150,
            active: 0,
            battery: 5,
            overHeatFlag : false,
            skillPoint : 1,
            weapons: {
                1: {name: 'ブレイクパンチ', power: 1200},
                2: {name: 'ブレイクパンチ', power: 1700},
                3: {name: 'ブレイクパンチ', power: 2300},
                4: {name: 'ブレイクパンチ', power: 2900},
                5: {name: 'ブレイクパンチ', power: 3800}
            },
            pilot : {
                type : 'quickCharge',
                battery : 3,
                hp : 0,
                power : 0,
                defense : 500,
                speed : 0
            },
            ability: {
                type: 'none'
            }
        };

        unitData['landozerRecoverHp'] = ce.clone(unitData['landozer']);
        unitData['landozerRecoverHp'].hp = 3500;
        unitData['landozerRecoverHp'].pilot =
        {
            type : 'recoverHp',
            value : 0.5,
            hp : 0,
            power : 0,
            defense : 0,
            speed : 0
        };

        unitData['landozerHyperArmor'] = ce.clone(unitData['landozer']);
        unitData['landozerHyperArmor'].ability = {
            type: 'hyperArmor',
            value : 0
        };

        unitData['landozerHyperShield'] = ce.clone(unitData['landozer']);
        unitData['landozerHyperShield'].ability = {
            type: 'hyperShield',
            value : 1000
        };

        unitData['zeroBraver'] = {
            name : 'ゼロブレイバー',
            pictName : 'ZeroBraver.PNG',
            hp : 4200,
            defense : 1000,
            speed : 230,
            active : 0,
            battery : 5,
            overHeatFlag : false,
            skillPoint : 1,
            weapons : {
                1 : {name : 'バスターナックル',power : 800},
                2 : {name : 'バスターナックル',power : 1100},
                3 : {name : 'バスターナックル',power : 1600},
                4 : {name : 'バスターナックル',power : 2100},
                5 : {name : 'バスターナックル',power : 2800}
            },
            pilot : {
                type : 'quickCharge',
                battery : 3,
                hp : 0,
                power : 0,
                defense : 0,
                speed : 0
            },
            ability: {
                type: 'none'
            }
        };
    })()

    that.get = function(unitId){
        return ce.clone(unitData[unitId]);
    }

    return that;
}

module.exports = battleUnitData;<commit_msg>戦闘テストの一時変数追加を共通化した<commit_after>var ce = require('cloneextend');

function battleUnitData() {
    var that = {};
    var unitData = {};

    function addData(id,data){
        data.active = 0;
        data.battery = 5;
        data.overHeatFlag = false;
        data.skillPoint = 1;
        unitData[id] = data;
    }

    (function(){
        var granBraver = {
            name: 'グランブレイバー',
            pictName: 'GranBraver.PNG',
            hp: 3200,
            defense : 1000,
            speed: 230,
            weapons: {
                1: {name: 'バスターナックル', power: 800},
                2: {name: 'バスターナックル', power: 1100},
                3: {name: 'バスターナックル', power: 1600},
                4: {name: 'バスターナックル', power: 2100},
                5: {name: 'バスターナックル', power: 2800}
            },
            pilot : {
                type : 'quickCharge',
                battery : 3,
                hp : 0,
                power : 0,
                defense : 0,
                speed : 0
            },
            ability: {
                type: 'none'
            }
        }
        addData('granBraver',granBraver);

        addData('granBraverSpeed1000',ce.cloneextend(granBraver,{
            speed : 1000
        }));

        addData('granBraverQuickCharge',ce.cloneextend(granBraver,{
            pilot : {
                type : 'quickCharge',
                battery : 3,
                hp : 0,
                power : 0,
                defense : 0,
                speed : 0
            }
        }));

        addData('granBraverStunAttack',ce.cloneextend(granBraver,{
            pilot : {
                type : 'stunAttack',
                hp : 0,
                power : 0,
                defense : 0,
                speed : 0
            }
        }));

        addData('granBraverGuardBreak',ce.cloneextend(granBraver,{
            pilot : {
                type : 'guardBreak',
                value : 300,
                hp : 0,
                power : 0,
                defense : 0,
                speed : 0
            }
        }));

        addData('granBraverSuperGuard',ce.cloneextend(granBraver,{
            pilot : {
                type : 'superGuard',
                value : 0.5,
                hp : 0,
                power : 0,
                defense : 0,
                speed : 0
            }
        }));

        addData('granBraverBoostBattery',ce.cloneextend(granBraver,{
            ability: {
                type : 'boostBattery',
                battery: 5,
                threshold: 0.3
            }
        }));

        addData('granBraverBoostActive',ce.cloneextend(granBraver,{
            ability : {
                type : 'boostActive',
                active : 0.3,
                threshold: 0.3
            }
        }));

        addData('granBraverBoostPower',ce.cloneextend(granBraver,{
            ability: {
                type : 'boostPower',
                power : 100,
                threshold: 0.3
            }
        }));

        var landozer =  {
            name: 'ランドーザ',
            pictName: 'Landozer.PNG',
            hp: 4700,
            defense : 1000,
            speed: 150,
            weapons: {
                1: {name: 'ブレイクパンチ', power: 1200},
                2: {name: 'ブレイクパンチ', power: 1700},
                3: {name: 'ブレイクパンチ', power: 2300},
                4: {name: 'ブレイクパンチ', power: 2900},
                5: {name: 'ブレイクパンチ', power: 3800}
            },
            pilot : {
                type : 'quickCharge',
                battery : 3,
                hp : 0,
                power : 0,
                defense : 500,
                speed : 0
            },
            ability: {
                type: 'none'
            }
        }
        addData('landozer',landozer);

        addData('landozerRecoverHp',ce.cloneextend(landozer,{
            hp : 3500,
            pilot: {
                type : 'recoverHp',
                value : 0.5,
                hp : 0,
                power : 0,
                defense : 0,
                speed : 0
            }
        }));

        addData('landozerHyperArmor',ce.cloneextend(landozer,{
            ability : {
                type: 'hyperArmor',
                value : 0
            }
        }));

        addData('landozerHyperShield',ce.cloneextend(landozer,{
            ability: {
                type: 'hyperShield',
                value : 1000
            }
        }));

        var zeroBraver = {
            name : 'ゼロブレイバー',
            pictName : 'ZeroBraver.PNG',
            hp : 4200,
            defense : 1000,
            speed : 230,
            active : 0,
            battery : 5,
            overHeatFlag : false,
            skillPoint : 1,
            weapons : {
                1 : {name : 'バスターナックル',power : 800},
                2 : {name : 'バスターナックル',power : 1100},
                3 : {name : 'バスターナックル',power : 1600},
                4 : {name : 'バスターナックル',power : 2100},
                5 : {name : 'バスターナックル',power : 2800}
            },
            pilot : {
                type : 'quickCharge',
                battery : 3,
                hp : 0,
                power : 0,
                defense : 0,
                speed : 0
            },
            ability: {
                type: 'none'
            }
        };
        addData('zeroBraver',zeroBraver);
    })()

    that.get = function(unitId){
        return ce.clone(unitData[unitId]);
    }

    return that;
}

module.exports = battleUnitData;<|endoftext|>


<commit_before>var TheBraverest = TheBraverest || {}

const API_PREFIX = '/api/';

function apiPath(controller, actionName) {
    return API_PREFIX +
        controller + '/' +
        (actionName ? actionName : '');
}

//API Controllers
TheBraverest.BraveChampionController = 'BraveChampion';

//API Methods
TheBraverest.actionGetBraveChampion = {
    url: apiPath(TheBraverest.BraveChampionController),
    method: 'GET'
};

//Location
TheBraverest.getLocationBuildIndex = function (version, seed) {

    return 'http://TheBraverest.com/Build?verion=' + version + '&seed=' + seed;
}

TheBraverest.getLocationDownloadJsonFile = function (version, seed) {
    return braveBuildURITemplate(version, seed, 'file');
};

TheBraverest.getLocationDownloadZipFile = function (version, seed) {
    return braveBuildURITemplate(version, seed, 'zip');
};

function braveBuildURITemplate(version, seed, format) {
    return "http://www.thebraverest.com/api/ItemSet/" +
    version + "/" + seed +
        (format ? "?format=" + format + "" : "");
}
<commit_msg>fixing things<commit_after>var TheBraverest = TheBraverest || {}

const API_PREFIX = '/api/';

function apiPath(controller, actionName) {
    return API_PREFIX +
        controller + '/' +
        (actionName ? actionName : '');
}

//API Controllers
TheBraverest.BraveChampionController = 'BraveChampion';

//API Methods
TheBraverest.actionGetBraveChampion = {
    url: apiPath(TheBraverest.BraveChampionController),
    method: 'GET'
};

//Location
TheBraverest.getLocationBuildIndex = function (version, seed) {

    return 'http://TheBraverest.com/Build?version=' + version + '&seed=' + seed;
}

TheBraverest.getLocationDownloadJsonFile = function (version, seed) {
    return braveBuildURITemplate(version, seed, 'file');
};

TheBraverest.getLocationDownloadZipFile = function (version, seed) {
    return braveBuildURITemplate(version, seed, 'zip');
};

function braveBuildURITemplate(version, seed, format) {
    return "http://www.thebraverest.com/api/ItemSet/" +
    version + "/" + seed +
        (format ? "?format=" + format + "" : "");
}
<|endoftext|>