<commit_before>/*global module:false*/
module.exports = function(grunt) {
    /*jshint laxcomma:true*/
    // Project configuration.

    "use strict";

    grunt.initConfig({
        pkg: "<json:package.json>",

        meta: {
            banner: "/*! <%= pkg.name %> - <%= pkg.description %> - <%= pkg.homepage %> | License: <%= pkg.license %> */"
        },

        lint: {
            files: ["grunt.js", "src/**/*.js"]
        },

        jshint: {
            options: {
                forin: true,
                noarg: true,
                noempty: true,
                eqeqeq: true,
                bitwise: true,
                strict: true,
                undef: true,
                unused: true,
                curly: true,
                browser: true,
                devel: true,
                indent: 4
            },

            globals: {
                lib: true,
                log: true
            }
        },

        concat: {
            dist: {
                src: [
                      "<banner:meta.banner>"
                    , "src/core/lib.js"
                    , "src/util/util.js"
                    , "src/util/Benchmark.js"
                    , "src/util/Bindable.js"
                    , "src/javascript/object.js"
                    , "src/javascript/array.js"
                    , "src/javascript/string.js"
                    , "src/javascript/date.js"
                    , "src/javascript/JSON.js"
                    , "src/dom/dom.js"
                    , "src/dom/NodeList.js"
                    , "src/event/event.js"
                    , "src/browser/ready.js"
                    , "src/browser/dimensions.js"
                    , "src/browser/ie.js"
                    , "src/tween/tween.js"
                    , "src/widget/widget.js"
                    , "src/widget/helpers.js"
                    , "src/widget/Model.js"
                    ],
                dest: "dist/<%= pkg.name %>.js"
            },

            after: {
                src: ["<banner:meta.banner>", "dist/<%= pkg.name %>.min.js"],
                dest: "dist/<%= pkg.name %>.min.js"
            }
        },

        min: {
            dist: {
                src: ["<banner:meta.banner>", "<config:concat.dist.dest>"],
                dest: "dist/<%= pkg.name %>.min.js"
            }
        },

        watch: {
            dist: {
                files: "<config:concat.dist.src>",
                tasks: "concat:dist"
            }
        },

        closureCompiler: {
            dist: {
                closureCompiler: "build/google-compiler-20120710.jar",
                js: "<config:concat.dist.dest>",
                output_file: "dist/<%= pkg.name %>.min.js",
                options: {
                    compilation_level: "ADVANCED_OPTIMIZATIONS",
                    language_in: "ECMASCRIPT5_STRICT"
                }
            }
        }
    });

    grunt.loadNpmTasks("grunt-closure-tools");

    // Default task.
    grunt.registerTask("default", "concat:dist closureCompiler concat:after");
};

<commit_msg>added wrapper function to closure compiler<commit_after>/*global module:false*/
module.exports = function(grunt) {
    /*jshint laxcomma:true*/
    // Project configuration.

    "use strict";

    grunt.initConfig({
        pkg: "<json:package.json>",

        meta: {
            banner: "/*! <%= pkg.name %> - <%= pkg.description %> - <%= pkg.homepage %> | License: <%= pkg.license %> */"
        },

        lint: {
            files: ["grunt.js", "src/**/*.js"]
        },

        jshint: {
            options: {
                forin: true,
                noarg: true,
                noempty: true,
                eqeqeq: true,
                bitwise: true,
                strict: true,
                undef: true,
                unused: true,
                curly: true,
                browser: true,
                devel: true,
                indent: 4
            },

            globals: {
                lib: true,
                log: true
            }
        },

        concat: {
            dist: {
                src: [
                      "<banner:meta.banner>"
                    , "src/core/lib.js"
                    , "src/util/util.js"
                    , "src/util/Benchmark.js"
                    , "src/util/Bindable.js"
                    , "src/javascript/object.js"
                    , "src/javascript/array.js"
                    , "src/javascript/string.js"
                    , "src/javascript/date.js"
                    , "src/javascript/JSON.js"
                    , "src/dom/dom.js"
                    , "src/dom/NodeList.js"
                    , "src/event/event.js"
                    , "src/browser/ready.js"
                    , "src/browser/dimensions.js"
                    , "src/browser/ie.js"
                    , "src/tween/tween.js"
                    , "src/widget/widget.js"
                    , "src/widget/helpers.js"
                    , "src/widget/Model.js"
                    ],
                dest: "dist/<%= pkg.name %>.js"
            },

            after: {
                src: ["<banner:meta.banner>", "dist/<%= pkg.name %>.min.js"],
                dest: "dist/<%= pkg.name %>.min.js"
            }
        },

        min: {
            dist: {
                src: ["<banner:meta.banner>", "<config:concat.dist.dest>"],
                dest: "dist/<%= pkg.name %>.min.js"
            }
        },

        watch: {
            dist: {
                files: "<config:concat.dist.src>",
                tasks: "concat:dist"
            }
        },

        closureCompiler: {
            dist: {
                closureCompiler: "build/google-compiler-20120710.jar",
                js: "<config:concat.dist.dest>",
                output_file: "dist/<%= pkg.name %>.min.js",
                options: {
                    compilation_level: "ADVANCED_OPTIMIZATIONS",
                    language_in: "ECMASCRIPT5_STRICT",
                    output_wrapper: "'(function(){%output%}).call(this);'"
                }
            }
        }
    });

    grunt.loadNpmTasks("grunt-closure-tools");

    // Default task.
    grunt.registerTask("default", "concat:dist closureCompiler concat:after");
};

<|endoftext|>


<commit_before>/**
 * Module Name: imgur
 * Description: Various imgur functionality
 */

var _ = require('underscore')._,
    request = require('request');

var imgur = function(dbot) {
    this.api = {
        'getRandomImage': function(callback) {
            var random = function(len) {
                var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
                return len ? chars.charAt(~~(Math.random()*chars.length)) + random(len-1) : "";
            };

            var testUrl = 'http://i.imgur.com/' +
                random(5) +
                '.png';
            var image = request(testUrl, function(error, response, body) {
                // 492 is body.length of a removed image
                if(!error && response.statusCode == 200 && body.length != 492) {
                    callback(testUrl);
                } else {
                    this.api.getRandomImage(callback);
                }
            }.bind(this));
        },

        'getImageInfo': function(slug, callback) {
            request.get({
                'url': 'https://api.imgur.com/3/image/' + slug + '.json',
                'headers': {
                    'Authorization': 'Client-ID 86fd3a8da348b65'
                }
            }, function(err, response, body) {
                callback(body);
            });
        }
    };

    this.commands = {
        '~ri': function(event) {
            this.api.getRandomImage(function(link) {
                event.reply(event.user + ': (' + dbot.t('nsfw') + ') ' + link);
            });
        }
    }

    this.onLoad = function() {
    }.bind(this);
};

exports.fetch = function(dbot) {
    return new imgur(dbot);
}
<commit_msg>show info about ~ri images [#350]<commit_after>/**
 * Module Name: imgur
 * Description: Various imgur functionality
 */

var _ = require('underscore')._,
    request = require('request');

var imgur = function(dbot) {
    this.api = {
        'getRandomImage': function(callback) {
            var random = function(len) {
                var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
                return len ? chars.charAt(~~(Math.random()*chars.length)) + random(len-1) : "";
            };

            var ext = [ 'gif', 'png', 'jpg' ];
            var testSlug = random(5);
            var testUrl = 'http://i.imgur.com/' +
                testSlug +
                '.' + ext[_.random(0, ext.length - 1)];
            var image = request(testUrl, function(error, response, body) {
                // 492 is body.length of a removed image
                if(!error && response.statusCode == 200 && body.length != 492) {
                    callback(testUrl, testSlug);
                } else {
                    this.api.getRandomImage(callback);
                }
            }.bind(this));
        },

        'getImageInfo': function(slug, callback) {
            request.get({
                'url': 'https://api.imgur.com/3/image/' + slug + '.json',
                'json': true,
                'headers': {
                    'Authorization': 'Client-ID 86fd3a8da348b65'
                }
            }, function(err, response, body) {
                callback(body);
            });
        }
    };

    this.commands = {
        '~ri': function(event) {
            this.api.getRandomImage(function(link, slug) {
                this.api.getImageInfo(slug, function(imgData) {
                    imgData = imgData.data;
                    var info = '[';
                    if(imgData.title) {
                        info += imgData.title + ' is ';
                    } else {
                        info += 'no-title is ';
                    }
                    if(imgData.animated) {
                        info += 'an animated ' + imgData.type.split('/')[1] + ' with ';
                    } else {
                        info += 'a non-animated ' + imgData.type.split('/')[1] + ' with ';
                    }
                    info += imgData.views + ' views.]';

                    event.reply(event.user + ': ' + link + ' ' + info);
                });

            }.bind(this));
        }
    }

    this.onLoad = function() {
    }.bind(this);
};

exports.fetch = function(dbot) {
    return new imgur(dbot);
}
<|endoftext|>


<commit_before>/*jshint node:true*/

var fs = require("fs");
var version = fs.readFileSync("./lib/backbone.viewmaster.js")
  .toString().match(/VERSION.*\"([0-9\.]+)\"/)[1];

module.exports = function(grunt) {
  grunt.loadNpmTasks('grunt-contrib-yuidoc');
  grunt.loadNpmTasks('grunt-exec');
  grunt.loadNpmTasks('grunt-templater');
  grunt.loadNpmTasks('grunt-contrib-copy');
  var pkg = require("./package.json");

  grunt.initConfig({

    yuidoc: {
      compile: {
        name: pkg.name,
        description: pkg.description,
        version: version,
        url: pkg.url,
        themedir: "public_source/yuidoc-theme",
        options: {
          paths: "lib",
          outdir: "public"
        }
      }
    },

    template: {
      doc: {
        src: 'public_source/template.html',
        dest: 'public/index.html',
        engine: "underscore",
        variables: {
          version: version,
          body: fs.readFileSync("./README.md").toString()
        }
      }
    },

    copy: {
      doc: {
        options: {
          basePath: "public_source"
        },
        files: {
          "./public/": ["./lib/*.js", "./public_source/**"]
        }
      },
      dist: {
        files: {
          "./public/": ["./lib/*.js", "./examples/**"]
        }
      }
    },

    min: {
      dist: {
        src: ["lib/backbone.viewmaster.js"],
        dest: "lib/backbone.viewmaster.min.js"
      }
    },

    watch: {
      files: "lib/*",
      tasks: "default"
    }

  });

  grunt.registerTask("default", "min yuidoc template copy");
};
<commit_msg>Publish tests<commit_after>/*jshint node:true*/

var fs = require("fs");
var version = fs.readFileSync("./lib/backbone.viewmaster.js")
  .toString().match(/VERSION.*\"([0-9\.]+)\"/)[1];

module.exports = function(grunt) {
  grunt.loadNpmTasks('grunt-contrib-yuidoc');
  grunt.loadNpmTasks('grunt-exec');
  grunt.loadNpmTasks('grunt-templater');
  grunt.loadNpmTasks('grunt-contrib-copy');
  var pkg = require("./package.json");

  grunt.initConfig({

    yuidoc: {
      compile: {
        name: pkg.name,
        description: pkg.description,
        version: version,
        url: pkg.url,
        themedir: "public_source/yuidoc-theme",
        options: {
          paths: "lib",
          outdir: "public"
        }
      }
    },

    template: {
      doc: {
        src: 'public_source/template.html',
        dest: 'public/index.html',
        engine: "underscore",
        variables: {
          version: version,
          body: fs.readFileSync("./README.md").toString()
        }
      }
    },

    copy: {
      doc: {
        options: {
          basePath: "public_source"
        },
        files: {
          "./public/": ["./lib/*.js", "./public_source/**"]
        }
      },
      dist: {
        files: {
          "./public/": ["./lib/*.js", "./examples/**", "./tests/**"]
        }
      }
    },

    min: {
      dist: {
        src: ["lib/backbone.viewmaster.js"],
        dest: "lib/backbone.viewmaster.min.js"
      }
    },

    watch: {
      files: "lib/*",
      tasks: "default"
    }

  });

  grunt.registerTask("default", "min yuidoc template copy");
};
<|endoftext|>


<commit_before>/**
 * Module Name: imgur
 * Description: Various imgur functionality
 */

var _ = require('underscore')._,
    request = require('request');

var imgur = function(dbot) {
    this.api = {
        'getRandomImage': function(callback) {
            var testUrl = 'http://i.imgur.com/' +
                Math.random().toString(36).substr(2,6) +
                '.jpg';
            var image = request(testUrl, function(error, response, body) {
                if(!error && response.statusCode == 200) {
                    callback(testUrl);
                } else {
                    this.api.getRandomImage(callback);
                }
            }.bind(this));
        }
    };

    this.commands = {
        '~randomimgur': function(event) {
            this.api.getRandomImage(function(link) {
                event.reply(event.user + ': ' + link);
            });
        }
    }
};

exports.fetch = function(dbot) {
    return new imgur(dbot);
}
<commit_msg>prevent returning deleted imgurs<commit_after>/**
 * Module Name: imgur
 * Description: Various imgur functionality
 */

var _ = require('underscore')._,
    request = require('request');

var imgur = function(dbot) {
    this.api = {
        'getRandomImage': function(callback) {
            var testUrl = 'http://i.imgur.com/' +
                Math.random().toString(36).substr(2,6) +
                '.jpg';
            var image = request(testUrl, function(error, response, body) {
                // 492 is body.length of a removed image
                if(!error && response.statusCode == 200 && body.length != 492) {
                    callback(testUrl);
                } else {
                    this.api.getRandomImage(callback);
                }
            }.bind(this));
        }
    };

    this.commands = {
        '~randomimgur': function(event) {
            this.api.getRandomImage(function(link) {
                event.reply(event.user + ': ' + link);
            });
        }
    }
};

exports.fetch = function(dbot) {
    return new imgur(dbot);
}
<|endoftext|>


<commit_before>/*
 * Rapid Interface Builder (RIB) - A simple WYSIWYG HTML5 app creator
 * Copyright (c) 2011-2012, Intel Corporation.
 *
 * This program is licensed under the terms and conditions of the
 * Apache License, version 2.0.  The full text of the Apache License is at
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 */
"use strict";

// Palette view widget

(function($, undefined) {

    $.widget('rib.paletteView', {

        options: {
            model: null
        },

        _create: function() {
            var o = this.options,
                e = this.element;

            this.refresh(null, this);

            return this;
        },

        _setOption: function(key, value) {
            switch (key) {
                case 'model':
                    this.options.model = value;
                    this.refresh(null, this);
                    break;
                default:
                    break;
            }
        },

        destroy: function() {
            // TODO: unbind any ADM event handlers
            $(this.element).find('.'+this.widgetName).remove();
            this.options.primaryTools.remove();
            this.options.secondaryTools.remove();
        },

        fontRegExp: new RegExp("src:\\s*url\\s*\\('../../"),

        refresh: function(event, widget) {
            var listWidgets, columns, generateWidget;

            widget = widget || this;

            generateWidget = function (container, name) {
                var href = location.href.replace(location.search, ''),
                    li = $('')
                        .appendTo(container),
                    imgName = BWidget.getPaletteImageName(name);
                $.get("src/css/images/widgets/" + imgName,
                    function (data, stat, resp) {
                        li.attr('src', 'data:image/svg+xml;utf8,' +
                            resp.responseText.replace(widget.fontRegExp,
                                "src: url('" + href + "src/css/"));
                    });
                $(li).disableSelection()
                    .addClass('nrc-palette-widget')
                    .data("adm-node", {type: name});
            };
            listWidgets = function (container, group) {
                $.each(group, function (i, value) {
                    if (value && typeof value === "string") {
                        if (BWidget.isPaletteWidget(value)) {
                            generateWidget(container, value);
                        }
                    }
                    else if (value)
                        listWidgets(container, value);
                });
            };

            if (widget.options && widget.options.model) {
                this.element.empty();
                this.element.append('
');
                listWidgets((this.element.find('.columns')), this.options.model);
                var w = this.element.find('.nrc-palette-widget');

                w.draggable({
                    scroll: false,
                    revert: false,
                    appendTo: 'body',
                    iframeFix: true,
                    containment: false,
                    connectToSortable: $(':rib-layoutView')
                                       .layoutView('option', 'contentDocument')
                                       .find('.ui-page-active'),
                    helper: 'clone',
                    refreshPositions: true,
                    stack: '.layoutView iframe',
                    revertDuration: 0,
                    filter: function() { return $.rib.dndfilter($(this)); },
                    start: function(event,ui){
                        var d = $(this).draggable('option','connectToSortable'),
                            f = $(':rib-layoutView')
                                    .layoutView('option','contentDocument'),
                            s = [], id;

                        if (ui.helper) {
                            if (ui.helper[0].id == "") {
                                ui.helper[0].id = this.id+'-helper';
                            }
                        }

                        // Must have an active page in order to filter
                        if (!ADM.getActivePage()) {
                            console.warning('Filter failure: No active page.');
                            return s;
                        } else {
                            id = ADM.getActivePage().getProperty('id');
                        }

                        // Find all adm-nodes (and page) on the active page
                        f = f.find('#'+id);
                        s = f.find('.adm-node').andSelf();

                        // First mark all nodes as blocked
                        s && s.addClass('ui-masked');

                        // Then unmark all valid targets
                        d && d.removeClass('ui-masked')
                              .addClass('ui-unmasked');

                        // Also unmark adm-node descendants of valid targets
                        // that are not also children of a masked container
                        // - Solves styling issues with nested containers
                        $('.ui-unmasked',f).each(function() {
                            var that = this, nodes;
                            $('.adm-node',this)
                                .not('.nrc-sortable-container')
                                .each(function() {
                                    var rents = $(this).parentsUntil(that,
                                          '.nrc-sortable-container.ui-masked');
                                    if (!rents.length) {
                                        $(this).removeClass('ui-masked')
                                               .addClass('ui-unmasked');
                                    }
                                });
                        });
                    },
                    stop: function(event,ui){
                        var f = $(':rib-layoutView')
                                    .layoutView('option','contentDocument');
                        f = f.find('#'+ADM.getActivePage().getProperty('id'));

                        // Reset masked states on all nodes on the active page
                        f.find('.ui-masked, .ui-unmasked')
                            .andSelf()
                            .removeClass('ui-masked ui-unmasked');

                        // Reset active state on all nodes on the active page
                        // - Fixes a glitch where ui-state-active sometimes
                        //   remains after dragging has completed...
                        f.find('.ui-state-active')
                            .removeClass('ui-state-active');
                    }
                })
                .disableSelection();
            }
        },
        resize: function(event, widget) {
            var headerHeight = 30, resizeBarHeight = 20, used, e;
            e = this.element;

            // allocate 70% of the remaining space for the palette
            used = 2 * headerHeight + resizeBarHeight;
            e.height(Math.round((e.parent().height() - used) * 0.7));
        }
    });
})(jQuery);
<commit_msg>[Palette View] Make sure there's no duplicated widget<commit_after>/*
 * Rapid Interface Builder (RIB) - A simple WYSIWYG HTML5 app creator
 * Copyright (c) 2011-2012, Intel Corporation.
 *
 * This program is licensed under the terms and conditions of the
 * Apache License, version 2.0.  The full text of the Apache License is at
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 */
"use strict";

// Palette view widget

(function($, undefined) {

    $.widget('rib.paletteView', {

        options: {
            model: null
        },

        _create: function() {
            var o = this.options,
                e = this.element;

            this.refresh(null, this);

            return this;
        },

        _setOption: function(key, value) {
            switch (key) {
                case 'model':
                    this.options.model = value;
                    this.refresh(null, this);
                    break;
                default:
                    break;
            }
        },

        destroy: function() {
            // TODO: unbind any ADM event handlers
            $(this.element).find('.'+this.widgetName).remove();
            this.options.primaryTools.remove();
            this.options.secondaryTools.remove();
        },

        fontRegExp: new RegExp("src:\\s*url\\s*\\('../../"),

        refresh: function(event, widget) {
            var listWidgets, columns, generateWidget;

            widget = widget || this;

            generateWidget = function (container, name) {
                var href = location.href.replace(location.search, ''),
                    li = $('')
                        .appendTo(container),
                    imgName = BWidget.getPaletteImageName(name);
                $.get("src/css/images/widgets/" + imgName,
                    function (data, stat, resp) {
                        li.attr('src', 'data:image/svg+xml;utf8,' +
                            resp.responseText.replace(widget.fontRegExp,
                                "src: url('" + href + "src/css/"));
                    });
                $(li).disableSelection()
                    .addClass('nrc-palette-widget')
                    .data("adm-node", {type: name});
            };
            listWidgets = function (container, group) {
                $.each(group, function (i, value) {
                    if (value && typeof value === "string") {
                        if (BWidget.isPaletteWidget(value) &&
                            // Avoid duplication
                            container.find("#BWidget-" + value).length === 0) {
                            generateWidget(container, value);
                        }
                    }
                    else if (value)
                        listWidgets(container, value);
                });
            };

            if (widget.options && widget.options.model) {
                this.element.empty();
                this.element.append('
');
                listWidgets((this.element.find('.columns')), this.options.model);
                var w = this.element.find('.nrc-palette-widget');

                w.draggable({
                    scroll: false,
                    revert: false,
                    appendTo: 'body',
                    iframeFix: true,
                    containment: false,
                    connectToSortable: $(':rib-layoutView')
                                       .layoutView('option', 'contentDocument')
                                       .find('.ui-page-active'),
                    helper: 'clone',
                    refreshPositions: true,
                    stack: '.layoutView iframe',
                    revertDuration: 0,
                    filter: function() { return $.rib.dndfilter($(this)); },
                    start: function(event,ui){
                        var d = $(this).draggable('option','connectToSortable'),
                            f = $(':rib-layoutView')
                                    .layoutView('option','contentDocument'),
                            s = [], id;

                        if (ui.helper) {
                            if (ui.helper[0].id == "") {
                                ui.helper[0].id = this.id+'-helper';
                            }
                        }

                        // Must have an active page in order to filter
                        if (!ADM.getActivePage()) {
                            console.warning('Filter failure: No active page.');
                            return s;
                        } else {
                            id = ADM.getActivePage().getProperty('id');
                        }

                        // Find all adm-nodes (and page) on the active page
                        f = f.find('#'+id);
                        s = f.find('.adm-node').andSelf();

                        // First mark all nodes as blocked
                        s && s.addClass('ui-masked');

                        // Then unmark all valid targets
                        d && d.removeClass('ui-masked')
                              .addClass('ui-unmasked');

                        // Also unmark adm-node descendants of valid targets
                        // that are not also children of a masked container
                        // - Solves styling issues with nested containers
                        $('.ui-unmasked',f).each(function() {
                            var that = this, nodes;
                            $('.adm-node',this)
                                .not('.nrc-sortable-container')
                                .each(function() {
                                    var rents = $(this).parentsUntil(that,
                                          '.nrc-sortable-container.ui-masked');
                                    if (!rents.length) {
                                        $(this).removeClass('ui-masked')
                                               .addClass('ui-unmasked');
                                    }
                                });
                        });
                    },
                    stop: function(event,ui){
                        var f = $(':rib-layoutView')
                                    .layoutView('option','contentDocument');
                        f = f.find('#'+ADM.getActivePage().getProperty('id'));

                        // Reset masked states on all nodes on the active page
                        f.find('.ui-masked, .ui-unmasked')
                            .andSelf()
                            .removeClass('ui-masked ui-unmasked');

                        // Reset active state on all nodes on the active page
                        // - Fixes a glitch where ui-state-active sometimes
                        //   remains after dragging has completed...
                        f.find('.ui-state-active')
                            .removeClass('ui-state-active');
                    }
                })
                .disableSelection();
            }
        },
        resize: function(event, widget) {
            var headerHeight = 30, resizeBarHeight = 20, used, e;
            e = this.element;

            // allocate 70% of the remaining space for the palette
            used = 2 * headerHeight + resizeBarHeight;
            e.height(Math.round((e.parent().height() - used) * 0.7));
        }
    });
})(jQuery);
<|endoftext|>


<commit_before>module.exports = function(grunt) {
  grunt.initConfig({
    lint: {
      files: ['javascripts/site.js']
    },
    concat: {
      foundation: {
        src: [
          'javascripts/foundation/jquery.cookie.js',
          'javascripts/foundation/jquery.event.move.js',
          'javascripts/foundation/jquery.event.swipe.js',
          'javascripts/foundation/jquery.foundation.accordian.js',
          'javascripts/foundation/jquery.foundation.alerts.js',
          'javascripts/foundation/jquery.foundation.buttons.js',
          'javascripts/foundation/jquery.foundation.clearing.js',
          'javascripts/foundation/jquery.foundation.forms.js',
          'javascripts/foundation/jquery.foundation.joyride.js',
          'javascripts/foundation/jquery.foundation.magellan.js',
          'javascripts/foundation/jquery.foundation.mediaQueryToggle.js',
          'javascripts/foundation/jquery.foundation.navigation.js',
          'javascripts/foundation/jquery.foundation.orbit.js',
          'javascripts/foundation/jquery.foundation.reveal.js',
          'javascripts/foundation/jquery.foundation.tabs.js',
          'javascripts/foundation/jquery.foundation.tooltips.js',
          'javascripts/foundation/jquery.foundation.topbar.js',
          'javascripts/foundation/jquery.foundation.offcanvas.js',
          'javascripts/foundation/jquery.foundation.placeholder.js',
          'javascripts/foundation/jquery.foundation.modernizr.foundation.js',
          'javascripts/foundation/app.js'
        ],
        dest: 'theme/javascripts/foundation.js'
      },
      libraries: {
        src: 'javascripts/contrib/*',
        dest: 'theme/javascripts/libraries.min.js'
      },
      sass: {
        src: [
          'stylesheets/app.css',
          'stylesheets/function-overrides.css',
          'stylesheets/compass.css'
        ],
        dest: 'theme/style.css'
      }
    },
    min: {
      site: {
        src: 'javascripts/site.js',
        dest: 'theme/javascripts/site.min.js'
      },
      foundation: {
        src: 'theme/javascripts/foundation.js',
        dest: 'theme/javascripts/foundation.min.js'
      }
    }
    /*compass: {
      dist: {
        options: {
          sassDir: 'sass',
          cssDir: 'theme'
        }
      }
    }*/
  });

  grunt.loadNpmTasks('grunt-contrib-compass');

  grunt.registerTask('default', 'concat lint min');
};<commit_msg>Remove incorrect call to modernizer<commit_after>module.exports = function(grunt) {
  grunt.initConfig({
    lint: {
      files: ['javascripts/site.js']
    },
    concat: {
      foundation: {
        src: [
          'javascripts/foundation/jquery.cookie.js',
          'javascripts/foundation/jquery.event.move.js',
          'javascripts/foundation/jquery.event.swipe.js',
          'javascripts/foundation/jquery.foundation.accordian.js',
          'javascripts/foundation/jquery.foundation.alerts.js',
          'javascripts/foundation/jquery.foundation.buttons.js',
          'javascripts/foundation/jquery.foundation.clearing.js',
          'javascripts/foundation/jquery.foundation.forms.js',
          'javascripts/foundation/jquery.foundation.joyride.js',
          'javascripts/foundation/jquery.foundation.magellan.js',
          'javascripts/foundation/jquery.foundation.mediaQueryToggle.js',
          'javascripts/foundation/jquery.foundation.navigation.js',
          'javascripts/foundation/jquery.foundation.orbit.js',
          'javascripts/foundation/jquery.foundation.reveal.js',
          'javascripts/foundation/jquery.foundation.tabs.js',
          'javascripts/foundation/jquery.foundation.tooltips.js',
          'javascripts/foundation/jquery.foundation.topbar.js',
          'javascripts/foundation/jquery.foundation.offcanvas.js',
          'javascripts/foundation/jquery.foundation.placeholder.js',
          'javascripts/foundation/app.js'
        ],
        dest: 'theme/javascripts/foundation.js'
      },
      libraries: {
        src: 'javascripts/contrib/*',
        dest: 'theme/javascripts/libraries.min.js'
      },
      sass: {
        src: [
          'stylesheets/app.css',
          'stylesheets/function-overrides.css',
          'stylesheets/compass.css'
        ],
        dest: 'theme/style.css'
      }
    },
    min: {
      site: {
        src: 'javascripts/site.js',
        dest: 'theme/javascripts/site.min.js'
      },
      foundation: {
        src: 'theme/javascripts/foundation.js',
        dest: 'theme/javascripts/foundation.min.js'
      }
    }
    /*compass: {
      dist: {
        options: {
          sassDir: 'sass',
          cssDir: 'theme'
        }
      }
    }*/
  });

  grunt.loadNpmTasks('grunt-contrib-compass');

  grunt.registerTask('default', 'concat lint min');
};<|endoftext|>


<commit_before>Module.register("jokes", {

  defaults:{
     baseUrl: "http://ron-swanson-quotes.herokuapp.com/v2/quotes"
  },

  getHeader: function(){
    return this.data.header
  },

  getTranslations: function(){
    return false
  },

  start: function(){

    Log.info("Starting module " + this.name);
    moment.locale(config.language);

    this.joke = null;

    this.sendSocketNotification("DISPLAY_JOKE");
    this.loaded = false;

  },

  getDom: function(){
    var div = document.createElement('div');
    div.className = "jokes-container";

    var jokeDisplay = document.createElement('span');
    jokeDisplay.className = 'joke-display';
    jokeDisplay.innerHTML = this.joke;
    div.appendChild(jokeDisplay);

    return div
  },

  notificationReceived: function(notification) {
    if (notification === "joke"){
      console.log("========== joke request ==========");
      this.sendSocketNotification("JOKE", this.defaults);
    }
  },

  socketNotificationReceived: function (notification, payload) {
    Log.log("socket recieved from Node Helper");
    if (notification === "JOKE_RESULT") {

      // for (var i = 0; i < 5; i++) {
      this.parsedDataSetter(payload);

      // }
    }
  },

  // getJoke: function(){
  //   var baseUrl = "http://ron-swanson-quotes.herokuapp.com/v2/quotes";
  //
  //   var self = this
  //
  //   var xhr = new XMLHttpRequest();
  //
  //   xhr.open("GET", baseUrl);
  //
  //   xhr.onreadystatechange = function(){
  //     if (xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {
  //
  //       self.parsedDataSetter(JSON.parse(this.response));
  //
  //     }
  //
  //   }
  //   xhr.send()
  // },

  parsedDataSetter: function(data){
    this.joke = data
    this.updateDom();

  },
})
<commit_msg>Update jokes.js<commit_after>Module.register("jokes", {

  defaults:{
     baseUrl: "http://ron-swanson-quotes.herokuapp.com/v2/quotes"
  },

  getHeader: function(){
    return this.data.header
  },

  getTranslations: function(){
    return false
  },

  start: function(){

    Log.info("Starting module " + this.name);
    moment.locale(config.language);

    this.joke = null;

    this.sendSocketNotification("DISPLAY_JOKE");
    this.loaded = false;

  },

  getDom: function(){
    var div = document.createElement('div');
    div.className = "jokes-container";

    var jokeDisplay = document.createElement('span');
    jokeDisplay.className = 'joke-display';
    jokeDisplay.innerHTML = this.joke;
    div.appendChild(jokeDisplay);

    return div
  },

  notificationReceived: function(notification) {
    if (notification === "joke"){
      console.log("========== joke request ==========");
      this.sendSocketNotification("JOKE", this.defaults);
      this.show();
    }else{
      this.hide();
    }
  },

  socketNotificationReceived: function (notification, payload) {
    Log.log("socket recieved from Node Helper");
    if (notification === "JOKE_RESULT") {

      // for (var i = 0; i < 5; i++) {
      this.parsedDataSetter(payload);

      // }
    }
  },

  // getJoke: function(){
  //   var baseUrl = "http://ron-swanson-quotes.herokuapp.com/v2/quotes";
  //
  //   var self = this
  //
  //   var xhr = new XMLHttpRequest();
  //
  //   xhr.open("GET", baseUrl);
  //
  //   xhr.onreadystatechange = function(){
  //     if (xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {
  //
  //       self.parsedDataSetter(JSON.parse(this.response));
  //
  //     }
  //
  //   }
  //   xhr.send()
  // },

  parsedDataSetter: function(data){
    this.joke = data
    this.updateDom();

  },
})
<|endoftext|>


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

// SET UP GLOBAL DISPLAY PARAMETERS
var GRID_SIZE = 25;
var HORIZONTAL_BOXES = 15;
var VERTICAL_BOXES = 15;
var RUN_PROFILER = false;
var REVEAL_LETTERS = 0;

var GRID_WIDTH = GRID_SIZE * HORIZONTAL_BOXES;
var GRID_HEIGHT = GRID_SIZE * VERTICAL_BOXES;

// UPDATE FUNCTIONS FOR THE GLOBAL DISPLAY SETTINGS
function updateBoxSize(numPixels){
    GRID_SIZE = numPixels;
    GRID_WIDTH = GRID_SIZE * HORIZONTAL_BOXES;
    GRID_HEIGHT = GRID_SIZE * VERTICAL_BOXES;
}

function updateGridSize(horizontal,vertical){
    if (horizontal > 0) HORIZONTAL_BOXES = horizontal;
    if (vertical > 0) VERTICAL_BOXES = vertical;

    GRID_WIDTH = GRID_SIZE * HORIZONTAL_BOXES;
    GRID_HEIGHT = GRID_SIZE * VERTICAL_BOXES;
}

function btnAddWords_click(){
    $('.loading').show();
    //  MAKES SURE THE LOADING ANIMATION RUNS
    //  FOR A SECOND TO SHOW ACTIVITY
    setTimeout(run,1000);
}

function btnPrint_click(){
    PrintCrossword();
}

function LoadSampleData(){
    $('#txtWords').val(
        'jumper,keeps you warm in winter\n' +
        'jeans,usually faded blue\n' +
        'skirt,women wear these over their legs\n' +
        'trousers,men wear these over their legs\n' +
        'socks,worn on the feet\n' +
        'shoes,usually have laces\n' +
        'shirt,worn on the body and usually has buttons\n' +
        'hat,keeps your head warm\n' +
        'gloves,normally only worn when it is very cold to protect your hands\n'
        );
}

function run(){

    xWords.Reset();

    canvas.width = GRID_WIDTH;
    canvas.height = GRID_HEIGHT;

    canvasQuestion.width = GRID_WIDTH;
    canvasQuestion.height = GRID_HEIGHT;

    contextQuestion.clearRect(0, 0, GRID_WIDTH, GRID_HEIGHT);
    context.clearRect(0, 0, GRID_WIDTH, GRID_HEIGHT);

    contextQuestion.beginPath();
    contextQuestion.lineWidth = 1;
    contextQuestion.strokeStyle = "black";

    context.beginPath();
    context.lineWidth = 1;
    context.strokeStyle = "black";

    DrawGrid();

    // FONT SIZE IS 80% SIZE OF EACH SQUARE
    var fontSize = Math.floor(GRID_SIZE * 0.8);

    var smallFontSize = Math.floor(GRID_SIZE * 0.35);
    if (GRID_SIZE < 34) smallFontSize = 12;

    context.font = fontSize.toString() + "px _sans";
    context.textBaseline = "middle";

    var contextQuestionSmallFont = smallFontSize.toString() + "px _sans";
    var contextQuestionLargeFont = fontSize.toString() + "px _sans";

    // GENERATE ARRAY OF WORDS TO PUT INTO THE CANVAS
    var rawData = $('#txtWords').val();
    var aValues = rawData.split('\n');

    // GET THE CROSSWORD
    if (RUN_PROFILER) console.clear();
    if (RUN_PROFILER) console.profile('xWords.Create()');

    var crossword = xWords.Create(
        VERTICAL_BOXES,
        HORIZONTAL_BOXES,
        aValues);

    if (RUN_PROFILER) console.profileEnd();

    // GET THE GRID WITH NUMBERS
    var qGrid = xWords.GetQuestionGrid();

    for (var i = 0; i < crossword.length; i++){
        for (var j = 0; j < crossword[i].length; j++){
            if (crossword[i][j].length == 0){

                contextQuestion.rect(i*GRID_SIZE,j*GRID_SIZE, GRID_SIZE, GRID_SIZE);
                contextQuestion.fill();

                context.rect(i*GRID_SIZE,j*GRID_SIZE, GRID_SIZE, GRID_SIZE);
                context.fill();
            } else {

                if (qGrid[i][j].length > 0){

                    var qAdjustW = GRID_SIZE * 0.05;
                    var qAdjustH = GRID_SIZE * 0.3;

                    if (GRID_SIZE < 34) {
                        qAdjustW = 1.9;
                        qAdjustH = 10.6;
                    }

                    contextQuestion.font = contextQuestionSmallFont;
                    contextQuestion.textBaseline = "alphabetic";
                    contextQuestion.fillText(qGrid[i][j],
                      i*GRID_SIZE + qAdjustW,
                      j*GRID_SIZE + qAdjustH);

                    contextQuestion.stroke();
                }

                if (REVEAL_LETTERS > 0){
                    if (Math.floor(Math.random() * 100) <
                        REVEAL_LETTERS){

                        contextQuestion.font = contextQuestionLargeFont;
                        contextQuestion.textBaseline = "middle";
                        var x1 = Math.round((GRID_SIZE -
                        contextQuestion.measureText(crossword[i][j]).width) / 2);
                        contextQuestion.fillText(crossword[i][j],
                          i*GRID_SIZE + x1 - 0.5,
                          j*GRID_SIZE + (GRID_SIZE/2));
                        contextQuestion.stroke();

                    }
                }

                var x = Math.round((GRID_SIZE -
                context.measureText(crossword[i][j]).width) / 2);
                context.fillText(crossword[i][j],
                  i*GRID_SIZE + x - 0.5,
                  j*GRID_SIZE + (GRID_SIZE/2));
            }
        }
    }

    contextQuestion.stroke();
    contextQuestion.closePath();

    context.stroke();
    context.closePath();

    // DISPLAY CLUES AND UNUSED WORDS
    DisplayClues();

    DisplayErrors();

    $('#downloadQuestion').prop('href', canvasQuestion.toDataURL('image/png'));
    $('#downloadAnswer').prop('href', canvas.toDataURL('image/png'));

    $('#mainContainer').show();
    $('.loading').hide();

    $('html, body').animate({
        scrollTop: $("#topContainer").offset().top
    }, 2000);
}

function DisplayErrors(){
    $('#errors').html("
ERRORS
");
    $('#errors').append(xWords.sErrors);
}

function DisplayClues(){

    $('#across').html("
ACROSS
");
    $('#down').html("
DOWN
");
    $('#unused').html("
UNUSED
");

    var unusedList = xWords.GetUnusedWords();
    for (var x = 0; x < unusedList.length; x++){
        $('#unused').append(
            '
' +
            unusedList[x] +
            '
');
    }

    var qList = xWords.GetQuestionList();

    for (var i = 0; i < qList.length; i++){

        switch (qList[i].d){

            case xWords.HORIZONTAL :
                $('#across').append(
                    '
' +
                    qList[i].num +
                    '. ' +
                    qList[i].clue +
                    '
');
                break;

            case xWords.VERTICAL :
                $('#down').append(
                    '
' +
                    qList[i].num +
                    '. ' +
                    qList[i].clue +
                    '
');
                break;

        }

    }
}

function DrawGrid(){
    for (var i = 0; i <= GRID_WIDTH; i+=GRID_SIZE){

        contextQuestion.moveTo(i,0);
        contextQuestion.lineTo(i,GRID_HEIGHT);
        contextQuestion.stroke();

        context.moveTo(i,0);
        context.lineTo(i,GRID_HEIGHT);
        context.stroke();
    }

    for (var i = 0; i <= GRID_HEIGHT; i+=GRID_SIZE){

        contextQuestion.moveTo(0, i);
        contextQuestion.lineTo(GRID_WIDTH, i);
        contextQuestion.stroke();

        context.moveTo(0, i);
        context.lineTo(GRID_WIDTH, i);
        context.stroke();
    }
}

function PrintCrossword()
{
    var html="<!DOCTYPE html>";
    html += '';

    html += '';
    html += '';
    html += '<input class="noprint" type="button" value="print" onclick="window.print();window.focus();" />';
    html += '';

    if ($('#txtCrosswordTitle').val().trim().length > 0){
        html += '
' + $('#txtCrosswordTitle').val().trim() + '
';
    } else {
        html += '
New crossword
';
    }

    html += '
';

    if (($("#rdAll").prop("checked"))||
        ($("#rdQuestion").prop("checked"))){

        html += '
';
        html += '';
        html += '
';

        html += '
';
        html += '
';

        html += '
' +    $('#across').html() +
                '
';

        html += '
' +    $('#down').html() +
                '
';

        html += '
';
        html += '
';
        html += '
';
    }

    if (($("#rdAll").prop("checked"))||
        ($("#rdAnswers").prop("checked"))){

        html += '
';
        html += '';
        html += '
';
        html+="";
    }

    var printWin = window.open('','','scrollbars=1');
    printWin.document.write(html);
    printWin.document.close();
    printWin.focus();
}
<commit_msg>Increased animation speed<commit_after>
/**
 *   Copyright 2014 Richard Rulach
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *
 *   You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing,
 *   software distributed under the License is distributed on
 *   an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 *   either express or implied. See the License for the specific
 *   language governing permissions and limitations under the License
**/

// SET UP GLOBAL DISPLAY PARAMETERS
var GRID_SIZE = 25;
var HORIZONTAL_BOXES = 15;
var VERTICAL_BOXES = 15;
var RUN_PROFILER = false;
var REVEAL_LETTERS = 0;

var GRID_WIDTH = GRID_SIZE * HORIZONTAL_BOXES;
var GRID_HEIGHT = GRID_SIZE * VERTICAL_BOXES;

// UPDATE FUNCTIONS FOR THE GLOBAL DISPLAY SETTINGS
function updateBoxSize(numPixels){
    GRID_SIZE = numPixels;
    GRID_WIDTH = GRID_SIZE * HORIZONTAL_BOXES;
    GRID_HEIGHT = GRID_SIZE * VERTICAL_BOXES;
}

function updateGridSize(horizontal,vertical){
    if (horizontal > 0) HORIZONTAL_BOXES = horizontal;
    if (vertical > 0) VERTICAL_BOXES = vertical;

    GRID_WIDTH = GRID_SIZE * HORIZONTAL_BOXES;
    GRID_HEIGHT = GRID_SIZE * VERTICAL_BOXES;
}

function btnAddWords_click(){
    $('.loading').show();
    //  MAKES SURE THE LOADING ANIMATION RUNS
    //  FOR A SECOND TO SHOW ACTIVITY
    setTimeout(run,1000);
}

function btnPrint_click(){
    PrintCrossword();
}

function LoadSampleData(){
    $('#txtWords').val(
        'jumper,keeps you warm in winter\n' +
        'jeans,usually faded blue\n' +
        'skirt,women wear these over their legs\n' +
        'trousers,men wear these over their legs\n' +
        'socks,worn on the feet\n' +
        'shoes,usually have laces\n' +
        'shirt,worn on the body and usually has buttons\n' +
        'hat,keeps your head warm\n' +
        'gloves,normally only worn when it is very cold to protect your hands\n'
        );
}

function run(){

    xWords.Reset();

    canvas.width = GRID_WIDTH;
    canvas.height = GRID_HEIGHT;

    canvasQuestion.width = GRID_WIDTH;
    canvasQuestion.height = GRID_HEIGHT;

    contextQuestion.clearRect(0, 0, GRID_WIDTH, GRID_HEIGHT);
    context.clearRect(0, 0, GRID_WIDTH, GRID_HEIGHT);

    contextQuestion.beginPath();
    contextQuestion.lineWidth = 1;
    contextQuestion.strokeStyle = "black";

    context.beginPath();
    context.lineWidth = 1;
    context.strokeStyle = "black";

    DrawGrid();

    // FONT SIZE IS 80% SIZE OF EACH SQUARE
    var fontSize = Math.floor(GRID_SIZE * 0.8);

    var smallFontSize = Math.floor(GRID_SIZE * 0.35);
    if (GRID_SIZE < 34) smallFontSize = 12;

    context.font = fontSize.toString() + "px _sans";
    context.textBaseline = "middle";

    var contextQuestionSmallFont = smallFontSize.toString() + "px _sans";
    var contextQuestionLargeFont = fontSize.toString() + "px _sans";

    // GENERATE ARRAY OF WORDS TO PUT INTO THE CANVAS
    var rawData = $('#txtWords').val();
    var aValues = rawData.split('\n');

    // GET THE CROSSWORD
    if (RUN_PROFILER) console.clear();
    if (RUN_PROFILER) console.profile('xWords.Create()');

    var crossword = xWords.Create(
        VERTICAL_BOXES,
        HORIZONTAL_BOXES,
        aValues);

    if (RUN_PROFILER) console.profileEnd();

    // GET THE GRID WITH NUMBERS
    var qGrid = xWords.GetQuestionGrid();

    for (var i = 0; i < crossword.length; i++){
        for (var j = 0; j < crossword[i].length; j++){
            if (crossword[i][j].length == 0){

                contextQuestion.rect(i*GRID_SIZE,j*GRID_SIZE, GRID_SIZE, GRID_SIZE);
                contextQuestion.fill();

                context.rect(i*GRID_SIZE,j*GRID_SIZE, GRID_SIZE, GRID_SIZE);
                context.fill();
            } else {

                if (qGrid[i][j].length > 0){

                    var qAdjustW = GRID_SIZE * 0.05;
                    var qAdjustH = GRID_SIZE * 0.3;

                    if (GRID_SIZE < 34) {
                        qAdjustW = 1.9;
                        qAdjustH = 10.6;
                    }

                    contextQuestion.font = contextQuestionSmallFont;
                    contextQuestion.textBaseline = "alphabetic";
                    contextQuestion.fillText(qGrid[i][j],
                      i*GRID_SIZE + qAdjustW,
                      j*GRID_SIZE + qAdjustH);

                    contextQuestion.stroke();
                }

                if (REVEAL_LETTERS > 0){
                    if (Math.floor(Math.random() * 100) <
                        REVEAL_LETTERS){

                        contextQuestion.font = contextQuestionLargeFont;
                        contextQuestion.textBaseline = "middle";
                        var x1 = Math.round((GRID_SIZE -
                        contextQuestion.measureText(crossword[i][j]).width) / 2);
                        contextQuestion.fillText(crossword[i][j],
                          i*GRID_SIZE + x1 - 0.5,
                          j*GRID_SIZE + (GRID_SIZE/2));
                        contextQuestion.stroke();

                    }
                }

                var x = Math.round((GRID_SIZE -
                context.measureText(crossword[i][j]).width) / 2);
                context.fillText(crossword[i][j],
                  i*GRID_SIZE + x - 0.5,
                  j*GRID_SIZE + (GRID_SIZE/2));
            }
        }
    }

    contextQuestion.stroke();
    contextQuestion.closePath();

    context.stroke();
    context.closePath();

    // DISPLAY CLUES AND UNUSED WORDS
    DisplayClues();

    DisplayErrors();

    $('#downloadQuestion').prop('href', canvasQuestion.toDataURL('image/png'));
    $('#downloadAnswer').prop('href', canvas.toDataURL('image/png'));

    $('#mainContainer').show();
    $('.loading').hide();

    $('html, body').animate({
        scrollTop: $("#topContainer").offset().top
    }, 400);
}

function DisplayErrors(){
    $('#errors').html("
ERRORS
");
    $('#errors').append(xWords.sErrors);
}

function DisplayClues(){

    $('#across').html("
ACROSS
");
    $('#down').html("
DOWN
");
    $('#unused').html("
UNUSED
");

    var unusedList = xWords.GetUnusedWords();
    for (var x = 0; x < unusedList.length; x++){
        $('#unused').append(
            '
' +
            unusedList[x] +
            '
');
    }

    var qList = xWords.GetQuestionList();

    for (var i = 0; i < qList.length; i++){

        switch (qList[i].d){

            case xWords.HORIZONTAL :
                $('#across').append(
                    '
' +
                    qList[i].num +
                    '. ' +
                    qList[i].clue +
                    '
');
                break;

            case xWords.VERTICAL :
                $('#down').append(
                    '
' +
                    qList[i].num +
                    '. ' +
                    qList[i].clue +
                    '
');
                break;

        }

    }
}

function DrawGrid(){
    for (var i = 0; i <= GRID_WIDTH; i+=GRID_SIZE){

        contextQuestion.moveTo(i,0);
        contextQuestion.lineTo(i,GRID_HEIGHT);
        contextQuestion.stroke();

        context.moveTo(i,0);
        context.lineTo(i,GRID_HEIGHT);
        context.stroke();
    }

    for (var i = 0; i <= GRID_HEIGHT; i+=GRID_SIZE){

        contextQuestion.moveTo(0, i);
        contextQuestion.lineTo(GRID_WIDTH, i);
        contextQuestion.stroke();

        context.moveTo(0, i);
        context.lineTo(GRID_WIDTH, i);
        context.stroke();
    }
}

function PrintCrossword()
{
    var html="<!DOCTYPE html>";
    html += '';

    html += '';
    html += '';
    html += '<input class="noprint" type="button" value="print" onclick="window.print();window.focus();" />';
    html += '';

    if ($('#txtCrosswordTitle').val().trim().length > 0){
        html += '
' + $('#txtCrosswordTitle').val().trim() + '
';
    } else {
        html += '
New crossword
';
    }

    html += '
';

    if (($("#rdAll").prop("checked"))||
        ($("#rdQuestion").prop("checked"))){

        html += '
';
        html += '';
        html += '
';

        html += '
';
        html += '
';

        html += '
' +    $('#across').html() +
                '
';

        html += '
' +    $('#down').html() +
                '
';

        html += '
';
        html += '
';
        html += '
';
    }

    if (($("#rdAll").prop("checked"))||
        ($("#rdAnswers").prop("checked"))){

        html += '
';
        html += '';
        html += '
';
        html+="";
    }

    var printWin = window.open('','','scrollbars=1');
    printWin.document.write(html);
    printWin.document.close();
    printWin.focus();
}
<|endoftext|>


<commit_before>/**
 * @file claim command
 * @author Sankarsan Kampa (a.k.a k3rn31p4nic)
 * @license MIT
 */

let claimedUsers = [];
const specialIDs = require('../../data/specialIDs.json');

exports.exec = (Bastion, message) => {
  if (!claimedUsers.includes(message.author.id)) {
    let rewardAmount = Bastion.functions.getRandomInt(50, 100);

    let rewardMessage;
    if (Bastion.user.id === '267035345537728512') {
      if (message.guild.id === specialIDs.bastionGuild) {
        rewardAmount *= 2;
        if (message.member && message.member.roles.has(specialIDs.patronsRole)) {
          rewardAmount += 500;
        }
        else if (message.member && message.member.roles.has(specialIDs.donorsRole)) {
          rewardAmount += 100;
        }

        rewardMessage = `Your account has been debited with **${rewardAmount}** Bastion Currencies.`;
      }
      else {
        rewardMessage = `Your account has been debited with **${rewardAmount}** Bastion Currencies.\n\n`
          + 'You can get 2x more Bastion Currencies if you use the `claim` or `daily` command in [Bastion HQ](https://discord.gg/fzx8fkt): https://discord.gg/fzx8fkt';
      }
    }
    else {
      rewardMessage = `Your account has been debited with **${rewardAmount}** Bastion Currencies.`;
    }

    Bastion.emit('userDebit', message.author, rewardAmount);
    claimedUsers.push(message.author.id);
    setTimeout(() => {
      claimedUsers.splice(claimedUsers.indexOf(message.author.id), 1);
    }, Bastion.functions.msUntilMidnight());

    /**
    * Send a message in the channel to let the user know that the operation was successful.
    */
    message.channel.send({
      embed: {
        color: Bastion.colors.GREEN,
        description: `${message.author} You've claimed your daily reward. Please check my message in your DM to see the reward amount.`
      }
    }).catch(e => {
      Bastion.log.error(e);
    });

    /**
    * Let the user know by DM that their account has been debited.
    */
    message.author.send({
      embed: {
        color: Bastion.colors.GREEN,
        description: rewardMessage
      }
    }).catch(e => {
      if (e.code !== 50007) {
        Bastion.log.error(e);
      }
    });
  }
  else {
    /**
     * Error condition is encountered.
     * @fires error
     */
    return Bastion.emit('error', Bastion.strings.error(message.guild.language, 'cooldown'), Bastion.strings.error(message.guild.language, 'claimCooldown', true, message.author), message.channel);
  }
};

exports.config = {
  aliases: [ 'daily' ],
  enabled: true
};

exports.help = {
  name: 'claim',
  botPermission: '',
  userTextPermission: '',
  userVoicePermission: '',
  usage: 'claim',
  example: []
};
<commit_msg>Update claim reward message<commit_after>/**
 * @file claim command
 * @author Sankarsan Kampa (a.k.a k3rn31p4nic)
 * @license MIT
 */

let claimedUsers = [];
const specialIDs = require('../../data/specialIDs.json');

exports.exec = (Bastion, message) => {
  if (!claimedUsers.includes(message.author.id)) {
    let rewardAmount = Bastion.functions.getRandomInt(50, 100);

    let rewardMessage;
    if (Bastion.user.id === '267035345537728512') {
      if (message.guild.id === specialIDs.bastionGuild) {
        rewardAmount *= 2;
        if (message.member && message.member.roles.has(specialIDs.patronsRole)) {
          rewardAmount += 500;
        }
        else if (message.member && message.member.roles.has(specialIDs.donorsRole)) {
          rewardAmount += 100;
        }

        rewardMessage = `Your account has been debited with **${rewardAmount}** Bastion Currencies.`;
      }
      else {
        rewardMessage = `Your account has been debited with **${rewardAmount}** Bastion Currencies.\n\n`
          + '💡 **Pro Tip**\nYou can get **2x** more Bastion Currencies when you use the `claim` or `daily` command in [Bastion HQ](https://discord.gg/fzx8fkt): https://discord.gg/fzx8fkt';
      }
    }
    else {
      rewardMessage = `Your account has been debited with **${rewardAmount}** Bastion Currencies.`;
    }

    Bastion.emit('userDebit', message.author, rewardAmount);
    claimedUsers.push(message.author.id);
    setTimeout(() => {
      claimedUsers.splice(claimedUsers.indexOf(message.author.id), 1);
    }, Bastion.functions.msUntilMidnight());

    /**
    * Send a message in the channel to let the user know that the operation was successful.
    */
    message.channel.send({
      embed: {
        color: Bastion.colors.GREEN,
        description: `${message.author} You've claimed your daily reward. Please check my message in your DM to see the reward amount.`
      }
    }).catch(e => {
      Bastion.log.error(e);
    });

    /**
    * Let the user know by DM that their account has been debited.
    */
    message.author.send({
      embed: {
        color: Bastion.colors.GREEN,
        description: rewardMessage
      }
    }).catch(e => {
      if (e.code !== 50007) {
        Bastion.log.error(e);
      }
    });
  }
  else {
    /**
     * Error condition is encountered.
     * @fires error
     */
    return Bastion.emit('error', Bastion.strings.error(message.guild.language, 'cooldown'), Bastion.strings.error(message.guild.language, 'claimCooldown', true, message.author), message.channel);
  }
};

exports.config = {
  aliases: [ 'daily' ],
  enabled: true
};

exports.help = {
  name: 'claim',
  botPermission: '',
  userTextPermission: '',
  userVoicePermission: '',
  usage: 'claim',
  example: []
};
<|endoftext|>


<commit_before>// This is the main application configuration file.  It is a Grunt
// configuration file, which you can learn more about here:
// https://github.com/cowboy/grunt/blob/master/docs/configuring.md
module.exports = function(grunt) {

  grunt.initConfig({

    // The clean task ensures all files are removed from the dist/ directory so
    // that no files linger from previous builds.
    clean: ["dist/"],

    // The lint task will run the build configuration and the application
    // JavaScript through JSHint and report any errors.  You can change the
    // options for this task, by reading this:
    // https://github.com/cowboy/grunt/blob/master/docs/task_lint.md
    lint: {
      files: [
        "build/config.js", "app/**/*.js"
      ]
    },

    // The jshint option for scripturl is set to lax, because the anchor
    // override inside main.js needs to test for them so as to not accidentally
    // route.
    jshint: {
      options: {
        scripturl: true
      }
    },

    // The jst task compiles all application templates into JavaScript
    // functions with the underscore.js template function from 1.2.4.  You can
    // change the namespace and the template options, by reading this:
    // https://github.com/gruntjs/grunt-contrib/blob/master/docs/jst.md
    //
    // The concat task depends on this file to exist, so if you decide to
    // remove this, ensure concat is updated accordingly.
    jst: {
      "dist/debug/templates.js": [
        "app/templates/**/*.html"
      ]
    },

    // The handlebars task compiles all application templates into JavaScript
    // functions using Handlebars templating engine.
    //
    // Since this task defaults to writing to the same file as the jst task,
    // edit the debug task replacing jst with handlebars.
    //
    // The concat task depends on this file to exist, so if you decide to
    // remove this, ensure concat is updated accordingly.
    handlebars: {
      "dist/debug/templates.js": ["app/templates/**/*.html"]
    },

    // The concatenate task is used here to merge the almond require/define
    // shim and the templates into the application code.  It's named
    // dist/debug/require.js, because we want to only load one script file in
    // index.html.
    concat: {
      "dist/debug/require.js": [
        "assets/js/libs/almond.js",
        "dist/debug/templates.js",
        "dist/debug/require.js"
      ]
    },

    // This task uses the MinCSS Node.js project to take all your CSS files in
    // order and concatenate them into a single CSS file named index.css.  It
    // also minifies all the CSS as well.  This is named index.css, because we
    // only want to load one stylesheet in index.html.
    mincss: {
      "dist/release/index.css": [
        "dist/debug/index.css"
      ]
    },

    // The stylus task is used to compile Stylus stylesheets into a single
    // CSS file for debug and release deployments.
    stylus: {
      // Put all your CSS files here, order matters!
      files: [
        "assets/vendor/h5bp/css/style.css",
        "assets/css/main.styl"
      ],

      // Default task which runs in debug mode, this will build out to the
      // `dist/debug` directory.
      compile: {
        // Used for @imports.
        options: { paths: ["assets/css"] },

        files: {
          "dist/debug/index.css": "<config:stylus.files>"
        }
      },

      // This dev task only runs with `watch:stylus` this will *completely*
      // overwrite the `assets/css/index.css` file referenced in `index.html`.
      // Use this only when you cannot use the `bbb server` runtime
      // compilation.
      dev: {
        // Used for @imports.
        options: { paths: ["assets/css"] },

        files: {
          "assets/css/index.css": "<config:stylus.files>"
        }
      }
    },

    // Takes the built require.js file and minifies it for filesize benefits.
    min: {
      "dist/release/require.js": [
        "dist/debug/require.js"
      ]
    },

    // Running the server without specifying an action will run the defaults,
    // port: 8000 and host: 127.0.0.1.  If you would like to change these
    // defaults, simply add in the properties `port` and `host` respectively.
    // Alternatively you can omit the port and host properties and the server
    // task will instead default to process.env.PORT or process.env.HOST.
    //
    // Changing the defaults might look something like this:
    //
    // server: {
    //   host: "127.0.0.1", port: 9001
    //   debug: { ... can set host and port here too ...
    //  }
    //
    //  To learn more about using the server task, please refer to the code
    //  until documentation has been written.
    server: {
      // Ensure the favicon is mapped correctly.
      files: { "favicon.ico": "favicon.ico" },

      debug: {
        // Ensure the favicon is mapped correctly.
        files: { "favicon.ico": "favicon.ico" },

        // Map `server:debug` to `debug` folders.
        folders: {
          "app": "dist/debug",
          "assets/js/libs": "dist/debug",
          "assets/css": "dist/debug"
        }
      },

      release: {
        // This makes it easier for deploying, by defaulting to any IP.
        host: "0.0.0.0",

        // Ensure the favicon is mapped correctly.
        files: { "favicon.ico": "favicon.ico" },

        // Map `server:release` to `release` folders.
        folders: {
          "app": "dist/release",
          "assets/js/libs": "dist/release",
          "assets/css": "dist/release"
        }
      }
    },

    // This task uses James Burke's excellent r.js AMD build tool.  In the
    // future other builders may be contributed as drop-in alternatives.
    requirejs: {
      // Include the main configuration file.
      mainConfigFile: "app/config.js",

      // Output file.
      out: "dist/debug/require.js",

      // Root application module.
      name: "config",

      // Do not wrap everything in an IIFE.
      wrap: false
    },

    // The headless QUnit testing environment is provided for "free" by Grunt.
    // Simply point the configuration to your test directory.
    qunit: {
      all: ["test/qunit/*.html"]
    },

    // The headless Jasmine testing is provided by grunt-jasmine-task. Simply
    // point the configuration to your test directory.
    jasmine: {
      all: ["test/jasmine/*.html"]
    },

    // The watch task can be used to monitor the filesystem and execute
    // specific tasks when files are modified.  By default, the watch task is
    // available to compile stylus templates if you are unable to use the
    // runtime builder (use if you have a custom server, PhoneGap, Adobe Air,
    // etc.)
    watch: {
      stylus: {
        files: ["grunt.js", "assets/css/**/*.styl"],
        tasks: "stylus:dev"
      }
    }

  });

  // The debug task will remove all contents inside the dist/ folder, lint
  // all your code, precompile all the underscore templates into
  // dist/debug/templates.js, compile all the application code into
  // dist/debug/require.js, and then concatenate the require/define shim
  // almond.js and dist/debug/templates.js into the require.js file.
  grunt.registerTask("debug", "clean lint jst requirejs concat stylus");

  // The release task will run the debug tasks and then minify the
  // dist/debug/require.js file and CSS files.
  grunt.registerTask("release", "debug min mincss");

};
<commit_msg>removed main.styl<commit_after>// This is the main application configuration file.  It is a Grunt
// configuration file, which you can learn more about here:
// https://github.com/cowboy/grunt/blob/master/docs/configuring.md
module.exports = function(grunt) {

  grunt.initConfig({

    // The clean task ensures all files are removed from the dist/ directory so
    // that no files linger from previous builds.
    clean: ["dist/"],

    // The lint task will run the build configuration and the application
    // JavaScript through JSHint and report any errors.  You can change the
    // options for this task, by reading this:
    // https://github.com/cowboy/grunt/blob/master/docs/task_lint.md
    lint: {
      files: [
        "build/config.js", "app/**/*.js"
      ]
    },

    // The jshint option for scripturl is set to lax, because the anchor
    // override inside main.js needs to test for them so as to not accidentally
    // route.
    jshint: {
      options: {
        scripturl: true
      }
    },

    // The jst task compiles all application templates into JavaScript
    // functions with the underscore.js template function from 1.2.4.  You can
    // change the namespace and the template options, by reading this:
    // https://github.com/gruntjs/grunt-contrib/blob/master/docs/jst.md
    //
    // The concat task depends on this file to exist, so if you decide to
    // remove this, ensure concat is updated accordingly.
    jst: {
      "dist/debug/templates.js": [
        "app/templates/**/*.html"
      ]
    },

    // The handlebars task compiles all application templates into JavaScript
    // functions using Handlebars templating engine.
    //
    // Since this task defaults to writing to the same file as the jst task,
    // edit the debug task replacing jst with handlebars.
    //
    // The concat task depends on this file to exist, so if you decide to
    // remove this, ensure concat is updated accordingly.
    handlebars: {
      "dist/debug/templates.js": ["app/templates/**/*.html"]
    },

    // The concatenate task is used here to merge the almond require/define
    // shim and the templates into the application code.  It's named
    // dist/debug/require.js, because we want to only load one script file in
    // index.html.
    concat: {
      "dist/debug/require.js": [
        "assets/js/libs/almond.js",
        "dist/debug/templates.js",
        "dist/debug/require.js"
      ]
    },

    // This task uses the MinCSS Node.js project to take all your CSS files in
    // order and concatenate them into a single CSS file named index.css.  It
    // also minifies all the CSS as well.  This is named index.css, because we
    // only want to load one stylesheet in index.html.
    mincss: {
      "dist/release/index.css": [
        "dist/debug/index.css"
      ]
    },

    // The stylus task is used to compile Stylus stylesheets into a single
    // CSS file for debug and release deployments.
    stylus: {
      // Put all your CSS files here, order matters!
      files: [
        "assets/vendor/h5bp/css/style.css"
      ],

      // Default task which runs in debug mode, this will build out to the
      // `dist/debug` directory.
      compile: {
        // Used for @imports.
        options: { paths: ["assets/css"] },

        files: {
          "dist/debug/index.css": "<config:stylus.files>"
        }
      },

      // This dev task only runs with `watch:stylus` this will *completely*
      // overwrite the `assets/css/index.css` file referenced in `index.html`.
      // Use this only when you cannot use the `bbb server` runtime
      // compilation.
      dev: {
        // Used for @imports.
        options: { paths: ["assets/css"] },

        files: {
          "assets/css/index.css": "<config:stylus.files>"
        }
      }
    },

    // Takes the built require.js file and minifies it for filesize benefits.
    min: {
      "dist/release/require.js": [
        "dist/debug/require.js"
      ]
    },

    // Running the server without specifying an action will run the defaults,
    // port: 8000 and host: 127.0.0.1.  If you would like to change these
    // defaults, simply add in the properties `port` and `host` respectively.
    // Alternatively you can omit the port and host properties and the server
    // task will instead default to process.env.PORT or process.env.HOST.
    //
    // Changing the defaults might look something like this:
    //
    // server: {
    //   host: "127.0.0.1", port: 9001
    //   debug: { ... can set host and port here too ...
    //  }
    //
    //  To learn more about using the server task, please refer to the code
    //  until documentation has been written.
    server: {
      // Ensure the favicon is mapped correctly.
      files: { "favicon.ico": "favicon.ico" },

      debug: {
        // Ensure the favicon is mapped correctly.
        files: { "favicon.ico": "favicon.ico" },

        // Map `server:debug` to `debug` folders.
        folders: {
          "app": "dist/debug",
          "assets/js/libs": "dist/debug",
          "assets/css": "dist/debug"
        }
      },

      release: {
        // This makes it easier for deploying, by defaulting to any IP.
        host: "0.0.0.0",

        // Ensure the favicon is mapped correctly.
        files: { "favicon.ico": "favicon.ico" },

        // Map `server:release` to `release` folders.
        folders: {
          "app": "dist/release",
          "assets/js/libs": "dist/release",
          "assets/css": "dist/release"
        }
      }
    },

    // This task uses James Burke's excellent r.js AMD build tool.  In the
    // future other builders may be contributed as drop-in alternatives.
    requirejs: {
      // Include the main configuration file.
      mainConfigFile: "app/config.js",

      // Output file.
      out: "dist/debug/require.js",

      // Root application module.
      name: "config",

      // Do not wrap everything in an IIFE.
      wrap: false
    },

    // The headless QUnit testing environment is provided for "free" by Grunt.
    // Simply point the configuration to your test directory.
    qunit: {
      all: ["test/qunit/*.html"]
    },

    // The headless Jasmine testing is provided by grunt-jasmine-task. Simply
    // point the configuration to your test directory.
    jasmine: {
      all: ["test/jasmine/*.html"]
    },

    // The watch task can be used to monitor the filesystem and execute
    // specific tasks when files are modified.  By default, the watch task is
    // available to compile stylus templates if you are unable to use the
    // runtime builder (use if you have a custom server, PhoneGap, Adobe Air,
    // etc.)
    watch: {
      stylus: {
        files: ["grunt.js", "assets/css/**/*.styl"],
        tasks: "stylus:dev"
      }
    }

  });

  // The debug task will remove all contents inside the dist/ folder, lint
  // all your code, precompile all the underscore templates into
  // dist/debug/templates.js, compile all the application code into
  // dist/debug/require.js, and then concatenate the require/define shim
  // almond.js and dist/debug/templates.js into the require.js file.
  grunt.registerTask("debug", "clean lint jst requirejs concat stylus");

  // The release task will run the debug tasks and then minify the
  // dist/debug/require.js file and CSS files.
  grunt.registerTask("release", "debug min mincss");

};
<|endoftext|>


<commit_before>// Copyright 2011 Google Inc. All Rights Reserved.

/**
 * @fileoverview cin file parser.
 * @author zork@google.com (Zach Kuznia)
 */

// Returns an array, which is [true, parsed_data] on success, or [false, error
// message] on failure. parsed_data is an object, containing metadata and data.
function parseCin(cin_input) {
  var lines = cin_input.split('\n');
  var data = {};
  var runningcmd = null;
  var table_command = {keyname: 1, chardef: 1,
                       quick: 1, quickkey: 1,
                       KEYSTROKE_REMAP: 1, KEYGROUPS: 1 };

  var failed = function(lineno, msg) {
    return [false, 'line ' + (lineno+1) + ': ' + msg];
  }

  for (var lineno in lines) {
    var line = lines[lineno];

    // Comment line start with '#'
    if (line.match(/^#/)) {
      continue;
    }

    // Command line
    var m = line.match(/^%(\w+)(?:\s+(\S+))?/);
    if (m) {
      var cmd = m[1];
      var arg = m[2];
      if (table_command[cmd]) {
        if (arg == 'begin') {
          runningcmd = cmd;
          if (data[cmd] != undefined)
            return failed(lineno, 'section already exists');
          data[cmd] = {};
        } else if (arg == 'end') {
          if (!runningcmd)
            return failed(lineno, 'end before begin');
          runningcmd = null;
        } else {
          return failed(lineno, 'should be begin/end');
        }
      } else {
        if (runningcmd)
          return failed(lineno, 'previous section has no end');
        if (arg == undefined)
          arg = true;
        else if (arg == 'false')
          arg = false;
        data[cmd] = arg;
      }
    } else if (table_command[cmd]) {
      // Extra arguments
      if (!cmd) continue;
      m = line.match(/^\s*(\S+)\s+(\S+)/);
      if (m) {
        var key = m[1];
        // TODO(hungte) Don't convert if %keep_key_case is found.
        key = key.toLowerCase();
        if (data[cmd][key] == undefined)
          data[cmd][key] = '';
        data[cmd][key] += m[2];
      } else {
        // bad line, just ignore
      }
    }
  }

  if (runningcmd && runningcmd != 'chardef') // iBus tables has no "%chardef end"
    return failed(lineno, 'previous section has no end');

  // verify mandatory fields
  if (data['prompt']) {  // gcin format
    data['cname'] = data['prompt'];
  }
  var mandatory_command = [
      'ename', 'cname', 'selkey', 'keyname', 'chardef'
      ];
  for (var i in mandatory_command) {
    if (data[mandatory_command[i]] == undefined)
      return failed(-1, 'mandatory section %' + mandatory_command[i] +
                    ' missing');
  }

  // TODO(hungte) Add more module parsers.
  var module = undefined;
  if (data.EXTENSION_ID)
    module = 'CrExtInp';

  var parsed_data = {
    metadata: {
      ename: data.ename,
      cname: data.cname,
      module: module,
    },
    data: data,
  };
  console.log('parse file:', data.ename, parsed_data);

  return [true, parsed_data];
}
<commit_msg>More comments for CIN variants.<commit_after>// Copyright 2011 Google Inc. All Rights Reserved.

/**
 * @fileoverview cin file parser.
 * @author zork@google.com (Zach Kuznia)
 */

// Returns an array, which is [true, parsed_data] on success, or [false, error
// message] on failure. parsed_data is an object, containing metadata and data.
function parseCin(cin_input) {
  var lines = cin_input.split('\n');
  var data = {};
  var runningcmd = null;
  var cmd;
  var table_command = {keyname: 1, chardef: 1,
                       quick: 1, quickkey: 1,
                       sel1st: 1, // re-order mappings, deprecated.
                       KEYSTROKE_REMAP: 1, KEYGROUPS: 1 };

  // TODO for very old XCIN table (1.x~2.1b), there's no %chardef -- anything
  // not inside commands are chardefs.

  var failed = function(lineno, msg) {
    return [false, 'line ' + (lineno+1) + ': ' + msg];
  }

  for (var lineno in lines) {
    var line = lines[lineno];

    // Comment line start with '#'
    if (line.match(/^#/)) {
      continue;
    }

    // Command line
    var m = line.match(/^%(\w+)(?:\s+(\S+))?/);
    if (m) {
      cmd = m[1];
      var arg = m[2];
      if (table_command[cmd]) {
        if (arg == 'begin') {
          runningcmd = cmd;
          if (data[cmd] != undefined)
            return failed(lineno, 'section already exists');
          data[cmd] = {};
        } else if (arg == 'end') {
          if (!runningcmd)
            return failed(lineno, 'end before begin');
          runningcmd = null;
        } else {
          return failed(lineno, 'should be begin/end');
        }
      } else {
        if (runningcmd)
          return failed(lineno, 'previous section has no end');
        if (arg == undefined)
          arg = true;
        else if (arg == 'false')
          arg = false;
        data[cmd] = arg;
      }
    } else if (table_command[cmd]) {
      // Extra arguments
      if (!cmd) continue;
      m = line.match(/^\s*(\S+)\s+(\S+)/);
      if (m) {
        var key = m[1];
        // TODO(hungte) Don't convert if %keep_key_case is found.
        key = key.toLowerCase();
        if (data[cmd][key] == undefined)
          data[cmd][key] = '';
        data[cmd][key] += m[2];
      } else {
        // bad line, just ignore
      }
    }
  }

  if (runningcmd && runningcmd != 'chardef') // iBus tables has no "%chardef end"
    return failed(lineno, 'previous section has no end');

  // verify mandatory fields
  if (data['prompt']) {  // gcin format
    data['cname'] = data['prompt'];
  }
  var mandatory_command = [
      'ename', 'cname', 'selkey', 'keyname', 'chardef'
      ];
  for (var i in mandatory_command) {
    if (data[mandatory_command[i]] == undefined)
      return failed(-1, 'mandatory section %' + mandatory_command[i] +
                    ' missing');
  }

  // TODO(hungte) Add more module parsers.
  var module = undefined;
  if (data.EXTENSION_ID)
    module = 'CrExtInp';

  var parsed_data = {
    metadata: {
      ename: data.ename,
      cname: data.cname,
      module: module,
    },
    data: data,
  };
  console.log('parse file:', data.ename, parsed_data);

  return [true, parsed_data];
}
<|endoftext|>


<commit_before>(function(window, $, jsSocials, undefined) {

    $.extend(jsSocials.shares, {

        email: {
            label: "E-mail",
            logo: "fa fa-at",
            shareUrl: "mailto:{to}?subject={text}&body={url}",
            countUrl: "",
            shareIn: "self"
        },

        twitter: {
            label: "Tweet",
            logo: "fa fa-twitter",
            shareUrl: "https://twitter.com/share?url={url}&text={text}&via={via}&hashtags={hashtags}",
            countUrl: ""
        },

        facebook: {
            label: "Like",
            logo: "fa fa-facebook",
            shareUrl: "https://facebook.com/sharer/sharer.php?u={url}",
            countUrl: "https://graph.facebook.com/?id={url}",
            getCount: function(data) {
                return data.share && data.share.share_count || 0;
            }
        },

        vkontakte: {
            label: "Like",
            logo: "fa fa-vk",
            shareUrl: "https://vk.com/share.php?url={url}&title={title}&description={text}",
            countUrl: "https://vk.com/share.php?act=count&index=1&url={url}",
            getCount: function(data) {
                return parseInt(data.slice(15, -2).split(', ')[1]);
            }
        },

        googleplus: {
            label: "+1",
            logo: "fa fa-google",
            shareUrl: "https://plus.google.com/share?url={url}",
            countUrl: "https://cors-anywhere.herokuapp.com/https://plusone.google.com/_/+1/fastbutton?url={url}",
            getCount: function(data) {
                return parseFloat((data.match(/\{c: ([.0-9E]+)/) || [])[1]);
            }
        },

        linkedin: {
            label: "Share",
            logo: "fa fa-linkedin",
            shareUrl: "https://www.linkedin.com/shareArticle?mini=true&url={url}",
            countUrl: "https://www.linkedin.com/countserv/count/share?format=jsonp&url={url}&callback=?",
            getCount: function(data) {
                return data.count;
            }
        },

        pinterest: {
            label: "Pin it",
            logo: "fa fa-pinterest",
            shareUrl: "https://pinterest.com/pin/create/bookmarklet/?media={media}&url={url}&description={text}",
            countUrl: "https://api.pinterest.com/v1/urls/count.json?&url={url}&callback=?",
            getCount: function(data) {
                return data.count;
            }
        },

        stumbleupon: {
            label: "Share",
            logo: "fa fa-stumbleupon",
            shareUrl: "http://www.stumbleupon.com/submit?url={url}&title={title}",
            countUrl:  "https://cors-anywhere.herokuapp.com/https://www.stumbleupon.com/services/1.01/badge.getinfo?url={url}",
            getCount: function(data) {
                return data.result.views;
            }
        },

        telegram: {
            label: "Telegram",
            logo: "fa fa-paper-plane",
            shareUrl: "tg://msg?text={url} {text}",
            countUrl: "",
            shareIn: "self"
        },

        whatsapp: {
            label: "WhatsApp",
            logo: "fa fa-whatsapp",
            shareUrl: "whatsapp://send?text={url} {text}",
            countUrl: "",
            shareIn: "self"
        },

        line: {
            label: "LINE",
            logo: "fa fa-comment",
            shareUrl: "http://line.me/R/msg/text/?{text} {url}",
            countUrl: ""
        },

        viber: {
            label: "Viber",
            logo: "fa fa-volume-control-phone",
            shareUrl: "viber://forward?text={url} {text}",
            countUrl: "",
            shareIn: "self"
        },

        pocket: {
            label: "Pocket",
            logo: "fa fa-get-pocket",
            shareUrl: "https://getpocket.com/save?url={url}&title={title}",
            countUrl: "",
        },

        messenger: {
            label: "Share",
            logo: "fa fa-commenting",
            shareUrl: "fb-messenger://share?link={url}",
            countUrl: "",
            shareIn: "self"
        }

    });

}(window, jQuery, window.jsSocials));

<commit_msg>Dropping Google+ count<commit_after>(function(window, $, jsSocials, undefined) {

    $.extend(jsSocials.shares, {

        email: {
            label: "E-mail",
            logo: "fa fa-at",
            shareUrl: "mailto:{to}?subject={text}&body={url}",
            countUrl: "",
            shareIn: "self"
        },

        twitter: {
            label: "Tweet",
            logo: "fa fa-twitter",
            shareUrl: "https://twitter.com/share?url={url}&text={text}&via={via}&hashtags={hashtags}",
            countUrl: ""
        },

        facebook: {
            label: "Like",
            logo: "fa fa-facebook",
            shareUrl: "https://facebook.com/sharer/sharer.php?u={url}",
            countUrl: "https://graph.facebook.com/?id={url}",
            getCount: function(data) {
                return data.share && data.share.share_count || 0;
            }
        },

        vkontakte: {
            label: "Like",
            logo: "fa fa-vk",
            shareUrl: "https://vk.com/share.php?url={url}&title={title}&description={text}",
            countUrl: "https://vk.com/share.php?act=count&index=1&url={url}",
            getCount: function(data) {
                return parseInt(data.slice(15, -2).split(', ')[1]);
            }
        },

        googleplus: {
            label: "+1",
            logo: "fa fa-google",
            shareUrl: "https://plus.google.com/share?url={url}",
            countUrl: ""
        },

        linkedin: {
            label: "Share",
            logo: "fa fa-linkedin",
            shareUrl: "https://www.linkedin.com/shareArticle?mini=true&url={url}",
            countUrl: "https://www.linkedin.com/countserv/count/share?format=jsonp&url={url}&callback=?",
            getCount: function(data) {
                return data.count;
            }
        },

        pinterest: {
            label: "Pin it",
            logo: "fa fa-pinterest",
            shareUrl: "https://pinterest.com/pin/create/bookmarklet/?media={media}&url={url}&description={text}",
            countUrl: "https://api.pinterest.com/v1/urls/count.json?&url={url}&callback=?",
            getCount: function(data) {
                return data.count;
            }
        },

        stumbleupon: {
            label: "Share",
            logo: "fa fa-stumbleupon",
            shareUrl: "http://www.stumbleupon.com/submit?url={url}&title={title}",
            countUrl:  "https://cors-anywhere.herokuapp.com/https://www.stumbleupon.com/services/1.01/badge.getinfo?url={url}",
            getCount: function(data) {
                return data.result.views;
            }
        },

        telegram: {
            label: "Telegram",
            logo: "fa fa-paper-plane",
            shareUrl: "tg://msg?text={url} {text}",
            countUrl: "",
            shareIn: "self"
        },

        whatsapp: {
            label: "WhatsApp",
            logo: "fa fa-whatsapp",
            shareUrl: "whatsapp://send?text={url} {text}",
            countUrl: "",
            shareIn: "self"
        },

        line: {
            label: "LINE",
            logo: "fa fa-comment",
            shareUrl: "http://line.me/R/msg/text/?{text} {url}",
            countUrl: ""
        },

        viber: {
            label: "Viber",
            logo: "fa fa-volume-control-phone",
            shareUrl: "viber://forward?text={url} {text}",
            countUrl: "",
            shareIn: "self"
        },

        pocket: {
            label: "Pocket",
            logo: "fa fa-get-pocket",
            shareUrl: "https://getpocket.com/save?url={url}&title={title}",
            countUrl: "",
        },

        messenger: {
            label: "Share",
            logo: "fa fa-commenting",
            shareUrl: "fb-messenger://share?link={url}",
            countUrl: "",
            shareIn: "self"
        }

    });

}(window, jQuery, window.jsSocials));

<|endoftext|>


<commit_before>var lastSaid = {};
var replaceRegex = /^s\/(.*?)\/(.*?)(:?\/g)?$/;

function replaceAll(find, replace, str) {
    return str.replace(new RegExp(find, 'g'), replace);
}

module.exports.msg =  function(text, from, reply, raw) {
    match = replaceRegex.exec(text);
    if (match) {
        // Replace the last thing the person said, if anything
        if (lastSaid[from] != undefined) {
            var personLastSaid = lastSaid[from],
                find = match[1],
                replace = match[2];
            var fixed = replaceAll(find, replace, personLastSaid);

            var response = "<" + from + "> " + fixed;

            reply(response);
        }
    } else {
        // The proper way to do this would be with scrollback module but w/e
        lastSaid[from] = text;
    }
}
<commit_msg>Fixed a bug in regex regex parsing<commit_after>var lastSaid = {};
var replaceRegex = /^s\/(.*?)\/(.*?)(?:(?:\/g)|(?:\/))?$/;

function replaceAll(find, replace, str) {
    return str.replace(new RegExp(find, 'g'), replace);
}

module.exports.msg =  function(text, from, reply, raw) {
    match = replaceRegex.exec(text);
    if (match) {
        // Replace the last thing the person said, if anything
        if (lastSaid[from] != undefined) {
            var personLastSaid = lastSaid[from],
                find = match[1],
                replace = match[2];
            var fixed = replaceAll(find, replace, personLastSaid);

            var response = "<" + from + "> " + fixed;

            reply(response);
        }
    } else {
        // The proper way to do this would be with scrollback module but w/e
        lastSaid[from] = text;
    }
}
<|endoftext|>