<commit_before>(function() {
  'use strict';

  let _defaults = {
    displayLength: Infinity,
    inDuration: 300,
    outDuration: 375,
    className: undefined,
    completeCallback: undefined,
    activationPercent: 0.8
  };

  class Toast {
    constructor(message, displayLength, className, completeCallback) {
      if (!message) {
        return;
      }

      this.options = {
        displayLength: displayLength,
        className: className,
        completeCallback: completeCallback
      };
      this.options = $.extend({}, Toast.defaults, this.options);
      this.message = message;
      this.panning = false;
      this.timeRemaining = this.options.displayLength;

      if (Toast._toasts.length === 0) {
        Toast._createContainer();
      }

      // Create new toast
      Toast._toasts.push(this);
      let toastElement = this.createToast();
      toastElement.M_Toast = this;
      this.el = toastElement;
      this._animateIn();
      this.setTimer();
    }

    static get defaults() {
      return _defaults;
    }

    static _createContainer() {
      let container = document.createElement('div');
      container.setAttribute('id', 'toast-container');

      // Add event handler
      container.addEventListener('touchstart', Toast._onDragStart);
      container.addEventListener('touchmove', Toast._onDragMove);
      container.addEventListener('touchend', Toast._onDragEnd);

      container.addEventListener('mousedown', Toast._onDragStart);
      document.addEventListener('mousemove', Toast._onDragMove);
      document.addEventListener('mouseup', Toast._onDragEnd);

      document.body.appendChild(container);
      Toast._container = container;
    }

    static _removeContainer() {
      // Add event handler
      document.removeEventListener('mousemove', Toast._onDragMove);
      document.removeEventListener('mouseup', Toast._onDragEnd);

      Toast._container.parentNode.removeChild(Toast._container);
      Toast._container = null;
    }

    static _onDragStart(e) {
      if (e.target && $(e.target).closest('.toast').length) {
        let $toast = $(e.target).closest('.toast');
        let toast = $toast[0].M_Toast;
        toast.panning = true;
        toast.el.classList.add('panning');
        Toast._draggedToast = toast;
        $toast[0].style.transition = null;
        toast.startingXPos = Toast._xPos(e);
        toast.time = Date.now();
        toast.xPos = Toast._xPos(e);
      }
    }

    static _onDragMove(e) {
      if (!!Toast._draggedToast) {
        e.preventDefault();
        let toast = Toast._draggedToast;
        toast.deltaX = Math.abs(toast.xPos - Toast._xPos(e));
        toast.xPos = Toast._xPos(e);
        toast.velocityX = toast.deltaX / (Date.now() - toast.time);
        toast.time = Date.now();

        let totalDeltaX = toast.xPos - toast.startingXPos;
        let activationDistance =
            toast.el.offsetWidth * toast.options.activationPercent;
        toast.el.style.transform = `translateX(${totalDeltaX}px)`;
        toast.el.style.opacity = 1-Math.abs(totalDeltaX / activationDistance);
      }
    }

    static _onDragEnd(e) {
      if (!!Toast._draggedToast) {
        let toast = Toast._draggedToast;
        toast.panning = false;
        toast.el.classList.remove('panning');

        let totalDeltaX = toast.xPos - toast.startingXPos;
        let activationDistance =
            toast.el.offsetWidth * toast.options.activationPercent;
        let shouldBeDismissed = Math.abs(totalDeltaX) > activationDistance ||
            toast.velocityX > 1;
        if (shouldBeDismissed) {
          toast.wasSwiped = true;
          toast.remove();

        } else {
          toast.el.style.transition = 'transform .2s, opacity .2s';
          toast.el.style.transform = null;
          toast.el.style.opacity = null;
        }
        Toast._draggedToast = null;
      }
    }

    /**
     * Get x position of mouse or touch event
     * @param {Event} e
     */
    static _xPos(e) {
      if (e.targetTouches && (e.targetTouches.length >= 1)) {
        return e.targetTouches[0].clientX;
      }
      // mouse event
      return e.clientX;
    }

    /**
     * Remove all toasts
     */
    static removeAll() {
      for(let toastIndex in Toast._toasts) {
        Toast._toasts[toastIndex].remove();
      }
    }

    createToast() {
      let toast = document.createElement('div');
      toast.classList.add('toast');

      // Add custom classes onto toast
      if (this.options.className) {
        let classes = this.options.className.split(' ');
        let i, count;
        for (i = 0, count = classes.length; i < count; i++) {
          toast.classList.add(classes[i]);
        }
      }

      // Set content
      if ( typeof HTMLElement === 'object' ?
           this.message instanceof HTMLElement :
           this.message && typeof this.message === 'object' &&
           this.message !== null && this.message.nodeType === 1 &&
           typeof this.message.nodeName==='string'
         ) {
        toast.appendChild(this.message);

      // Check if it is jQuery object
      } else if (this.message instanceof jQuery) {
        $(toast).append(this.message);

        // Insert as text;
      } else {
        toast.innerHTML = this.message;
      }

      // Append toasft
      Toast._container.appendChild(toast);
      return toast;
    }

    _animateIn() {
      // Animate toast in
      Vel(this.el, {top: 0,  opacity: 1 }, {
        duration: 300,
        easing: 'easeOutCubic',
        queue: false
      });
    }

    setTimer() {
      if (this.timeRemaining !== Infinity)  {
        this.counterInterval = setInterval(() => {
          // If toast is not being dragged, decrease its time remaining
          if (!this.panning) {
            this.timeRemaining -= 20;
          }

          // Animate toast out
          if (this.timeRemaining <= 0) {
            this.remove();
          }
        }, 20);
      }
    }

    remove() {
      window.clearInterval(this.counterInterval);
      let activationDistance =
          this.el.offsetWidth * this.options.activationPercent;

      if(this.wasSwiped) {
        this.el.style.transition = 'transform .05s, opacity .05s';
        this.el.style.transform = `translateX(${activationDistance}px)`;
        this.el.style.opacity = 0;
      }

      Vel(
        this.el,
        {opacity: 0, marginTop: '-40px'},
        {
          duration: this.options.outDuration,
          easing: 'easeOutExpo',
          queue: false,
          complete: () => {
            // Call the optional callback
            if(typeof(this.options.completeCallback) === 'function') {
              this.options.completeCallback();
            }
            // Remove toast from DOM
            this.el.parentNode.removeChild(this.el);
            Toast._toasts.splice(Toast._toasts.indexOf(this), 1);
            if (Toast._toasts.length === 0) {
              Toast._removeContainer();
            }
          }
        }
      );
    }
  }

  /**
   * @static
   * @memberof Toast
   */
  Toast._toasts = [];

  /**
   * @static
   * @memberof Toast
   */
  Toast._container = null;

  /**
   * @static
   * @memberof Toast
   */
  Toast._draggedToast = null;

  window.Materialize.Toast = Toast;
  window.Materialize.toast = function(message, displayLength, className, completeCallback) {
    return new Toast(message, displayLength, className, completeCallback);
  }
// };
})();
<commit_msg>Add jsdoc to toasts<commit_after>(function() {
  'use strict';

  let _defaults = {
    displayLength: Infinity,
    inDuration: 300,
    outDuration: 375,
    className: undefined,
    completeCallback: undefined,
    activationPercent: 0.8
  };

  class Toast {
    constructor(message, displayLength, className, completeCallback) {
      if (!message) {
        return;
      }

      /**
       * Options for the toast
       * @member Toast#options
       */
      this.options = {
        displayLength: displayLength,
        className: className,
        completeCallback: completeCallback
      };

      this.options = $.extend({}, Toast.defaults, this.options);
      this.message = message;

      /**
       * Describes current pan state toast
       * @type {Boolean}
       */
      this.panning = false;

      /**
       * Time remaining until toast is removed
       */
      this.timeRemaining = this.options.displayLength;

      if (Toast._toasts.length === 0) {
        Toast._createContainer();
      }

      // Create new toast
      Toast._toasts.push(this);
      let toastElement = this.createToast();
      toastElement.M_Toast = this;
      this.el = toastElement;
      this._animateIn();
      this.setTimer();
    }

    static get defaults() {
      return _defaults;
    }

    /**
     * Append toast container and add event handlers
     */
    static _createContainer() {
      let container = document.createElement('div');
      container.setAttribute('id', 'toast-container');

      // Add event handler
      container.addEventListener('touchstart', Toast._onDragStart);
      container.addEventListener('touchmove', Toast._onDragMove);
      container.addEventListener('touchend', Toast._onDragEnd);

      container.addEventListener('mousedown', Toast._onDragStart);
      document.addEventListener('mousemove', Toast._onDragMove);
      document.addEventListener('mouseup', Toast._onDragEnd);

      document.body.appendChild(container);
      Toast._container = container;
    }

    /**
     * Remove toast container and event handlers
     */
    static _removeContainer() {
      // Add event handler
      document.removeEventListener('mousemove', Toast._onDragMove);
      document.removeEventListener('mouseup', Toast._onDragEnd);

      Toast._container.parentNode.removeChild(Toast._container);
      Toast._container = null;
    }

    /**
     * Begin drag handler
     * @param {Event} e
     */
    static _onDragStart(e) {
      if (e.target && $(e.target).closest('.toast').length) {
        let $toast = $(e.target).closest('.toast');
        let toast = $toast[0].M_Toast;
        toast.panning = true;
        Toast._draggedToast = toast;
        toast.el.classList.add('panning');
        toast.el.style.transition = null;
        toast.startingXPos = Toast._xPos(e);
        toast.time = Date.now();
        toast.xPos = Toast._xPos(e);
      }
    }

    /**
     * Drag move handler
     * @param {Event} e
     */
    static _onDragMove(e) {
      if (!!Toast._draggedToast) {
        e.preventDefault();
        let toast = Toast._draggedToast;
        toast.deltaX = Math.abs(toast.xPos - Toast._xPos(e));
        toast.xPos = Toast._xPos(e);
        toast.velocityX = toast.deltaX / (Date.now() - toast.time);
        toast.time = Date.now();

        let totalDeltaX = toast.xPos - toast.startingXPos;
        let activationDistance =
            toast.el.offsetWidth * toast.options.activationPercent;
        toast.el.style.transform = `translateX(${totalDeltaX}px)`;
        toast.el.style.opacity = 1-Math.abs(totalDeltaX / activationDistance);
      }
    }

    /**
     * End drag handler
     * @param {Event} e
     */
    static _onDragEnd(e) {
      if (!!Toast._draggedToast) {
        let toast = Toast._draggedToast;
        toast.panning = false;
        toast.el.classList.remove('panning');

        let totalDeltaX = toast.xPos - toast.startingXPos;
        let activationDistance =
            toast.el.offsetWidth * toast.options.activationPercent;
        let shouldBeDismissed = Math.abs(totalDeltaX) > activationDistance ||
            toast.velocityX > 1;

        // Remove toast
        if (shouldBeDismissed) {
          toast.wasSwiped = true;
          toast.remove();

        // Animate toast back to original position
        } else {
          toast.el.style.transition = 'transform .2s, opacity .2s';
          toast.el.style.transform = null;
          toast.el.style.opacity = null;
        }
        Toast._draggedToast = null;
      }
    }

    /**
     * Get x position of mouse or touch event
     * @param {Event} e
     */
    static _xPos(e) {
      if (e.targetTouches && (e.targetTouches.length >= 1)) {
        return e.targetTouches[0].clientX;
      }
      // mouse event
      return e.clientX;
    }

    /**
     * Remove all toasts
     */
    static removeAll() {
      for(let toastIndex in Toast._toasts) {
        Toast._toasts[toastIndex].remove();
      }
    }

    /**
     * Create toast and append it to toast container
     */
    createToast() {
      let toast = document.createElement('div');
      toast.classList.add('toast');

      // Add custom classes onto toast
      if (this.options.className) {
        let classes = this.options.className.split(' ');
        let i, count;
        for (i = 0, count = classes.length; i < count; i++) {
          toast.classList.add(classes[i]);
        }
      }

      // Set content
      if ( typeof HTMLElement === 'object' ?
           this.message instanceof HTMLElement :
           this.message && typeof this.message === 'object' &&
           this.message !== null && this.message.nodeType === 1 &&
           typeof this.message.nodeName==='string'
         ) {
        toast.appendChild(this.message);

      // Check if it is jQuery object
      } else if (this.message instanceof jQuery) {
        $(toast).append(this.message);

        // Insert as text;
      } else {
        toast.innerHTML = this.message;
      }

      // Append toasft
      Toast._container.appendChild(toast);
      return toast;
    }

    /**
     * Animate in toast
     */
    _animateIn() {
      // Animate toast in
      Vel(this.el, {top: 0,  opacity: 1 }, {
        duration: 300,
        easing: 'easeOutCubic',
        queue: false
      });
    }

    /**
     * Create setInterval which automatically removes toast when timeRemaining >= 0
     * has been reached
     */
    setTimer() {
      if (this.timeRemaining !== Infinity)  {
        this.counterInterval = setInterval(() => {
          // If toast is not being dragged, decrease its time remaining
          if (!this.panning) {
            this.timeRemaining -= 20;
          }

          // Animate toast out
          if (this.timeRemaining <= 0) {
            this.remove();
          }
        }, 20);
      }
    }

    /**
     * Dismiss toast with animation
     */
    remove() {
      window.clearInterval(this.counterInterval);
      let activationDistance =
          this.el.offsetWidth * this.options.activationPercent;

      if(this.wasSwiped) {
        this.el.style.transition = 'transform .05s, opacity .05s';
        this.el.style.transform = `translateX(${activationDistance}px)`;
        this.el.style.opacity = 0;
      }

      Vel(
        this.el,
        {opacity: 0, marginTop: '-40px'},
        {
          duration: this.options.outDuration,
          easing: 'easeOutExpo',
          queue: false,
          complete: () => {
            // Call the optional callback
            if(typeof(this.options.completeCallback) === 'function') {
              this.options.completeCallback();
            }
            // Remove toast from DOM
            this.el.parentNode.removeChild(this.el);
            Toast._toasts.splice(Toast._toasts.indexOf(this), 1);
            if (Toast._toasts.length === 0) {
              Toast._removeContainer();
            }
          }
        }
      );
    }
  }

  /**
   * @static
   * @memberof Toast
   * @type {Array.<Toast>}
   */
  Toast._toasts = [];

  /**
   * @static
   * @memberof Toast
   */
  Toast._container = null;

  /**
   * @static
   * @memberof Toast
   * @type {Toast}
   */
  Toast._draggedToast = null;

  window.Materialize.Toast = Toast;
  window.Materialize.toast = function(message, displayLength, className, completeCallback) {
    return new Toast(message, displayLength, className, completeCallback);
  }
})();
<|endoftext|>


<commit_before>Template.user.helpers = ({
  userId: function() {
    var controller = User.controller();
    return controller.state.get('userId');
  }
})

Template.user.events = ({

})

Template.user.rendered = function() {
  console.log(this);
  Session.set('user', this.data)
  Session.set('wishList', Wishlists.findOne({
    'owner': this.data._id
  }))
}<commit_msg>semicolons<commit_after>Template.user.helpers = ({
  userId: function() {
    var controller = User.controller();
    return controller.state.get('userId');
  }
});

Template.user.events = ({

});

Template.user.rendered = function() {
  console.log(this);
  Session.set('user', this.data);
  Session.set('wishList', Wishlists.findOne({
    'owner': this.data._id
  }));
};<|endoftext|>


<commit_before>const expect = require('chai').expect;
const std = require('../../src/index');

//TODO: WIP
describe('薪資給付', () => {
  describe('月薪', () => {
    it('以月薪 36,000 元計算，平均時薪為 150 元', () => {
      let result = std.hourlySalary(36000);
      expect(result.value).eq(150);
      expect(result.reference[0].id).eq('勞動 2字第 0960130677 號函');
      // https://laws.mol.gov.tw/FLAW/FLAWDOC03.aspx?datatype=etype&lc1=%5bc%5d%E5%8B%9E%E5%8B%95%E5%9F%BA%E6%BA%96%E6%B3%95%2c24&cnt=37&recordno=10
    });

    describe('加班費', () => {
      describe('紀念日、節日、勞動節 (holiday)', () => {

      });

      describe('例假日 (regular leave)', () => {
        it('因天災、事變或突發事件，雇主認有繼續工作之必要時，徵得勞工同意後，' +
          '工資加倍發給。月薪制勞工，平均時薪 150 元並工作 2 小時，' +
          '加給工資 1200 元（勞基法 39, 40 條），額外休假一天', () => {
          const accident = true;
          const consent = true;
          let result = std.overtimePay(150, 2, std.REGULAR_LEAVE, accident, consent);
          expect(result.value).eq(1200);
          expect(result.extraLeave.value).eq(1);
          expect(result.extraLeave.unit).eq('day');
          expect(result.reference[0].id).eq('LSA-39');
          expect(result.reference[1].id).eq('LSA-40');
          //https://laws.mol.gov.tw/FLAW/FLAWDOC03.aspx?datatype=etype&lc1=%5bc%5d%E5%8B%9E%E5%8B%95%E5%9F%BA%E6%BA%96%E6%B3%95%2c40&cnt=19&recordno=10
          expect(result.reference[2].id).eq('台八十三勞動一字第 102498 號函');
        });

        it('若「無」天災、事變或突發事件，但雇主要求於例假日工作並且徵得勞工同意時，此為違法加班' +
          '工資加倍發給。月薪制勞工，平均時薪 150 元並工作 2 小時，' +
          '加給工資 1200 元（勞基法 39, 40 條），額外休假一天', () => {
          const accident = false;
          const consent = true;
          let result = std.overtimePay(150, 2, std.REGULAR_LEAVE, accident, consent);
          /*
          expect result looks like this:
          {
            status: std.ILLEGAL,
            value: 1200,
            extraLeave: {
              value: 1,
              unit: 'day'
            },
            reference: [
              {
                id: 'LSA-39',
                description: '第三十六條所定之例假、休息日、第....',
                url: 'http://laws.mol.gov.tw/FLAW/FLAWDOC01.aspx?lsid=FL014930&flno=39'
              },
              { id: 'LSA-40' },
              { id: 'LSA-79' },
              { id: '台八十三勞動一字第 102498 號函' }
            ],
            fines: [
              { min: 20000, max: 1000000, according: 'LSA-79' }
            ]
          };
          */
          expect(result.value).eq(1200);
          expect(result.extraLeave.value).eq(1);
          expect(result.extraLeave.unit).eq('day');
          expect(result.reference[0].id).eq('LSA-39');
          expect(result.reference[1].id).eq('LSA-40');
          expect(result.reference[2].id).eq('LSA-79');

          // https://laws.mol.gov.tw/FLAW/FLAWDOC03.aspx?datatype=etype&lc1=%5bc%5d%E5%8B%9E%E5%8B%95%E5%9F%BA%E6%BA%96%E6%B3%95%2c40&cnt=19&recordno=10
          expect(result.reference[3].id).eq('台八十三勞動一字第 102498 號函');
          expect(result.status).eq(std.ILLEGAL);

          // 79 條，罰則介於二萬到一百萬
          expect(result.fines[0].according).eq('LSA-79');
          expect(result.fines[0].min).eq(20000);
          expect(result.fines[0].max).eq(1000000);
        });
      });

      describe('休息日 (rest day)', () => {
        it('月薪制勞工, 平均時薪 150 工作 1 小時，實領加班費為 900 元（勞基法 24 條）', () => {
          let result = std.overtimePay(150, 1, std.REST_DAY);
          expect(result.value).eq(900);
          expect(result.reference[0].id).eq('LSA-24');
        });

        it('月薪制勞工, 平均時薪 150 工作 2 小時，實領加班費為 900 元（勞基法 24 條）', () => {
          let result = std.overtimePay(150, 2, std.REST_DAY);
          expect(result.value).eq(900);
          expect(result.reference[0].id).eq('LSA-24');
        });

        it('月薪制勞工, 平均時薪 150 工作 4 小時，實領加班費為 900 元（勞基法 24 條）', () => {
          let result = std.overtimePay(150, 4, std.REST_DAY);
          expect(result.value).eq(900);
          expect(result.reference[0].id).eq('LSA-24');
        });

        it('月薪制勞工, 平均時薪 150 工作 5 小時，實領加班費為 1900 元（勞基法 24 條）', () => {
          let result = std.overtimePay(150, 5, std.REST_DAY);
          expect(result.value).eq(1900);
          expect(result.reference[0].id).eq('LSA-24');
        });

        it('月薪制勞工, 平均時薪 150 工作 5.5 個小時，實領加班費為 1900 元（勞基法 24 條）', () => {
          let result = std.overtimePay(150, 5.5, std.REST_DAY);
          expect(result.value).eq(1900);
          expect(result.reference[0].id).eq('LSA-24');
        });

        it('月薪制勞工, 平均時薪 150 工作 8 個小時，實領加班費為 1900 元（勞基法 24 條）', () => {
          let result = std.overtimePay(150, 8, std.REST_DAY);
          expect(result.value).eq(1900);
          expect(result.reference[0].id).eq('LSA-24');
        });

        it('月薪制勞工, 平均時薪 150 工作 8.5 個小時，實領加班費為 2900 元（勞基法 24 條）', () => {
          let result = std.overtimePay(150, 8.5, std.REST_DAY);
          expect(result.value).eq(2900);
          expect(result.reference[0].id).eq('LSA-24');
        });

        it('月薪制勞工, 平均時薪 150 工作 10 個小時，實領加班費為 2900 元（勞基法 24 條）', () => {
          let result = std.overtimePay(150, 10, std.REST_DAY);
          expect(result.value).eq(2900);
          expect(result.reference[0].id).eq('LSA-24');
        });

        it('月薪制勞工, 平均時薪 150 工作 12 個小時，實領加班費為 2900 元（勞基法 24 條）', () => {
          let result = std.overtimePay(150, 12, std.REST_DAY);
          expect(result.value).eq(2900);
          expect(result.reference[0].id).eq('LSA-24');
        });

        it('月薪制勞工, 平均時薪 150 工作 13 個小時，結果回傳不合法（勞基法 32 條）', () => {
          let result = std.overtimePay(150, 13, std.REST_DAY);
          expect(result.status).eq(std.ILLEGAL);
          expect(result.reference[0].id).eq('LSA-32');
        });
      });
    });
  });

  describe('時薪制', () => {
    it('基本時薪 120 元，工作 8 小時因為 960 元', () => {
      pass();
    });
  });
});
<commit_msg>Fix test case for illegal overtime work on regular leave day<commit_after>const expect = require('chai').expect;
const std = require('../../src/index');

//TODO: WIP
describe('薪資給付', () => {
  describe('月薪', () => {
    it('以月薪 36,000 元計算，平均時薪為 150 元', () => {
      let result = std.hourlySalary(36000);
      expect(result.value).eq(150);
      expect(result.reference[0].id).eq('勞動 2字第 0960130677 號函');
      // https://laws.mol.gov.tw/FLAW/FLAWDOC03.aspx?datatype=etype&lc1=%5bc%5d%E5%8B%9E%E5%8B%95%E5%9F%BA%E6%BA%96%E6%B3%95%2c24&cnt=37&recordno=10
    });

    describe('加班費', () => {
      describe('紀念日、節日、勞動節 (holiday)', () => {

      });

      describe('例假日 (regular leave)', () => {
        it('因天災、事變或突發事件，雇主認有繼續工作之必要時，徵得勞工同意後，' +
          '工資加倍發給。月薪制勞工，平均時薪 150 元並工作 2 小時，' +
          '加給工資 1200 元（勞基法 39, 40 條），額外休假一天', () => {
          const accident = true;
          const consent = true;
          let result = std.overtimePay(150, 2, std.REGULAR_LEAVE, accident, consent);
          expect(result.value).eq(1200);
          expect(result.extraLeave.value).eq(1);
          expect(result.extraLeave.unit).eq('day');
          expect(result.reference[0].id).eq('LSA-39');
          expect(result.reference[1].id).eq('LSA-40');
          //https://laws.mol.gov.tw/FLAW/FLAWDOC03.aspx?datatype=etype&lc1=%5bc%5d%E5%8B%9E%E5%8B%95%E5%9F%BA%E6%BA%96%E6%B3%95%2c40&cnt=19&recordno=10
          expect(result.reference[2].id).eq('台八十三勞動一字第 102498 號函');
        });

        it('若「無」天災、事變或突發事件，但雇主要求於例假日工作並且徵得勞工同意時，此為違法加班' +
          '工資加倍發給。月薪制勞工，平均時薪 150 元並工作 2 小時，' +
          '加給工資 1200 元（勞基法 39, 40 條）', () => {
          const accident = false;
          const consent = true;
          let result = std.overtimePay(150, 2, std.REGULAR_LEAVE, accident, consent);
          /*
          expect result looks like this:
          {
            status: std.ILLEGAL,
            value: 1200,
            extraLeave: {
              value: 1,
              unit: 'day'
            },
            reference: [
              {
                id: 'LSA-39',
                description: '第三十六條所定之例假、休息日、第....',
                url: 'http://laws.mol.gov.tw/FLAW/FLAWDOC01.aspx?lsid=FL014930&flno=39'
              },
              { id: 'LSA-40' },
              { id: 'LSA-79' },
              { id: '台八十三勞動一字第 102498 號函' }
            ],
            fines: [
              { min: 20000, max: 1000000, according: 'LSA-79' }
            ]
          };
          */
          expect(result.value).eq(1200);
          expect(result.extraLeave.value).eq(0);
          expect(result.extraLeave.unit).eq('day');
          expect(result.reference[0].id).eq('LSA-39');
          expect(result.reference[1].id).eq('LSA-40');
          expect(result.reference[2].id).eq('LSA-79');

          // https://laws.mol.gov.tw/FLAW/FLAWDOC03.aspx?datatype=etype&lc1=%5bc%5d%E5%8B%9E%E5%8B%95%E5%9F%BA%E6%BA%96%E6%B3%95%2c40&cnt=19&recordno=10
          expect(result.reference[3].id).eq('台八十三勞動一字第 102498 號函');
          expect(result.status).eq(std.ILLEGAL);

          // 79 條，罰則介於二萬到一百萬
          expect(result.fines[0].according).eq('LSA-79');
          expect(result.fines[0].min).eq(20000);
          expect(result.fines[0].max).eq(1000000);
        });
      });

      describe('休息日 (rest day)', () => {
        it('月薪制勞工, 平均時薪 150 工作 1 小時，實領加班費為 900 元（勞基法 24 條）', () => {
          let result = std.overtimePay(150, 1, std.REST_DAY);
          expect(result.value).eq(900);
          expect(result.reference[0].id).eq('LSA-24');
        });

        it('月薪制勞工, 平均時薪 150 工作 2 小時，實領加班費為 900 元（勞基法 24 條）', () => {
          let result = std.overtimePay(150, 2, std.REST_DAY);
          expect(result.value).eq(900);
          expect(result.reference[0].id).eq('LSA-24');
        });

        it('月薪制勞工, 平均時薪 150 工作 4 小時，實領加班費為 900 元（勞基法 24 條）', () => {
          let result = std.overtimePay(150, 4, std.REST_DAY);
          expect(result.value).eq(900);
          expect(result.reference[0].id).eq('LSA-24');
        });

        it('月薪制勞工, 平均時薪 150 工作 5 小時，實領加班費為 1900 元（勞基法 24 條）', () => {
          let result = std.overtimePay(150, 5, std.REST_DAY);
          expect(result.value).eq(1900);
          expect(result.reference[0].id).eq('LSA-24');
        });

        it('月薪制勞工, 平均時薪 150 工作 5.5 個小時，實領加班費為 1900 元（勞基法 24 條）', () => {
          let result = std.overtimePay(150, 5.5, std.REST_DAY);
          expect(result.value).eq(1900);
          expect(result.reference[0].id).eq('LSA-24');
        });

        it('月薪制勞工, 平均時薪 150 工作 8 個小時，實領加班費為 1900 元（勞基法 24 條）', () => {
          let result = std.overtimePay(150, 8, std.REST_DAY);
          expect(result.value).eq(1900);
          expect(result.reference[0].id).eq('LSA-24');
        });

        it('月薪制勞工, 平均時薪 150 工作 8.5 個小時，實領加班費為 2900 元（勞基法 24 條）', () => {
          let result = std.overtimePay(150, 8.5, std.REST_DAY);
          expect(result.value).eq(2900);
          expect(result.reference[0].id).eq('LSA-24');
        });

        it('月薪制勞工, 平均時薪 150 工作 10 個小時，實領加班費為 2900 元（勞基法 24 條）', () => {
          let result = std.overtimePay(150, 10, std.REST_DAY);
          expect(result.value).eq(2900);
          expect(result.reference[0].id).eq('LSA-24');
        });

        it('月薪制勞工, 平均時薪 150 工作 12 個小時，實領加班費為 2900 元（勞基法 24 條）', () => {
          let result = std.overtimePay(150, 12, std.REST_DAY);
          expect(result.value).eq(2900);
          expect(result.reference[0].id).eq('LSA-24');
        });

        it('月薪制勞工, 平均時薪 150 工作 13 個小時，結果回傳不合法（勞基法 32 條）', () => {
          let result = std.overtimePay(150, 13, std.REST_DAY);
          expect(result.status).eq(std.ILLEGAL);
          expect(result.reference[0].id).eq('LSA-32');
        });
      });
    });
  });

  describe('時薪制', () => {
    it('基本時薪 120 元，工作 8 小時因為 960 元', () => {
      pass();
    });
  });
});
<|endoftext|>


<commit_before>var gulp = require('gulp');
var less = require('gulp-less');
var cleanCSS = require('gulp-clean-css');
var rename = require("gulp-rename");
var replace = require('gulp-replace');
var uglify = require('gulp-uglify');
var htmlmin = require('gulp-htmlmin');
var vulcanize = require('gulp-vulcanize');

// Minify HTML
gulp.task('minify-html', function() {
  return gulp.src('./index.html')
    .pipe(replace('src/components.html', 'critical.html'))
    .pipe(htmlmin({
      collapseWhitespace: true,
      removeComments: true,
      minifyCSS: true,
      minifyJS: true
    }))
    .pipe(gulp.dest('dist'));
});

// Compile LESS files from /less into /css
gulp.task('less', function() {
    return gulp.src('less/clean-blog.less')
        .pipe(less())
        .pipe(rename({ suffix: '.min' }))
        .pipe(gulp.dest('css'));
});

// Minify compiled CSS
gulp.task('minify-css', ['less'], function() {
    return gulp.src('css/clean-blog.css')
        .pipe(cleanCSS({ compatibility: 'ie8' }))
        .pipe(rename({ suffix: '.min' }))
        .pipe(gulp.dest('css'));
});

// Minify JS
gulp.task('minify-js', function() {
    return gulp.src('js/clean-blog.js')
        .pipe(uglify())
        .pipe(rename({ suffix: '.min' }))
        .pipe(gulp.dest('js'));
});

// Vulcanize Web Components
gulp.task('vulcanize', function () {
    gulp.src('src/components.html')
        .pipe(vulcanize({
            stripComments: true,
            inlineScripts: true,
            inlineCss: true
        }))
        .pipe(replace('../node_modules/font-awesome/fonts/', 'fonts/'))
        .pipe(rename('critical.html'))
        .pipe(gulp.dest('dist'));
});

// Copy files
gulp.task('copy', function() {
    gulp.src(['img/**'])
        .pipe(gulp.dest('dist/img'))
    gulp.src(['node_modules/font-awesome/fonts/**'])
        .pipe(gulp.dest('dist/fonts'))
    gulp.src(['bower_components/webcomponentsjs/webcomponents-lite.min.js'])
        .pipe(gulp.dest('dist/js'));
})

// Run everything
gulp.task('default', ['less', 'minify-css', 'minify-html', 'minify-js', 'vulcanize', 'copy']);
<commit_msg>minify vulcanized output<commit_after>var gulp = require('gulp');
var less = require('gulp-less');
var cleanCSS = require('gulp-clean-css');
var rename = require("gulp-rename");
var replace = require('gulp-replace');
var uglify = require('gulp-uglify');
var htmlmin = require('gulp-htmlmin');
var vulcanize = require('gulp-vulcanize');

// Minify HTML
gulp.task('minify-html', function() {
  return gulp.src('./index.html')
    .pipe(replace('src/components.html', 'critical.html'))
    .pipe(htmlmin({
      collapseWhitespace: true,
      removeComments: true,
      minifyCSS: true,
      minifyJS: true
    }))
    .pipe(gulp.dest('dist'));
});

// Compile LESS files from /less into /css
gulp.task('less', function() {
    return gulp.src('less/clean-blog.less')
      .pipe(less())
      .pipe(rename({ suffix: '.min' }))
      .pipe(gulp.dest('css'));
});

// Minify compiled CSS
gulp.task('minify-css', ['less'], function() {
    return gulp.src('css/clean-blog.css')
      .pipe(cleanCSS({ compatibility: 'ie8' }))
      .pipe(rename({ suffix: '.min' }))
      .pipe(gulp.dest('css'));
});

// Minify JS
gulp.task('minify-js', function() {
    return gulp.src('js/clean-blog.js')
      .pipe(uglify())
      .pipe(rename({ suffix: '.min' }))
      .pipe(gulp.dest('js'));
});

// Vulcanize Web Components
gulp.task('vulcanize', function () {
    gulp.src('src/components.html')
      .pipe(vulcanize({
        stripComments: true,
        inlineScripts: true,
        inlineCss: true
      }))
      .pipe(htmlmin({
        collapseWhitespace: true,
        removeComments: true,
        minifyCSS: true,
        minifyJS: true
      }))
      .pipe(replace('../node_modules/font-awesome/fonts/', 'fonts/'))
      .pipe(rename('critical.html'))
      .pipe(gulp.dest('dist'));
});

// Copy files
gulp.task('copy', function() {
    gulp.src(['img/**'])
      .pipe(gulp.dest('dist/img'))
    gulp.src(['node_modules/font-awesome/fonts/**'])
      .pipe(gulp.dest('dist/fonts'))
    gulp.src(['bower_components/webcomponentsjs/webcomponents-lite.min.js'])
      .pipe(gulp.dest('dist/js'));
})

// Run everything
gulp.task('default', ['less', 'minify-css', 'minify-html', 'minify-js', 'vulcanize', 'copy']);
<|endoftext|>


<commit_before>var Upvote = (function (window, document) {

	that = this;

	// endEvent = hasTouch ? 'touchend' : 'mouseup',

	Upvote = function (opts) {

		that = this;

		this.current_category = 'us';

		// ---------------------------------------------------------
		// Muench launch
		// ---------------------------------------------------------

		// Options from user
		for (i in opts) this.options[i] = opts[i];

		// ---------------------------------------------------------
		// Skimmin launch
		// ---------------------------------------------------------

        	$('.upvote-container').on('click', this.fn_tap_upvote.bind(this));
        	$('.category-container').on('click', this.fn_change_category.bind(this));

		window.addEventListener('load', function() {
		    FastClick.attach(document.body);
		}, false);

		this.fn_hide_rendering_icons();
		this.fn_loading();
       		this.fn_reveal_content();

    	};

	Upvote.prototype = {

		// ------------------------------------------------------
		// Skimmin Core Functions
		// ------------------------------------------------------

        	// primarily used to hide slow rendering
        	fn_loading: function() {

            	that = this;

            	/*$('#L').fadeIn(0);
            	$('#L').addClass('animated zoomIn');

            	setTimeout(function() {
            		$('#O').fadeIn(0);
            		$('#O').addClass('animated zoomIn');
            	}, 75);

            	setTimeout(function() {
            		$('#A').fadeIn(0);
            		$('#A').addClass('animated zoomIn');
            	}, 150);

            	setTimeout(function() {
            		$('#D').fadeIn(0);
            		$('#D').addClass('animated zoomIn');
            	}, 225);

            	setTimeout(function() {
            		$('#I').fadeIn(0);
            		$('#I').addClass('animated zoomIn');
            	}, 300);

            	setTimeout(function() {
            		$('#N').fadeIn(0);
            		$('#N').addClass('animated zoomIn');
            	}, 375);

            	setTimeout(function() {
            		$('#G').fadeIn(0);
            		$('#G').addClass('animated zoomIn');
            	}, 450);*/

            	/*setTimeout(function() {
            		$('#loading-container').addClass('animated pulse');
            	}, 1500);*/

            	/*setTimeout(function() {
            		$('#L').removeClass('animated zoomIn');
            		$('#O').removeClass('animated zoomIn');
            		$('#A').removeClass('animated zoomIn');
            		$('#D').removeClass('animated zoomIn');
            		$('#I').removeClass('animated zoomIn');
            		$('#N').removeClass('animated zoomIn');
            		$('#G').removeClass('animated zoomIn');
            	}, 1500);*/

            	int_loading_count = 0;
            	arr_colors = Array('rgba(52, 152, 219, 1)', 'rgba(255, 140, 0, 1)', 'rgba(231, 76, 60, 1)', 'rgba(0, 128, 0, .9)', 'rgba(0, 154, 136, .9)', 'rgba(164, 121, 228, 1)');

            	// bool_kill_next_loop = false;

        		// $('#loading-circle').addClass('animated pulse');

        	pulsing_circle_interval = setInterval(function() {

        			/*$('#L').fadeOut(300);
        			$('#O').fadeOut(300);
        			$('#A').fadeOut(300);
        			$('#D').fadeOut(300);
        			$('#I').fadeOut(300);
        			$('#N').fadeOut(300);
        			$('#G').fadeOut(300);*/

        			if (int_loading_count == 0 || int_loading_count == 1 || int_loading_count == 2 || int_loading_count == 3) {

        				$('#L').fadeIn(0);
            				$('#L').addClass('animated zoomIn');

            				setTimeout(function() {
            					$('#O').fadeIn(0);
            					$('#O').addClass('animated zoomIn');
            				}, 75);

            				setTimeout(function() {
            					$('#A').fadeIn(0);
            					$('#A').addClass('animated zoomIn');
            				}, 150);

            				setTimeout(function() {
            					$('#D').fadeIn(0);
            					$('#D').addClass('animated zoomIn');
            				}, 225);

            				setTimeout(function() {
            					$('#I').fadeIn(0);
            					$('#I').addClass('animated zoomIn');
            				}, 300);

            				setTimeout(function() {
            					$('#N').fadeIn(0);
            					$('#N').addClass('animated zoomIn');
            				}, 375);

            				setTimeout(function() {
            					$('#G').fadeIn(0);
            					$('#G').addClass('animated zoomIn');
            				}, 450);

        				/*setTimeout(function() {
        					$('#L').removeClass('animated zoomIn');
        					$('#O').removeClass('animated zoomIn');
        					$('#A').removeClass('animated zoomIn');
        					$('#D').removeClass('animated zoomIn');
        					$('#I').removeClass('animated zoomIn');
        					$('#N').removeClass('animated zoomIn');
        					$('#G').removeClass('animated zoomIn');
        				}, 1000);

        				setTimeout(function(){
        					$('#L').addClass('animated zoomOut');
        					$('#O').addClass('animated zoomOut');
        					$('#A').addClass('animated zoomOut');
        					$('#D').addClass('animated zoomOut');
        					$('#I').addClass('animated zoomOut');
        					$('#N').addClass('animated zoomOut');
        					$('#G').addClass('animated zoomOut');
        				}, 1700);*/

        				$('#L').css('-webkit-transform', 'translateY(5px)');
        				setTimeout(function() {
        					$('#L').css('-webkit-transform', 'translateY(0px)');
        				}, 300);

        				setTimeout(function() {
        					$('#O').css('-webkit-transform', 'translateY(5px)');
        				}, 100);
        				setTimeout(function() {
        					$('#O').css('-webkit-transform', 'translateY(0px)');
        				}, 400);

        				setTimeout(function() {
        					$('#A').css('-webkit-transform', 'translateY(5px)');
        				}, 200);
        				setTimeout(function() {
        					$('#A').css('-webkit-transform', 'translateY(0px)');
        				}, 500);

        				setTimeout(function() {
        					$('#D').css('-webkit-transform', 'translateY(5px)');
        				}, 300);
        				setTimeout(function() {
        					$('#D').css('-webkit-transform', 'translateY(0px)');
        				}, 600);

        				setTimeout(function() {
        					$('#I').css('-webkit-transform', 'translateY(5px)');
        				}, 400);
        				setTimeout(function() {
        					$('#I').css('-webkit-transform', 'translateY(0px)');
        				}, 700);

        				setTimeout(function() {
        					$('#N').css('-webkit-transform', 'translateY(5px)');
        				}, 500);
        				setTimeout(function() {
        					$('#N').css('-webkit-transform', 'translateY(0px)');
        				}, 800);

        				setTimeout(function() {
        					$('#G').css('-webkit-transform', 'translateY(5px)');
        				}, 600);
        				setTimeout(function() {
        					$('#G').css('-webkit-transform', 'translateY(0px)');
        				}, 900);

        			}

        			/*if (int_loading_count == 0 || int_loading_count == 2 || int_loading_count == 4 || int_loading_count == 6 || int_loading_count == 8) {
        				$('#L').css('opacity', '0');
        				$('#O').css('opacity', '0');
        				$('#A').css('opacity', '0');
        				$('#D').css('opacity', '0');
        				$('#I').css('opacity', '0');
        				$('#N').css('opacity', '0');
        				$('#G').css('opacity', '0');
        			}
        			else {
        				$('#L').css('opacity', '1');
        				$('#O').css('opacity', '1');
        				$('#A').css('opacity', '1');
        				$('#D').css('opacity', '1');
        				$('#I').css('opacity', '1');
        				$('#N').css('opacity', '1');
        				$('#G').css('opacity', '1');
        			}*/

        			// $('#L').addClass('zoomOut');
        			/*$('#L').css('opacity', '.7');

        			setTimeout(function() {
        				// $('#O').addClass('zoomOut');
        				$('#L').css('opacity', '1');
        				$('#O').css('opacity', '.7');
        			}, 75);

        			setTimeout(function() {
        				$('#O').css('opacity', '1');
        				$('#A').css('opacity', '.7');
        			}, 150);

        			setTimeout(function() {
        				$('#A').css('opacity', '1');
        				$('#D').css('opacity', '.7');
        			}, 225);

        			setTimeout(function() {
        				$('#D').css('opacity', '1');
        				$('#I').css('opacity', '.7');
        			}, 300);

        			setTimeout(function() {
        				$('#I').css('opacity', '1');
        				$('#N').css('opacity', '.7');
        			}, 375);

        			setTimeout(function() {
        				$('#N').css('opacity', '1');
        				$('#G').css('opacity', '.7');
        			}, 450);*/

        			// $('#loading-circle').css('background-color', arr_colors[int_loading_count]);
        			int_loading_count += 1;
        			if (int_loading_count == 8) {
        				clearInterval(pulsing_circle_interval);
        				setTimeout(function() {
        					// $('#loading-container').addClass('animated slideOutUp');
        					$('#loading-container').fadeOut(300);
        				}, 500);
        				setTimeout(function() {
        					$('#content').fadeIn(0);
        					$('#content').addClass('animated bounceInUp');
        					// $('#content').addClass('animated slideInUp');
        				}, 750);
        			}

        			/*setTimeout(function() {
        				$('#loading-circle').css('opacity', '1');
        			}, 500);*/

        		}, 1800);

        	},

        	fn_reveal_content: function() {

        		/*setTimeout(function() {
        			$('#loading-circle').addClass('animated zoomOut');
        			$('#content').addClass('animated slideInUp');
        		}, 300);*/

        	},

        	fn_hide_rendering_icons: function() {

        		setTimeout(function() {
        			$('.rendering-container').addClass('display-none');
        		}, 3000);

        	},

        	fn_change_category: function(e) {

        		if (this.current_category == 'world') {
        			$('#category-container').removeClass('world')
        			$('#category-container').addClass('us');
        			$('#category-text').html('us');
        			this.current_category = 'us';
        		}

        		else if (this.current_category == 'us') {
        			$('#category-container').removeClass('us')
        			$('#category-container').addClass('sports');
        			$('#category-text').html('sports');
        			this.current_category = 'sports';
        		}

        		else if (this.current_category == 'sports') {
        			$('#category-container').removeClass('sports')
        			$('#category-container').addClass('business');
        			$('#category-text').html('business');
        			this.current_category = 'business';
        		}

        		else if (this.current_category == 'business') {
        			$('#category-container').removeClass('business')
        			$('#category-container').addClass('technology');
        			$('#category-text').html('technology');
        			this.current_category = 'technology';
        		}

        		else if (this.current_category == 'technology') {
        			$('#category-container').removeClass('technology')
        			$('#category-container').addClass('entertainment');
        			$('#category-text').html('entertainment');
        			this.current_category = 'entertainment';
        		}

        		else {
        			$('#category-container').removeClass('entertainment')
        			$('#category-container').addClass('world');
        			$('#category-text').html('world');
        			this.current_category = 'world';
        		}

        		if ($('.upvote-container').hasClass('upvoted') == true) {
        			$('.upvote-container').removeClass('us world sports business technology entertainment');
        			$('.upvote-text').removeClass('us world sports business technology entertainment');
        			$('.upvote-icon').removeClass('us world sports business technology entertainment');
        			$('.upvote-container').addClass(this.current_category);
        			$('.upvote-text').addClass(this.current_category);
        			$('.upvote-icon').addClass(this.current_category);
        		}

        	},

		fn_tap_upvote: function() {

			if ($('.upvote-container').hasClass('upvoted') == true) {

				$('.upvote-container').removeClass('upvoted');

				setTimeout(function() {
        				$('.upvote-container').removeClass('tapped us world sports business technology entertainment');
        				$('.upvote-text').removeClass('us world sports business technology entertainment');
        				$('.upvote-text').html(30);
        				$('.upvote-icon').removeClass('us world sports business technology entertainment');
        			}, 300);
        		}

			else {

				$('.upvote-container').addClass('upvoted');
    				setTimeout(function() {
        				$('.upvote-container').addClass('tapped ' + that.current_category);
        				$('.upvote-text').addClass(that.current_category);
        				$('.upvote-text').html(31);
        				$('.upvote-icon').addClass(that.current_category);
    				}, 300);
			}

		},

	};

	return Upvote;

})(window, document);
<commit_msg>Update upvote.js<commit_after>var Upvote = (function (window, document) {

	that = this;

	// endEvent = hasTouch ? 'touchend' : 'mouseup',

	Upvote = function (opts) {

		that = this;

		this.current_category = 'us';

		// ---------------------------------------------------------
		// Muench launch
		// ---------------------------------------------------------

		// Options from user
		for (i in opts) this.options[i] = opts[i];

		// ---------------------------------------------------------
		// Skimmin launch
		// ---------------------------------------------------------

        	$('.upvote-container').on('click', this.fn_tap_upvote.bind(this));
        	$('.category-container').on('click', this.fn_change_category.bind(this));

		window.addEventListener('load', function() {
		    FastClick.attach(document.body);
		}, false);

		this.fn_hide_rendering_icons();
		this.fn_loading();
       		this.fn_reveal_content();

    	};

	Upvote.prototype = {

		// ------------------------------------------------------
		// Skimmin Core Functions
		// ------------------------------------------------------

        	// primarily used to hide slow rendering
        	fn_loading: function() {

            	that = this;

            	/*$('#L').fadeIn(0);
            	$('#L').addClass('animated zoomIn');

            	setTimeout(function() {
            		$('#O').fadeIn(0);
            		$('#O').addClass('animated zoomIn');
            	}, 75);

            	setTimeout(function() {
            		$('#A').fadeIn(0);
            		$('#A').addClass('animated zoomIn');
            	}, 150);

            	setTimeout(function() {
            		$('#D').fadeIn(0);
            		$('#D').addClass('animated zoomIn');
            	}, 225);

            	setTimeout(function() {
            		$('#I').fadeIn(0);
            		$('#I').addClass('animated zoomIn');
            	}, 300);

            	setTimeout(function() {
            		$('#N').fadeIn(0);
            		$('#N').addClass('animated zoomIn');
            	}, 375);

            	setTimeout(function() {
            		$('#G').fadeIn(0);
            		$('#G').addClass('animated zoomIn');
            	}, 450);*/

            	/*setTimeout(function() {
            		$('#loading-container').addClass('animated pulse');
            	}, 1500);*/

            	/*setTimeout(function() {
            		$('#L').removeClass('animated zoomIn');
            		$('#O').removeClass('animated zoomIn');
            		$('#A').removeClass('animated zoomIn');
            		$('#D').removeClass('animated zoomIn');
            		$('#I').removeClass('animated zoomIn');
            		$('#N').removeClass('animated zoomIn');
            		$('#G').removeClass('animated zoomIn');
            	}, 1500);*/

            	int_loading_count = 0;
            	arr_colors = Array('rgba(52, 152, 219, 1)', 'rgba(255, 140, 0, 1)', 'rgba(231, 76, 60, 1)', 'rgba(0, 128, 0, .9)', 'rgba(0, 154, 136, .9)', 'rgba(164, 121, 228, 1)');

            	// bool_kill_next_loop = false;

        		// $('#loading-circle').addClass('animated pulse');

        	pulsing_circle_interval = setInterval(function() {

        			/*$('#L').fadeOut(300);
        			$('#O').fadeOut(300);
        			$('#A').fadeOut(300);
        			$('#D').fadeOut(300);
        			$('#I').fadeOut(300);
        			$('#N').fadeOut(300);
        			$('#G').fadeOut(300);*/

        			if (int_loading_count == 0 || int_loading_count == 1 || int_loading_count == 2 || int_loading_count == 3) {

        				$('#L').fadeIn(0);
            				// $('#L').addClass('animated zoomIn');

            				setTimeout(function() {
            					$('#O').fadeIn(0);
            					// $('#O').addClass('animated zoomIn');
            				}, 75);

            				setTimeout(function() {
            					$('#A').fadeIn(0);
            					// $('#A').addClass('animated zoomIn');
            				}, 150);

            				setTimeout(function() {
            					$('#D').fadeIn(0);
            					// $('#D').addClass('animated zoomIn');
            				}, 225);

            				setTimeout(function() {
            					$('#I').fadeIn(0);
            					// $('#I').addClass('animated zoomIn');
            				}, 300);

            				setTimeout(function() {
            					$('#N').fadeIn(0);
            					// $('#N').addClass('animated zoomIn');
            				}, 375);

            				setTimeout(function() {
            					$('#G').fadeIn(0);
            					// $('#G').addClass('animated zoomIn');
            				}, 450);

        				/*setTimeout(function() {
        					$('#L').removeClass('animated zoomIn');
        					$('#O').removeClass('animated zoomIn');
        					$('#A').removeClass('animated zoomIn');
        					$('#D').removeClass('animated zoomIn');
        					$('#I').removeClass('animated zoomIn');
        					$('#N').removeClass('animated zoomIn');
        					$('#G').removeClass('animated zoomIn');
        				}, 1000);

        				setTimeout(function(){
        					$('#L').addClass('animated zoomOut');
        					$('#O').addClass('animated zoomOut');
        					$('#A').addClass('animated zoomOut');
        					$('#D').addClass('animated zoomOut');
        					$('#I').addClass('animated zoomOut');
        					$('#N').addClass('animated zoomOut');
        					$('#G').addClass('animated zoomOut');
        				}, 1700);*/

        				$('#L').css('-webkit-transform', 'translateY(5px)');
        				setTimeout(function() {
        					$('#L').css('-webkit-transform', 'translateY(0px)');
        				}, 300);

        				setTimeout(function() {
        					$('#O').css('-webkit-transform', 'translateY(5px)');
        				}, 100);
        				setTimeout(function() {
        					$('#O').css('-webkit-transform', 'translateY(0px)');
        				}, 400);

        				setTimeout(function() {
        					$('#A').css('-webkit-transform', 'translateY(5px)');
        				}, 200);
        				setTimeout(function() {
        					$('#A').css('-webkit-transform', 'translateY(0px)');
        				}, 500);

        				setTimeout(function() {
        					$('#D').css('-webkit-transform', 'translateY(5px)');
        				}, 300);
        				setTimeout(function() {
        					$('#D').css('-webkit-transform', 'translateY(0px)');
        				}, 600);

        				setTimeout(function() {
        					$('#I').css('-webkit-transform', 'translateY(5px)');
        				}, 400);
        				setTimeout(function() {
        					$('#I').css('-webkit-transform', 'translateY(0px)');
        				}, 700);

        				setTimeout(function() {
        					$('#N').css('-webkit-transform', 'translateY(5px)');
        				}, 500);
        				setTimeout(function() {
        					$('#N').css('-webkit-transform', 'translateY(0px)');
        				}, 800);

        				setTimeout(function() {
        					$('#G').css('-webkit-transform', 'translateY(5px)');
        				}, 600);
        				setTimeout(function() {
        					$('#G').css('-webkit-transform', 'translateY(0px)');
        				}, 900);

        			}

        			/*if (int_loading_count == 0 || int_loading_count == 2 || int_loading_count == 4 || int_loading_count == 6 || int_loading_count == 8) {
        				$('#L').css('opacity', '0');
        				$('#O').css('opacity', '0');
        				$('#A').css('opacity', '0');
        				$('#D').css('opacity', '0');
        				$('#I').css('opacity', '0');
        				$('#N').css('opacity', '0');
        				$('#G').css('opacity', '0');
        			}
        			else {
        				$('#L').css('opacity', '1');
        				$('#O').css('opacity', '1');
        				$('#A').css('opacity', '1');
        				$('#D').css('opacity', '1');
        				$('#I').css('opacity', '1');
        				$('#N').css('opacity', '1');
        				$('#G').css('opacity', '1');
        			}*/

        			// $('#L').addClass('zoomOut');
        			/*$('#L').css('opacity', '.7');

        			setTimeout(function() {
        				// $('#O').addClass('zoomOut');
        				$('#L').css('opacity', '1');
        				$('#O').css('opacity', '.7');
        			}, 75);

        			setTimeout(function() {
        				$('#O').css('opacity', '1');
        				$('#A').css('opacity', '.7');
        			}, 150);

        			setTimeout(function() {
        				$('#A').css('opacity', '1');
        				$('#D').css('opacity', '.7');
        			}, 225);

        			setTimeout(function() {
        				$('#D').css('opacity', '1');
        				$('#I').css('opacity', '.7');
        			}, 300);

        			setTimeout(function() {
        				$('#I').css('opacity', '1');
        				$('#N').css('opacity', '.7');
        			}, 375);

        			setTimeout(function() {
        				$('#N').css('opacity', '1');
        				$('#G').css('opacity', '.7');
        			}, 450);*/

        			// $('#loading-circle').css('background-color', arr_colors[int_loading_count]);
        			int_loading_count += 1;
        			if (int_loading_count == 8) {
        				clearInterval(pulsing_circle_interval);
        				setTimeout(function() {
        					// $('#loading-container').addClass('animated slideOutUp');
        					$('#loading-container').fadeOut(300);
        				}, 500);
        				setTimeout(function() {
        					$('#content').fadeIn(0);
        					$('#content').addClass('animated bounceInUp');
        					// $('#content').addClass('animated slideInUp');
        				}, 750);
        			}

        			/*setTimeout(function() {
        				$('#loading-circle').css('opacity', '1');
        			}, 500);*/

        		}, 1800);

        	},

        	fn_reveal_content: function() {

        		/*setTimeout(function() {
        			$('#loading-circle').addClass('animated zoomOut');
        			$('#content').addClass('animated slideInUp');
        		}, 300);*/

        	},

        	fn_hide_rendering_icons: function() {

        		setTimeout(function() {
        			$('.rendering-container').addClass('display-none');
        		}, 3000);

        	},

        	fn_change_category: function(e) {

        		if (this.current_category == 'world') {
        			$('#category-container').removeClass('world')
        			$('#category-container').addClass('us');
        			$('#category-text').html('us');
        			this.current_category = 'us';
        		}

        		else if (this.current_category == 'us') {
        			$('#category-container').removeClass('us')
        			$('#category-container').addClass('sports');
        			$('#category-text').html('sports');
        			this.current_category = 'sports';
        		}

        		else if (this.current_category == 'sports') {
        			$('#category-container').removeClass('sports')
        			$('#category-container').addClass('business');
        			$('#category-text').html('business');
        			this.current_category = 'business';
        		}

        		else if (this.current_category == 'business') {
        			$('#category-container').removeClass('business')
        			$('#category-container').addClass('technology');
        			$('#category-text').html('technology');
        			this.current_category = 'technology';
        		}

        		else if (this.current_category == 'technology') {
        			$('#category-container').removeClass('technology')
        			$('#category-container').addClass('entertainment');
        			$('#category-text').html('entertainment');
        			this.current_category = 'entertainment';
        		}

        		else {
        			$('#category-container').removeClass('entertainment')
        			$('#category-container').addClass('world');
        			$('#category-text').html('world');
        			this.current_category = 'world';
        		}

        		if ($('.upvote-container').hasClass('upvoted') == true) {
        			$('.upvote-container').removeClass('us world sports business technology entertainment');
        			$('.upvote-text').removeClass('us world sports business technology entertainment');
        			$('.upvote-icon').removeClass('us world sports business technology entertainment');
        			$('.upvote-container').addClass(this.current_category);
        			$('.upvote-text').addClass(this.current_category);
        			$('.upvote-icon').addClass(this.current_category);
        		}

        	},

		fn_tap_upvote: function() {

			if ($('.upvote-container').hasClass('upvoted') == true) {

				$('.upvote-container').removeClass('upvoted');

				setTimeout(function() {
        				$('.upvote-container').removeClass('tapped us world sports business technology entertainment');
        				$('.upvote-text').removeClass('us world sports business technology entertainment');
        				$('.upvote-text').html(30);
        				$('.upvote-icon').removeClass('us world sports business technology entertainment');
        			}, 300);
        		}

			else {

				$('.upvote-container').addClass('upvoted');
    				setTimeout(function() {
        				$('.upvote-container').addClass('tapped ' + that.current_category);
        				$('.upvote-text').addClass(that.current_category);
        				$('.upvote-text').html(31);
        				$('.upvote-icon').addClass(that.current_category);
    				}, 300);
			}

		},

	};

	return Upvote;

})(window, document);
<|endoftext|>


<commit_before>const request = require('request-promise');
const qs = require('querystring');
const pino = require('pino');

const pkg = require('../package.json');

const error = {
  noToken: 'You need to specify your access token',
  noParams: 'You need to specify the required parameters, consult the documentation for more details'
};

const logger = new pino({
  name: `${pkg.name} v${pkg.version}`,
  prettyPrint: true
});

class User {

/**
  * @class User
  * @constructor
  * @param {String} token Bot Token
  * @param {String} baseUrl (Optional) Custom pwetelegram API instance URL
  **/

  constructor(opts) {
    opts.token ? this.token = opts.token : outputError(error.noToken);
    this.baseUrl = opts.baseUrl || 'api.pwrtelegram.xyz';
  }

  _request(method, params) {
    const options = {};
    options.uri = `https://${this.baseUrl}/user${this.token}/${method}?${params}`;
    options.headers = {
      'content-type': 'application/json',
      'accept': 'application/x-www-form-urlencoded'
    };
    options.json = true;
    console.log(options)
    return request(options)
      .then(ctx => {;
        if (ctx.ok) {
          return ctx;
        } else {
          outputError(ctx);
        }
      });
  };

/**
  * Send text message.
  * @param  {Number|String} chatId Unique identifier for the message recipient
  * @param  {String} text Text of the message to be sent
  * @param  {Object} [options] Additional Telegram query options
  * @return {Promise} Updates
  * @see https://core.telegram.org/method/messages.sendMessage
  **/
  sendMessage(chatId, message, opts = {}) {
    opts.peer = chatId;
    opts.message = message;
    return this._request('messages.sendMessage', qs.stringify(opts));
  };

/**
  * Send photo from url.
  * @param  {Number|String} chatId Unique identifier for the message recipient
  * @param  {String} url Input url
  * @param  {String} caption Media caption
  * @param  {Object} [options] Additional Telegram query options
  * @return {Promise} Updates
  * @see https://core.telegram.org/method/messages.sendMedia
  **/
  sendPhotoExternal(chatId, url, caption, opts = {}) {
    opts.peer = chatId;
    opts.media = JSON.stringify({
      '_': 'inputMediaPhotoExternal',
      'url': url,
      'caption': caption
    })
    return this._request('messages.sendMedia', qs.stringify(opts));
  };

/**
  * Send gif from url.
  * @param  {Number|String} chatId Unique identifier for the message recipient
  * @param  {String} url Input url
  * @param  {String} caption Media caption
  * @param  {Object} [options] Additional Telegram query options
  * @return {Promise} Updates
  * @see https://core.telegram.org/method/messages.sendMedia
  **/
  sendGifExternal(chatId, url, caption, opts = {}) {
    opts.peer = chatId;
    opts.media = JSON.stringify({
      '_': 'inputMediaGifExternal',
      'url': url,
      'q': caption
    })
    return this._request('messages.sendMedia', qs.stringify(opts));
  };

/**
  * Send document from url.
  * @param  {Number|String} chatId Unique identifier for the message recipient
  * @param  {String} url Input url
  * @param  {String} caption Media caption
  * @param  {Object} [options] Additional Telegram query options
  * @return {Promise} Updates
  * @see https://core.telegram.org/method/messages.sendMedia
  **/
  sendDocumentExternal(chatId, url, caption, opts = {}) {
    opts.peer = chatId;
    opts.media = JSON.stringify({
      '_': 'inputMediaDocumentExternal',
      'url': url,
      'caption': caption
    })
    return this._request('messages.sendMedia', qs.stringify(opts));
  };

/**
  * Set typing.
  * @param  {Number|String} chatId Unique identifier for the message recipient
  * @param  {String} action Type of action to be sent
  * @return {Promise} Boolean
  * @see https://core.telegram.org/method/messages.setTyping
  **/
  setTyping(chatId, chatAction, opts = {}) {
    opts.peer = chatId;
    opts.action = JSON.stringify({
      '_': chatAction
    })
    return this._request('messages.setTyping', qs.stringify(opts));
  };

/**
  * Set typing with uploads.
  * @param  {Number|String} chatId Unique identifier for the message recipient
  * @param  {String} action Type of action to be sent
  * @param  {Number} progress Upload progress
  * @return {Promise} Boolean
  * @see https://core.telegram.org/method/messages.setTyping
  **/
  setUploadTyping(chatId, chatAction, progress, opts = {}) {
    opts.peer = chatId;
    opts.action = JSON.stringify({
      '_': chatAction,
      'progress': progress
    })
    return this._request('messages.setTyping', qs.stringify(opts));
  };

/**
  * Forward text message.
  * @param  {Number|String} chatId Unique identifier for the message recipient
  * @param  {Number|String} messageId Unique identifier of the message to be forwarded
  * @return {Promise}
  * @see https://core.telegram.org/method/messages.forwardMessage
  **/
  forwardMessage(chatId, messageId, opts = {}) {
    opts.peer = chatId;
    opts.id = messageId;
    return this._request('messages.forwardMessage', qs.stringify(opts));
  };

/**
  * Invite user to a channel/supergroup.
  * @param  {Number|String} chatId Unique identifier for the channel/supergroup
  * @param  {String} userId Unique identifier for the user to be added
  * @return {Promise} Updates
  * @see https://tjhorner.com/tl-schema/method/channels.inviteToChannel
  **/
  inviteUser(chatId, users, opts = {}) {
    opts.channel = chatId;
    opts.users = JSON.stringify([users]);
    return this._request('channels.inviteToChannel', qs.stringify(opts));
  };

/**
  * Edit supergroup/channel title.
  * @param  {Number|String} chatId Unique identifier for the message recipient
  * @param  {String} title New title for the supergroup/channel
  * @return {Promise}
  * @see https://tjhorner.com/tl-schema/method/channels.editTitle
  **/
  editTitle(chatId, title, opts = {}) {
    opts.channel = chatId;
    opts.title = messageId;
    return this._request('channels.editTitle', qs.stringify(opts));
  };

}

const outputError = (function (err) {
  logger.error(err);
  return
})

module.exports = User;
<commit_msg>Add editAbout method<commit_after>const request = require('request-promise');
const qs = require('querystring');
const pino = require('pino');

const pkg = require('../package.json');

const error = {
  noToken: 'You need to specify your access token',
  noParams: 'You need to specify the required parameters, consult the documentation for more details'
};

const logger = new pino({
  name: `${pkg.name} v${pkg.version}`,
  prettyPrint: true
});

class User {

/**
  * @class User
  * @constructor
  * @param {String} token Bot Token
  * @param {String} baseUrl (Optional) Custom pwetelegram API instance URL
  **/

  constructor(opts) {
    opts.token ? this.token = opts.token : outputError(error.noToken);
    this.baseUrl = opts.baseUrl || 'api.pwrtelegram.xyz';
  }

  _request(method, params) {
    const options = {};
    options.uri = `https://${this.baseUrl}/user${this.token}/${method}?${params}`;
    options.headers = {
      'content-type': 'application/json',
      'accept': 'application/x-www-form-urlencoded'
    };
    options.json = true;
    console.log(options)
    return request(options)
      .then(ctx => {;
        if (ctx.ok) {
          return ctx;
        } else {
          outputError(ctx);
        }
      });
  };

/**
  * Send text message.
  * @param  {Number|String} chatId Unique identifier for the message recipient
  * @param  {String} text Text of the message to be sent
  * @param  {Object} [options] Additional Telegram query options
  * @return {Promise} Updates
  * @see https://core.telegram.org/method/messages.sendMessage
  **/
  sendMessage(chatId, message, opts = {}) {
    opts.peer = chatId;
    opts.message = message;
    return this._request('messages.sendMessage', qs.stringify(opts));
  };

/**
  * Send photo from url.
  * @param  {Number|String} chatId Unique identifier for the message recipient
  * @param  {String} url Input url
  * @param  {String} caption Media caption
  * @param  {Object} [options] Additional Telegram query options
  * @return {Promise} Updates
  * @see https://core.telegram.org/method/messages.sendMedia
  **/
  sendPhotoExternal(chatId, url, caption, opts = {}) {
    opts.peer = chatId;
    opts.media = JSON.stringify({
      '_': 'inputMediaPhotoExternal',
      'url': url,
      'caption': caption
    })
    return this._request('messages.sendMedia', qs.stringify(opts));
  };

/**
  * Send gif from url.
  * @param  {Number|String} chatId Unique identifier for the message recipient
  * @param  {String} url Input url
  * @param  {String} caption Media caption
  * @param  {Object} [options] Additional Telegram query options
  * @return {Promise} Updates
  * @see https://core.telegram.org/method/messages.sendMedia
  **/
  sendGifExternal(chatId, url, caption, opts = {}) {
    opts.peer = chatId;
    opts.media = JSON.stringify({
      '_': 'inputMediaGifExternal',
      'url': url,
      'q': caption
    })
    return this._request('messages.sendMedia', qs.stringify(opts));
  };

/**
  * Send document from url.
  * @param  {Number|String} chatId Unique identifier for the message recipient
  * @param  {String} url Input url
  * @param  {String} caption Media caption
  * @param  {Object} [options] Additional Telegram query options
  * @return {Promise} Updates
  * @see https://core.telegram.org/method/messages.sendMedia
  **/
  sendDocumentExternal(chatId, url, caption, opts = {}) {
    opts.peer = chatId;
    opts.media = JSON.stringify({
      '_': 'inputMediaDocumentExternal',
      'url': url,
      'caption': caption
    })
    return this._request('messages.sendMedia', qs.stringify(opts));
  };

/**
  * Set typing.
  * @param  {Number|String} chatId Unique identifier for the message recipient
  * @param  {String} action Type of action to be sent
  * @return {Promise} Boolean
  * @see https://core.telegram.org/method/messages.setTyping
  **/
  setTyping(chatId, chatAction, opts = {}) {
    opts.peer = chatId;
    opts.action = JSON.stringify({
      '_': chatAction
    })
    return this._request('messages.setTyping', qs.stringify(opts));
  };

/**
  * Set typing with uploads.
  * @param  {Number|String} chatId Unique identifier for the message recipient
  * @param  {String} action Type of action to be sent
  * @param  {Number} progress Upload progress
  * @return {Promise} Boolean
  * @see https://core.telegram.org/method/messages.setTyping
  **/
  setUploadTyping(chatId, chatAction, progress, opts = {}) {
    opts.peer = chatId;
    opts.action = JSON.stringify({
      '_': chatAction,
      'progress': progress
    })
    return this._request('messages.setTyping', qs.stringify(opts));
  };

/**
  * Forward text message.
  * @param  {Number|String} chatId Unique identifier for the message recipient
  * @param  {Number|String} messageId Unique identifier of the message to be forwarded
  * @return {Promise}
  * @see https://core.telegram.org/method/messages.forwardMessage
  **/
  forwardMessage(chatId, messageId, opts = {}) {
    opts.peer = chatId;
    opts.id = messageId;
    return this._request('messages.forwardMessage', qs.stringify(opts));
  };

/**
  * Invite user to a channel/supergroup.
  * @param  {Number|String} chatId Unique identifier for the channel/supergroup
  * @param  {String} userId Unique identifier for the user to be added
  * @return {Promise} Updates
  * @see https://tjhorner.com/tl-schema/method/channels.inviteToChannel
  **/
  inviteUser(chatId, users, opts = {}) {
    opts.channel = chatId;
    opts.users = JSON.stringify([users]);
    return this._request('channels.inviteToChannel', qs.stringify(opts));
  };

/**
  * Edit supergroup/channel title.
  * @param  {Number|String} chatId Unique identifier for the message recipient
  * @param  {String} title New title for the supergroup/channel
  * @return {Promise}
  * @see https://tjhorner.com/tl-schema/method/channels.editTitle
  **/
  editTitle(chatId, title, opts = {}) {
    opts.channel = chatId;
    opts.title = title;
    return this._request('channels.editTitle', qs.stringify(opts));
  };

/**
  * Edit supergroup/channel about.
  * @param  {Number|String} chatId Unique identifier for the message recipient
  * @param  {String} about New about text for the supergroup/channel
  * @return {Promise}
  * @see https://tjhorner.com/tl-schema/method/channels.editAbout
  **/
  editTitle(chatId, about, opts = {}) {
    opts.channel = chatId;
    opts.about = about;
    return this._request('channels.editAbout', qs.stringify(opts));
  };

}

const outputError = (function (err) {
  logger.error(err);
  return
})

module.exports = User;
<|endoftext|>


<commit_before>/**
 * Sends the users data to the servlet for a query to be completed, then renders the
 * results on the page.
 * TODO: implement redirect to search page
 */
async function search() {
    // Uncomment to initialize test data for search testing
    /*let tempForm = new FormData();
    tempForm.append("action", "initialize");
    let myInit = {
        body: new URLSearchParams(tempForm),
        headers: {'Content-Type': 'application/x-www-form-urlencoded'},
        method: "POST",
    };
    fetch("/adminAuth_test_congifureTestData?", myInit);*/

    const searchQuery = (new URL(document.location)).searchParams.get("query");

    let response = await fetch("/search?query=" + searchQuery);
    let responseText = await response.text();
    let recipeList = JSON.parse(responseText);

    recipeList.forEach(elem => createRecipeCard("content", elem));
}

/**
 * Redirects to the search page with the query in the URL search params.
 */
function redirectSearchPage() {
  let userQuery =  document.getElementById("search-box").value;
  window.location.assign("/pages/Search.jsp?query=" + userQuery);
}

/**
 * The function to load the main page and display content properly
 */
mainPageLoad = () => {
  // TODO: implement the call to search and rendering functions here for the intial load of the
  // search page. This will be called everytime the page is refreshed.
}<commit_msg>Update search.js<commit_after>/**
 * Sends the users data to the servlet for a query to be completed, then renders the
 * results on the page.
 * TODO: implement redirect to search page
 */
async function search() {
    // Uncomment to initialize test data for search testing
    /*let tempForm = new FormData();
    tempForm.append("action", "initialize");
    let myInit = {
        body: new URLSearchParams(tempForm),
        headers: {'Content-Type': 'application/x-www-form-urlencoded'},
        method: "POST",
    };
    fetch("/adminAuth_test_congifureTestData?", myInit);*/

    const searchQuery = (new URL(document.location)).searchParams.get("query");

    const response = await fetch("/search?query=" + searchQuery);
    const responseText = await response.text();
    const recipeList = JSON.parse(responseText);

    recipeList.forEach(elem => createRecipeCard("content", elem));
}

/**
 * Redirects to the search page with the query in the URL search params.
 */
function redirectSearchPage() {
  const userQuery =  document.getElementById("search-box").value;
  window.location.assign("/pages/Search.jsp?query=" + userQuery);
}

/**
 * The function to load the main page and display content properly
 */
mainPageLoad = () => {
  // TODO: implement the call to search and rendering functions here for the intial load of the
  // search page. This will be called everytime the page is refreshed.
}
<|endoftext|>


<commit_before>var Upvote = (function (window, document) {

	that = this;

	// endEvent = hasTouch ? 'touchend' : 'mouseup',

	Upvote = function (opts) {

		that = this;

		this.current_category = 'us';

		// ---------------------------------------------------------
		// Muench launch
		// ---------------------------------------------------------

		// Options from user
		for (i in opts) this.options[i] = opts[i];

		// ---------------------------------------------------------
		// Skimmin launch
		// ---------------------------------------------------------

        	$('.upvote-container').on('click', this.fn_tap_upvote.bind(this));
        	$('.category-container').on('click', this.fn_change_category.bind(this));

		window.addEventListener('load', function() {
		    FastClick.attach(document.body);
		}, false);

		this.fn_hide_rendering_icons();
		this.fn_loading();
       		this.fn_reveal_content();

    	};

	Upvote.prototype = {

		// ------------------------------------------------------
		// Skimmin Core Functions
		// ------------------------------------------------------

        	// primarily used to hide slow rendering
        	fn_loading: function() {

            	that = this;

            	// $('#loading-circle').addClass('animated bounceIn');

            	int_loading_count = 0;
            	arr_colors = Array('rgba(52, 152, 219, 1)', 'rgba(255, 140, 0, 1)', 'rgba(231, 76, 60, 1)', 'rgba(0, 128, 0, .9)', 'rgba(0, 154, 136, .9)', 'rgba(164, 121, 228, 1)');

            	// bool_kill_next_loop = false;

        		// $('#loading-circle').addClass('animated pulse');

        		pulsing_circle_interval = setInterval(function() {

        			$('#loading-circle').css('opacity', '.7');

        			/*$('#L').css('opacity', '.8');
        			$('#L').css('-webkit-transition', '-webkit-transform .5s');
        			$('#L').css('-webkit-transform', 'scale (.9)');

        			setTimeout(function() {
        				$('#L').css('opacity', '1');
        				$('#L').css('-webkit-transform', 'scale(1)');
        			}, 500);

        			setTimeout(function() {
        				$('#O').css('opacity', '1');
        				$('#A').css('opacity', '.8');
        			}, 200);

        			setTimeout(function() {
        				$('#A').css('opacity', '1');
        				$('#D').css('opacity', '.8');
        			}, 300);

        			setTimeout(function() {
        				$('#D').css('opacity', '1');
        				$('#I').css('opacity', '.8');
        			}, 400);

        			setTimeout(function() {
        				$('#I').css('opacity', '1');
        				$('#N').css('opacity', '.8');
        			}, 500);

        			setTimeout(function() {
        				$('#N').css('opacity', '1');
        				$('#G').css('opacity', '.75');
        			}, 600);

        			setTimeout(function() {
        				$('#G').css('opacity', '1');
        			}, 700);*/

        			// $('#loading-circle').css('background-color', arr_colors[int_loading_count]);
        			/*int_loading_count += 1;
        			if (int_loading_count == 4) {
        				clearInterval(pulsing_circle_interval);
        				setTimeout(function() {
        					$('#loading-circle').addClass('animated slideOutUp');
        					$('#loading-circle').fadeOut(300);
        				}, 500);
        				setTimeout(function() {
        					$('#content').fadeIn(300);
        					$('#content').addClass('animated slideInUp');
        				}, 750);
        			}*/

        			setTimeout(function() {
        				$('#loading-circle').css('opacity', '1');
        			}, 500);

        		}, 1000);

        	},

        	fn_reveal_content: function() {

        		/*setTimeout(function() {
        			$('#loading-circle').addClass('animated zoomOut');
        			$('#content').addClass('animated slideInUp');
        		}, 300);*/

        	},

        	fn_hide_rendering_icons: function() {

        		setTimeout(function() {
        			$('.rendering-container').addClass('display-none');
        		}, 3000);

        	},

        	fn_change_category: function(e) {

        		if (this.current_category == 'world') {
        			$('#category-container').removeClass('world')
        			$('#category-container').addClass('us');
        			$('#category-text').html('us');
        			this.current_category = 'us';
        		}

        		else if (this.current_category == 'us') {
        			$('#category-container').removeClass('us')
        			$('#category-container').addClass('sports');
        			$('#category-text').html('sports');
        			this.current_category = 'sports';
        		}

        		else if (this.current_category == 'sports') {
        			$('#category-container').removeClass('sports')
        			$('#category-container').addClass('business');
        			$('#category-text').html('business');
        			this.current_category = 'business';
        		}

        		else if (this.current_category == 'business') {
        			$('#category-container').removeClass('business')
        			$('#category-container').addClass('technology');
        			$('#category-text').html('technology');
        			this.current_category = 'technology';
        		}

        		else if (this.current_category == 'technology') {
        			$('#category-container').removeClass('technology')
        			$('#category-container').addClass('entertainment');
        			$('#category-text').html('entertainment');
        			this.current_category = 'entertainment';
        		}

        		else {
        			$('#category-container').removeClass('entertainment')
        			$('#category-container').addClass('world');
        			$('#category-text').html('world');
        			this.current_category = 'world';
        		}

        		if ($('.upvote-container').hasClass('upvoted') == true) {
        			$('.upvote-container').removeClass('us world sports business technology entertainment');
        			$('.upvote-text').removeClass('us world sports business technology entertainment');
        			$('.upvote-icon').removeClass('us world sports business technology entertainment');
        			$('.upvote-container').addClass(this.current_category);
        			$('.upvote-text').addClass(this.current_category);
        			$('.upvote-icon').addClass(this.current_category);
        		}

        	},

		fn_tap_upvote: function() {

			if ($('.upvote-container').hasClass('upvoted') == true) {

				$('.upvote-container').removeClass('upvoted');

				setTimeout(function() {
        				$('.upvote-container').removeClass('tapped us world sports business technology entertainment');
        				$('.upvote-text').removeClass('us world sports business technology entertainment');
        				$('.upvote-text').html(30);
        				$('.upvote-icon').removeClass('us world sports business technology entertainment');
        			}, 300);
        		}

			else {

				$('.upvote-container').addClass('upvoted');
    				setTimeout(function() {
        				$('.upvote-container').addClass('tapped ' + that.current_category);
        				$('.upvote-text').addClass(that.current_category);
        				$('.upvote-text').html(31);
        				$('.upvote-icon').addClass(that.current_category);
    				}, 300);
			}

		},

	};

	return Upvote;

})(window, document);
<commit_msg>Update upvote.js<commit_after>var Upvote = (function (window, document) {

	that = this;

	// endEvent = hasTouch ? 'touchend' : 'mouseup',

	Upvote = function (opts) {

		that = this;

		this.current_category = 'us';

		// ---------------------------------------------------------
		// Muench launch
		// ---------------------------------------------------------

		// Options from user
		for (i in opts) this.options[i] = opts[i];

		// ---------------------------------------------------------
		// Skimmin launch
		// ---------------------------------------------------------

        	$('.upvote-container').on('click', this.fn_tap_upvote.bind(this));
        	$('.category-container').on('click', this.fn_change_category.bind(this));

		window.addEventListener('load', function() {
		    FastClick.attach(document.body);
		}, false);

		this.fn_hide_rendering_icons();
		this.fn_loading();
       		this.fn_reveal_content();

    	};

	Upvote.prototype = {

		// ------------------------------------------------------
		// Skimmin Core Functions
		// ------------------------------------------------------

        	// primarily used to hide slow rendering
        	fn_loading: function() {

            	that = this;

            	// $('#loading-circle').addClass('animated bounceIn');

            	int_loading_count = 0;
            	arr_colors = Array('rgba(52, 152, 219, 1)', 'rgba(255, 140, 0, 1)', 'rgba(231, 76, 60, 1)', 'rgba(0, 128, 0, .9)', 'rgba(0, 154, 136, .9)', 'rgba(164, 121, 228, 1)');

            	// bool_kill_next_loop = false;

        		// $('#loading-circle').addClass('animated pulse');

        		pulsing_circle_interval = setInterval(function() {

        			// $('#loading-circle').css('opacity', '.7');

        			$('#L').css('opacity', '.8');
        			$('#L').css('-webkit-transition', '-webkit-transform .5s');
        			$('#L').css('-webkit-transform', 'scale (.9)');

        			setTimeout(function() {
        				$('#L').css('opacity', '1');
        				$('#L').css('-webkit-transform', 'scale(1)');
        			}, 500);

        			setTimeout(function() {
        				$('#O').css('opacity', '1');
        				$('#A').css('opacity', '.8');
        			}, 200);

        			setTimeout(function() {
        				$('#A').css('opacity', '1');
        				$('#D').css('opacity', '.8');
        			}, 300);

        			setTimeout(function() {
        				$('#D').css('opacity', '1');
        				$('#I').css('opacity', '.8');
        			}, 400);

        			setTimeout(function() {
        				$('#I').css('opacity', '1');
        				$('#N').css('opacity', '.8');
        			}, 500);

        			setTimeout(function() {
        				$('#N').css('opacity', '1');
        				$('#G').css('opacity', '.75');
        			}, 600);

        			setTimeout(function() {
        				$('#G').css('opacity', '1');
        			}, 700);*/

        			// $('#loading-circle').css('background-color', arr_colors[int_loading_count]);
        			int_loading_count += 1;
        			if (int_loading_count == 4) {
        				clearInterval(pulsing_circle_interval);
        				setTimeout(function() {
        					$('#loading-circle').addClass('animated slideOutUp');
        					$('#loading-circle').fadeOut(300);
        				}, 500);
        				setTimeout(function() {
        					$('#content').fadeIn(300);
        					$('#content').addClass('animated slideInUp');
        				}, 750);
        			}

        			/*setTimeout(function() {
        				$('#loading-circle').css('opacity', '1');
        			}, 500);*/

        		}, 1000);

        	},

        	fn_reveal_content: function() {

        		/*setTimeout(function() {
        			$('#loading-circle').addClass('animated zoomOut');
        			$('#content').addClass('animated slideInUp');
        		}, 300);*/

        	},

        	fn_hide_rendering_icons: function() {

        		setTimeout(function() {
        			$('.rendering-container').addClass('display-none');
        		}, 3000);

        	},

        	fn_change_category: function(e) {

        		if (this.current_category == 'world') {
        			$('#category-container').removeClass('world')
        			$('#category-container').addClass('us');
        			$('#category-text').html('us');
        			this.current_category = 'us';
        		}

        		else if (this.current_category == 'us') {
        			$('#category-container').removeClass('us')
        			$('#category-container').addClass('sports');
        			$('#category-text').html('sports');
        			this.current_category = 'sports';
        		}

        		else if (this.current_category == 'sports') {
        			$('#category-container').removeClass('sports')
        			$('#category-container').addClass('business');
        			$('#category-text').html('business');
        			this.current_category = 'business';
        		}

        		else if (this.current_category == 'business') {
        			$('#category-container').removeClass('business')
        			$('#category-container').addClass('technology');
        			$('#category-text').html('technology');
        			this.current_category = 'technology';
        		}

        		else if (this.current_category == 'technology') {
        			$('#category-container').removeClass('technology')
        			$('#category-container').addClass('entertainment');
        			$('#category-text').html('entertainment');
        			this.current_category = 'entertainment';
        		}

        		else {
        			$('#category-container').removeClass('entertainment')
        			$('#category-container').addClass('world');
        			$('#category-text').html('world');
        			this.current_category = 'world';
        		}

        		if ($('.upvote-container').hasClass('upvoted') == true) {
        			$('.upvote-container').removeClass('us world sports business technology entertainment');
        			$('.upvote-text').removeClass('us world sports business technology entertainment');
        			$('.upvote-icon').removeClass('us world sports business technology entertainment');
        			$('.upvote-container').addClass(this.current_category);
        			$('.upvote-text').addClass(this.current_category);
        			$('.upvote-icon').addClass(this.current_category);
        		}

        	},

		fn_tap_upvote: function() {

			if ($('.upvote-container').hasClass('upvoted') == true) {

				$('.upvote-container').removeClass('upvoted');

				setTimeout(function() {
        				$('.upvote-container').removeClass('tapped us world sports business technology entertainment');
        				$('.upvote-text').removeClass('us world sports business technology entertainment');
        				$('.upvote-text').html(30);
        				$('.upvote-icon').removeClass('us world sports business technology entertainment');
        			}, 300);
        		}

			else {

				$('.upvote-container').addClass('upvoted');
    				setTimeout(function() {
        				$('.upvote-container').addClass('tapped ' + that.current_category);
        				$('.upvote-text').addClass(that.current_category);
        				$('.upvote-text').html(31);
        				$('.upvote-icon').addClass(that.current_category);
    				}, 300);
			}

		},

	};

	return Upvote;

})(window, document);
<|endoftext|>