<commit_before>{
  const {dom,domfn,on,once,model,component,run} = rilti
  const {div,span,a,aside,article,button,header,input,main,p,b,html} = dom
  const {attr, attrToggle, css, emit} = domfn
  const tickBox = dom['tick-box']

  const strBool = str => {
    if (str === true || str === false) return str
    return str !== 'false'
  }

  component('tick-box', {
    props: {
      get ticked() { return strBool(attr(this, 'ticked')) },
      set ticked(val) {
        if ((val = strBool(val)) !== this.ticked) {
          attr(this, 'ticked', val)
        }
      }
    },
    create: el => on.click(el, () => el.ticked = !el.ticked),
    attr: {
      ticked: {
        update(el) {
          emit(el, 'ticked', el.ticked)
        }
      }
    }
  })

  var todos = model(JSON.parse(localStorage.getItem('todos') || '{}'))
  const todoCount = () => {
    const all = todos.store.size
    let done = 0
    todos.each(val => val && (done++))
    return {all, done, undone: all - done}
  }

  const updateStorage = () => {
    localStorage.setItem('todos', todos.toJSON())
    todos.emit.update(todoCount())
  }
  todos.on.set(updateStorage)
  todos.on.delete(updateStorage)

  component('todo-list',  {
    create(el) {
      const tdMaker = header({render: el})

      const todoSubmit = (txt = tdInput.value, state = false) => {
        dom['todo-item']({
          render: el,
          attr: {state}
        }, txt)
        todos.emit.newTodo()
      }

      todos.each((val, key) => todoSubmit(key, val))

      const tdInput = input({
        render: tdMaker,
        attr: {
          type: 'text'
        },
        on: {
          keydown({keyCode}) {
            if (keyCode === 13) todoSubmit()
          }
        }
      })

      todos.on.newTodo(() => tdInput.value = '')

      const tdSubmitBtn = button({
        render: tdMaker,
        on: {
          click: () => todoSubmit()
        }
      },
        'add todo'
      )

      const setMode = mode => () => {
        attr(el, 'mode', mode)
        localStorage.setItem('todo-mode', mode)
      }
      setMode(localStorage.getItem('todo-mode') || 'all')()

      const allCount = span({
        on: { click: setMode('all') }
      })
      const doneCount = span({
        on: { click: setMode('done') }
      })
      const undoneCount = span({
        on: { click: setMode('undone') }
      })

      const populateCounts = ({all, done, undone} = todoCount()) => {
        allCount.textContent = `all: ${all}`
        doneCount.textContent = `done: ${done}`
        undoneCount.textContent = `undone: ${undone}`
      }

      populateCounts()
      todos.on.update(populateCounts)

      aside({renderAfter: tdMaker}, allCount, doneCount, undoneCount)
    }
  })

  component('todo-item', {
    props: {
      get state() { return strBool(attr(this, 'state')) },
      set state(val) {
        if ((val = strBool(val)) !== this.state) {
          attr(this, 'state', val)
        }
      },
      set txt(val)  {
        if (val !== this.txt) {
          if (this.txt_el) {
            this.txt_el.textContent = val = (''+val).trim()
            this.update()
          } else {
            on.mount(this, () => this.txt = val)
          }
        }
      },
      get txt() {
        return this.txt_el ? this.txt_el.textContent.trim() : ''
      }
    },
    create(el) {

      el.del = () => {
        el.remove()
        todos.del(el.txt)
        todos.del(el.oldtxt)
      }
      el.update = () => {
        const {txt, state, oldtxt} = el
        if (txt && txt !== 'add todo text') {
          if (txt !== oldtxt) {
            todos.del(oldtxt)
            el.oldtxt = txt
          }
          todos[txt] = state
        }
        el.tick_el.ticked = state
      }

      el.del_el = span({
        class: 'delete-todo',
        on: { click: el.del }
      }, '✕')

      el.txt_el = span({
        class: 'txt',
        attr: { contenteditable: true },
        on: { input: el.update }
      })

      el.tick_el = tickBox({
        attr: { ticked: el.state },
        on: {
          ticked() {
            el.state = el.tick_el.ticked
          }
        }
      })

    },
    mount(el) {
      el.oldtxt = el.textContent || 'add todo text'
      if (!el.txt) {
        el.txt_el.textContent = el.oldtxt
      }
      el.innerHTML = ''
      el.append(el.del_el, el.txt_el, el.tick_el)
      el.update()
    },
    destroy(el) {
      el.del()
    },
    attr: {
      state: {
        update(el) { el.update() }
      }
    }
  })

}
<commit_msg>no null todos<commit_after>{
  const {dom,domfn,on,once,model,component,run} = rilti
  const {div,span,a,aside,article,button,header,input,main,p,b,html} = dom
  const {attr, attrToggle, css, emit} = domfn
  const tickBox = dom['tick-box']

  const strBool = str => {
    if (str === true || str === false) return str
    return str !== 'false'
  }

  component('tick-box', {
    props: {
      get ticked() { return strBool(attr(this, 'ticked')) },
      set ticked(val) {
        if ((val = strBool(val)) !== this.ticked) {
          attr(this, 'ticked', val)
        }
      }
    },
    create: el => on.click(el, () => el.ticked = !el.ticked),
    attr: {
      ticked: {
        update(el) {
          emit(el, 'ticked', el.ticked)
        }
      }
    }
  })

  var todos = model(JSON.parse(localStorage.getItem('todos') || '{}'))
  const todoCount = () => {
    const all = todos.store.size
    let done = 0
    todos.each(val => val && (done++))
    return {all, done, undone: all - done}
  }

  const updateStorage = () => {
    localStorage.setItem('todos', todos.toJSON())
    todos.emit.update(todoCount())
  }
  todos.on.set(updateStorage)
  todos.on.delete(updateStorage)

  component('todo-list',  {
    create(el) {
      const tdMaker = header({render: el})

      const todoSubmit = (txt = tdInput.value.trim(), state = false) => {
        if (txt && txt.length) {
          dom['todo-item']({
            render: el,
            attr: {state}
          }, txt)
          todos.emit.newTodo()
        }
      }

      todos.each((val, key) => todoSubmit(key, val))

      const tdInput = input({
        render: tdMaker,
        attr: {
          type: 'text'
        },
        on: {
          keydown({keyCode}) {
            if (keyCode === 13) todoSubmit()
          }
        }
      })

      todos.on.newTodo(() => tdInput.value = '')

      const tdSubmitBtn = button({
        render: tdMaker,
        on: {
          click: () => todoSubmit()
        }
      },
        'add todo'
      )

      const setMode = mode => () => {
        attr(el, 'mode', mode)
        localStorage.setItem('todo-mode', mode)
      }
      setMode(localStorage.getItem('todo-mode') || 'all')()

      const allCount = span({
        on: { click: setMode('all') }
      })
      const doneCount = span({
        on: { click: setMode('done') }
      })
      const undoneCount = span({
        on: { click: setMode('undone') }
      })

      const populateCounts = ({all, done, undone} = todoCount()) => {
        allCount.textContent = `all: ${all}`
        doneCount.textContent = `done: ${done}`
        undoneCount.textContent = `undone: ${undone}`
      }

      populateCounts()
      todos.on.update(populateCounts)

      aside({renderAfter: tdMaker}, allCount, doneCount, undoneCount)
    }
  })

  component('todo-item', {
    props: {
      get state() { return strBool(attr(this, 'state')) },
      set state(val) {
        if ((val = strBool(val)) !== this.state) {
          attr(this, 'state', val)
        }
      },
      set txt(val)  {
        if (val !== this.txt) {
          if (this.txt_el) {
            this.txt_el.textContent = val = (''+val).trim()
            this.update()
          } else {
            on.mount(this, () => this.txt = val)
          }
        }
      },
      get txt() {
        return this.txt_el ? this.txt_el.textContent.trim() : ''
      }
    },
    create(el) {

      el.del = () => {
        el.remove()
        todos.del(el.txt)
        todos.del(el.oldtxt)
      }
      el.update = () => {
        const {txt, state, oldtxt} = el
        if (txt && txt !== 'add todo text') {
          if (txt !== oldtxt) {
            todos.del(oldtxt)
            el.oldtxt = txt
          }
          todos[txt] = state
        }
        el.tick_el.ticked = state
      }

      el.del_el = span({
        class: 'delete-todo',
        on: { click: el.del }
      }, '✕')

      el.txt_el = span({
        class: 'txt',
        attr: { contenteditable: true },
        on: { input: el.update }
      })

      el.tick_el = tickBox({
        attr: { ticked: el.state },
        on: {
          ticked() {
            el.state = el.tick_el.ticked
          }
        }
      })

    },
    mount(el) {
      el.oldtxt = el.textContent || 'add todo text'
      if (!el.txt) {
        el.txt_el.textContent = el.oldtxt
      }
      el.innerHTML = ''
      el.append(el.del_el, el.txt_el, el.tick_el)
      el.update()
    },
    destroy(el) {
      el.del()
    },
    attr: {
      state: {
        update(el) { el.update() }
      }
    }
  })

}
<|endoftext|>


<commit_before>var React = require('react');
var Reflux = require('reflux');
var Logic = require('../../../browser/logic');

var points = (function () {
  var color = '#df4b26';
  var size = 5;
  var points = [];
  var forEach = function (fn, a) { a.forEach(fn); };

  var Point = function (x, y, dragging, color, size) {
    this.getX = function () { return x; };
    this.getY = function () { return y; };
    this.getColor = function () { return color; };
    this.getSize = function () { return size; };
    this.getDragging = function () { return dragging; };
  };

  Point.prototype.data = function () {
    return {
      x: this.getX(),
      y: this.getY(),
      color: this.getColor(),
      size: this.getSize(),
      dragging: this.getDragging()
    }
  };

  var add = function (x, y, dragging) {
    var p;
    if (x instanceof Object) {
      p = new Point(x.x, x.y, !!x.dragging, x.color, x.size);
    } else {
      p = new Point(x, y, !!dragging, color, size);
    }
    points.push(p);
    return p;
  };

  var getPrevAndCurrPoints = function (i) {
    return [ points[i - 1] && points[i - 1].data(), points[i].data() ];
  };

  return {
    /**
     * Add a new Point to the drawing.
     *
     * @method add
     * @param x {int} The x cordination.
     * @param y {int} The y cordination.
     * @param dragging {boolean} True if its not the first point in current line.
     * @return Returns the newly created Point.
     */

    add: add,

    addArray: forEach.bind(null, add),

    nrOfPoints: function () { return points.length; },

    /**
     * Set the color. All points after the color is changed till its
     * changed again will have the same color.
     *
     * @method setColor
     * @param c {string} The new color.
     */

    setColor: function (c) { color = c; },

    /**
     * Set the size. All points after the size is changed til its changed
     * again will have the same size.
     *
     * @method setSize
     * @param s {int} The new size.
     */

    setSize: function (s) { size = s; },

    /**
     * Remove all points.
     *
     * @method clear
     */

    clear: function () { points = []; },

    /**
     * Iterate through each point.
     *
     * @method each
     * @param fn {function} Callback function that takes two parameters
     *                      (previous and current). Previous is undefined
     *                      if its the first point.
     */

    each: function (fn) {
      for (var i = 0; i < points.length; i += 1) {
        fn.apply(null, getPrevAndCurrPoints(i));
      }
    },

    /**
     * Gets the previous and the current point.
     *
     * @method last
     * @param fn {function} Callbakc function that takes two parameters
     *                      (previous and current). Previous is undefined
     *                      if its the first point.
     */

    last: function (fn) {
      fn.apply(null, getPrevAndCurrPoints(points.length - 1));
    }
  };
}());

module.exports = React.createClass({
  mixins: [Reflux.listenTo(Logic.store, 'handleCrayonUpdate')],

  propTypes: {
    offsetX: React.PropTypes.number,
    offsetY: React.PropTypes.number
  },

  getDefaultProps: function () {
    return { offsetX: 0, offsetY: 0 };
  },

  getInitialState: function () {
    return { painting: false };
  },

  componentDidMount: function () {
    this.context = this.refs.canvas.getDOMNode().getContext('2d');

    // Prevent Chrome from selecting the canvas
    this.context.canvas.onselectstart = function () { return false; };
    this.context.canvas.onmousedown = function () { return false; };

    this._setSizeAndColor(Logic.store.crayon.size, Logic.store.crayon.color);
    this._clear();

    this._start(); // TODO Remove!
  },

  componentDidUpdate: function () {
    // Need to upadate the context when the component is updated or
    // this.context will be undefined.
    this.context = this.refs.canvas.getDOMNode().getContext('2d');
  },

  handleCrayonUpdate: function (crayon) {
    if (crayon.event === 'crayon' && crayon.type === 'update') {
      this._setSizeAndColor(crayon.data.size, crayon.data.color);
    }
  },

  _start: function () {
    this.context.canvas.addEventListener('mousedown', this._startDrawing);
    this.context.canvas.addEventListener('mouseup', this._stopDrawing);
    this.context.canvas.addEventListener('mousemove', this._drawing);
    this.context.canvas.addEventListener('mouseleave', this._stopDrawing); // Firefox etc.
    this.context.canvas.addEventListener('mouseout', this._stopDrawing); // Chrome
  },

  _stop: function () {
    this.context.canvas.removeEventListener('mousedown', this._startDrawing);
    this.context.canvas.removeEventListener('mouseup', this._stopDrawing);
    this.context.canvas.removeEventListener('mousemove', this._drawing);
    this.context.canvas.removeEventListener('mouseleave', this._stopDrawing); // Firefox etc.
    this.context.canvas.removeEventListener('mouseout', this._stopDrawing); // Chrome
  },

  _setSizeAndColor: function (size, color) {
    points.setSize(size);
    points.setColor(color);
  },

  _clear: function () {
    this.setState({ painting: false });
    // Remove all points
    points.clear();
    // Clear the canvas
    this.context.clearRect(0, 0, this.context.canvas.width, this.context.canvas.height);
    // Pencil style
    this.context.lineJoin = 'round';
  },

  _addPoint: function (x, y, dragging) {
    var xx = x - this.context.canvas.offsetLeft - this.props.offsetX;
    var yy = y - this.context.canvas.offsetTop - this.props.offsetY;
    var p = points.add(xx, yy, dragging);

    // Send points to server
    //room.sendPoints(p.data());
    // Start drawing
    points.last(this._drawLine);
  },

  _startDrawing: function (e) {
    this.setState({ painting: true });
		this._addPoint(e.pageX, e.pageY);
	},

  _stopDrawing: function () {
    this.setState({ painting: false });
	},

  _drawing: function (e) {
		if (this.state.painting) {
			this._addPoint(e.pageX, e.pageY, true);
		}
	},

  // former draw() TODO Remove this comment!!!!
  _drawLine: function (prev, curr) {
		if (typeof prev === 'undefined' || prev.color !== curr.color || prev.size !== curr.size) {
			// Pencil style
			this.context.strokeStyle = curr.color;
			this.context.lineWidth = curr.size;
		}

		// Drawing
		this.context.beginPath();

		if (curr.dragging) {
			this.context.moveTo(prev.x, prev.y);
		} else {
			this.context.moveTo(curr.x - 0.1, curr.y - 0.1); // Make a dot
		}
		this.context.lineTo(curr.x, curr.y);

		this.context.closePath();
		this.context.stroke();
	},

  render: function () {
    return (

          <canvas id="artboard" width="800" height="600" ref="canvas"></canvas>

        );
  }
});
<commit_msg>Refactor points<commit_after>var React = require('react');
var Reflux = require('reflux');
var Logic = require('../../../browser/logic');

var points = (function () {
  var color = '#df4b26';
  var size = 5;
  var points = [];
  var forEach = function (fn, a) { a.forEach(fn); };

  var add = function (x, y, dragging) {
    var p;
    if (x instanceof Object) {
      console.log('TODO Is this used?');
      p = { x: x.x, y: x.y, color: x.color, size: x.size, dragging: !!x.dragging };
    } else {
      p = { x: x, y: y, color: color, size: size, dragging: !!dragging };
    }
    points.push(p);
    return p;
  };

  var getPrevAndCurrPoints = function (i) {
    return [ points[i - 1] && points[i - 1], points[i] ];
  };

  return {
    /**
     * Add a new Point to the drawing.
     *
     * @method add
     * @param x {int} The x cordination.
     * @param y {int} The y cordination.
     * @param dragging {boolean} True if its not the first point in current line.
     * @return Returns the newly created Point.
     */

    add: add,

    addArray: forEach.bind(null, add),

    nrOfPoints: function () { return points.length; },

    /**
     * Set the color. All points after the color is changed till its
     * changed again will have the same color.
     *
     * @method setColor
     * @param c {string} The new color.
     */

    setColor: function (c) { color = c; },

    /**
     * Set the size. All points after the size is changed til its changed
     * again will have the same size.
     *
     * @method setSize
     * @param s {int} The new size.
     */

    setSize: function (s) { size = s; },

    /**
     * Remove all points.
     *
     * @method clear
     */

    clear: function () { points = []; },

    /**
     * Iterate through each point.
     *
     * @method each
     * @param fn {function} Callback function that takes two parameters
     *                      (previous and current). Previous is undefined
     *                      if its the first point.
     */

    each: function (fn) {
      for (var i = 0; i < points.length; i += 1) {
        fn.apply(null, getPrevAndCurrPoints(i));
      }
    },

    /**
     * Gets the previous and the current point.
     *
     * @method last
     * @param fn {function} Callbakc function that takes two parameters
     *                      (previous and current). Previous is undefined
     *                      if its the first point.
     */

    last: function (fn) {
      fn.apply(null, getPrevAndCurrPoints(points.length - 1));
    }
  };
}());

module.exports = React.createClass({
  mixins: [Reflux.listenTo(Logic.store, 'handleCrayonUpdate')],

  propTypes: {
    offsetX: React.PropTypes.number,
    offsetY: React.PropTypes.number
  },

  getDefaultProps: function () {
    return { offsetX: 0, offsetY: 0 };
  },

  getInitialState: function () {
    return { painting: false };
  },

  componentDidMount: function () {
    this.context = this.refs.canvas.getDOMNode().getContext('2d');

    // Prevent Chrome from selecting the canvas
    this.context.canvas.onselectstart = function () { return false; };
    this.context.canvas.onmousedown = function () { return false; };

    this._setSizeAndColor(Logic.store.crayon.size, Logic.store.crayon.color);
    this._clear();

    this._start(); // TODO Remove!
  },

  componentDidUpdate: function () {
    // Need to upadate the context when the component is updated or
    // this.context will be undefined.
    this.context = this.refs.canvas.getDOMNode().getContext('2d');
  },

  handleCrayonUpdate: function (crayon) {
    if (crayon.event === 'crayon' && crayon.type === 'update') {
      this._setSizeAndColor(crayon.data.size, crayon.data.color);
    }
  },

  _start: function () {
    this.context.canvas.addEventListener('mousedown', this._startDrawing);
    this.context.canvas.addEventListener('mouseup', this._stopDrawing);
    this.context.canvas.addEventListener('mousemove', this._drawing);
    this.context.canvas.addEventListener('mouseleave', this._stopDrawing); // Firefox etc.
    this.context.canvas.addEventListener('mouseout', this._stopDrawing); // Chrome
  },

  _stop: function () {
    this.context.canvas.removeEventListener('mousedown', this._startDrawing);
    this.context.canvas.removeEventListener('mouseup', this._stopDrawing);
    this.context.canvas.removeEventListener('mousemove', this._drawing);
    this.context.canvas.removeEventListener('mouseleave', this._stopDrawing); // Firefox etc.
    this.context.canvas.removeEventListener('mouseout', this._stopDrawing); // Chrome
  },

  _setSizeAndColor: function (size, color) {
    points.setSize(size);
    points.setColor(color);
  },

  _clear: function () {
    this.setState({ painting: false });
    // Remove all points
    points.clear();
    // Clear the canvas
    this.context.clearRect(0, 0, this.context.canvas.width, this.context.canvas.height);
    // Pencil style
    this.context.lineJoin = 'round';
  },

  _addPoint: function (x, y, dragging) {
    var xx = x - this.context.canvas.offsetLeft - this.props.offsetX;
    var yy = y - this.context.canvas.offsetTop - this.props.offsetY;
    var p = points.add(xx, yy, dragging);

    // Send points to server
    //room.sendPoints(p.data());
    // Start drawing
    points.last(this._drawLine);
  },

  _startDrawing: function (e) {
    this.setState({ painting: true });
		this._addPoint(e.pageX, e.pageY);
	},

  _stopDrawing: function () {
    this.setState({ painting: false });
	},

  _drawing: function (e) {
		if (this.state.painting) {
			this._addPoint(e.pageX, e.pageY, true);
		}
	},

  // former draw() TODO Remove this comment!!!!
  _drawLine: function (prev, curr) {
		if (typeof prev === 'undefined' || prev.color !== curr.color || prev.size !== curr.size) {
			// Pencil style
			this.context.strokeStyle = curr.color;
			this.context.lineWidth = curr.size;
		}

		// Drawing
		this.context.beginPath();

		if (curr.dragging) {
			this.context.moveTo(prev.x, prev.y);
		} else {
			this.context.moveTo(curr.x - 0.1, curr.y - 0.1); // Make a dot
		}
		this.context.lineTo(curr.x, curr.y);

		this.context.closePath();
		this.context.stroke();
	},

  render: function () {
    return (

          <canvas id="artboard" width="800" height="600" ref="canvas"></canvas>

        );
  }
});
<|endoftext|>


<commit_before>export function getPokemon() {
  const url = 'http://localhost:8000/pokemon';
  const headers = {
    'Accept': 'application/json',
    'Content-Type': 'application/json'
  };
  const options = {
    method: 'GET',
    headers: headers
  };
  return fetch(url, options)
    .then((response) => {
      return response.json()
    })
    .then((json) => {
      return json.pokemon
    });
}

export function getPokemonByName(name = "bulbasaur") {
  const url = `http://localhost:8000/pokemon/${name}`;
  const headers = {
    'Accept': 'application/json',
    'Content-Type': 'application/json'
  };
  const options = {
    method: 'GET',
    headers: headers
  };
  return fetch(url, options)
    .then((response) => {
      return response.json()
    })
    .then((json) => json);
}
<commit_msg>refactor(api): abstracted common logic into separate function<commit_after>export function getPokemon() {
  const url = 'http://localhost:8000/pokemon';
  return apiCall(url).then((json) => {
      return json.pokemon
    });
}

export function getPokemonByName(name = "bulbasaur") {
  const url = `http://localhost:8000/pokemon/${name}`;
  return apiCall(url).then((json) => json);
}

function apiCall(url) {
  const headers = {
    'Accept': 'application/json',
    'Content-Type': 'application/json'
  };
  const options = {
    method: 'GET',
    headers: headers
  };
  return fetch(url, options)
    .then((response) => {
      return response.json()
    });
}
<|endoftext|>


<commit_before>// @jsx glam

import glam from 'glam';
import React from 'react';
import md from 'react-markings';
import { Link as RRLink } from 'react-router-dom';

import Svg from '../Svg';
import store from './store';

// ==============================
// Syntax Highlighter
// ==============================

import SyntaxHighlighter, {
  registerLanguage,
} from 'react-syntax-highlighter/prism-light';
import jsx from 'react-syntax-highlighter/languages/prism/jsx';
import { coy } from 'react-syntax-highlighter/styles/prism';

const customCoy = {
  ...coy,
  'code[class*="language-"]': {
    ...coy['code[class*="language-"]'],
    fontFamily: null, // inherit from css
  },
  'pre[class*="language-"]': {
    ...coy['pre[class*="language-"]'],
    fontFamily: null, // inherit from css
  },
};

registerLanguage('jsx', jsx);

// ==============================
// Helpers
// ==============================

function slugify(str: string): string {
  return str.replace(/\W/g, '-').toLowerCase();
}

const Anchor = props => (
  <RRLink
    css={{
      color: 'inherit',
      textDecoration: 'none',
    }}
    {...props}
  />
);

// ==============================
// Renderers
// ==============================

function getLabel(children) {
  let str = '';

  if (Array.isArray(children)) {
    children.forEach(c => {
      if (Array.isArray(c)) {
        getLabel(c);
      } else if (c.props) {
        str = c.props.children;
      } else {
        str = c;
      }
    });
  } else if (children.props) {
    getLabel(children.props.children);
  } else {
    str = children;
  }

  return str;
}

const Chain = props => (
  <Svg
    alt="Link to"
    size={16}
    css={{
      color: '#4C9AFF',
      paddingRight: 10,
      opacity: 0,
      position: 'absolute',
      top: '50%',
      transform: 'translate(-100%, -50%)',
      transition: 'opacity 200ms',
    }}
    {...props}
  >
    <path d="M7.859 14.691l-0.81 0.805c-0.701 0.695-1.843 0.695-2.545 0-0.336-0.334-0.521-0.779-0.521-1.252s0.186-0.916 0.521-1.252l2.98-2.955c0.617-0.613 1.779-1.515 2.626-0.675 0.389 0.386 1.016 0.384 1.403-0.005 0.385-0.389 0.383-1.017-0.006-1.402-1.438-1.428-3.566-1.164-5.419 0.675l-2.98 2.956c-0.715 0.709-1.108 1.654-1.108 2.658 0 1.006 0.394 1.949 1.108 2.658 0.736 0.73 1.702 1.096 2.669 1.096s1.934-0.365 2.669-1.096l0.811-0.805c0.389-0.385 0.391-1.012 0.005-1.4s-1.014-0.39-1.403-0.006zM16.891 3.207c-1.547-1.534-3.709-1.617-5.139-0.197l-1.009 1.002c-0.389 0.386-0.392 1.013-0.006 1.401 0.386 0.389 1.013 0.391 1.402 0.005l1.010-1.001c0.74-0.736 1.711-0.431 2.346 0.197 0.336 0.335 0.522 0.779 0.522 1.252s-0.186 0.917-0.522 1.251l-3.18 3.154c-1.454 1.441-2.136 0.766-2.427 0.477-0.389-0.386-1.016-0.383-1.401 0.005s-0.384 1.017 0.005 1.401c0.668 0.662 1.43 0.99 2.228 0.99 0.977 0 2.010-0.492 2.993-1.467l3.18-3.153c0.712-0.71 1.107-1.654 1.107-2.658s-0.395-1.949-1.109-2.659z" />
  </Svg>
);

const Heading = props => {
  const { children, level, nodeKey } = props;

  const Tag = `h${level}`;
  const label = getLabel(children);
  const slug = slugify(label);
  const linkify = [1, 2].includes(level);

  if (linkify) {
    store.add(nodeKey, { key: nodeKey, label, level, path: `#${slug}` });
  }
  const css = {
    marginTop: 0,
    '&:not(:first-child)': { marginTop: 30 },
  };

  return linkify ? (
    <Tag id={slug} css={css}>
      <Anchor
        to={`#${slug}`}
        css={{
          position: 'relative',
          '&:hover > svg': { opacity: 1, transitionDelay: '300ms' },
        }}
      >
        <Chain />
        {children}
      </Anchor>
    </Tag>
  ) : (
    <Tag css={css}>{children}</Tag>
  );
};

// eslint-disable-next-line no-unused-vars
export const Code = ({ children, inline, literal, nodeKey }) => (

    {literal}

);

export const CodeBlock = ({ codeinfo, literal, nodeKey, ...props }) => {
  const language = codeinfo[0];

  return (
    <SyntaxHighlighter
      language={language}
      style={customCoy}
      customStyle={{
        borderRadius: 4,
        fontSize: 13,
        marginBottom: '1em',
        marginTop: '1em',
        overflowX: 'auto',
        WebkitOverflowScrolling: 'touch',
      }}
      {...props}
    >
      {literal}
    </SyntaxHighlighter>
  );
};
CodeBlock.defaultProps = { codeinfo: [], language: 'jsx' };

const Blockquote = ({ nodeKey, ...props }) => (

);

const Link = ({ href, ...props }) => (
  href[0] === '/'
    ? <RRLink to={href} {...props} />
    :
);

// ==============================
// Exports
// ==============================

export default md.customize({
  renderers: { Blockquote, Code, Heading, CodeBlock, Link },
});
<commit_msg>Fixing a warning in the docs website<commit_after>// @jsx glam

import glam from 'glam';
import React from 'react';
import md from 'react-markings';
import { Link as RRLink } from 'react-router-dom';

import Svg from '../Svg';
import store from './store';

// ==============================
// Syntax Highlighter
// ==============================

import SyntaxHighlighter, {
  registerLanguage,
} from 'react-syntax-highlighter/prism-light';
import jsx from 'react-syntax-highlighter/languages/prism/jsx';
import { coy } from 'react-syntax-highlighter/styles/prism';

const customCoy = {
  ...coy,
  'code[class*="language-"]': {
    ...coy['code[class*="language-"]'],
    fontFamily: null, // inherit from css
  },
  'pre[class*="language-"]': {
    ...coy['pre[class*="language-"]'],
    fontFamily: null, // inherit from css
  },
};

registerLanguage('jsx', jsx);

// ==============================
// Helpers
// ==============================

function slugify(str: string): string {
  return str.replace(/\W/g, '-').toLowerCase();
}

const Anchor = props => (
  <RRLink
    css={{
      color: 'inherit',
      textDecoration: 'none',
    }}
    {...props}
  />
);

// ==============================
// Renderers
// ==============================

function getLabel(children) {
  let str = '';

  if (Array.isArray(children)) {
    children.forEach(c => {
      if (Array.isArray(c)) {
        getLabel(c);
      } else if (c.props) {
        str = c.props.children;
      } else {
        str = c;
      }
    });
  } else if (children.props) {
    getLabel(children.props.children);
  } else {
    str = children;
  }

  return str;
}

const Chain = props => (
  <Svg
    alt="Link to"
    size={16}
    css={{
      color: '#4C9AFF',
      paddingRight: 10,
      opacity: 0,
      position: 'absolute',
      top: '50%',
      transform: 'translate(-100%, -50%)',
      transition: 'opacity 200ms',
    }}
    {...props}
  >
    <path d="M7.859 14.691l-0.81 0.805c-0.701 0.695-1.843 0.695-2.545 0-0.336-0.334-0.521-0.779-0.521-1.252s0.186-0.916 0.521-1.252l2.98-2.955c0.617-0.613 1.779-1.515 2.626-0.675 0.389 0.386 1.016 0.384 1.403-0.005 0.385-0.389 0.383-1.017-0.006-1.402-1.438-1.428-3.566-1.164-5.419 0.675l-2.98 2.956c-0.715 0.709-1.108 1.654-1.108 2.658 0 1.006 0.394 1.949 1.108 2.658 0.736 0.73 1.702 1.096 2.669 1.096s1.934-0.365 2.669-1.096l0.811-0.805c0.389-0.385 0.391-1.012 0.005-1.4s-1.014-0.39-1.403-0.006zM16.891 3.207c-1.547-1.534-3.709-1.617-5.139-0.197l-1.009 1.002c-0.389 0.386-0.392 1.013-0.006 1.401 0.386 0.389 1.013 0.391 1.402 0.005l1.010-1.001c0.74-0.736 1.711-0.431 2.346 0.197 0.336 0.335 0.522 0.779 0.522 1.252s-0.186 0.917-0.522 1.251l-3.18 3.154c-1.454 1.441-2.136 0.766-2.427 0.477-0.389-0.386-1.016-0.383-1.401 0.005s-0.384 1.017 0.005 1.401c0.668 0.662 1.43 0.99 2.228 0.99 0.977 0 2.010-0.492 2.993-1.467l3.18-3.153c0.712-0.71 1.107-1.654 1.107-2.658s-0.395-1.949-1.109-2.659z" />
  </Svg>
);

const Heading = props => {
  const { children, level, nodeKey } = props;

  const Tag = `h${level}`;
  const label = getLabel(children);
  const slug = slugify(label);
  const linkify = [1, 2].includes(level);

  if (linkify) {
    store.add(nodeKey, { key: nodeKey, label, level, path: `#${slug}` });
  }
  const css = {
    marginTop: 0,
    '&:not(:first-child)': { marginTop: 30 },
  };

  return linkify ? (
    <Tag id={slug} css={css}>
      <Anchor
        to={`#${slug}`}
        css={{
          position: 'relative',
          '&:hover > svg': { opacity: 1, transitionDelay: '300ms' },
        }}
      >
        <Chain />
        {children}
      </Anchor>
    </Tag>
  ) : (
    <Tag css={css}>{children}</Tag>
  );
};

// eslint-disable-next-line no-unused-vars
export const Code = ({ children, inline, literal, nodeKey }) => (

    {literal}

);

export const CodeBlock = ({ codeinfo, literal, nodeKey, ...props }) => {
  const language = codeinfo[0];

  return (
    <SyntaxHighlighter
      language={language}
      style={customCoy}
      customStyle={{
        borderRadius: 4,
        fontSize: 13,
        marginBottom: '1em',
        marginTop: '1em',
        overflowX: 'auto',
        WebkitOverflowScrolling: 'touch',
      }}
      {...props}
    >
      {literal}
    </SyntaxHighlighter>
  );
};
CodeBlock.defaultProps = { codeinfo: [], language: 'jsx' };

const Blockquote = ({ nodeKey, ...props }) => (

);

const Link = ({ nodeKey, href, ...props }) =>
  href[0] === '/' ? (
    <RRLink to={href} {...props} />
  ) : (

  );

// ==============================
// Exports
// ==============================

export default md.customize({
  renderers: { Blockquote, Code, Heading, CodeBlock, Link },
});
<|endoftext|>


<commit_before>'use strict'

function HomeWorld() {
    this.__init__()
}

HomeWorld.prototype = {
    scene: null,
    player: null,

    hello_message: null,

    got_camera: null,

    current_world: null,

    //

    __init__: function() {

        this.current_world = false

        this.got_camera = false

        this.scene = new THREE.Scene()

        // Going to try to create a plane here.
        var plane_geometry = new THREE.PlaneGeometry(2000, 2000, 10, 10)
        plane_geometry.applyMatrix(new THREE.Matrix4().makeRotationX(- Math.PI / 2))
        //var plane_material = new THREE.MeshBasicMaterial({color: 0x0000ff})
        var plane_material = new THREE.MeshLambertMaterial({color: 0xccffcc, side: THREE.FrontSide, wireframe: true})
        var plane_mesh     = new THREE.Mesh(plane_geometry, plane_material)
        this.add_to_scene(plane_mesh)

        var light3 = new THREE.PointLight(0xccffcc, .8, 0)
        light3.position.set(5, 100, 5)
        this.add_to_scene(light3)

        var color1 = '#b9ffd2'
        var color2 = '#090920'
        var light2 = new THREE.HemisphereLight(color1, color2, .5)
        this.add_to_scene(light2)

        var light = new THREE.AmbientLight(0x404040, .2) // soft white light
        this.add_to_scene(light)

        this.ajax_status = new Floating2DText(400, 30, '', TYPE_TITLE, this.scene)
        this.ajax_status.update_position_and_look_at(new THREE.Vector3(150, 100, 45), new THREE.Vector3(150, 100, 55))

        // Create the 2 week views here.
        // Temporary design testing.

        var number_of_segments = 14
        var angle_delta = (Math.PI * 2.0) / number_of_segments
        var radius = 300

        this.day_titles = []

        for (var i = 0; i < number_of_segments; i++) {
            var day_string = ''
            switch(i % 7) {
            case 0:
                day_string = 'Monday'
                break
            case 1:
                day_string = 'Tuesday'
                break
            case 2:
                day_string = 'Wednesday'
                break
            case 3:
                day_string = 'Thursday'
                break
            case 4:
                day_string = 'Friday'
                break
            case 5:
                day_string = 'Saturday'
                break
            case 6:
                day_string = 'Sunday'
                break
            }
            console.log('Day string : ' + day_string)
            var day_floating_text = new Floating2DText(100, 25, day_string, TYPE_TITLE, this.scene)

            var x_position = Math.cos(angle_delta * i) * radius
            var z_position = Math.sin(angle_delta * i) * radius

            console.log( x_position + '\t' + z_position)

            day_floating_text.update_position_and_look_at(new THREE.Vector3(x_position, 50, z_position), new THREE.Vector3(0, 50, 0))
            this.day_titles.push(day_floating_text)
        }
    },

    update: function() {

    },

    add_to_scene: function(object) {
        this.scene.add(object)
    },

    enter_world: function() {
        this.current_world = true
        if (this.got_camera === false) {
            this.add_to_scene(this.player.fps_controls.get_object())
        }
        if (this.hello_message === null) {
            this.ajax_status.update_text('Welcome back ' + this.player.username)
        }
        this.player.set_position(new THREE.Vector3(130, 90, 300))
    },

    exit_world: function() {
        this.current_world = false
    }
}

<commit_msg>general updating 08<commit_after>'use strict'

function HomeWorld() {
    this.__init__()
}

HomeWorld.prototype = {
    scene: null,
    player: null,

    hello_message: null,

    got_camera: null,

    current_world: null,

    //

    __init__: function() {

        this.current_world = false

        this.got_camera = false

        this.scene = new THREE.Scene()

        // Going to try to create a plane here.
        var plane_geometry = new THREE.PlaneGeometry(2000, 2000, 10, 10)
        plane_geometry.applyMatrix(new THREE.Matrix4().makeRotationX(- Math.PI / 2))
        //var plane_material = new THREE.MeshBasicMaterial({color: 0x0000ff})
        var plane_material = new THREE.MeshLambertMaterial({color: 0xccffcc, side: THREE.FrontSide, wireframe: true})
        var plane_mesh     = new THREE.Mesh(plane_geometry, plane_material)
        this.add_to_scene(plane_mesh)

        var light3 = new THREE.PointLight(0xccffcc, .8, 0)
        light3.position.set(5, 100, 5)
        this.add_to_scene(light3)

        var color1 = '#b9ffd2'
        var color2 = '#090920'
        var light2 = new THREE.HemisphereLight(color1, color2, .5)
        this.add_to_scene(light2)

        var light = new THREE.AmbientLight(0x404040, .2) // soft white light
        this.add_to_scene(light)

        this.ajax_status = new Floating2DText(400, 30, '', TYPE_TITLE, this.scene)
        this.ajax_status.update_position_and_look_at(new THREE.Vector3(150, 100, 45), new THREE.Vector3(150, 100, 55))

        // Create the 2 week views here.
        // Temporary design testing.

        var number_of_segments = 14
        var angle_delta = (Math.PI * 2.0) / number_of_segments
        var radius = 400

        this.day_titles = []

        var week = 0

        for (var i = 0; i < number_of_segments; i++) {
            var day_string = ''
            var x_position = Math.cos(angle_delta * i) * radius
            var z_position = Math.sin(angle_delta * i) * radius
            switch(i % 7) {
            case 0:
                day_string = 'Monday'
                if (week == 0) {
                    var week_title = new Floating2DText(150, 25, day_string, TYPE_TITLE, this.scene)
                    week_title.update_position_and_look_at(new THREE.Vector3(x_position, 50, z_position), new THREE.Vector3(0, 50, 0))
                } else if (week == 1) {

                }
                break
            case 1:
                day_string = 'Tuesday'
                break
            case 2:
                day_string = 'Wednesday'
                break
            case 3:
                day_string = 'Thursday'
                break
            case 4:
                day_string = 'Friday'
                break
            case 5:
                day_string = 'Saturday'
                break
            case 6:
                day_string = 'Sunday'
                break
            }

            var day_floating_text = new Floating2DText(150, 25, day_string, TYPE_TITLE, this.scene)
            console.log( x_position + '\t' + z_position)

            day_floating_text.update_position_and_look_at(new THREE.Vector3(x_position, 50, z_position), new THREE.Vector3(0, 50, 0))
            this.day_titles.push(day_floating_text)
        }
    },

    update: function() {

    },

    add_to_scene: function(object) {
        this.scene.add(object)
    },

    enter_world: function() {
        this.current_world = true
        if (this.got_camera === false) {
            this.add_to_scene(this.player.fps_controls.get_object())
        }
        if (this.hello_message === null) {
            this.ajax_status.update_text('Welcome back ' + this.player.username)
        }
        this.player.set_position(new THREE.Vector3(130, 90, 300))
    },

    exit_world: function() {
        this.current_world = false
    }
}

<|endoftext|>


<commit_before><commit_msg>only loading rawgit files for this git repo but at least it is loading them now<commit_after><|endoftext|>


<commit_before>/* List Creator Javascript
 */
var sessionVar = Math.random();
var skipVersions = false;
var lastName = '';

function checklink() {
	//http://www.minecraftforum.net/topic/\d+-
	var link = $('#link').val();
	if(link != "") {
		if(/^[a-z]+:\/\//i.test(link)) {
			if(/(http:\/\/)*(www.)*minecraftforum.net\/topic\/\d+-./.test(link)) {
				$('#link').val(link.match(/(http:\/\/)*(www.)*minecraftforum.net\/topic\/\d+-/)[0]);
				$('#linktext').html('MCF Link cut');
			}
			link = $('#link').val();
			if(!/http:\/\/bit\.ly\/[a-zA-Z0-9]*/.test(link)) {
				if($('#linktext').html() == 'MCF Link cut') {
					$('#linktext').html('MCF Link cut - bit.ly this link');
				} else {
					$('#linktext').html('bit.ly this link');
				}
			}
		} else {
			$('#linktext').html('Not a valid link');
		}
	} else {
		$('#linktext').html('Link to the mod\'s page');
	}
}

function setVersions(versionlist) {
	window.skipVersions = true;
	var versions = versionlist.split(',');
	if(versions.indexOf('1.5.2') != -1)
		$('#ver152').attr('checked', true);
	else
		$('#ver152').attr('checked', false);
	if(versions.indexOf('1.5.1') != -1)
		$('#ver151').attr('checked', true);
	else
		$('#ver151').attr('checked', false);
	if(versions.indexOf('1.5.0') != -1)
		$('#ver150').attr('checked', true);
	else
		$('#ver150').attr('checked', false);
	if(versions.indexOf('1.4.7') != -1)
		$('#ver147').attr('checked', true);
	else
		$('#ver147').attr('checked', false);
	if(versions.indexOf('1.4.5') != -1)
		$('#ver145').attr('checked', true);
	else
		$('#ver145').attr('checked', false);
	if(versions.indexOf('1.4.2') != -1)
		$('#ver142').attr('checked', true);
	else
		$('#ver142').attr('checked', false);
}

function bitly() {
	$.getJSON("tools/bitly.php?mode=save&link=" + $('#link').val(), function(data) {
			$('#link').val(data['link']);
			$('#linktext').html('Link shortened!');
			generate();
		});
}

function loadbitly() {
	var link = $('#link').val();
	if(/http:\/\/bit\.ly\/[a-zA-Z0-9]*/.test(link)) {
		$('#linktext').html('Extracting bitly info...');
		$.getJSON("tools/bitly.php?mode=info&link=" + $('#link').val(), function(data) {
			if(/ - Minecraft Forum/.test(data['title']))
				data['title'] = data['title'].replace(/ - Minecraft Forum/, "");
			if(/\[[a-zA-Z0-9.]*\]/.test(data['title']))
				data['title'] = data['title'].replace(/\[[a-zA-Z0-9.\/]*\]/g, "");
			data['title'] = $.trim(data['title']);
			$('#linktext').html('' + data['title'] + '');
		});
	}
}

function generate() {
	var json = '  {\r\n';
	json += '    "name":"' + $.trim($('#name').val()) + '",\r\n';
	json += '    "other":"' + $.trim($('#other').val()) + '",\r\n';
	json += '    "link":"' + $.trim($('#link').val()) + '",\r\n';
	json += '    "desc":"' + $.trim($('#desc').val()) + '",\r\n';
	json += '    "author":"' + $.trim($('#author').val()) + '",\r\n';
	if($.trim($('#type').val()) != "")
		json += '    "type":["' +
			$.map($('#type').val().split(','), $.trim).join('","') +
			'"],\r\n';
	else
		json += '    "type":[],\r\n';

	if($.trim($('#dependencies').val()) != "")
		json += '    "dependencies":["' +
			$.map($('#dependencies').val().split(','), $.trim).join('","') +
			'"],\r\n';
	else
		json += '    "dependencies":[],\r\n';

	var versions = new Array();
	if($('#ver142').is(':checked'))
		versions.push('1.4.2');
	if($('#ver145').is(':checked')) {
		versions.push('1.4.4');
		versions.push('1.4.5');
	}
	if($('#ver147').is(':checked')) {
		versions.push('1.4.6');
		versions.push('1.4.7');
	}
	if($('#ver150').is(':checked'))
		versions.push('1.5.0');
	if($('#ver151').is(':checked'))
		versions.push('1.5.1');
	if($('#ver152').is(':checked'))
		versions.push('1.5.2');
	if(versions.length > 0)
		json += '    "versions":["' + versions.join('","') + '"]\r\n';
	else
		json += '    "versions":[]\r\n';

	json += '  }';
	$('#output').val(json);
}

function reset() {
	var json = '  {\r\n';
	json += '    "name":"",\r\n';
	json += '    "other":"",\r\n';
	json += '    "link":"",\r\n';
	json += '    "desc":"",\r\n';
	json += '    "author":"",\r\n';
	json += '    "type":[],\r\n';
	json += '    "dependencies":[],\r\n';
	json += '    "versions":[]\r\n';
	json += '  }';
	$('#output').val(json);
}

function checkExist() {
	if($('#name').val != window.lastName) {
		$('#nametext').html('Matching existing mods...');
		$.getJSON("../list/modlist.json?" + window.sessionVar, function(data) {
			var match = false;
			for(var i = 0; i < Object.keys(data).length; i++) {
				if(data[i].name.toUpperCase() == $.trim($('#name').val().toUpperCase())) {
					$('#name').val(data[i].name);
					$('#other').val(data[i].other);
					$('#link').val(data[i].link);
					$('#desc').val(data[i].desc);
					$('#author').val(data[i].author);

					$('#type').val(data[i].type.join(','));
					$('#dependencies').val(data[i].dependencies.join(','));

					if(window.skipVersions === false) {
						if(data[i].versions.indexOf('1.5.2') != -1)
							$('#ver152').attr('checked', true);
						else
							$('#ver152').attr('checked', false);
						if(data[i].versions.indexOf('1.5.1') != -1)
							$('#ver151').attr('checked', true);
						else
							$('#ver151').attr('checked', false);
						if(data[i].versions.indexOf('1.5.0') != -1)
							$('#ver150').attr('checked', true);
						else
							$('#ver150').attr('checked', false);
						if(data[i].versions.indexOf('1.4.7') != -1)
							$('#ver147').attr('checked', true);
						else
							$('#ver147').attr('checked', false);
						if(data[i].versions.indexOf('1.4.5') != -1)
							$('#ver145').attr('checked', true);
						else
							$('#ver145').attr('checked', false);
						if(data[i].versions.indexOf('1.4.2') != -1)
							$('#ver142').attr('checked', true);
						else
							$('#ver142').attr('checked', false);
					}
					window.skipVersions = false;

					$('#nametext').html('Match Found');
					checkOtherMods();
					generate();
					loadbitly();
					match = true;
					break;
				}
			}
			if(!match) {
				$('#nametext').html('No match found');
			}
		});
	}
}

function checkOtherMods() {
	$('#authortext').html('Matching existing authors...');
	$.getJSON("../list/modlist.json?" + window.sessionVar, function(data) {
		var match = false;
		var modcount = 0;
		for(var i = 0; i < Object.keys(data).length; i++) {
			if(data[i].author.toUpperCase() == $.trim($('#author').val().toUpperCase())) {
				$('#author').val(data[i].author);
				match = true;
				modcount++;
			}
		}
		if(!match) {
			$('#authortext').html('No entries by this author');
		} else {
			if(modcount == 1)
				$('#authortext').html('1 mod by this author');
			else
				$('#authortext').html('' + modcount + ' mods by this author');
		}
	});
}

function checkDepends() {

}

function hideDivs() {
	$('.canhide').css('display','none');
}

$('#name').focus(function() {
	window.lastName = $('#name').val();
});
$('#name').bind('input propertychange', null,generate);
$('#name').blur(checkExist);
$('#other').bind('input propertychange', null,generate);
$('#link').bind('input propertychange', null,checklink);
$('#link').bind('input propertychange', null,generate);
$('#link').blur(loadbitly);
$('#desc').bind('input propertychange', null,generate);
$('#author').bind('input propertychange', null,generate);
$('#author').blur(checkOtherMods);
$('#type').bind('input propertychange', null,generate);
$('#dependencies').bind('input propertychange', null,generate);
$('#dependencies').bind('input propertychange', null,checkDepends);
$('#ver152').click(generate);
$('#ver151').click(generate);
$('#ver150').click(generate);
$('#ver147').click(generate);
$('#ver145').click(generate);
$('#ver142').click(generate);
$('#reset').click(reset);
$('#output').focus(function() {
    var $this = $(this);
    $this.select();

    // Work around Chrome's little problem
    $this.mouseup(function() {
        // Prevent further mouseup intervention
        $this.unbind('mouseup');
        return false;
    });
});

// main.js
var clip = new ZeroClipboard(document.getElementById('copy'), {
  moviePath: '../resources/flash/ZeroClipboard.swf'
});

$('.canhide').html(
	$('.canhide').html() +
	'
×
'
	);<commit_msg>Added Link name placeholder in case bitly name is empty<commit_after>/* List Creator Javascript
 */
var sessionVar = Math.random();
var skipVersions = false;
var lastName = '';

function checklink() {
	//http://www.minecraftforum.net/topic/\d+-
	var link = $('#link').val();
	if(link != "") {
		if(/^[a-z]+:\/\//i.test(link)) {
			if(/(http:\/\/)*(www.)*minecraftforum.net\/topic\/\d+-./.test(link)) {
				$('#link').val(link.match(/(http:\/\/)*(www.)*minecraftforum.net\/topic\/\d+-/)[0]);
				$('#linktext').html('MCF Link cut');
			}
			link = $('#link').val();
			if(!/http:\/\/bit\.ly\/[a-zA-Z0-9]*/.test(link)) {
				if($('#linktext').html() == 'MCF Link cut') {
					$('#linktext').html('MCF Link cut - bit.ly this link');
				} else {
					$('#linktext').html('bit.ly this link');
				}
			}
		} else {
			$('#linktext').html('Not a valid link');
		}
	} else {
		$('#linktext').html('Link to the mod\'s page');
	}
}

function setVersions(versionlist) {
	window.skipVersions = true;
	var versions = versionlist.split(',');
	if(versions.indexOf('1.5.2') != -1)
		$('#ver152').attr('checked', true);
	else
		$('#ver152').attr('checked', false);
	if(versions.indexOf('1.5.1') != -1)
		$('#ver151').attr('checked', true);
	else
		$('#ver151').attr('checked', false);
	if(versions.indexOf('1.5.0') != -1)
		$('#ver150').attr('checked', true);
	else
		$('#ver150').attr('checked', false);
	if(versions.indexOf('1.4.7') != -1)
		$('#ver147').attr('checked', true);
	else
		$('#ver147').attr('checked', false);
	if(versions.indexOf('1.4.5') != -1)
		$('#ver145').attr('checked', true);
	else
		$('#ver145').attr('checked', false);
	if(versions.indexOf('1.4.2') != -1)
		$('#ver142').attr('checked', true);
	else
		$('#ver142').attr('checked', false);
}

function bitly() {
	$.getJSON("tools/bitly.php?mode=save&link=" + $('#link').val(), function(data) {
			$('#link').val(data['link']);
			$('#linktext').html('Link shortened!');
			generate();
		});
}

function loadbitly() {
	var link = $('#link').val();
	if(/http:\/\/bit\.ly\/[a-zA-Z0-9]*/.test(link)) {
		$('#linktext').html('Extracting bitly info...');
		$.getJSON("tools/bitly.php?mode=info&link=" + $('#link').val(), function(data) {
			if(/ - Minecraft Forum/.test(data['title']))
				data['title'] = data['title'].replace(/ - Minecraft Forum/, "");
			if(/\[[a-zA-Z0-9.]*\]/.test(data['title']))
				data['title'] = data['title'].replace(/\[[a-zA-Z0-9.\/]*\]/g, "");
			data['title'] = $.trim(data['title']);
			if(data['title'] == "")
				data['title'] = "Link";
			$('#linktext').html('' + data['title'] + '');
		});
	}
}

function generate() {
	var json = '  {\r\n';
	json += '    "name":"' + $.trim($('#name').val()) + '",\r\n';
	json += '    "other":"' + $.trim($('#other').val()) + '",\r\n';
	json += '    "link":"' + $.trim($('#link').val()) + '",\r\n';
	json += '    "desc":"' + $.trim($('#desc').val()) + '",\r\n';
	json += '    "author":"' + $.trim($('#author').val()) + '",\r\n';
	if($.trim($('#type').val()) != "")
		json += '    "type":["' +
			$.map($('#type').val().split(','), $.trim).join('","') +
			'"],\r\n';
	else
		json += '    "type":[],\r\n';

	if($.trim($('#dependencies').val()) != "")
		json += '    "dependencies":["' +
			$.map($('#dependencies').val().split(','), $.trim).join('","') +
			'"],\r\n';
	else
		json += '    "dependencies":[],\r\n';

	var versions = new Array();
	if($('#ver142').is(':checked'))
		versions.push('1.4.2');
	if($('#ver145').is(':checked')) {
		versions.push('1.4.4');
		versions.push('1.4.5');
	}
	if($('#ver147').is(':checked')) {
		versions.push('1.4.6');
		versions.push('1.4.7');
	}
	if($('#ver150').is(':checked'))
		versions.push('1.5.0');
	if($('#ver151').is(':checked'))
		versions.push('1.5.1');
	if($('#ver152').is(':checked'))
		versions.push('1.5.2');
	if(versions.length > 0)
		json += '    "versions":["' + versions.join('","') + '"]\r\n';
	else
		json += '    "versions":[]\r\n';

	json += '  }';
	$('#output').val(json);
}

function reset() {
	var json = '  {\r\n';
	json += '    "name":"",\r\n';
	json += '    "other":"",\r\n';
	json += '    "link":"",\r\n';
	json += '    "desc":"",\r\n';
	json += '    "author":"",\r\n';
	json += '    "type":[],\r\n';
	json += '    "dependencies":[],\r\n';
	json += '    "versions":[]\r\n';
	json += '  }';
	$('#output').val(json);
}

function checkExist() {
	if($('#name').val != window.lastName) {
		$('#nametext').html('Matching existing mods...');
		$.getJSON("../list/modlist.json?" + window.sessionVar, function(data) {
			var match = false;
			for(var i = 0; i < Object.keys(data).length; i++) {
				if(data[i].name.toUpperCase() == $.trim($('#name').val().toUpperCase())) {
					$('#name').val(data[i].name);
					$('#other').val(data[i].other);
					$('#link').val(data[i].link);
					$('#desc').val(data[i].desc);
					$('#author').val(data[i].author);

					$('#type').val(data[i].type.join(','));
					$('#dependencies').val(data[i].dependencies.join(','));

					if(window.skipVersions === false) {
						if(data[i].versions.indexOf('1.5.2') != -1)
							$('#ver152').attr('checked', true);
						else
							$('#ver152').attr('checked', false);
						if(data[i].versions.indexOf('1.5.1') != -1)
							$('#ver151').attr('checked', true);
						else
							$('#ver151').attr('checked', false);
						if(data[i].versions.indexOf('1.5.0') != -1)
							$('#ver150').attr('checked', true);
						else
							$('#ver150').attr('checked', false);
						if(data[i].versions.indexOf('1.4.7') != -1)
							$('#ver147').attr('checked', true);
						else
							$('#ver147').attr('checked', false);
						if(data[i].versions.indexOf('1.4.5') != -1)
							$('#ver145').attr('checked', true);
						else
							$('#ver145').attr('checked', false);
						if(data[i].versions.indexOf('1.4.2') != -1)
							$('#ver142').attr('checked', true);
						else
							$('#ver142').attr('checked', false);
					}
					window.skipVersions = false;

					$('#nametext').html('Match Found');
					checkOtherMods();
					generate();
					loadbitly();
					match = true;
					break;
				}
			}
			if(!match) {
				$('#nametext').html('No match found');
			}
		});
	}
}

function checkOtherMods() {
	$('#authortext').html('Matching existing authors...');
	$.getJSON("../list/modlist.json?" + window.sessionVar, function(data) {
		var match = false;
		var modcount = 0;
		for(var i = 0; i < Object.keys(data).length; i++) {
			if(data[i].author.toUpperCase() == $.trim($('#author').val().toUpperCase())) {
				$('#author').val(data[i].author);
				match = true;
				modcount++;
			}
		}
		if(!match) {
			$('#authortext').html('No entries by this author');
		} else {
			if(modcount == 1)
				$('#authortext').html('1 mod by this author');
			else
				$('#authortext').html('' + modcount + ' mods by this author');
		}
	});
}

function checkDepends() {

}

function hideDivs() {
	$('.canhide').css('display','none');
}

$('#name').focus(function() {
	window.lastName = $('#name').val();
});
$('#name').bind('input propertychange', null,generate);
$('#name').blur(checkExist);
$('#other').bind('input propertychange', null,generate);
$('#link').bind('input propertychange', null,checklink);
$('#link').bind('input propertychange', null,generate);
$('#link').blur(loadbitly);
$('#desc').bind('input propertychange', null,generate);
$('#author').bind('input propertychange', null,generate);
$('#author').blur(checkOtherMods);
$('#type').bind('input propertychange', null,generate);
$('#dependencies').bind('input propertychange', null,generate);
$('#dependencies').bind('input propertychange', null,checkDepends);
$('#ver152').click(generate);
$('#ver151').click(generate);
$('#ver150').click(generate);
$('#ver147').click(generate);
$('#ver145').click(generate);
$('#ver142').click(generate);
$('#reset').click(reset);
$('#output').focus(function() {
    var $this = $(this);
    $this.select();

    // Work around Chrome's little problem
    $this.mouseup(function() {
        // Prevent further mouseup intervention
        $this.unbind('mouseup');
        return false;
    });
});

// main.js
var clip = new ZeroClipboard(document.getElementById('copy'), {
  moviePath: '../resources/flash/ZeroClipboard.swf'
});

$('.canhide').html(
	$('.canhide').html() +
	'
×
'
	);<|endoftext|>


<commit_before>// forest change
import * as gladAlerts from './widgets/forest-change/glad-alerts';
import * as treeLoss from './widgets/forest-change/tree-loss';
import * as treeLossGlobal from './widgets/forest-change/tree-loss-global';
import * as treeLossRanked from './widgets/forest-change/tree-loss-ranked';
import * as faoDeforest from './widgets/forest-change/fao-deforest';
import * as faoReforest from './widgets/forest-change/fao-reforest';
import * as firesAlerts from './widgets/forest-change/fires-alerts';
import * as firesRanked from './widgets/forest-change/fires-ranked';
import * as gladRanked from './widgets/forest-change/glad-ranked';
import * as treeCoverGain from './widgets/forest-change/tree-cover-gain';
import * as treeGainLocated from './widgets/forest-change/tree-gain-located';
import * as treeLossLocated from './widgets/forest-change/tree-loss-located';
import * as treeLossPlantations from './widgets/forest-change/tree-loss-plantations';
import * as treeLossTsc from './widgets/forest-change/tree-loss-tsc';

// land cover
import * as treeCover from './widgets/land-cover/tree-cover';
import * as treeCover2000 from './widgets/land-cover/tree-cover-2000';
import * as treeCover2010 from './widgets/land-cover/tree-cover-2010';
import * as treeCoverRanked from './widgets/land-cover/tree-cover-ranked';
import * as treeCoverPlantations from './widgets/land-cover/tree-cover-plantations';
import * as rankedPlantations from './widgets/land-cover/ranked-plantations';
import * as faoCover from './widgets/land-cover/fao-cover';
import * as globalLandCover from './widgets/land-cover/global-land-cover';
import * as intactTreeCover from './widgets/land-cover/intact-tree-cover';
import * as primaryForest from './widgets/land-cover/primary-forest';
import * as treeCoverLocated from './widgets/land-cover/tree-cover-located';

// Climate
import * as emissions from './widgets/climate/emissions';
import * as woodyBiomass from './widgets/climate/whrc-biomass/';
import * as soilBiomass from './widgets/climate/soil-organic';
// import * as emissionsDeforestation from './widgets/climate/emissions-deforestation';
import * as emissionsPlantations from './widgets/climate/emissions-plantations';
import * as futureCarbonGains from './widgets/climate/future-carbon-gains';
import * as cumulativeEmissions from './widgets/climate/cumulative-emissions';
import * as carbonStock from './widgets/climate/carbon-stock';

// Biodiversity
// import * as gladBiodiversity from './widgets/biodiversity/glad-biodiversity';

// Land Use
import * as economicImpact from './widgets/land-use/economic-impact';
import * as forestryEmployment from './widgets/land-use/forestry-employment';

import * as traseCommodities from './widgets/land-use/trase-commodities';

export default {
  // forest change
  gladAlerts,
  treeLoss,
  treeLossGlobal,
  treeLossRanked,
  firesAlerts,
  firesRanked,
  faoDeforest,
  faoReforest,
  gladRanked,
  treeCoverGain,
  treeGainLocated,
  treeLossLocated,
  treeLossPlantations,
  treeLossTsc,
  // land cover
  treeCover,
  treeCover2000,
  treeCover2010,
  treeCoverRanked,
  rankedPlantations,
  treeCoverPlantations,
  faoCover,
  globalLandCover,
  intactTreeCover,
  primaryForest,
  treeCoverLocated,
  // climate
  emissions,
  // emissionsDeforestation,
  emissionsPlantations,
  woodyBiomass,
  soilBiomass,
  futureCarbonGains,
  cumulativeEmissions,
  carbonStock,
  // biodiversity
  // gladBiodiversity,
  // land use
  economicImpact,
  forestryEmployment,
  traseCommodities
};
<commit_msg>enable biomass loss in manifest<commit_after>// forest change
import * as gladAlerts from './widgets/forest-change/glad-alerts';
import * as treeLoss from './widgets/forest-change/tree-loss';
import * as treeLossGlobal from './widgets/forest-change/tree-loss-global';
import * as treeLossRanked from './widgets/forest-change/tree-loss-ranked';
import * as faoDeforest from './widgets/forest-change/fao-deforest';
import * as faoReforest from './widgets/forest-change/fao-reforest';
import * as firesAlerts from './widgets/forest-change/fires-alerts';
import * as firesRanked from './widgets/forest-change/fires-ranked';
import * as gladRanked from './widgets/forest-change/glad-ranked';
import * as treeCoverGain from './widgets/forest-change/tree-cover-gain';
import * as treeGainLocated from './widgets/forest-change/tree-gain-located';
import * as treeLossLocated from './widgets/forest-change/tree-loss-located';
import * as treeLossPlantations from './widgets/forest-change/tree-loss-plantations';
import * as treeLossTsc from './widgets/forest-change/tree-loss-tsc';

// land cover
import * as treeCover from './widgets/land-cover/tree-cover';
import * as treeCover2000 from './widgets/land-cover/tree-cover-2000';
import * as treeCover2010 from './widgets/land-cover/tree-cover-2010';
import * as treeCoverRanked from './widgets/land-cover/tree-cover-ranked';
import * as treeCoverPlantations from './widgets/land-cover/tree-cover-plantations';
import * as rankedPlantations from './widgets/land-cover/ranked-plantations';
import * as faoCover from './widgets/land-cover/fao-cover';
import * as globalLandCover from './widgets/land-cover/global-land-cover';
import * as intactTreeCover from './widgets/land-cover/intact-tree-cover';
import * as primaryForest from './widgets/land-cover/primary-forest';
import * as treeCoverLocated from './widgets/land-cover/tree-cover-located';

// Climate
import * as emissions from './widgets/climate/emissions';
import * as woodyBiomass from './widgets/climate/whrc-biomass/';
import * as soilBiomass from './widgets/climate/soil-organic';
import * as emissionsDeforestation from './widgets/climate/emissions-deforestation';
import * as emissionsPlantations from './widgets/climate/emissions-plantations';
import * as futureCarbonGains from './widgets/climate/future-carbon-gains';
import * as cumulativeEmissions from './widgets/climate/cumulative-emissions';
import * as carbonStock from './widgets/climate/carbon-stock';

// Biodiversity
// import * as gladBiodiversity from './widgets/biodiversity/glad-biodiversity';

// Land Use
import * as economicImpact from './widgets/land-use/economic-impact';
import * as forestryEmployment from './widgets/land-use/forestry-employment';

import * as traseCommodities from './widgets/land-use/trase-commodities';

export default {
  // forest change
  gladAlerts,
  treeLoss,
  treeLossGlobal,
  treeLossRanked,
  firesAlerts,
  firesRanked,
  faoDeforest,
  faoReforest,
  gladRanked,
  treeCoverGain,
  treeGainLocated,
  treeLossLocated,
  treeLossPlantations,
  treeLossTsc,
  // land cover
  treeCover,
  treeCover2000,
  treeCover2010,
  treeCoverRanked,
  rankedPlantations,
  treeCoverPlantations,
  faoCover,
  globalLandCover,
  intactTreeCover,
  primaryForest,
  treeCoverLocated,
  // climate
  emissions,
  emissionsDeforestation,
  emissionsPlantations,
  woodyBiomass,
  soilBiomass,
  futureCarbonGains,
  cumulativeEmissions,
  carbonStock,
  // biodiversity
  // gladBiodiversity,
  // land use
  economicImpact,
  forestryEmployment,
  traseCommodities
};
<|endoftext|>


<commit_before>/*
 * Electronic Logistics Management Information System (eLMIS) is a supply chain management system for health commodities in a developing country setting.
 *
 * Copyright (C) 2015  John Snow, Inc (JSI). This program was produced for the U.S. Agency for International Development (USAID). It was prepared under the USAID | DELIVER PROJECT, Task Order 4.
 *
 * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

services.factory('VaccineDiseases', function ($resource) {
  return $resource('/vaccine/disease/all.json', {}, {});
});

services.factory('VaccineDisease', function ($resource) {
  return $resource('/vaccine/disease/get/:id.json', {id : '@id'}, {});
});

services.factory('SaveVaccineDisease', function ($resource) {
  return $resource('/vaccine/disease/save.json', {}, update);
});

services.factory('SaveVaccineProductDose', function ($resource) {
  return $resource('/vaccine/product-dose/save.json', {}, update);
});

services.factory('VaccineProductDose', function ($resource) {
  return $resource('/vaccine/product-dose/get/:programId.json', {productId : '@programId'}, {});
});

services.factory('VaccineIvdTabConfigs', function ($resource) {
  return $resource('/vaccine/config/tab-visibility/:programId.json', {productId : '@programId'}, {});
});

services.factory('SaveVaccineIvdTabConfigs', function ($resource) {
  return $resource('/vaccine/config/save-tab-visibility.json', {}, update);
});

services.factory('VaccineReportConfigurablePrograms', function ($resource) {
  return $resource('/vaccine/report/programs.json', {}, {});
});

services.factory('VaccineSupervisedIvdPrograms', function ($resource) {
  return $resource('/vaccine/report/ivd-form/supervised-programs.json', {}, {});
});

services.factory('VaccineHomeFacilityIvdPrograms', function ($resource) {
  return $resource('/vaccine/report/ivd-form/programs.json', {}, {});
});

services.factory('VaccineReportPrograms', function ($resource) {
  return $resource('/vaccine/report/programs.json', {}, {});
});

services.factory('VaccineReportFacilities', function ($resource) {
  return $resource('/vaccine/report/ivd-form/facilities/:programId.json', { programId: '@programId'}, {});
});

services.factory('VaccineReportPeriods', function ($resource) {
  return $resource('/vaccine/report/periods/:facilityId/:programId.json', {facilityId: '@facilityId', programId: '@programId'}, {});
});

services.factory('ViewVaccineReportPeriods', function ($resource) {
  return $resource('/vaccine/report/view-periods/:facilityId/:programId.json', {facilityId: '@facilityId', programId: '@programId'}, {});
});

services.factory('VaccineReportInitiate', function ($resource) {
  return $resource('/vaccine/report/initialize/:facilityId/:programId/:periodId.json', {facilityId: '@facilityId', programId: '@programId', periodId: '@periodId'}, {});
});

services.factory('VaccineReport', function ($resource) {
  return $resource('/vaccine/report/get/:id.json', {id: '@id'}, {});
});

services.factory('VaccineReportSave', function ($resource) {
  return $resource('/vaccine/report/save.json', {}, update);
});

services.factory('VaccineReportSubmit', function ($resource) {
  return $resource('/vaccine/report/submit.json', {}, update);
});

services.factory('VaccineColumnTemplate', function ($resource) {
  return $resource('/vaccine/columns/get/:id.json', {id : '@id'}, {});
});

services.factory('VaccineColumnTemplateSave', function ($resource) {
  return $resource('/vaccine/columns/save.json', {}, update);
});

services.factory('VaccineDiscardingReasons', function($resource){
  return $resource('/vaccine/discarding/reasons/all.json',{},{});
});

services.factory('StockCards', function($resource){
   return $resource('/api/v2/facilities/:facilityId/stockCards.json', {facilityId: '@facilityId'}, {});
});

services.factory('Forecast', function($resource){
//TODO call Forecast API
});

services.factory('ProgramProducts',function($resource){
    return $resource('/programProducts/programId/:programId.json',{programId:'@programId'},{});
});

services.factory('VaccineInventoryPrograms',function($resource){
    return $resource('/vaccine/inventory/programs.json',{},{});
});

services.factory('SaveVaccineInventoryAdjustment',function($resource){
    return $resource('/vaccine/inventory/stock/adjustment.json',{},{update:{method:'PUT'}});
});

services.factory('VaccineAdjustmentReasons',function($resource){
    return $resource('/api/v2/stockManagement/adjustmentReasons.json',{},{});
});

services.factory('VaccineProgramProducts', function ($resource) {
  return $resource('/vaccine/inventory/programProducts/programId/:programId.json', {}, {});
});

services.factory('ProductLots', function ($resource) {
  return $resource('/vaccine/inventory/lots/byProduct/:productId.json', {productId:'@productId'}, {});
});

services.factory('SaveVaccineInventoryReceived',function($resource){
    return $resource('/vaccine/inventory/stock/credit.json',{},{update:{method:'PUT'}});
});

services.factory('SaveVaccineInventoryConfigurations',function($resource){
    return $resource('/vaccine/inventory/configuration/save.json',{},{update:{method:'PUT'}});
});

services.factory('VaccineInventoryConfigurations',function($resource){
    return $resource('/vaccine/inventory/configuration/getAll.json',{},{});
});

services.factory('ManufacturerList', function ($resource) {
  return $resource('/vaccine/manufacturers.json', {}, {});
});

services.factory('VaccineIssueStock', function($resource){
    return $resource('/vaccine/inventory/stock/debit.json',{}, update);
});

/*

services.factory('VaccineSupervisedIvdPrograms', function ($resource) {
    return $resource('/vaccine/orderRequisition/ivd-form/supervised-programs.json', {}, {});
});
*/

services.factory('VaccineReportPrograms', function ($resource) {
    return $resource('/vaccine/orderRequisition/programs.json', {}, {});
});

services.factory('VaccineOrderRequisitionReportPeriods', function ($resource) {
    return $resource('/vaccine/orderRequisition/periods/:facilityId/:programId.json', {facilityId: '@facilityId', programId: '@programId'}, {});
});

services.factory('ViewOrderRequisitionVaccineReportPeriods', function ($resource) {
    return $resource('/vaccine/orderRequisition/view-periods/:facilityId/:programId.json', {facilityId: '@facilityId', programId: '@programId'}, {});
});

services.factory('VaccineOrderRequisitionReportInitiate', function ($resource) {
    return $resource('/vaccine/orderRequisition/initialize/:periodId/:programId/:facilityId.json', {facilityId: '@facilityId', programId: '@programId', periodId: '@periodId'}, {});
});

services.factory('VaccineOrderRequisitionReportInitiateEmergency', function ($resource) {
    return $resource('/vaccine/orderRequisition/initializeEmergency/:periodId/:programId/:facilityId.json', {facilityId: '@facilityId', programId: '@programId', periodId: '@periodId'}, {});
});

services.factory('VaccineOrderRequisitionReport', function ($resource) {
    return $resource('/vaccine/orderRequisition/get/:id.json', {id: '@id'}, {});
});

services.factory('UserHomeFacility', function ($resource) {
    return $resource('/vaccine/orderRequisition/userHomeFacility.json', {}, {});
});

services.factory('UserPrograms', function ($resource) {
    return $resource('/reports/user-programs.json', {}, {});
});

services.factory('VaccineOrderRequisitionSubmit', function ($resource) {
    return $resource('/vaccine/orderRequisition/submit.json', {}, update);
});

services.factory('VaccineOrderRequisitionColumns', function ($resource) {
    return $resource('/vaccine/columns/get/columns.json', {}, {});
});

services.factory('VaccinePendingRequisitions', function ($resource) {
    return $resource('/vaccine/orderRequisition/getPendingRequest/:facilityId/:programId.json', {}, {});
});

services.factory('LoggedInUserDetails',function($resource){
    return $resource('/vaccine/orderRequisition/loggedInUserDetails.json',{},{});
});

services.factory('ProgramForUserHomeFacility', function($resource){
    return $resource('/vaccine/orderRequisition/order-requisition/programs.json',{},{});
});

services.factory('VaccineOrderRequisitionInsert', function($resource){
    return $resource('/vaccine/orderRequisition/initialize/:programId/:facilityId.json',{programId:'@programId',facilityId:'@facilityId'},{});
});

services.factory('VaccineOrderRequisitionLastReport', function($resource){
    return $resource('/vaccine/orderRequisition/lastReport/:facilityId/:programId.json',{facilityId:'@facilityId',programId:'@programId'},{});
});

services.factory('VaccineOrderRequisitionSave', function ($resource) {
    return $resource('/vaccine/orderRequisition/save.json', {}, update);
});

services.factory('VaccineOrderRequisitionSubmit', function ($resource) {
    return $resource('/vaccine/orderRequisition/submit.json', {}, update);
});

services.factory('VaccineHomeFacilityPrograms', function ($resource) {
    return $resource('/vaccine/orderRequisition/programs.json', {}, {});
});

services.factory('UpdateOrderRequisitionStatus',function($resource){
    return $resource('/vaccine/orderRequisition/updateOrderRequest/:orderId.json',{orderId:'@orderId'},{update:{method:'PUT'}});
});

services.factory('VaccineLastStockMovement', function ($resource) {
    return $resource('/vaccine/inventory/stock/lastReport.json', {}, {});
});
<commit_msg>Add Service to get/save distributions<commit_after>/*
 * Electronic Logistics Management Information System (eLMIS) is a supply chain management system for health commodities in a developing country setting.
 *
 * Copyright (C) 2015  John Snow, Inc (JSI). This program was produced for the U.S. Agency for International Development (USAID). It was prepared under the USAID | DELIVER PROJECT, Task Order 4.
 *
 * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

services.factory('VaccineDiseases', function ($resource) {
  return $resource('/vaccine/disease/all.json', {}, {});
});

services.factory('VaccineDisease', function ($resource) {
  return $resource('/vaccine/disease/get/:id.json', {id : '@id'}, {});
});

services.factory('SaveVaccineDisease', function ($resource) {
  return $resource('/vaccine/disease/save.json', {}, update);
});

services.factory('SaveVaccineProductDose', function ($resource) {
  return $resource('/vaccine/product-dose/save.json', {}, update);
});

services.factory('VaccineProductDose', function ($resource) {
  return $resource('/vaccine/product-dose/get/:programId.json', {productId : '@programId'}, {});
});

services.factory('VaccineIvdTabConfigs', function ($resource) {
  return $resource('/vaccine/config/tab-visibility/:programId.json', {productId : '@programId'}, {});
});

services.factory('SaveVaccineIvdTabConfigs', function ($resource) {
  return $resource('/vaccine/config/save-tab-visibility.json', {}, update);
});

services.factory('VaccineReportConfigurablePrograms', function ($resource) {
  return $resource('/vaccine/report/programs.json', {}, {});
});

services.factory('VaccineSupervisedIvdPrograms', function ($resource) {
  return $resource('/vaccine/report/ivd-form/supervised-programs.json', {}, {});
});

services.factory('VaccineHomeFacilityIvdPrograms', function ($resource) {
  return $resource('/vaccine/report/ivd-form/programs.json', {}, {});
});

services.factory('VaccineReportPrograms', function ($resource) {
  return $resource('/vaccine/report/programs.json', {}, {});
});

services.factory('VaccineReportFacilities', function ($resource) {
  return $resource('/vaccine/report/ivd-form/facilities/:programId.json', { programId: '@programId'}, {});
});

services.factory('VaccineReportPeriods', function ($resource) {
  return $resource('/vaccine/report/periods/:facilityId/:programId.json', {facilityId: '@facilityId', programId: '@programId'}, {});
});

services.factory('ViewVaccineReportPeriods', function ($resource) {
  return $resource('/vaccine/report/view-periods/:facilityId/:programId.json', {facilityId: '@facilityId', programId: '@programId'}, {});
});

services.factory('VaccineReportInitiate', function ($resource) {
  return $resource('/vaccine/report/initialize/:facilityId/:programId/:periodId.json', {facilityId: '@facilityId', programId: '@programId', periodId: '@periodId'}, {});
});

services.factory('VaccineReport', function ($resource) {
  return $resource('/vaccine/report/get/:id.json', {id: '@id'}, {});
});

services.factory('VaccineReportSave', function ($resource) {
  return $resource('/vaccine/report/save.json', {}, update);
});

services.factory('VaccineReportSubmit', function ($resource) {
  return $resource('/vaccine/report/submit.json', {}, update);
});

services.factory('VaccineColumnTemplate', function ($resource) {
  return $resource('/vaccine/columns/get/:id.json', {id : '@id'}, {});
});

services.factory('VaccineColumnTemplateSave', function ($resource) {
  return $resource('/vaccine/columns/save.json', {}, update);
});

services.factory('VaccineDiscardingReasons', function($resource){
  return $resource('/vaccine/discarding/reasons/all.json',{},{});
});

services.factory('StockCards', function($resource){
   return $resource('/api/v2/facilities/:facilityId/stockCards.json', {facilityId: '@facilityId'}, {});
});

services.factory('Forecast', function($resource){
//TODO call Forecast API
});

services.factory('ProgramProducts',function($resource){
    return $resource('/programProducts/programId/:programId.json',{programId:'@programId'},{});
});

services.factory('VaccineInventoryPrograms',function($resource){
    return $resource('/vaccine/inventory/programs.json',{},{});
});

services.factory('SaveVaccineInventoryAdjustment',function($resource){
    return $resource('/vaccine/inventory/stock/adjustment.json',{},{update:{method:'PUT'}});
});

services.factory('VaccineAdjustmentReasons',function($resource){
    return $resource('/api/v2/stockManagement/adjustmentReasons.json',{},{});
});

services.factory('VaccineProgramProducts', function ($resource) {
  return $resource('/vaccine/inventory/programProducts/programId/:programId.json', {}, {});
});

services.factory('ProductLots', function ($resource) {
  return $resource('/vaccine/inventory/lots/byProduct/:productId.json', {productId:'@productId'}, {});
});

services.factory('SaveVaccineInventoryReceived',function($resource){
    return $resource('/vaccine/inventory/stock/credit.json',{},{update:{method:'PUT'}});
});

services.factory('SaveVaccineInventoryConfigurations',function($resource){
    return $resource('/vaccine/inventory/configuration/save.json',{},{update:{method:'PUT'}});
});

services.factory('VaccineInventoryConfigurations',function($resource){
    return $resource('/vaccine/inventory/configuration/getAll.json',{},{});
});

services.factory('ManufacturerList', function ($resource) {
  return $resource('/vaccine/manufacturers.json', {}, {});
});

services.factory('VaccineIssueStock', function($resource){
    return $resource('/vaccine/inventory/stock/debit.json',{}, update);
});

/*

services.factory('VaccineSupervisedIvdPrograms', function ($resource) {
    return $resource('/vaccine/orderRequisition/ivd-form/supervised-programs.json', {}, {});
});
*/

services.factory('VaccineReportPrograms', function ($resource) {
    return $resource('/vaccine/orderRequisition/programs.json', {}, {});
});

services.factory('VaccineOrderRequisitionReportPeriods', function ($resource) {
    return $resource('/vaccine/orderRequisition/periods/:facilityId/:programId.json', {facilityId: '@facilityId', programId: '@programId'}, {});
});

services.factory('ViewOrderRequisitionVaccineReportPeriods', function ($resource) {
    return $resource('/vaccine/orderRequisition/view-periods/:facilityId/:programId.json', {facilityId: '@facilityId', programId: '@programId'}, {});
});

services.factory('VaccineOrderRequisitionReportInitiate', function ($resource) {
    return $resource('/vaccine/orderRequisition/initialize/:periodId/:programId/:facilityId.json', {facilityId: '@facilityId', programId: '@programId', periodId: '@periodId'}, {});
});

services.factory('VaccineOrderRequisitionReportInitiateEmergency', function ($resource) {
    return $resource('/vaccine/orderRequisition/initializeEmergency/:periodId/:programId/:facilityId.json', {facilityId: '@facilityId', programId: '@programId', periodId: '@periodId'}, {});
});

services.factory('VaccineOrderRequisitionReport', function ($resource) {
    return $resource('/vaccine/orderRequisition/get/:id.json', {id: '@id'}, {});
});

services.factory('UserHomeFacility', function ($resource) {
    return $resource('/vaccine/orderRequisition/userHomeFacility.json', {}, {});
});

services.factory('UserPrograms', function ($resource) {
    return $resource('/reports/user-programs.json', {}, {});
});

services.factory('VaccineOrderRequisitionSubmit', function ($resource) {
    return $resource('/vaccine/orderRequisition/submit.json', {}, update);
});

services.factory('VaccineOrderRequisitionColumns', function ($resource) {
    return $resource('/vaccine/columns/get/columns.json', {}, {});
});

services.factory('VaccinePendingRequisitions', function ($resource) {
    return $resource('/vaccine/orderRequisition/getPendingRequest/:facilityId/:programId.json', {}, {});
});

services.factory('LoggedInUserDetails',function($resource){
    return $resource('/vaccine/orderRequisition/loggedInUserDetails.json',{},{});
});

services.factory('ProgramForUserHomeFacility', function($resource){
    return $resource('/vaccine/orderRequisition/order-requisition/programs.json',{},{});
});

services.factory('VaccineOrderRequisitionInsert', function($resource){
    return $resource('/vaccine/orderRequisition/initialize/:programId/:facilityId.json',{programId:'@programId',facilityId:'@facilityId'},{});
});

services.factory('VaccineOrderRequisitionLastReport', function($resource){
    return $resource('/vaccine/orderRequisition/lastReport/:facilityId/:programId.json',{facilityId:'@facilityId',programId:'@programId'},{});
});

services.factory('VaccineOrderRequisitionSave', function ($resource) {
    return $resource('/vaccine/orderRequisition/save.json', {}, update);
});

services.factory('VaccineOrderRequisitionSubmit', function ($resource) {
    return $resource('/vaccine/orderRequisition/submit.json', {}, update);
});

services.factory('VaccineHomeFacilityPrograms', function ($resource) {
    return $resource('/vaccine/orderRequisition/programs.json', {}, {});
});

services.factory('UpdateOrderRequisitionStatus',function($resource){
    return $resource('/vaccine/orderRequisition/updateOrderRequest/:orderId.json',{orderId:'@orderId'},{update:{method:'PUT'}});
});

services.factory('VaccineLastStockMovement', function ($resource) {
    return $resource('/vaccine/inventory/stock/lastReport.json', {}, {});
});

services.factory('FacilityDistributed', function ($resource) {
    return $resource('/vaccine/inventory/distribution/getDistributed.json', {}, {});
});

services.factory('SaveDistribution', function ($resource) {
    return $resource('/vaccine/inventory/distribution/save.json', {}, {save:{method:'POST'}});
});

services.factory('DistributedFacilities', function ($resource) {
    return $resource('/vaccine/inventory/distribution/getDistributed.json', {}, {});
});<|endoftext|>


<commit_before>const handler = require('../db/migration-handler')

module.exports.up = handler(async function (db) {
  db.renameCollection('bookmarks', 'presets')
})

module.exports.down = handler(async function (db) {
  db.renameCollection('presets', 'bookmarks')
})
<commit_msg>Fix migration<commit_after>const handler = require('../db/migration-handler')

module.exports.up = handler(async function (db) {
  await db.renameCollection('bookmarks', 'presets')
})

module.exports.down = handler(async function (db) {
  const collections = await db.collections()
  if (collections.find((c) => c.collectionName === 'presets') != null) {
    await db.renameCollection('presets', 'bookmarks')
  }
})
<|endoftext|>


<commit_before>onionoo = require('../lib/onionoo');

module.exports = (req, res) => {
  onionoo.summary({ limit: 5 })
    .then(data => res.render('listing.html', { onionoo: data }));
}
<commit_msg>Format summary results<commit_after>onionoo = require('../lib/onionoo');

module.exports = (req, res) => {
  onionoo
    .summary({ search: 'jug' })
    .then(summary => {
      const nodes = summary.relays.concat(summary.bridges);
      return Promise.all(nodes.map(node => onionoo.details({ lookup: node.f || node.h })));
    })
    .then(summaryDetails => {
      const nodes = summaryDetails.map(details => {
        if(details.relays[0]) {
          details.relays[0].type = 'relay';
          return details.relays[0];
        } else if(details.bridges[0]) {
          details.bridges[0].type = 'bridge';
          return details.bridges[0];
        }
      });
      return res.render('listing.html', { onionoo: nodes });
    });
}
<|endoftext|>


<commit_before>/* @flow */
"use strict";

import scrollContainer from "$WIDGETS/scrollContainer";
import View from "$LIB/View";
import glyph from "$WIDGETS/glyph";
import list from "$WIDGETS/list";
import listItem from "$WIDGETS/listItem";
import listItemContents from "$WIDGETS/listItemContents";
import listItemActions from "$WIDGETS/listItemActions";
import listItemSpacer from "$WIDGETS/listItemSpacer";
import listHeading from "$WIDGETS/listHeading";
import listIndicator from "$WIDGETS/listIndicator";

import h from "yasmf-h";
import L from "$APP/localization/localization";
import GCS from "$LIB/grandCentralStation";

import dictionariesList from "./dictionariesList";

const kp = require("keypather")();

export default class MenuView extends View {
    get TARGET_SELECTORS() {
        return [
            {selector: "tap:ul li > button:not([value^='APP:'])", emit: "dictionaryItemTapped"},
            {selector: "tap:ul li > button[value^='APP:']", emit: "navItemTapped"}
        ];
    }

    get MENU_ITEMS() {
        return [/*
            {label: "nav:get-more-dictionaries", emit: "APP:DO:moreDictionaries"},
            {label: "nav:readability", emit:"APP:DO:readability"},*/
            {label: "nav:settings", emit: "APP:DO:settings"},
            {label: "nav:about", emit: "APP:DO:about"}];
    }

    template() {
        let model = kp.get(this, "controller.model"); // get the dictionary list model
        if (!model) {model = {dictionaries: []}};
        // return a list of all the available dictionaries along with options for downloading
        // more and changing settings.
        return scrollContainer({contents: list({
            contents: dictionariesList(model).concat(
                listItemSpacer(),
                this.MENU_ITEMS.map(item => {
                    return listItem({
                        contents: listItemContents({
                            props: {
                                value: item.emit
                            },
                            contents: [
                                h.el("div.y-flex", L.T(item.label))
                            ]
                        })
                    });
                }))
        })
    });
    }

    onDictionaryItemTapped(sender: Object, notice: string, listItem: Node) {
        GCS.emit("APP:DO:viewDictionary", listItem.value);   // select another dictionary
        GCS.emit("APP:DO:menu");   // close the sidebar
    }

    onNavItemTapped(sender: Object, notice: string, listItem: Node) {
        GCS.emit(listItem.value);   // notify the app that it needs to navigate
    }
}

export function createMenuView(options = {}) {
    return new MenuView(options);
}
<commit_msg>Remove dictionary selection ATM<commit_after>/* @flow */
"use strict";

import scrollContainer from "$WIDGETS/scrollContainer";
import View from "$LIB/View";
import glyph from "$WIDGETS/glyph";
import list from "$WIDGETS/list";
import listItem from "$WIDGETS/listItem";
import listItemContents from "$WIDGETS/listItemContents";
import listItemActions from "$WIDGETS/listItemActions";
import listItemSpacer from "$WIDGETS/listItemSpacer";
import listHeading from "$WIDGETS/listHeading";
import listIndicator from "$WIDGETS/listIndicator";

import h from "yasmf-h";
import L from "$APP/localization/localization";
import GCS from "$LIB/grandCentralStation";

import dictionariesList from "./dictionariesList";

const kp = require("keypather")();

export default class MenuView extends View {
    get TARGET_SELECTORS() {
        return [
            {selector: "tap:ul li > button:not([value^='APP:'])", emit: "dictionaryItemTapped"},
            {selector: "tap:ul li > button[value^='APP:']", emit: "navItemTapped"}
        ];
    }

    get MENU_ITEMS() {
        return [/*
            {label: "nav:get-more-dictionaries", emit: "APP:DO:moreDictionaries"},
            {label: "nav:readability", emit:"APP:DO:readability"},*/
            {label: "nav:settings", emit: "APP:DO:settings"},
            {label: "nav:about", emit: "APP:DO:about"}];
    }

    template() {
        let model = kp.get(this, "controller.model"); // get the dictionary list model
        if (!model) {model = {dictionaries: []}};
        // return a list of all the available dictionaries along with options for downloading
        // more and changing settings.
        return scrollContainer({contents: list({
            contents: /*dictionariesList(model).concat(
                listItemSpacer(),*/
                this.MENU_ITEMS.map(item => {
                    return listItem({
                        contents: listItemContents({
                            props: {
                                value: item.emit
                            },
                            contents: [
                                h.el("div.y-flex", L.T(item.label))
                            ]
                        })
                    });
                }) /*)*/
        })
    });
    }

    onDictionaryItemTapped(sender: Object, notice: string, listItem: Node) {
        GCS.emit("APP:DO:viewDictionary", listItem.value);   // select another dictionary
        GCS.emit("APP:DO:menu");   // close the sidebar
    }

    onNavItemTapped(sender: Object, notice: string, listItem: Node) {
        GCS.emit(listItem.value);   // notify the app that it needs to navigate
    }
}

export function createMenuView(options = {}) {
    return new MenuView(options);
}
<|endoftext|>