<commit_before>import React, {Component} from 'react';

import Widget from 'src/Widget';
import WidgetHeader from 'src/WidgetHeader';
import MaterialTreeSelect from 'src/MaterialTreeSelect';

import PropTypeDescTable from 'components/PropTypeDescTable';
import doc from 'examples/assets/propTypes/MaterialTreeSelect.json';

import 'sass/containers/app/modules/fields/MaterialTreeSelectExamples.scss';

class MaterialTreeSelectExamples extends Component {

    constructor(props) {

        super(props);

        this.data = {
            id: '0',
            text: 'Root',
            desc: 'Root',
            children: [{
                id: '00',
                text: 'Children 0 - 0',
                desc: 'Children 0 - 0'
            }, {
                id: '01',
                text: 'Children 0 - 1',
                desc: 'Children 0 - 1',
                children: [{
                    id: '010',
                    text: 'Children 0 - 1 - 0',
                    desc: 'Children 0 - 1 - 0'
                }, {
                    id: '011',
                    text: 'Children 0 - 1 - 1',
                    desc: 'Children 0 - 1 - 1'
                }, {
                    id: '012',
                    text: 'Children 0 - 1 - 2',
                    desc: 'Children 0 - 1 - 2'
                }]
            }, {
                id: '02',
                text: 'Children 0 - 2',
                desc: 'Children 0 - 2'
            }]
        };

    }

    onChangeHandler = value => {
        console.log(value);
    };

    render() {
        return (

MaterialTreeSelectExamples

                    MaterialTreeSelect use to store operating elements. Click on the contact and a
                    drop-down menu will appear. You can select from the list and execute the appropriate command.

Examples

                <Widget>

                    <WidgetHeader className="example-header"
                                  title="Basic"/>

Treesimple example.

                                <MaterialTreeSelect theme={MaterialTreeSelect.Theme.HIGHLIGHT}
                                                    data={this.data}
                                                    value={{
                                                        id: '010',
                                                        text: 'Children 0 - 1 - 0',
                                                        desc: 'Children 0 - 1 - 0'
                                                    }}
                                                    onChange={this.onChangeHandler}/>

                </Widget>

                <Widget>

                    <WidgetHeader className="example-header"
                                  title="Basic"/>

MaterialDropdownSelect simple example.

                                    <MaterialTreeSelect theme={MaterialTreeSelect.Theme.HIGHLIGHT}
                                                        label="Label"
                                                        placeholder="Placeholder"
                                                        selectMode={MaterialTreeSelect.SelectMode.MULTI_SELECT}
                                                        autoClose={false}
                                                        data={this.data}
                                                        collapsedIconCls="far fa-plus-square"
                                                        expandedIconCls="far fa-minus-square"
                                                        checkboxUncheckedIconCls="far fa-circle"
                                                        checkboxCheckedIconCls="fas fa-check-circle"
                                                        checkboxIndeterminateIconCls="fas fa-minus-circle"
                                                        onChange={this.onChangeHandler}/>

                </Widget>

Properties

                <PropTypeDescTable data={doc}/>

        );
    }
};

export default MaterialTreeSelectExamples;<commit_msg>update MaterialTreeSelectExamples<commit_after>import React, {Component} from 'react';

import Widget from 'src/Widget';
import WidgetHeader from 'src/WidgetHeader';
import MaterialTreeSelect from 'src/MaterialTreeSelect';

import PropTypeDescTable from 'components/PropTypeDescTable';
import doc from 'examples/assets/propTypes/MaterialTreeSelect.json';

import 'sass/containers/app/modules/fields/MaterialTreeSelectExamples.scss';

class MaterialTreeSelectExamples extends Component {

    constructor(props) {

        super(props);

        this.data = {
            id: '0',
            text: 'Root',
            desc: 'Root',
            children: [{
                id: '00',
                text: 'Children 0 - 0',
                desc: 'Children 0 - 0'
            }, {
                id: '01',
                text: 'Children 0 - 1',
                desc: 'Children 0 - 1',
                children: [{
                    id: '010',
                    text: 'Children 0 - 1 - 0',
                    desc: 'Children 0 - 1 - 0'
                }, {
                    id: '011',
                    text: 'Children 0 - 1 - 1',
                    desc: 'Children 0 - 1 - 1'
                }, {
                    id: '012',
                    text: 'Children 0 - 1 - 2',
                    desc: 'Children 0 - 1 - 2'
                }]
            }, {
                id: '02',
                text: 'Children 0 - 2',
                desc: 'Children 0 - 2'
            }]
        };

    }

    onChangeHandler = value => {
        console.log(value);
    };

    render() {
        return (

MaterialTreeSelectExamples

                    MaterialTreeSelect
                    use to store operating elements. Click on the contact and a
                    drop-down menu will appear. You can select from the list and execute the appropriate command.

Examples

                <Widget>

                    <WidgetHeader className="example-header"
                                  title="Basic"/>

Treesimple example.

                                <MaterialTreeSelect theme={MaterialTreeSelect.Theme.HIGHLIGHT}
                                                    data={this.data}
                                                    value={{
                                                        id: '010',
                                                        text: 'Children 0 - 1 - 0',
                                                        desc: 'Children 0 - 1 - 0'
                                                    }}
                                                    onChange={this.onChangeHandler}/>

                </Widget>

                <Widget>

                    <WidgetHeader className="example-header"
                                  title="Basic"/>

MaterialDropdownSelect simple example.

                                    <MaterialTreeSelect theme={MaterialTreeSelect.Theme.HIGHLIGHT}
                                                        label="Label"
                                                        placeholder="Placeholder"
                                                        selectMode={MaterialTreeSelect.SelectMode.MULTI_SELECT}
                                                        autoClose={false}
                                                        data={this.data}
                                                        isSelectRecursive={true}
                                                        collapsedIconCls="far fa-plus-square"
                                                        expandedIconCls="far fa-minus-square"
                                                        checkboxUncheckedIconCls="far fa-circle"
                                                        checkboxCheckedIconCls="fas fa-check-circle"
                                                        checkboxIndeterminateIconCls="fas fa-minus-circle"
                                                        onChange={this.onChangeHandler}/>

                </Widget>

Properties

                <PropTypeDescTable data={doc}/>

        );
    }
};

export default MaterialTreeSelectExamples;<|endoftext|>


<commit_before>const ExtractTextPlugin = require('extract-text-webpack-plugin');
const LiveReloadPlugin = require('webpack-livereload-plugin');
const path = require('path');
const webpack = require('webpack');

const clientPath = path.join(__dirname, '..', 'client');
const buildPath = path.join(clientPath, 'build');

module.exports = {
  entry: [
    'babel-polyfill',
    'webpack/hot/dev-server',
    path.join(clientPath, 'source/main.jsx')
  ],
  resolve: {
    extensions: ['', '.js', '.jsx', '.json']
  },
  output: {
    path: buildPath,
    filename: './bundle.js'
  },
  devtool: 'source-map',
  devServer: { <% if (serverport) { %>
    proxy: {
      '/api*': {
        target: 'http://localhost:<%= serverport %>',
        secure: false
      }
    }, <% } %>
    contentBase: buildPath,
    hot: true
  },
  module: {
    loaders: [
      {
        test: /\.(js|jsx)$/,
        loader: 'babel',
        include: [
          path.join(clientPath, 'source')
        ],
        query: {
          cacheDirectory: true,
          presets: ['es2015', 'react']
        }
      },
      {
        test: /\.json$/,
        loader: 'json'
      },
      {
        test: /\.css$/,
        loader: ExtractTextPlugin.extract("style-loader", "css-loader")
      },
    ],
    preLoaders: [
      {
        test: /\.(js|jsx)$/,
        loader: 'eslint'
      }
    ],
  },
  plugins: [
    new ExtractTextPlugin("[name].css"),
    new LiveReloadPlugin({appendScriptTag: true}),
  ]
};
<commit_msg>Gzip files are now hidden<commit_after>const ExtractTextPlugin = require('extract-text-webpack-plugin');
const LiveReloadPlugin = require('webpack-livereload-plugin');
const path = require('path');
const webpack = require('webpack');

const clientPath = path.join(__dirname, '..', 'client');
const buildPath = path.join(clientPath, 'build');

module.exports = {
  entry: [
    'babel-polyfill',
    'webpack/hot/dev-server',
    path.join(clientPath, 'source/main.jsx')
  ],
  resolve: {
    extensions: ['', '.js', '.jsx', '.json']
  },
  output: {
    path: buildPath,
    filename: './bundle.js'
  },
  devtool: 'source-map',
  devServer: { <% if (serverport) { %>
    proxy: {
      '/api*': {
        target: 'http://localhost:<%= serverport %>',
        secure: false
      }
    }, <% } %>
    contentBase: buildPath,
    hot: true
  },
  module: {
    loaders: [
      {
        test: /\.(js|jsx)$/,
        loader: 'babel',
        include: [
          path.join(clientPath, 'source')
        ],
        query: {
          cacheDirectory: '/tmp',
          presets: ['es2015', 'react']
        }
      },
      {
        test: /\.json$/,
        loader: 'json'
      },
      {
        test: /\.css$/,
        loader: ExtractTextPlugin.extract("style-loader", "css-loader")
      },
    ],
    preLoaders: [
      {
        test: /\.(js|jsx)$/,
        loader: 'eslint'
      }
    ],
  },
  plugins: [
    new ExtractTextPlugin("[name].css"),
    new LiveReloadPlugin({appendScriptTag: true}),
  ]
};
<|endoftext|>


<commit_before>var
    SearchContext,
    Search,
    Iterable;

(function($) {
    "use strict";

    try {
        Object.defineProperties($, {
            flatten: {
                value: function(linkedList) {
                    var
                        iterator,
                        flattened = [],
                        allowedPattern = /^(Array|Arguments)$/,
                        className = Object.className(linkedList);

                    if (className == "Arguments") {
                        linkedList = $.from(linkedList);
                    } else if (!allowedPattern.test(className)) {
                        return linkedList;
                    }

                    // this way will treate all as String after run .join
                    // linkedList = linkedList.join().split(",");
                    iterator = SearchContext.Proxy
                        .new(Search.Graphs.BFS.Object.new(linkedList));
                    iterator.research(function(item) {
                        if (!allowedPattern.test(Object.className(item))) {
                            flattened.push(item);
                        }
                    });

                    return flattened;
                }
            },

            compact: {
                value: function(collection) {
                    var
                        newArr = [];

                    collection.forEach(function(v) {
                        if (typeof v == "string") {
                            if (v !== "") {
                                newArr.push(v);
                            }
                        } else {
                            if (v !== undefined && v !== null) {
                                newArr.push(v);
                            }
                        }
                    });

                    return newArr;
                }
            }
        });

        Object.defineProperties($.prototype, {

            clone: {
                value: function() {
                    var
                        clone = [];

                    Object.assign(clone, this);

                    return clone;
                }
            },

            indexOfEquivalence: {
                // value: function(comparator, startingIndex = 0) {
                value: function(comparator, startingIndex) {
                    if(typeof startingIndex != "number") {startingIndex = 0;}

                    var
                        item,
                        i = startingIndex;

                    if (!comparator || typeof startingIndex != "number") {
                        return -1;
                    }

                    for (i = startingIndex; i < this.length; i++) {
                        item = this[i];
                        if (typeof item == "function") {
                            if (item == comparator) {
                                return i;
                            }
                        } else {
                            if (item === undefined) {
                                console.warn("Item to compare is " +
                                                "undefined!");
                            }

                            // change to overridable equals method. Maybe using valueOf
                            if (Object.areEquivalents(item, comparator)) {
                                return i;
                            }
                        }
                    }

                    // debugger
                    return -1;
                }
            },

            uniq: {
                value: function() {
                    return this.reduce(function(aux, value) {
                        if (aux.indexOfEquivalence(value) == -1) {
                            aux.push(value);
                        }
                        return aux;
                    }, []);
                }
            },

            includes: {
                value: function(items) {
                    var
                        args = Array.from(arguments).uniq(),
                        mainReference = this,
                        count = 0;

                    args.forEach(function(arg) {
                        if (mainReference.indexOfEquivalence(arg) > -1) {
                            count += 1;
                        }
                    });

                    return count == args.length;
                }
            },

            delete: {
                value: function(index) {
                    return this.splice(index, 1);
                }
            },

            deleteValue: {
                value: function(amount) {
                    var
                        counter,
                        index,
                        mainReference = this,
                        deleted = [],
                        partsToDelete = Array.from(arguments);

                    partsToDelete.shift();
                    partsToDelete.forEach(function(i) {
                        counter = amount;
                        while (counter-- > 0 && mainReference.count(i)) {
                            index = mainReference.indexOfEquivalence(i);
                            if (index > -1) {
                                deleted.push(mainReference.splice(index, 1)[0]);
                            }
                        }
                    });

                    return deleted;
                }
            },

            without: {
                value: function() {
                    var
                        parts = $.flatten(arguments),
                        clone = [];

                    clone = this.clone();

                    parts.forEach(function(i) {
                        clone.deleteValue(clone.count(i), i);
                    });

                    return clone;
                }
            },

            count: {
                value: function(item) {

                    var
                        self = this,
                        count = 0,
                        i = 0;

                    while (true) {
                        i = self.indexOfEquivalence(item, i);
                        if (i > -1) {
                            count++;
                            if (++i == self.length) {
                                break;
                            }
                        } else {
                            break;
                        }
                    }

                    return count;
                }
            },

            firstFromASlice: {
                value: function(slice, startingIndex, caseSensitive) {
                    var
                        regexp,
                        iterator,
                        self = this,
                        clone = self.clone(),
                        index = -1;

                    if (typeof startingIndex != "number") {
                        if (typeof startingIndex == "boolean") {
                            caseSensitive = startingIndex;
                        }
                        startingIndex = 0;
                    }

                    if (typeof caseSensitive != "boolean") {
                        caseSensitive = false;
                    }

                    if (startingIndex === 0) {
                        clone = clone.asc();
                    }

                    slice = slice.trim();

                    if (!caseSensitive) {
                        regexp = new RegExp(slice, "i");
                    } else {
                        regexp = new RegExp(slice);
                    }

                    iterator = Iterable.Proxy.new(this);
                    iterator.each(function(v, i) {
                        if (typeof v == "string" && i >= startingIndex) {
                            if (v.search(regexp) != -1) {
                                index = i;
                                this.finalize();
                            }
                        }
                    });

                    return index;
                }
            },

            countSlice: {
                value: function(slice, startingIndex, caseSensitive) {
                    var
                        i,
                        regexp,
                        self = this,
                        clone = self.clone(),
                        count = 0;

                    if (typeof startingIndex != "number") {
                        if (typeof startingIndex == "boolean") {
                            caseSensitive = startingIndex;
                        }
                        startingIndex = 0;
                    }

                    if (typeof caseSensitive != "boolean") {
                        caseSensitive = false;
                    }

                    if (startingIndex === 0) {
                        clone = clone.asc();
                    }

                    slice = slice.trim();

                    if (!caseSensitive) {
                        regexp = new RegExp(slice, "i");
                    } else {
                        regexp = new RegExp(slice);
                    }

                    i = parseInt(clone.firstFromASlice(slice, startingIndex,
                                                     caseSensitive));

                    if (i > -1) {
                        while (i < this.length) {
                            if (clone[i].trim().search(regexp) > -1) {
                                count += 1;
                                i += 1;
                            } else {
                                break;
                            }
                        }
                    }

                    return count;
                }
            },

            differences: {
                value: function(sets) {
                    var
                        clone = this.clone();

                    sets = Array.from(arguments);

                    if (sets.length <= 0) {
                        return this;
                    }

                    clone.uniq().forEach(function(item) {
                        sets.forEach(function(set) {
                            clone.deleteValue(set.count(item), item);
                        });
                    });

                    return clone;
                }
            },

            flatten: {
                value: function() {
                    return $.flatten(this);
                }
            },

            normalizeToLowerCase: {
                value: function() {
                    var
                        clone = [];

                    this.forEach(function(value) {
                        if (typeof value == "string") {
                            clone.push(value.toLowerCase()());
                        }
                    });

                    return clone;
                }
            },

            capitalize: {
                value: function() {
                    var
                        clone = [];

                    this.forEach(function(value) {
                        if (typeof value == "string") {
                            clone.push(value.capitalize());
                        }
                    });

                    return clone;
                }
            },

            spaceOut: {
                value: function() {
                    var
                        i = 0,
                        clone = this.clone();

                    while (i < clone.lastIndex()) {
                        clone[i++] += " ";
                    }

                    return clone;
                }
            },

            compact: {
                value: function() {
                    return $.compact(this);
                }
            },

            asc: {
                value: function() {
                    var
                        clone = this.clone(),
                        compareFunction = function(a, b) {
                            return a > b;
                        };

                    clone.sort(compareFunction);

                    return clone;
                }
            },

            desc: {
                value: function() {
                    var
                        clone = this.clone(),
                        compareFunction = function(a, b) {
                            return a < b;
                        };

                    clone.sort(compareFunction);

                    return clone;
                }
            },

            min: {
                value: function() {
                    return Math.min.apply(null, this);
                }
            },

            max: {
                value: function() {
                    return Math.max.apply(null, this);
                }
            },

            first: {
                value: function() {
                    return this[0];
                }
            },

            lastIndex: {
                value: function() {
                    return this.length - 1;
                }
            },

            last: {
                value: function() {
                    return this[this.lastIndex()];
                }
            }

        });
    } catch(e) {}

})(Array);
<commit_msg>remove unecessary code<commit_after>var
    SearchContext,
    Search,
    Iterable;

(function($) {
    "use strict";

    try {
        Object.defineProperties($, {
            flatten: {
                value: function(linkedList) {
                    var
                        iterator,
                        flattened = [],
                        allowedPattern = /^(Array|Arguments)$/,
                        className = Object.className(linkedList);

                    if (className == "Arguments") {
                        linkedList = $.from(linkedList);
                    } else if (!allowedPattern.test(className)) {
                        return linkedList;
                    }

                    // this way will treate all as String after run .join
                    // linkedList = linkedList.join().split(",");
                    iterator = SearchContext.Proxy
                        .new(Search.Graphs.BFS.Object.new(linkedList));
                    iterator.research(function(item) {
                        if (!allowedPattern.test(Object.className(item))) {
                            flattened.push(item);
                        }
                    });

                    return flattened;
                }
            },

            compact: {
                value: function(collection) {
                    var
                        newArr = [];

                    collection.forEach(function(v) {
                        if (typeof v == "string") {
                            if (v !== "") {
                                newArr.push(v);
                            }
                        } else {
                            if (v !== undefined && v !== null) {
                                newArr.push(v);
                            }
                        }
                    });

                    return newArr;
                }
            }
        });

        Object.defineProperties($.prototype, {

            clone: {
                value: function() {
                    var
                        clone = [];

                    Object.assign(clone, this);

                    return clone;
                }
            },

            indexOfEquivalence: {
                // value: function(comparator, startingIndex = 0) {
                value: function(comparator, startingIndex) {
                    if(typeof startingIndex != "number") {startingIndex = 0;}

                    var
                        item,
                        i = startingIndex;

                    for (i = startingIndex; i < this.length; i++) {
                        item = this[i];
                        if (typeof item == "function") {
                            if (item == comparator) {
                                return i;
                            }
                        } else {
                            if (item === undefined) {
                                console.warn("Item to compare is " +
                                                "undefined!");
                            }

                            // change to overridable equals method. Maybe using valueOf
                            if (Object.areEquivalents(item, comparator)) {
                                return i;
                            }
                        }
                    }

                    // debugger
                    return -1;
                }
            },

            uniq: {
                value: function() {
                    return this.reduce(function(aux, value) {
                        if (aux.indexOfEquivalence(value) == -1) {
                            aux.push(value);
                        }
                        return aux;
                    }, []);
                }
            },

            includes: {
                value: function(items) {
                    var
                        args = Array.from(arguments).uniq(),
                        mainReference = this,
                        count = 0;

                    args.forEach(function(arg) {
                        if (mainReference.indexOfEquivalence(arg) > -1) {
                            count += 1;
                        }
                    });

                    return count == args.length;
                }
            },

            delete: {
                value: function(index) {
                    return this.splice(index, 1);
                }
            },

            deleteValue: {
                value: function(amount) {
                    var
                        counter,
                        index,
                        mainReference = this,
                        deleted = [],
                        partsToDelete = Array.from(arguments);

                    partsToDelete.shift();
                    partsToDelete.forEach(function(i) {
                        counter = amount;
                        while (counter-- > 0 && mainReference.count(i)) {
                            index = mainReference.indexOfEquivalence(i);
                            if (index > -1) {
                                deleted.push(mainReference.splice(index, 1)[0]);
                            }
                        }
                    });

                    return deleted;
                }
            },

            without: {
                value: function() {
                    var
                        parts = $.flatten(arguments),
                        clone = [];

                    clone = this.clone();

                    parts.forEach(function(i) {
                        clone.deleteValue(clone.count(i), i);
                    });

                    return clone;
                }
            },

            count: {
                value: function(item) {

                    var
                        self = this,
                        count = 0,
                        i = 0;

                    while (true) {
                        i = self.indexOfEquivalence(item, i);
                        if (i > -1) {
                            count++;
                            if (++i == self.length) {
                                break;
                            }
                        } else {
                            break;
                        }
                    }

                    return count;
                }
            },

            firstFromASlice: {
                value: function(slice, startingIndex, caseSensitive) {
                    var
                        regexp,
                        iterator,
                        self = this,
                        clone = self.clone(),
                        index = -1;

                    if (typeof startingIndex != "number") {
                        if (typeof startingIndex == "boolean") {
                            caseSensitive = startingIndex;
                        }
                        startingIndex = 0;
                    }

                    if (typeof caseSensitive != "boolean") {
                        caseSensitive = false;
                    }

                    if (startingIndex === 0) {
                        clone = clone.asc();
                    }

                    slice = slice.trim();

                    if (!caseSensitive) {
                        regexp = new RegExp(slice, "i");
                    } else {
                        regexp = new RegExp(slice);
                    }

                    iterator = Iterable.Proxy.new(this);
                    iterator.each(function(v, i) {
                        if (typeof v == "string" && i >= startingIndex) {
                            if (v.search(regexp) != -1) {
                                index = i;
                                this.finalize();
                            }
                        }
                    });

                    return index;
                }
            },

            countSlice: {
                value: function(slice, startingIndex, caseSensitive) {
                    var
                        i,
                        regexp,
                        self = this,
                        clone = self.clone(),
                        count = 0;

                    if (typeof startingIndex != "number") {
                        if (typeof startingIndex == "boolean") {
                            caseSensitive = startingIndex;
                        }
                        startingIndex = 0;
                    }

                    if (typeof caseSensitive != "boolean") {
                        caseSensitive = false;
                    }

                    if (startingIndex === 0) {
                        clone = clone.asc();
                    }

                    slice = slice.trim();

                    if (!caseSensitive) {
                        regexp = new RegExp(slice, "i");
                    } else {
                        regexp = new RegExp(slice);
                    }

                    i = parseInt(clone.firstFromASlice(slice, startingIndex,
                                                     caseSensitive));

                    if (i > -1) {
                        while (i < this.length) {
                            if (clone[i].trim().search(regexp) > -1) {
                                count += 1;
                                i += 1;
                            } else {
                                break;
                            }
                        }
                    }

                    return count;
                }
            },

            differences: {
                value: function(sets) {
                    var
                        clone = this.clone();

                    sets = Array.from(arguments);

                    if (sets.length <= 0) {
                        return this;
                    }

                    clone.uniq().forEach(function(item) {
                        sets.forEach(function(set) {
                            clone.deleteValue(set.count(item), item);
                        });
                    });

                    return clone;
                }
            },

            flatten: {
                value: function() {
                    return $.flatten(this);
                }
            },

            normalizeToLowerCase: {
                value: function() {
                    var
                        clone = [];

                    this.forEach(function(value) {
                        if (typeof value == "string") {
                            clone.push(value.toLowerCase()());
                        }
                    });

                    return clone;
                }
            },

            capitalize: {
                value: function() {
                    var
                        clone = [];

                    this.forEach(function(value) {
                        if (typeof value == "string") {
                            clone.push(value.capitalize());
                        }
                    });

                    return clone;
                }
            },

            spaceOut: {
                value: function() {
                    var
                        i = 0,
                        clone = this.clone();

                    while (i < clone.lastIndex()) {
                        clone[i++] += " ";
                    }

                    return clone;
                }
            },

            compact: {
                value: function() {
                    return $.compact(this);
                }
            },

            asc: {
                value: function() {
                    var
                        clone = this.clone(),
                        compareFunction = function(a, b) {
                            return a > b;
                        };

                    clone.sort(compareFunction);

                    return clone;
                }
            },

            desc: {
                value: function() {
                    var
                        clone = this.clone(),
                        compareFunction = function(a, b) {
                            return a < b;
                        };

                    clone.sort(compareFunction);

                    return clone;
                }
            },

            min: {
                value: function() {
                    return Math.min.apply(null, this);
                }
            },

            max: {
                value: function() {
                    return Math.max.apply(null, this);
                }
            },

            first: {
                value: function() {
                    return this[0];
                }
            },

            lastIndex: {
                value: function() {
                    return this.length - 1;
                }
            },

            last: {
                value: function() {
                    return this[this.lastIndex()];
                }
            }

        });
    } catch(e) {}

})(Array);
<|endoftext|>


<commit_before>import gulp from "gulp";
import browserify from "browserify";
import source from "vinyl-source-stream";

gulp.task("default", () => {

  return browserify("src/app.js")
    .transform("babelify")
    .bundle()
    .pipe(source("bundle.js"))
    .pipe(gulp.dest("dist"));

});

<commit_msg>Add transpile, watch tasks<commit_after>import gulp from "gulp";
import browserify from "browserify";
import source from "vinyl-source-stream";

gulp.task("transpile", () => {

  return browserify("src/app.js")
    .transform("babelify")
    .bundle()
    .pipe(source("bundle.js"))
    .pipe(gulp.dest("dist"));

});

gulp.task("watch", ["transpile"], () => {
  gulp.watch("src/**/*.js", ["transpile"]);
});

gulp.task("default", ["transpile"]);
<|endoftext|>


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

    angular
        .module('orange')
        .controller('DoctorSearchCtrl', DoctorSearchCtrl);

    DoctorSearchCtrl.$inject = ['$scope', '$state', '$ionicLoading', 'OrangeApi', '$ionicModal',
                                'DoctorService', 'GlobalService'];

    /* @ngInject */
    function DoctorSearchCtrl($scope, $state, $ionicLoading, OrangeApi, $ionicModal, DoctorService, GlobalService) {
        var vm = this;

        vm.title = 'Find Doctor';
        vm.name = {};
        vm.address = {};
        vm.doctors = [];

        DoctorService.setItem(null);

        vm.search = function (form) {
            form.$submitted = true;
            if (!_.isEmpty(form.$error)) {
                return;
            }

            $ionicLoading.show({
                template: 'Search...'
            });

            var query = { search: {
                    name: [vm.name],
                    address: [vm.address]
                }
            };

            OrangeApi.npi.post(query).then(searchSuccess);
        };

        function searchSuccess(doctors) {
            $ionicLoading.hide();

            vm.doctors = [];

            _.each(doctors['providers'], function (provider) {
                var doctor = {};

                doctor['name'] = _.startCase(
                    [
                        provider.name_prefix,
                        provider.first_name,
                        provider.middle_name,
                        provider.last_name
                    ].join(' ').toLowerCase()
                );

                if (!_.isUndefined(provider.name_suffix)) {
                    doctor['name'] += ' ' + provider.name_suffix;
                }

                doctor['phone'] = provider.practice_address.phone;
                var address = (provider.practice_address.address_line + ' dividerf '
                    + provider.practice_address.city + ' dividers '
                    + provider.practice_address.state + ' dividert '
                    + provider.practice_address.zip).toLowerCase();

                doctor['address'] = _.startCase(address).replace(' Dividerf ', ',\n')
                    .replace(' Dividers ', ' ').replace(' Dividert ', ', ');

                doctor['title'] = provider.credential;

                vm.doctors.push(doctor)
            });
            if (!vm.doctors.length) {
                GlobalService.showError('No Doctors Found.');
                return;
            }

            vm.modal.show();
        }

        vm.addGo = function(doctor) {
            DoctorService.setItem(doctor);
            $state.go('app.doctors.add');
            vm.modal.hide();
        };

        $ionicModal.fromTemplateUrl('templates/doctors/doctors.search_list.modal.html', {
            scope: $scope,
            animation: 'slide-in-up'
        }).then(function(modal) {
            vm.modal = modal;
        });

    }
})();
<commit_msg>[artefact][ORANGE-308] Add doctor manually when search not found<commit_after>(function () {
    "use strict";

    angular
        .module('orange')
        .controller('DoctorSearchCtrl', DoctorSearchCtrl);

    DoctorSearchCtrl.$inject = ['$scope', '$state', '$ionicLoading', 'OrangeApi', '$ionicModal',
                                'DoctorService', 'GlobalService'];

    /* @ngInject */
    function DoctorSearchCtrl($scope, $state, $ionicLoading, OrangeApi, $ionicModal, DoctorService, GlobalService) {
        var vm = this;

        vm.title = 'Find Doctor';
        vm.name = {};
        vm.address = {};
        vm.doctors = [];

        DoctorService.setItem(null);

        vm.search = function (form) {
            form.$submitted = true;
            if (!_.isEmpty(form.$error)) {
                return;
            }

            $ionicLoading.show({
                template: 'Search...'
            });

            var query = { search: {
                    name: [vm.name],
                    address: [vm.address]
                }
            };

            OrangeApi.npi.post(query).then(searchSuccess);
        };

        function searchSuccess(doctors) {
            $ionicLoading.hide();

            vm.doctors = [];

            _.each(doctors['providers'], function (provider) {
                var doctor = {};

                doctor['name'] = _.startCase(
                    [
                        provider.name_prefix,
                        provider.first_name,
                        provider.middle_name,
                        provider.last_name
                    ].join(' ').toLowerCase()
                );

                if (!_.isUndefined(provider.name_suffix)) {
                    doctor['name'] += ' ' + provider.name_suffix;
                }

                doctor['phone'] = provider.practice_address.phone;
                var address = (provider.practice_address.address_line + ' dividerf '
                    + provider.practice_address.city + ' dividers '
                    + provider.practice_address.state + ' dividert '
                    + provider.practice_address.zip).toLowerCase();

                doctor['address'] = _.startCase(address).replace(' Dividerf ', ',\n')
                    .replace(' Dividers ', ' ').replace(' Dividert ', ', ');

                doctor['title'] = provider.credential;

                vm.doctors.push(doctor)
            });
            if (!vm.doctors.length) {
                GlobalService.showConfirm('Doctors not found. Do you want add doctor manually?').then(
                    function (confirm) {
                        if (confirm) {
                            $state.go('app.doctors.add');
                        }
                    }
                );
                return;
            }

            vm.modal.show();
        }

        vm.addGo = function(doctor) {
            DoctorService.setItem(doctor);
            $state.go('app.doctors.add');
            vm.modal.hide();
        };

        $ionicModal.fromTemplateUrl('templates/doctors/doctors.search_list.modal.html', {
            scope: $scope,
            animation: 'slide-in-up'
        }).then(function(modal) {
            vm.modal = modal;
        });

    }
})();
<|endoftext|>


<commit_before>'use strict';

let AdmZip = require('adm-zip');
let request = require('request');
let path = require('path');
let fs = require('fs-extra');

import InstallableItem from './installable-item';

class VagrantInstall extends InstallableItem {
  constructor(installerDataSvc, downloadUrl, installFile) {
    super(downloadUrl, installFile);

    this.installerDataSvc = installerDataSvc;

    this.downloadedFile = path.join(this.installerDataSvc.tempDir(), 'vagrant.zip');
    this.vagrantPathScript = path.join(this.installerDataSvc.tempDir(), 'set-vagrant-path.ps1');
  }

  checkForExistingInstall() {
  }

  downloadInstaller(progress, success, failure) {
    progress.setDesc('Downloading Vagrant');

    // Need to download the file
    let writeStream = fs.createWriteStream(this.downloadedFile);
    let downloadSize = 0;
    let currentSize = 0;

    request
      .get(this.downloadUrl)
      .on('error', (err) => {
        writeStream.close();
        failure(err);
      })
      .on('response', (response) => {
        downloadSize = response.headers['content-length'];
      })
      .on('data', (data) => {
        currentSize += data.length;
        progress.setCurrent(Math.round((currentSize / downloadSize) * 100));
        progress.setLabel(progress.current + "%");
      })
      .on('end', () => {
        writeStream.end();
      })
      .pipe(writeStream)
      .on('close', () => {
        return success();
      });
  }

  install(progress, success, failure) {
    progress.setDesc('Installing Vagrant');

    let vagrantZip = new AdmZip(this.downloadedFile);
    vagrantZip.extractAllTo(this.installerDataSvc.tempDir(), true);

    let vagrantExploded = path.join(this.installerDataSvc.tempDir(), 'vagrant-distribution-1.7.4', 'windows-64');

    fs.move(vagrantExploded, this.installerDataSvc.vagrantDir(), (err) => {
      if (err) return failure(err);

      // Set required paths
      let data = [
        '$newPath = "' + path.join(this.installerDataSvc.vagrantDir(), 'bin') + '";',
        '$oldPath = [Environment]::GetEnvironmentVariable("path", "User");',
        '[Environment]::SetEnvironmentVariable("Path", "$newPath;$oldPath", "User");',
        '[Environment]::Exit(0)'
      ].join('\r\n');
      fs.writeFileSync(this.vagrantPathScript, data);

      require('child_process')
        .exec(
          [
            'setx RUBYLIB "' + path.join(this.installerDataSvc.vagrantDir(), 'lib', 'ruby', '2.1.0') + '"',
            'setx GEM_HOME "' + path.join(this.installerDataSvc.vagrantDir(), 'lib', 'ruby', 'gems') + '"'
          ].join(' && '),
          (error, stdout, stderr) => {
            console.log(stdout);
            console.log(stderr);
            if (error !== null) {
              failure(error);
            }

            require('child_process')
              .execFile(
                'powershell',
                [
                  this.vagrantPathScript
                ],
                (error, stdout, stderr) => {
                  console.log(stdout);
                  console.log(stderr);
                  if (error !== null) {
                    failure(error);
                  }

                  progress.setComplete("Complete");
                  success();
                }
              );
          }
        );
    });
  }
}

export default VagrantInstall;
<commit_msg>Allow vagrant install to run powershell scripts<commit_after>'use strict';

let AdmZip = require('adm-zip');
let request = require('request');
let path = require('path');
let fs = require('fs-extra');

import InstallableItem from './installable-item';

class VagrantInstall extends InstallableItem {
  constructor(installerDataSvc, downloadUrl, installFile) {
    super(downloadUrl, installFile);

    this.installerDataSvc = installerDataSvc;

    this.downloadedFile = path.join(this.installerDataSvc.tempDir(), 'vagrant.zip');
    this.vagrantPathScript = path.join(this.installerDataSvc.tempDir(), 'set-vagrant-path.ps1');
  }

  checkForExistingInstall() {
  }

  downloadInstaller(progress, success, failure) {
    progress.setDesc('Downloading Vagrant');

    // Need to download the file
    let writeStream = fs.createWriteStream(this.downloadedFile);
    let downloadSize = 0;
    let currentSize = 0;

    request
      .get(this.downloadUrl)
      .on('error', (err) => {
        writeStream.close();
        failure(err);
      })
      .on('response', (response) => {
        downloadSize = response.headers['content-length'];
      })
      .on('data', (data) => {
        currentSize += data.length;
        progress.setCurrent(Math.round((currentSize / downloadSize) * 100));
        progress.setLabel(progress.current + "%");
      })
      .on('end', () => {
        writeStream.end();
      })
      .pipe(writeStream)
      .on('close', () => {
        return success();
      });
  }

  install(progress, success, failure) {
    progress.setDesc('Installing Vagrant');

    let vagrantZip = new AdmZip(this.downloadedFile);
    vagrantZip.extractAllTo(this.installerDataSvc.tempDir(), true);

    let vagrantExploded = path.join(this.installerDataSvc.tempDir(), 'vagrant-distribution-1.7.4', 'windows-64');

    fs.move(vagrantExploded, this.installerDataSvc.vagrantDir(), (err) => {
      if (err) return failure(err);

      // Set required paths
      let data = [
        '$newPath = "' + path.join(this.installerDataSvc.vagrantDir(), 'bin') + '";',
        '$oldPath = [Environment]::GetEnvironmentVariable("path", "User");',
        '[Environment]::SetEnvironmentVariable("Path", "$newPath;$oldPath", "User");',
        '[Environment]::Exit(0)'
      ].join('\r\n');
      fs.writeFileSync(this.vagrantPathScript, data);

      require('child_process')
        .exec(
          [
            'setx RUBYLIB "' + path.join(this.installerDataSvc.vagrantDir(), 'lib', 'ruby', '2.1.0') + '"',
            'setx GEM_HOME "' + path.join(this.installerDataSvc.vagrantDir(), 'lib', 'ruby', 'gems') + '"'
          ].join(' && '),
          (error, stdout, stderr) => {
            console.log(stdout);
            console.log(stderr);
            if (error !== null) {
              failure(error);
            }

            require('child_process')
              .execFile(
                'powershell',
                [
                  '-ExecutionPolicy',
                  'ByPass',
                  '-File',
                  this.vagrantPathScript
                ],
                (error, stdout, stderr) => {
                  console.log(stdout);
                  console.log(stderr);
                  if (error !== null) {
                    failure(error);
                  }

                  progress.setComplete("Complete");
                  success();
                }
              );
          }
        );
    });
  }
}

export default VagrantInstall;
<|endoftext|>


<commit_before>ChannelsController = {

  loadChannel: function(username, channel_id) {
    var channel = Channels.get(channel_id);
    Channels.setUsername(username);

    try {
      mpmetrics.track("mp_page_view", {
        mp_page: window.location.href
      });
    } catch(e) {}

    if ( !channel ) {
      channel = this.view.channelView.subchannels.get(channel_id);
      channel.collection = Channels;
    }
    channel.set({new_facts: false});
    return channel;
  },

  // TODO: This function needs to wait for loading (Of channel contents in main column)
  setupChannelReloading: function(){
    var args = arguments;

    if ( typeof localStorage === "object"
      && localStorage !== null
      && localStorage['reload'] === "false" ) {
      return;
    }

    setTimeout(function(){
      Channels.fetch({
        success: args.callee
      });
    }, 7000);
  },

  commonChannelViews: function(channel) {
    FactlinkApp.relatedUsersRegion.show(new RelatedUsersView({model: channel}));
    var channelCollectionView = new ChannelCollectionView({collection: window.Channels});
    this.setupChannelReloading();
    FactlinkApp.channelListRegion.show(channelCollectionView);
    var userView = new UserView({model: channel.user});
    FactlinkApp.userblockRegion.show(userView);
  },

  getChannelFacts: function(username, channel_id) {
    var channel = this.loadChannel(username, channel_id);
    this.commonChannelViews(channel);
    FactlinkApp.mainRegion.show(new ChannelView({model: channel}));
  },

  getChannelActivities: function(username, channel_id) {
    var channel = this.loadChannel(username, channel_id);
    this.commonChannelViews(channel);
    FactlinkApp.mainRegion.show(new ChannelActivitiesView({model: channel}));
  }

}
<commit_msg>set the current channel from the channelscontroller<commit_after>ChannelsController = {

  loadChannel: function(username, channel_id) {
    var channel = Channels.get(channel_id);
    Channels.setUsername(username);

    try {
      mpmetrics.track("mp_page_view", {
        mp_page: window.location.href
      });
    } catch(e) {}

    if ( !channel ) {
      channel = this.view.channelView.subchannels.get(channel_id);
      channel.collection = Channels;
    }
    channel.set({new_facts: false});
    return channel;
  },

  // TODO: This function needs to wait for loading (Of channel contents in main column)
  setupChannelReloading: function(){
    var args = arguments;

    if ( typeof localStorage === "object"
      && localStorage !== null
      && localStorage['reload'] === "false" ) {
      return;
    }

    setTimeout(function(){
      Channels.fetch({
        success: args.callee
      });
    }, 7000);
  },

  commonChannelViews: function(channel) {
    window.currentChannel = channel;
    FactlinkApp.relatedUsersRegion.show(new RelatedUsersView({model: channel}));
    var channelCollectionView = new ChannelCollectionView({collection: window.Channels});
    this.setupChannelReloading();
    FactlinkApp.channelListRegion.show(channelCollectionView);
    var userView = new UserView({model: channel.user});
    FactlinkApp.userblockRegion.show(userView);
  },

  getChannelFacts: function(username, channel_id) {
    var channel = this.loadChannel(username, channel_id);
    this.commonChannelViews(channel);
    FactlinkApp.mainRegion.show(new ChannelView({model: channel}));
  },

  getChannelActivities: function(username, channel_id) {
    var channel = this.loadChannel(username, channel_id);
    this.commonChannelViews(channel);
    FactlinkApp.mainRegion.show(new ChannelActivitiesView({model: channel}));
  }

}
<|endoftext|>


<commit_before>module.exports = function(options) {

feature_types = require('../utilities/feature_types')

var generateKMLHeader = function() {
  var header = "<?xml version='1.0' encoding='UTF-8'?>" +
               "<kml xmlns='http://www.opengis.net/kml/2.2' " +
               "xmlns:gx='http://www.google.com/kml/ext/2.2' " +
               "xmlns:kml='http://www.opengis.net/kml/2.2' " +
               "xmlns:atom='http://www.w3.org/2005/Atom'>";
  return header;
};

var generateKMLDocument = function() {

  var types = feature_types.getTypes();

  var doc = "<Document>" +
	          "  <name>MAGE-Export.kml</name>" +
	          "  <open>1</open>";
  for(i in types) {
    var type = types[i];
    doc += "";
    doc += "";
    doc += "";
    doc += "";
  }
	 return doc;
};

var generateKMLFolderStart = function(name) {
  var folder = "<Folder>" +
               "  <name>" + name + "</name>";
  return folder;
};

var generatePlacemark = function(name, styleUrl, lon, lat, alt, feature, attachments) {

  var desc = "
Properties
";
  Object.keys(feature).forEach(function(key) {
    desc += key + ':  ' + feature[key] + '
';
  });

  var media = "
Media Attachments
";
  if(attachments) {
    for(var i = 0; i < attachments.length; i++) {
      var attachment = attachments[i];

      if((/^image/).test(attachment.contentType)) {
        media += '
';
      }
      else {
        media += '' + attachment.name + '
';
      }

    }
  }

  switch (feature.EVENTLEVEL)
  {
    case 'Normal':
      styleColor = "blue";
      break;
    case 'Yellow':
      styleColor = "yellow";
      break;
    case 'Green':
      styleColor = "green";
      break;
    case 'Red':
      styleColor = "red";
      break;
    default:
      styleColor = "blue";
  }

  var placemark = "<Placemark>" +
                  "  <name>" + name + "</name>" +
                  "  " +
                  "  <Point>" +
                  "    <coordinates>" + lon + "," + lat + "," + alt + "</coordinates>" +
                  "  </Point>" +
                  "  <description>" + desc + '
' + media +"</description>" +
                  "</Placemark>";

  return placemark;
};

var generateKMLDocumentClose = function() {
  var doc = "</Document>";
  return doc;
};

var generateKMLFolderClose = function() {
  var folder = "</Folder>";
  return folder;
};

var generateKMLClose = function() {
	var kml = "</kml>";
	return kml;
};

return {
  generateKMLHeader: generateKMLHeader,
  generateKMLDocument: generateKMLDocument,
  generateKMLFolderStart: generateKMLFolderStart,
  generatePlacemark: generatePlacemark,
  generateKMLFolderClose: generateKMLFolderClose,
  generateKMLDocumentClose: generateKMLDocumentClose,
  generateKMLClose: generateKMLClose
 }

}()<commit_msg>bug fix for busted media URL<commit_after>module.exports = function(options) {

feature_types = require('../utilities/feature_types')

var generateKMLHeader = function() {
  var header = "<?xml version='1.0' encoding='UTF-8'?>" +
               "<kml xmlns='http://www.opengis.net/kml/2.2' " +
               "xmlns:gx='http://www.google.com/kml/ext/2.2' " +
               "xmlns:kml='http://www.opengis.net/kml/2.2' " +
               "xmlns:atom='http://www.w3.org/2005/Atom'>";
  return header;
};

var generateKMLDocument = function() {

  var types = feature_types.getTypes();

  var doc = "<Document>" +
	          "  <name>MAGE-Export.kml</name>" +
	          "  <open>1</open>";
  for(i in types) {
    var type = types[i];
    doc += "";
    doc += "";
    doc += "";
    doc += "";
  }
	 return doc;
};

var generateKMLFolderStart = function(name) {
  var folder = "<Folder>" +
               "  <name>" + name + "</name>";
  return folder;
};

var generatePlacemark = function(name, styleUrl, lon, lat, alt, feature, attachments) {

  var desc = "
Properties
";
  Object.keys(feature).forEach(function(key) {
    desc += key + ':  ' + feature[key] + '
';
  });

  var media = "
Media Attachments
";
  if(attachments) {
    for(var i = 0; i < attachments.length; i++) {
      var attachment = attachments[i];

      if((/^image/).test(attachment.contentType)) {
        media += '
';
      }
      else {
        media += '' + attachment.name + '"
';
      }

    }
  }

  switch (feature.EVENTLEVEL)
  {
    case 'Normal':
      styleColor = "blue";
      break;
    case 'Yellow':
      styleColor = "yellow";
      break;
    case 'Green':
      styleColor = "green";
      break;
    case 'Red':
      styleColor = "red";
      break;
    default:
      styleColor = "blue";
  }

  var placemark = "<Placemark>" +
                  "  <name>" + name + "</name>" +
                  "  " +
                  "  <Point>" +
                  "    <coordinates>" + lon + "," + lat + "," + alt + "</coordinates>" +
                  "  </Point>" +
                  "  <description>" + desc + '
' + media +"</description>" +
                  "</Placemark>";

  return placemark;
};

var generateKMLDocumentClose = function() {
  var doc = "</Document>";
  return doc;
};

var generateKMLFolderClose = function() {
  var folder = "</Folder>";
  return folder;
};

var generateKMLClose = function() {
	var kml = "</kml>";
	return kml;
};

return {
  generateKMLHeader: generateKMLHeader,
  generateKMLDocument: generateKMLDocument,
  generateKMLFolderStart: generateKMLFolderStart,
  generatePlacemark: generatePlacemark,
  generateKMLFolderClose: generateKMLFolderClose,
  generateKMLDocumentClose: generateKMLDocumentClose,
  generateKMLClose: generateKMLClose
 }

}()<|endoftext|>


<commit_before>if(Quill == null){
  alert("You must download quilljs! It needs to be in the same directory as y-richtext!");
}

var quill = new Quill('#editor', {
    modules: {
        'multi-cursor': true,
        'link-tooltip': true,
        'image-tooltip': true
    },
    theme: 'snow'
});
quill.addModule('toolbar', { container: '#toolbar' });
window.connector = new Y.WebRTC('sqfjqsmdlkjrhguemslkfjmlsdkjf');
/* window.connector = new Y.WebRTC('sqfjqsmdlkjrhguemslkfjmlsdkjf',
    {url: 'http://localhost:8888'}); */
// connector.debug = true;
window.y = new Y(connector);

// TODO: only for debugging
// y.HB.setGarbageCollectTimeout(2000)
y.observe (function (events) {
    for (i in events){
        if(events[i].name === 'editor'){
            y.val('editor').bind('QuillJs', quill);
            window.editor = y.val('editor')
        }
    }
});

connector.whenSynced(function(){
    if(y.val('editor') == null){
        y.val('editor', new Y.RichText("QuillJs", quill));
    }
});
<commit_msg>better consistency<commit_after>if(Quill == null){
  alert("You must download quilljs! It needs to be in the same directory as y-richtext!");
}

var quill = new Quill('#editor', {
    modules: {
        'multi-cursor': true,
        'link-tooltip': true,
        'image-tooltip': true
    },
    theme: 'snow'
});
quill.addModule('toolbar', { container: '#toolbar' });
window.connector = new Y.WebRTC('sqfjqsmdlkjrhguemslkfjmlsdkjf');

// connector.debug = true;
window.y = new Y(connector);

checkConsistency = function(){
  deltas = editor.getDelta()
  quill_deltas = quill.getContents().ops
  for(d in deltas){
    delta = deltas[d]
    for(name in delta){
      value = delta[name]
      quill_value = quill_deltas[d][name]
      if(value.constructor === Object){
        for(n in value){
          if(value[n] !== quill_value[n]){
            return false
          }
        }
      } else if(value !== quill_value){
        return false
      }
    }
  }
  return true
}

quill.on("text-change", function(){
  window.setTimeout(function(){
    if(editor != null && editor.getDelta != null){
      console.log("Quill & y-richtext are equal: "+checkConsistency())
    }
  },0)
})

// TODO: only for debugging
y._model.HB.stopGarbageCollection()
y.observe (function (events) {
    for (i in events){
        if(events[i].name === 'editor'){
            y.val('editor').bind('QuillJs', quill);
            window.editor = y.val('editor')
        }
    }
});

connector.whenSynced(function(){
    if(y.val('editor') == null){
        y.val('editor', new Y.RichText("QuillJs", quill));
    }
});
<|endoftext|>


<commit_before>import React, {Component} from "react"
import Codemirror from 'react-codemirror'
import {html as html_beautify} from 'js-beautify'
import Modal from 'react-modal'
require('codemirror/mode/htmlmixed/htmlmixed');

export default class CodeMirror extends Component {
    constructor(props) {
        super(props);

        this.onClickBound = this.onClick.bind(this);

        this.beautifyOptions = {
            "wrap_line_length": 140
        };
        if (this.props.node) {
            this.state = {
                sourceEditorActive: false
            };
        } else {
            this.state = {}
        }
        this.code = this.props.data && this.props.data.html || this.props.html;
    }

    componentWillUnmount(){
        console.log(`Code mirror ${this.props.id} unmounted`);
    }

    updateCode(newCode) {
        this.code = newCode
    }

    onSave() {
        this.props.updatePiece && this.props.updatePiece(this.props.id, {data: {html: this.code, updateNode: this.props.data.updateNode}});
        this.props.savePiece && this.props.savePiece(this.props.id);
        this.setState({sourceEditorActive: false})
    }

    onClose() {
        this.props.node ? this.setState({sourceEditorActive: false}) : (this.props.onClose && this.props.onClose())
    }

    createEditor(){
        // this.props.node
        if(this.props.node) {
            this.props.node.addEventListener('click', this.onClickBound);
        }
    }

    destroyEditor(){
        if(this.props.node) {
            this.props.node.removeEventListener('click', this.onClickBound);
        }
    }

    renderNonReactAttributes(){
        if (this.props.editorActive && !this.state.sourceEditorActive) {
            this.createEditor();
            if(this.props.node) {
                this.props.node.classList.add(...this.props.className.split(' '));
            }
        }
        else {
            this.destroyEditor();
            if(this.props.node) {
                this.props.node.classList.remove(...this.props.className.split(' '));
            }
        }

        //render new data
        if(this.props.node) {
            let content = this.props.node.innerHTML;
            let data = this.props.data;
            let needRender = data.updateNode != undefined && data.updateNode != null ? data.updateNode : true;
            if (content != data.html && needRender == true) {
                this.props.node.innerHTML = data.html;
            }
        }

    }

    onClick(e){
        e.preventDefault();
        this.setState({sourceEditorActive: true});
    }

    render() {
        let codemirror = null;

        if(this.state.sourceEditorActive || !this.props.node){
            //if there is no this.props.node, it means this component is invoked manually with custom html directly in props and should be just rendered
            //if this.state.sourceEditorActive and this.props.node presents, it means that is a regular piece with control over node and sourceEditorActive means modal is open
            let options = {
                lineNumbers: true,
                mode: 'htmlmixed'
            };
            const html = this.props.node ? this.props.data.html : this.props.html;
            codemirror =  <Modal contentLabel="Edit source" isOpen={true} overlayClassName="r_modal-overlay r_visible"
                                 className="r_modal-content"
                                 onRequestClose={this.onClose.bind(this)}>
                <Codemirror
                    value={html_beautify(html)}
                    onChange={this.updateCode.bind(this)} options={options}/>

Cancel

this.props.node ? this.onSave() : (this.props.onSave && this.props.onSave(this.code))}>
                        Save

            </Modal>;
        } else {
            codemirror = React.createElement(this.props.wrapper, {});
        }

        this.renderNonReactAttributes();
        return codemirror;
    }
}

/**
 * Specify component should be rendered inside target node and capture all inside html
 * @type {string}
 */
CodeMirror.__renderType = "BEFORE";
CodeMirror.__name = "Source";
<commit_msg>added showing the message on redaxtorbar if   data was changed and updateNode == true<commit_after>import React, {Component} from "react"
import Codemirror from 'react-codemirror'
import {html as html_beautify} from 'js-beautify'
import Modal from 'react-modal'
require('codemirror/mode/htmlmixed/htmlmixed');

export default class CodeMirror extends Component {
    constructor(props) {
        super(props);

        this.onClickBound = this.onClick.bind(this);

        this.beautifyOptions = {
            "wrap_line_length": 140
        };
        if (this.props.node) {
            this.state = {
                sourceEditorActive: false
            };
        } else {
            this.state = {}
        }
        this.code = this.props.data && this.props.data.html || this.props.html;

        if(this.props.data) {
            this.initDataKeys = Object.keys(this.props.data);
        }
    }

    componentWillUnmount(){
        console.log(`Code mirror ${this.props.id} unmounted`);
    }

    updateCode(newCode) {
        this.code = newCode
    }

    shouldComponentUpdate(nextProps, nextState){
        let data = this.props.data;
        if (data) {
            let needRender = data.updateNode != undefined && data.updateNode != null ? data.updateNode : true;
            if (!needRender && nextProps.data != this.props.data) {
                let isChanged = false;
                this.initDataKeys.forEach(key => isChanged = isChanged && (nextProps.data[key] != this.props.data[key]));
                this.props.setPieceMessage && this.props.setPieceMessage(this.props.id, 'Page refresh required', 'warning');
            }
        }
        return true;
    }

    onSave() {
        this.props.updatePiece && this.props.updatePiece(this.props.id, {data: {html: this.code, updateNode: this.props.data.updateNode}});
        this.props.savePiece && this.props.savePiece(this.props.id);
        this.setState({sourceEditorActive: false})
    }

    onClose() {
        this.props.node ? this.setState({sourceEditorActive: false}) : (this.props.onClose && this.props.onClose())
    }

    createEditor(){
        // this.props.node
        if(this.props.node) {
            this.props.node.addEventListener('click', this.onClickBound);
        }
    }

    destroyEditor(){
        if(this.props.node) {
            this.props.node.removeEventListener('click', this.onClickBound);
        }
    }

    renderNonReactAttributes(){
        if (this.props.editorActive && !this.state.sourceEditorActive) {
            this.createEditor();
            if(this.props.node) {
                this.props.node.classList.add(...this.props.className.split(' '));
            }
        }
        else {
            this.destroyEditor();
            if(this.props.node) {
                this.props.node.classList.remove(...this.props.className.split(' '));
            }
        }

        //render new data
        if(this.props.node) {
            let content = this.props.node.innerHTML;
            let data = this.props.data;
            let needRender = data.updateNode != undefined && data.updateNode != null ? data.updateNode : true;
            if (content != data.html && needRender == true) {
                this.props.node.innerHTML = data.html;
            }
        }

    }

    onClick(e){
        e.preventDefault();
        this.setState({sourceEditorActive: true});
    }

    render() {
        let codemirror = null;

        if(this.state.sourceEditorActive || !this.props.node){
            //if there is no this.props.node, it means this component is invoked manually with custom html directly in props and should be just rendered
            //if this.state.sourceEditorActive and this.props.node presents, it means that is a regular piece with control over node and sourceEditorActive means modal is open
            let options = {
                lineNumbers: true,
                mode: 'htmlmixed'
            };
            const html = this.props.node ? this.props.data.html : this.props.html;
            codemirror =  <Modal contentLabel="Edit source" isOpen={true} overlayClassName="r_modal-overlay r_visible"
                                 className="r_modal-content"
                                 onRequestClose={this.onClose.bind(this)}>
                <Codemirror
                    value={html_beautify(html)}
                    onChange={this.updateCode.bind(this)} options={options}/>

Cancel

this.props.node ? this.onSave() : (this.props.onSave && this.props.onSave(this.code))}>
                        Save

            </Modal>;
        } else {
            codemirror = React.createElement(this.props.wrapper, {});
        }

        this.renderNonReactAttributes();
        return codemirror;
    }
}

/**
 * Specify component should be rendered inside target node and capture all inside html
 * @type {string}
 */
CodeMirror.__renderType = "BEFORE";
CodeMirror.__name = "Source";
<|endoftext|>


<commit_before>'use strict';

var color = require('../config/color');

exports.parseEmoticons = parseEmoticons;

var emotes = {
	'feelscri':'http://i.imgur.com/JEMjW4f.jpg',
	'feelspac':'http://i.imgur.com/Dc9DBUz.png',
	'#freewolf':'http://i.imgur.com/ybxWXiG.png',
	'feelstea':'http://media.tumblr.com/68eb56721b0833c66c8a9542ed515594/tumblr_inline_mkj23fgNsZ1qz4rgp.gif',
	'feelsbd':'http://i.imgur.com/YyEdmwX.png',
	'feelsbm':'http://i.imgur.com/xwfJb2z.png',
	'feelsbn':'http://i.imgur.com/wp51rIg.png',
	'feelsdd':'http://i.imgur.com/fXtdLtV.png',
	'feelsdoge':'http://i.imgur.com/GklYWvi.png',
	'feelsgd':'http://i.imgur.com/Jf0n4BL.png',
	'feelsgn':'http://i.imgur.com/juJQh0J.png',
	'feelshp':'http://i.imgur.com/1W19BDG.png',
	'feelsmd':'http://i.imgur.com/DJHMdSw.png',
	'feelsnv':'http://i.imgur.com/XF6kIdJ.png',
	'feelsok':'http://i.imgur.com/gu3Osve.png',
	'feelspika':'http://i.imgur.com/mBq3BAW.png',
	'feelspink':'http://i.imgur.com/jqfB8Di.png',
	'feelspn':'http://i.imgur.com/wSSM6Zk.png',
	'feelspr':'http://i.imgur.com/3VtkKfJ.png',
	'feelsrg':'http://i.imgur.com/DsRQCsI.png',
	'feelsrs':'http://i.imgur.com/qGEot0R.png',
	'feelssc':'http://i.imgur.com/cm6oTZ1.png',
	'fukya':'http://i.imgur.com/ampqCZi.gif',
	'funnylol':'http://i.imgur.com/SlzCghq.png',
	'hmmface':'http://i.imgur.com/Z5lOwfZ.png',
	'noface':'http://i.imgur.com/H744eRE.png',
	'Obama':'http://i.imgur.com/rBA9M7A.png',
	'oshet':'http://i.imgur.com/yr5DjuZ.png',
	'Sanic':'http://i.imgur.com/Y6etmna.png',
	'wtfman':'http://i.imgur.com/kwR8Re9.png',
	'xaa':'http://i.imgur.com/V728AvL.png',
	'yayface':'http://i.imgur.com/anY1jf8.png',
	'yesface':'http://i.imgur.com/k9YCF6K.png',
};

var emotesKeys = Object.keys(emotes);
var patterns = [];
var metachars = /[[\]{}()*+?.\\|^$\-,&#\s]/g;

for (var i in emotes) {
	if (emotes.hasOwnProperty(i)) {
		patterns.push('(' + i.replace(metachars, '\\$&') + ')');
	}
}
var patternRegex = new RegExp(patterns.join('|'), 'g');

/**
 * Parse emoticons in message.
 *
 * @param {String} message
 * @param {Object} room
 * @param {Object} user
 * @param {Boolean} pm - returns a string if it is in private messages
 * @returns {Boolean|String}
 */
function parseEmoticons(message, room, user, pm) {
	if (typeof message !== 'string' || (!pm && room.disableEmoticons)) return false;

	var match = false;
	var len = emotesKeys.length;

	while (len--) {
		if (message && message.indexOf(emotesKeys[len]) >= 0) {
			match = true;
			break;
		}
	}

	if (!match) return false;

	// escape HTML
	message = Tools.escapeHTML(message);

	// add emotes
	message = message.replace(patternRegex, function (match) {
		var emote = emotes[match];
		return typeof emote === 'string' ? '' : match;
	});

	// __italics__
	message = message.replace(/\_\_([^< ](?:[^<]*?[^< ])?)\_\_(?![^<]*?<\/a)/g, '$1');

	// **bold**
	message = message.replace(/\*\*([^< ](?:[^<]*?[^< ])?)\*\*/g, '$1');

	var group = user.getIdentity().charAt(0);
	if (room.auth) group = room.auth[user.userid] || group;

	var style = "background:none;border:0;padding:0 5px 0 0;font-family:Verdana,Helvetica,Arial,sans-serif;font-size:9pt;cursor:pointer";

	message = "
" + "" + group + "" + "<button name='parseCommand' value='/user " + user.name + "' style='" + style + "'>" + "" + user.name + ":" + "</button>" + message + "
";
	if (pm) return message;

	room.addRaw(message);

	return true;
}

/**
 * Create a two column table listing emoticons.
 *
 * @return {String} emotes table
 */
function create_table() {
	var emotes_name = Object.keys(emotes);
	var emotes_list = [];
	var emotes_group_list = [];
	var len = emotes_name.length;
	var i;

	for (i = 0; i < len; i++) {
		emotes_list.push("" +
			"" +
			emotes_name[i] + "	");
	}

	var emotes_list_right = emotes_list.splice(len / 2, len / 2);

	for (i = 0; i < len / 2; i++) {
		var emote1 = emotes_list[i],
			emote2 = emotes_list_right[i];
		if (emote2) {
			emotes_group_list.push("
" + emote1 + emote2 + "
");
		} else {
			emotes_group_list.push("
" + emote1 + "
");
		}
	}

	return "
List of Emoticons" + "

" + "
" + emotes_group_list.join("") + "
" + "

";
}

var emotes_table = create_table();

exports.commands = {
	blockemote: 'blockemoticons',
	blockemotes: 'blockemoticons',
	blockemoticon: 'blockemoticons',
	blockemoticons: function (target, room, user) {
		if (user.blockEmoticons === (target || true)) return this.sendReply("You are already blocking emoticons in private messages! To unblock, use /unblockemoticons");
		user.blockEmoticons = true;
		return this.sendReply("You are now blocking emoticons in private messages.");
	},
	blockemoticonshelp: ["/blockemoticons - Blocks emoticons in private messages. Unblock them with /unblockemoticons."],

	unblockemote: 'unblockemoticons',
	unblockemotes: 'unblockemoticons',
	unblockemoticon: 'unblockemoticons',
	unblockemoticons: function (target, room, user) {
		if (!user.blockEmoticons) return this.sendReply("You are not blocking emoticons in private messages! To block, use /blockemoticons");
		user.blockEmoticons = false;
		return this.sendReply("You are no longer blocking emoticons in private messages.");
	},
	unblockemoticonshelp: ["/unblockemoticons - Unblocks emoticons in private messages. Block them with /blockemoticons."],

	emotes: 'emoticons',
	emoticons: function (target, room, user) {
		if (!this.canBroadcast()) return;
		this.sendReply("|raw|" + emotes_table);
	},
	emoticonshelp: ["/emoticons - Get a list of emoticons."],

	toggleemote: 'toggleemoticons',
	toggleemotes: 'toggleemoticons',
	toggleemoticons: function (target, room, user) {
		if (!this.can('declare', null, room)) return false;
		room.disableEmoticons = !room.disableEmoticons;
		this.sendReply("Disallowing emoticons is set to " + room.disableEmoticons + " in this room.");
		if (room.disableEmoticons) {
			this.add("|raw|
Emoticons are disabled!
Emoticons will not work.
");
		} else {
			this.add("|raw|
Emoticons are enabled!
Emoticons will work now.
");
		}
	},
	toggleemoticonshelp: ["/toggleemoticons - Toggle emoticons on or off."],

	rande: 'randemote',
	randemote: function (target, room, user) {
		if (!this.canBroadcast()) return;
		var rng = Math.floor(Math.random() * emotesKeys.length);
		var randomEmote = emotesKeys[rng];
		this.sendReplyBox("");
	},
	randemotehelp: ["/randemote - Get a random emote."],
};
<commit_msg>Update emoticons.js<commit_after>'use strict';

var color = require('../config/color');

exports.parseEmoticons = parseEmoticons;

var emotes = {
	'feelscri':'http://i.imgur.com/JEMjW4f.jpg',
	'feelspac':'http://i.imgur.com/Dc9DBUz.png',
	'#freewolf':'http://i.imgur.com/ybxWXiG.png',
	'feelstea':'http://media.tumblr.com/68eb56721b0833c66c8a9542ed515594/tumblr_inline_mkj23fgNsZ1qz4rgp.gif',
	'feelsbd':'http://i.imgur.com/YyEdmwX.png',
	'feelsbm':'http://i.imgur.com/xwfJb2z.png',
	'feelsbn':'http://i.imgur.com/wp51rIg.png',
	'feelsdd':'http://i.imgur.com/fXtdLtV.png',
	'feelsdoge':'http://i.imgur.com/GklYWvi.png',
	'feelsgd':'http://i.imgur.com/Jf0n4BL.png',
	'feelsgn':'http://i.imgur.com/juJQh0J.png',
	'feelshp':'http://i.imgur.com/1W19BDG.png',
	'feelsmd':'http://i.imgur.com/DJHMdSw.png',
	'feelsnv':'http://i.imgur.com/XF6kIdJ.png',
	'feelsok':'http://i.imgur.com/gu3Osve.png',
	'feelspika':'http://i.imgur.com/mBq3BAW.png',
	'feelspink':'http://i.imgur.com/jqfB8Di.png',
	'feelspn':'http://i.imgur.com/wSSM6Zk.png',
	'feelspr':'http://i.imgur.com/3VtkKfJ.png',
	'feelsrg':'http://i.imgur.com/DsRQCsI.png',
	'feelsrs':'http://i.imgur.com/qGEot0R.png',
	'feelssc':'http://i.imgur.com/cm6oTZ1.png',
	'fukya':'http://i.imgur.com/ampqCZi.gif',
	'funnylol':'http://i.imgur.com/SlzCghq.png',
	'hmmface':'http://i.imgur.com/Z5lOwfZ.png',
	'noface':'http://i.imgur.com/H744eRE.png',
	'feelsdean':'http://i.imgur.com/PJubQO2.png',
	'oshet':'http://i.imgur.com/yr5DjuZ.png',
	'Sanic':'http://i.imgur.com/Y6etmna.png',
	'wtfman':'http://i.imgur.com/kwR8Re9.png',
	'xaa':'http://i.imgur.com/V728AvL.png',
	'yayface':'http://i.imgur.com/anY1jf8.png',
	'yesface':'http://i.imgur.com/k9YCF6K.png',
};

var emotesKeys = Object.keys(emotes);
var patterns = [];
var metachars = /[[\]{}()*+?.\\|^$\-,&#\s]/g;

for (var i in emotes) {
	if (emotes.hasOwnProperty(i)) {
		patterns.push('(' + i.replace(metachars, '\\$&') + ')');
	}
}
var patternRegex = new RegExp(patterns.join('|'), 'g');

/**
 * Parse emoticons in message.
 *
 * @param {String} message
 * @param {Object} room
 * @param {Object} user
 * @param {Boolean} pm - returns a string if it is in private messages
 * @returns {Boolean|String}
 */
function parseEmoticons(message, room, user, pm) {
	if (typeof message !== 'string' || (!pm && room.disableEmoticons)) return false;

	var match = false;
	var len = emotesKeys.length;

	while (len--) {
		if (message && message.indexOf(emotesKeys[len]) >= 0) {
			match = true;
			break;
		}
	}

	if (!match) return false;

	// escape HTML
	message = Tools.escapeHTML(message);

	// add emotes
	message = message.replace(patternRegex, function (match) {
		var emote = emotes[match];
		return typeof emote === 'string' ? '' : match;
	});

	// __italics__
	message = message.replace(/\_\_([^< ](?:[^<]*?[^< ])?)\_\_(?![^<]*?<\/a)/g, '$1');

	// **bold**
	message = message.replace(/\*\*([^< ](?:[^<]*?[^< ])?)\*\*/g, '$1');

	var group = user.getIdentity().charAt(0);
	if (room.auth) group = room.auth[user.userid] || group;

	var style = "background:none;border:0;padding:0 5px 0 0;font-family:Verdana,Helvetica,Arial,sans-serif;font-size:9pt;cursor:pointer";

	message = "
" + "" + group + "" + "<button name='parseCommand' value='/user " + user.name + "' style='" + style + "'>" + "" + user.name + ":" + "</button>" + message + "
";
	if (pm) return message;

	room.addRaw(message);

	return true;
}

/**
 * Create a two column table listing emoticons.
 *
 * @return {String} emotes table
 */
function create_table() {
	var emotes_name = Object.keys(emotes);
	var emotes_list = [];
	var emotes_group_list = [];
	var len = emotes_name.length;
	var i;

	for (i = 0; i < len; i++) {
		emotes_list.push("" +
			"" +
			emotes_name[i] + "	");
	}

	var emotes_list_right = emotes_list.splice(len / 2, len / 2);

	for (i = 0; i < len / 2; i++) {
		var emote1 = emotes_list[i],
			emote2 = emotes_list_right[i];
		if (emote2) {
			emotes_group_list.push("
" + emote1 + emote2 + "
");
		} else {
			emotes_group_list.push("
" + emote1 + "
");
		}
	}

	return "
List of Emoticons" + "

" + "
" + emotes_group_list.join("") + "
" + "

";
}

var emotes_table = create_table();

exports.commands = {
	blockemote: 'blockemoticons',
	blockemotes: 'blockemoticons',
	blockemoticon: 'blockemoticons',
	blockemoticons: function (target, room, user) {
		if (user.blockEmoticons === (target || true)) return this.sendReply("You are already blocking emoticons in private messages! To unblock, use /unblockemoticons");
		user.blockEmoticons = true;
		return this.sendReply("You are now blocking emoticons in private messages.");
	},
	blockemoticonshelp: ["/blockemoticons - Blocks emoticons in private messages. Unblock them with /unblockemoticons."],

	unblockemote: 'unblockemoticons',
	unblockemotes: 'unblockemoticons',
	unblockemoticon: 'unblockemoticons',
	unblockemoticons: function (target, room, user) {
		if (!user.blockEmoticons) return this.sendReply("You are not blocking emoticons in private messages! To block, use /blockemoticons");
		user.blockEmoticons = false;
		return this.sendReply("You are no longer blocking emoticons in private messages.");
	},
	unblockemoticonshelp: ["/unblockemoticons - Unblocks emoticons in private messages. Block them with /blockemoticons."],

	emotes: 'emoticons',
	emoticons: function (target, room, user) {
		if (!this.canBroadcast()) return;
		this.sendReply("|raw|" + emotes_table);
	},
	emoticonshelp: ["/emoticons - Get a list of emoticons."],

	toggleemote: 'toggleemoticons',
	toggleemotes: 'toggleemoticons',
	toggleemoticons: function (target, room, user) {
		if (!this.can('declare', null, room)) return false;
		room.disableEmoticons = !room.disableEmoticons;
		this.sendReply("Disallowing emoticons is set to " + room.disableEmoticons + " in this room.");
		if (room.disableEmoticons) {
			this.add("|raw|
Emoticons are disabled!
Emoticons will not work.
");
		} else {
			this.add("|raw|
Emoticons are enabled!
Emoticons will work now.
");
		}
	},
	toggleemoticonshelp: ["/toggleemoticons - Toggle emoticons on or off."],

	rande: 'randemote',
	randemote: function (target, room, user) {
		if (!this.canBroadcast()) return;
		var rng = Math.floor(Math.random() * emotesKeys.length);
		var randomEmote = emotesKeys[rng];
		this.sendReplyBox("");
	},
	randemotehelp: ["/randemote - Get a random emote."],
};
<|endoftext|>


<commit_before>var loadTodos = function() {
  $.ajax({
    url: "/graphql?query={todoList{id,text,done}}"
  }).done(function(data) {
    console.log(data);
    var dataParsed = JSON.parse(data);
    var todos = dataParsed.data.todoList;

    if (!todos.length) {
      $('.todo-list-container').append('
There are no tasks for you today
');
    }

    $.each(todos, function(i, v) {
      var doneHtml = '<input id="' + v.id + '" type="checkbox"' + (v.done ? ' checked="checked"' : '') + '>';
      var labelHtml = '' + doneHtml + v.text + '';
      var itemHtml = '
' + labelHtml + '
';

      $('.todo-list-container').append(itemHtml);
    });
  });
};

$(document).ready(function() {
  loadTodos();
});
<commit_msg>Add "Add task" functionality, use the mutation<commit_after>var handleTodoList = function(object) {
  var todos = object;

  if (!todos.length) {
    $('.todo-list-container').append('
There are no tasks for you today
');
  }

  $.each(todos, function(i, v) {
    var doneHtml = '<input id="' + v.id + '" type="checkbox"' + (v.done ? ' checked="checked"' : '') + '>';
    var labelHtml = '' + doneHtml + v.text + '';
    var itemHtml = '
' + labelHtml + '
';

    $('.todo-list-container').append(itemHtml);
  });
};

var loadTodos = function() {
  $.ajax({
    url: "/graphql?query={todoList{id,text,done}}"
  }).done(function(data) {
    console.log(data);
    var dataParsed = JSON.parse(data);
    handleTodoList(dataParsed.data.todoList);
  });
};

var addTodo = function(todoText) {
  if (!todoText || todoText === "") {
    alert('Please specify a task');
    return;
  }

  $.ajax({
    url: '/graphql?query=mutation+_{createTodo(text:"' + todoText + '"){id,text,done}}'
  }).done(function(data) {
    console.log(data);
    var dataParsed = JSON.parse(data);
    var todoList = [dataParsed.data.createTodo];
    handleTodoList(todoList);
  });
};

$(document).ready(function() {
  $('.todo-add-form button').click(function(){
    addTodo($('.todo-add-form #task').val());
    $('.todo-add-form #task').val('');
  });

  loadTodos();
});
<|endoftext|>