<commit_before>/* global config, path, project */

module.exports = function(grunt) {
	grunt.registerTask('configScript', function() {
		// Core scripts
		if (project.script.core.enable === true) {
			var features = project.script.core.features,
				weeScriptRoot = config.paths.wee + 'script/';

			config.script.files.push(weeScriptRoot + 'wee.js');

			// Set global data variables
			if (
				(project.data && Object.keys(project.data).length) ||
				(project.script.data && Object.keys(project.script.data).length)
			) {
				var weeScriptGlobal = config.paths.temp + 'data.js',
					configVars = Wee.$extend(project.data, project.script.data || {}),
					script = 'Wee.$set("global", ' + JSON.stringify(configVars) + ');';

				grunt.file.write(weeScriptGlobal, script);

				config.script.files.push(weeScriptGlobal);
			}

			if (features.chain === true) {
				config.script.files.push(weeScriptRoot + 'wee.chain.js');
			}

			if (features.animate === true) {
				config.script.files.push(weeScriptRoot + 'wee.animate.js');

				if (features.chain === true) {
					config.script.files.push(weeScriptRoot + 'chain/wee.chain.animate.js');
				}
			}

			if (features.assets === true) {
				config.script.files.push(weeScriptRoot + 'wee.assets.js');
			}

			if (features.data === true) {
				config.script.files.push(weeScriptRoot + 'wee.data.js');
			}

			if (features.dom === true) {
				config.script.files.push(weeScriptRoot + 'wee.dom.js');

				if (features.chain === true) {
					config.script.files.push(weeScriptRoot + 'chain/wee.chain.dom.js');
				}
			}

			if (features.events === true) {
				config.script.files.push(weeScriptRoot + 'wee.events.js');

				if (features.chain === true) {
					config.script.files.push(weeScriptRoot + 'chain/wee.chain.events.js');
				}
			}

			if (features.history === true) {
				config.script.files.push(weeScriptRoot + 'wee.history.js');
			}

			if (features.routes === true) {
				config.script.files.push(weeScriptRoot + 'wee.routes.js');
			}

			if (features.screen === true) {
				config.script.files.push(weeScriptRoot + 'wee.screen.js');
			}

			if (features.touch === true) {
				config.script.files.push(weeScriptRoot + 'wee.touch.js');
			}

			if (features.view === true) {
				config.script.files.push(weeScriptRoot + 'wee.view.js');

				if (features.chain === true) {
					config.script.files.push(weeScriptRoot + 'chain/wee.chain.view.js');
				}
			}
		}

		// Build/vendor directory scripts
		config.script.files.push(config.paths.jsSource + 'build/vendor/**/*.js');

		// Remaining build directory scripts
		config.script.files.push(config.paths.jsSource + 'build/**/*.js');

		// Project.config file build files
		project.script.build.forEach(function(name) {
			config.script.files.push(Wee.buildPath(config.paths.jsSource, name));
		});

		// Custom/script.js file
		config.script.files.push(config.paths.jsSource + 'custom/script.js');

		// Compile custom
		for (var target in project.script.compile) {
			var taskName = target.replace(/\./g, '-') + '-script',
				sources = project.script.compile[target],
				src = [];

			if (sources instanceof Array) {
				for (var source in sources) {
					src.push(Wee.buildPath(config.paths.jsSource, sources[source]));
				}
			} else {
				src = Wee.buildPath(config.paths.jsSource, sources);
			}

			// Merge watch config
			grunt.config.set('watch.' + taskName, {
				files: src,
				tasks: [
					'uglify:' + taskName
				]
			});

			// Create uglify task
			grunt.config.set('uglify.' + taskName, {
				files: [{
					dest: Wee.buildPath(config.paths.js, target),
					src: src
				}]
			});

			// Run task
			grunt.task.run('uglify:' + taskName);
		}

		// Configure source maps
		if (project.script.sourceMaps === true) {
			grunt.config.set('uglify.options.sourceMap', true);
			grunt.config.set('uglify.options.sourceMapIncludeSources', true);
			grunt.config.set('uglify.options.sourceMapName', function(dest) {
				var scriptRoot = path.normalize(config.paths.js),
					moduleRoot = path.normalize(config.paths.modules);
				dest = path.normalize(dest)
					.replace(scriptRoot, '')
					.replace(moduleRoot, '/')
					.replace(/^\\|\//, '')
					.replace(/\\|\//g, '.')
					.replace('.min.js', '');

				return path.join(config.paths.jsMaps, dest + '.js.map');
			});
		}
	});
};<commit_msg>Queue chaning features to ensure shorthand $. syntax is available for all core and DOM methods<commit_after>/* global config, path, project */

module.exports = function(grunt) {
	grunt.registerTask('configScript', function() {
		// Core scripts
		if (project.script.core.enable === true) {
			var features = project.script.core.features,
				weeScriptRoot = config.paths.wee + 'script/',
				chained = [];

			config.script.files.push(weeScriptRoot + 'wee.js');

			// Set global data variables
			if (
				(project.data && Object.keys(project.data).length) ||
				(project.script.data && Object.keys(project.script.data).length)
			) {
				var weeScriptGlobal = config.paths.temp + 'data.js',
					configVars = Wee.$extend(project.data, project.script.data || {}),
					script = 'Wee.$set("global", ' + JSON.stringify(configVars) + ');';

				grunt.file.write(weeScriptGlobal, script);

				config.script.files.push(weeScriptGlobal);
			}

			if (features.chain === true) {
				chained.push(weeScriptRoot + 'wee.chain.js');
			}

			if (features.animate === true) {
				config.script.files.push(weeScriptRoot + 'wee.animate.js');

				if (features.chain === true) {
					chained.push(weeScriptRoot + 'chain/wee.chain.animate.js');
				}
			}

			if (features.assets === true) {
				config.script.files.push(weeScriptRoot + 'wee.assets.js');
			}

			if (features.data === true) {
				config.script.files.push(weeScriptRoot + 'wee.data.js');
			}

			if (features.dom === true) {
				config.script.files.push(weeScriptRoot + 'wee.dom.js');

				if (features.chain === true) {
					chained.push(weeScriptRoot + 'chain/wee.chain.dom.js');
				}
			}

			if (features.events === true) {
				config.script.files.push(weeScriptRoot + 'wee.events.js');

				if (features.chain === true) {
					chained.push(weeScriptRoot + 'chain/wee.chain.events.js');
				}
			}

			if (features.history === true) {
				config.script.files.push(weeScriptRoot + 'wee.history.js');
			}

			if (features.routes === true) {
				config.script.files.push(weeScriptRoot + 'wee.routes.js');
			}

			if (features.screen === true) {
				config.script.files.push(weeScriptRoot + 'wee.screen.js');
			}

			if (features.touch === true) {
				config.script.files.push(weeScriptRoot + 'wee.touch.js');
			}

			if (features.view === true) {
				config.script.files.push(weeScriptRoot + 'wee.view.js');

				if (features.chain === true) {
					chained.push(weeScriptRoot + 'chain/wee.chain.view.js');
				}
			}

			config.script.files = config.script.files.concat(chained);
		}

		// Build/vendor directory scripts
		config.script.files.push(config.paths.jsSource + 'build/vendor/**/*.js');

		// Remaining build directory scripts
		config.script.files.push(config.paths.jsSource + 'build/**/*.js');

		// Project.config file build files
		project.script.build.forEach(function(name) {
			config.script.files.push(Wee.buildPath(config.paths.jsSource, name));
		});

		// Custom/script.js file
		config.script.files.push(config.paths.jsSource + 'custom/script.js');

		// Compile custom
		for (var target in project.script.compile) {
			var taskName = target.replace(/\./g, '-') + '-script',
				sources = project.script.compile[target],
				src = [];

			if (sources instanceof Array) {
				for (var source in sources) {
					src.push(Wee.buildPath(config.paths.jsSource, sources[source]));
				}
			} else {
				src = Wee.buildPath(config.paths.jsSource, sources);
			}

			// Merge watch config
			grunt.config.set('watch.' + taskName, {
				files: src,
				tasks: [
					'uglify:' + taskName
				]
			});

			// Create uglify task
			grunt.config.set('uglify.' + taskName, {
				files: [{
					dest: Wee.buildPath(config.paths.js, target),
					src: src
				}]
			});

			// Run task
			grunt.task.run('uglify:' + taskName);
		}

		// Configure source maps
		if (project.script.sourceMaps === true) {
			grunt.config.set('uglify.options.sourceMap', true);
			grunt.config.set('uglify.options.sourceMapIncludeSources', true);
			grunt.config.set('uglify.options.sourceMapName', function(dest) {
				var scriptRoot = path.normalize(config.paths.js),
					moduleRoot = path.normalize(config.paths.modules);
				dest = path.normalize(dest)
					.replace(scriptRoot, '')
					.replace(moduleRoot, '/')
					.replace(/^\\|\//, '')
					.replace(/\\|\//g, '.')
					.replace('.min.js', '');

				return path.join(config.paths.jsMaps, dest + '.js.map');
			});
		}
	});
};<|endoftext|>


<commit_before>/* global config, path, project */

module.exports = function(grunt) {
	grunt.registerTask('configScript', function() {
		// Core scripts
		if (project.script.core.enable === true) {
			var features = project.script.core.features,
				weeScriptRoot = config.paths.wee + 'script/',
				chained = [];

			config.script.files.push(weeScriptRoot + 'wee.js');

			// Set global data variables
			if (
				(project.data && Object.keys(project.data).length) ||
				(project.script.data && Object.keys(project.script.data).length)
			) {
				var weeScriptGlobal = config.paths.temp + 'data.js',
					configVars = Wee.$extend(project.data, project.script.data || {}),
					script = 'Wee.$set("global", ' + JSON.stringify(configVars) + ');';

				grunt.file.write(weeScriptGlobal, script);

				config.script.files.push(weeScriptGlobal);
			}

			if (features.chain === true) {
				chained.push(weeScriptRoot + 'wee.chain.js');
			}

			if (features.animate === true) {
				config.script.files.push(weeScriptRoot + 'wee.animate.js');

				if (features.chain === true) {
					chained.push(weeScriptRoot + 'chain/wee.chain.animate.js');
				}
			}

			if (features.assets === true) {
				config.script.files.push(weeScriptRoot + 'wee.assets.js');
			}

			if (features.data === true) {
				config.script.files.push(weeScriptRoot + 'wee.data.js');
			}

			if (features.dom === true) {
				config.script.files.push(weeScriptRoot + 'wee.dom.js');

				if (features.chain === true) {
					chained.push(weeScriptRoot + 'chain/wee.chain.dom.js');
				}
			}

			if (features.events === true) {
				config.script.files.push(weeScriptRoot + 'wee.events.js');

				if (features.chain === true) {
					chained.push(weeScriptRoot + 'chain/wee.chain.events.js');
				}
			}

			if (features.history === true) {
				config.script.files.push(weeScriptRoot + 'wee.history.js');
			}

			if (features.routes === true) {
				config.script.files.push(weeScriptRoot + 'wee.routes.js');
			}

			if (features.screen === true) {
				config.script.files.push(weeScriptRoot + 'wee.screen.js');
			}

			if (features.touch === true) {
				config.script.files.push(weeScriptRoot + 'wee.touch.js');
			}

			if (features.view === true) {
				config.script.files.push(weeScriptRoot + 'wee.view.js');

				if (features.chain === true) {
					chained.push(weeScriptRoot + 'chain/wee.chain.view.js');
				}
			}

			config.script.files = config.script.files.concat(chained);
		}

		// Build/vendor directory scripts
		config.script.files.push(config.paths.jsSource + 'build/vendor/**/*.js');

		// Remaining build directory scripts
		config.script.files.push(config.paths.jsSource + 'build/**/*.js');

		// Project.config file build files
		project.script.build.forEach(function(name) {
			config.script.files.push(Wee.buildPath(config.paths.jsSource, name));
		});

		// Custom/script.js file
		config.script.files.push(config.paths.jsSource + 'custom/script.js');

		// Compile custom
		for (var target in project.script.compile) {
			var taskName = target.replace(/\./g, '-') + '-script',
				sources = project.script.compile[target],
				src = [];

			if (sources instanceof Array) {
				for (var source in sources) {
					src.push(Wee.buildPath(config.paths.jsSource, sources[source]));
				}
			} else {
				src = Wee.buildPath(config.paths.jsSource, sources);
			}

			// Merge watch config
			grunt.config.set('watch.' + taskName, {
				files: src,
				tasks: [
					'uglify:' + taskName
				]
			});

			// Create uglify task
			grunt.config.set('uglify.' + taskName, {
				files: [{
					dest: Wee.buildPath(config.paths.js, target),
					src: src
				}]
			});

			// Run task
			grunt.task.run('uglify:' + taskName);
		}

		// Configure source maps
		if (project.script.sourceMaps === true) {
			grunt.config.set('uglify.options.sourceMap', true);
			grunt.config.set('uglify.options.sourceMapIncludeSources', true);
			grunt.config.set('uglify.options.sourceMapName', function(dest) {
				var scriptRoot = path.normalize(config.paths.js),
					moduleRoot = path.normalize(config.paths.modules);
				dest = path.normalize(dest)
					.replace(scriptRoot, '')
					.replace(moduleRoot, '/')
					.replace(/^\\|\//, '')
					.replace(/\\|\//g, '.')
					.replace('.min.js', '');

				return path.join(config.paths.jsMaps, dest + '.js.map');
			});
		}
	});
};<commit_msg>Pull in morphdom for differential DOM updating<commit_after>/* global config, path, project */

module.exports = function(grunt) {
	grunt.registerTask('configScript', function() {
		// Core scripts
		if (project.script.core.enable === true) {
			var features = project.script.core.features,
				weeScriptRoot = config.paths.wee + 'script/',
				chained = [];

			config.script.files.push(weeScriptRoot + 'wee.js');

			// Set global data variables
			if (
				(project.data && Object.keys(project.data).length) ||
				(project.script.data && Object.keys(project.script.data).length)
			) {
				var weeScriptGlobal = config.paths.temp + 'data.js',
					configVars = Wee.$extend(project.data, project.script.data || {}),
					script = 'Wee.$set("global", ' + JSON.stringify(configVars) + ');';

				grunt.file.write(weeScriptGlobal, script);

				config.script.files.push(weeScriptGlobal);
			}

			if (features.chain === true) {
				chained.push(weeScriptRoot + 'wee.chain.js');
			}

			if (features.animate === true) {
				config.script.files.push(weeScriptRoot + 'wee.animate.js');

				if (features.chain === true) {
					chained.push(weeScriptRoot + 'chain/wee.chain.animate.js');
				}
			}

			if (features.assets === true) {
				config.script.files.push(weeScriptRoot + 'wee.assets.js');
			}

			if (features.data === true) {
				config.script.files.push(weeScriptRoot + 'wee.data.js');
			}

			if (features.dom === true) {
				config.script.files.push(weeScriptRoot + 'wee.dom.js');

				if (features.chain === true) {
					chained.push(weeScriptRoot + 'chain/wee.chain.dom.js');
				}
			}

			if (features.events === true) {
				config.script.files.push(weeScriptRoot + 'wee.events.js');

				if (features.chain === true) {
					chained.push(weeScriptRoot + 'chain/wee.chain.events.js');
				}
			}

			if (features.history === true) {
				config.script.files.push(weeScriptRoot + 'wee.history.js');
			}

			if (features.routes === true) {
				config.script.files.push(weeScriptRoot + 'wee.routes.js');
			}

			if (features.screen === true) {
				config.script.files.push(weeScriptRoot + 'wee.screen.js');
			}

			if (features.touch === true) {
				config.script.files.push(weeScriptRoot + 'wee.touch.js');
			}

			if (features.view === true) {
				config.script.files.push(weeScriptRoot + 'wee.view.js');
				config.script.files.push(weeScriptRoot + 'lib/domdiff.js');

				if (features.chain === true) {
					chained.push(weeScriptRoot + 'chain/wee.chain.view.js');
				}
			}

			config.script.files = config.script.files.concat(chained);
		}

		// Build/vendor directory scripts
		config.script.files.push(config.paths.jsSource + 'build/vendor/**/*.js');

		// Remaining build directory scripts
		config.script.files.push(config.paths.jsSource + 'build/**/*.js');

		// Project.config file build files
		project.script.build.forEach(function(name) {
			config.script.files.push(Wee.buildPath(config.paths.jsSource, name));
		});

		// Custom/script.js file
		config.script.files.push(config.paths.jsSource + 'custom/script.js');

		// Compile custom
		for (var target in project.script.compile) {
			var taskName = target.replace(/\./g, '-') + '-script',
				sources = project.script.compile[target],
				src = [];

			if (sources instanceof Array) {
				for (var source in sources) {
					src.push(Wee.buildPath(config.paths.jsSource, sources[source]));
				}
			} else {
				src = Wee.buildPath(config.paths.jsSource, sources);
			}

			// Merge watch config
			grunt.config.set('watch.' + taskName, {
				files: src,
				tasks: [
					'uglify:' + taskName
				]
			});

			// Create uglify task
			grunt.config.set('uglify.' + taskName, {
				files: [{
					dest: Wee.buildPath(config.paths.js, target),
					src: src
				}]
			});

			// Run task
			grunt.task.run('uglify:' + taskName);
		}

		// Configure source maps
		if (project.script.sourceMaps === true) {
			grunt.config.set('uglify.options.sourceMap', true);
			grunt.config.set('uglify.options.sourceMapIncludeSources', true);
			grunt.config.set('uglify.options.sourceMapName', function(dest) {
				var scriptRoot = path.normalize(config.paths.js),
					moduleRoot = path.normalize(config.paths.modules);
				dest = path.normalize(dest)
					.replace(scriptRoot, '')
					.replace(moduleRoot, '/')
					.replace(/^\\|\//, '')
					.replace(/\\|\//g, '.')
					.replace('.min.js', '');

				return path.join(config.paths.jsMaps, dest + '.js.map');
			});
		}
	});
};<|endoftext|>


<commit_before>(function($) {
    var defaults = {}
    $.fn.pos = function(options) {
        //define instance for use in child functions
        var $this = $(this);
        //set default options
        defaults = {
            scan: true,
            swipe: true,
            data: {
                scan: '',
                swipe: ''
            },
            events: {
                scan: {
                    barcode: 'scan.pos.barcode'
                },
                swipe: {
                    card: 'swipe.pos.card'
                }
            },
            regexp: {
                scan: {
                    barcode: '\\d+'
                },
                swipe: {
                    card: '\\%B(\\d+)\\^(\\w+)\\/(\\w+)\\^\\d+\\?;\\d+=(\\d\\d)(\\d\\d)\\d+\\?'
                }
            },
            prefix: {
                scan: {
                    barcode: ''
                },
                swipe: {
                    card: ''
                }
            }
        };
        //extend options
        $this.options = $.extend(true, {}, defaults, options);

        $this.keypress(function(event) {
            if ($this.options.scan) {
                if (event.which == 13) {
                    var scanexp = new RegExp('^' + $this.options.prefix.scan.barcode + $this.options.regexp.scan.barcode + '$');
                    if (defaults.data.scan.match(scanexp)) {
                        $this.trigger({
                            type: $this.options.events.scan.barcode,
                            code: defaults.data.scan,
                            time: new Date()
                        });
                    }

                    defaults.data.scan = '';
                } else {
                    var char = String.fromCharCode(event.which);
                    defaults.data.scan += char;
                }
            }

            if ($this.options.swipe) {
                if (event.which == 13) {
                    var swipexp = new RegExp('^' + $this.options.regexp.swipe.card + '$');
                    if (defaults.data.swipe.match(swipexp)) {
                        var swipe_match = swipexp.exec(defaults.data.swipe);
                        var date = new Date();
                        var year = date.getFullYear();
                        year = year.toString().substring(0, 2) + swipe_match[4];
                        $this.trigger({
                            type: $this.options.events.swipe.card,
                            swipe_data: swipe_match[0],
                            card_number: swipe_match[1],
                            card_holder_last_name: swipe_match[2],
                            card_holder_first_name: swipe_match[3],
                            card_exp_date_month: swipe_match[5],
                            card_exp_date_year_2: swipe_match[4],
                            card_exp_date_year_4: year,
                            time: date
                        });
                    }
                    defaults.data.swipe = '';
                } else {
                    var char = String.fromCharCode(event.which);
                    defaults.data.swipe += char.replace(/ /g, '');
                }
            }
        });
    };
})(jQuery);
<commit_msg>updated to private data object<commit_after>(function($) {
    var defaults = {}
    $.fn.pos = function(options) {
        //define instance for use in child functions
        var $this = $(this);
	var data = {
		scan: '',
		swipe: ''
	};
        //set default options
        defaults = {
            scan: true,
            swipe: true,
            events: {
                scan: {
                    barcode: 'scan.pos.barcode'
                },
                swipe: {
                    card: 'swipe.pos.card'
                }
            },
            regexp: {
                scan: {
                    barcode: '\\d+'
                },
                swipe: {
                    card: '\\%B(\\d+)\\^(\\w+)\\/(\\w+)\\^\\d+\\?;\\d+=(\\d\\d)(\\d\\d)\\d+\\?'
                }
            },
            prefix: {
                scan: {
                    barcode: ''
                },
                swipe: {
                    card: ''
                }
            }
        };
        //extend options
        $this.options = $.extend(true, {}, defaults, options);

        $this.keypress(function(event) {
            if ($this.options.scan) {
                if (event.which == 13) {
                    var scanexp = new RegExp('^' + $this.options.prefix.scan.barcode + $this.options.regexp.scan.barcode + '$');
                    if (defaults.data.scan.match(scanexp)) {
                        $this.trigger({
                            type: $this.options.events.scan.barcode,
                            code: data.scan,
                            time: new Date()
                        });
                    }
                    data.scan = '';
                } else {
                    var char = String.fromCharCode(event.which);
                    data.scan += char;
                }
            }

            if ($this.options.swipe) {
                if (event.which == 13) {
                    var swipexp = new RegExp('^' + $this.options.prefix.swipe.card + $this.options.regexp.swipe.card + '$');
                    if (data.swipe.match(swipexp)) {
                        var swipe_match = swipexp.exec(data.swipe);
                        var date = new Date();
                        var year = date.getFullYear();
                        year = year.toString().substring(0, 2) + swipe_match[4];
                        $this.trigger({
                            type: $this.options.events.swipe.card,
                            swipe_data: swipe_match[0],
                            card_number: swipe_match[1],
                            card_holder_last_name: swipe_match[2],
                            card_holder_first_name: swipe_match[3],
                            card_exp_date_month: swipe_match[5],
                            card_exp_date_year_2: swipe_match[4],
                            card_exp_date_year_4: year,
                            time: date
                        });
                    }
                    data.swipe = '';
                } else {
                    var char = String.fromCharCode(event.which);
                    data.swipe += char.replace(/ /g, '');
                }
            }
        });
    };
})(jQuery);
<|endoftext|>


<commit_before>import loggerCreator from "app/utils/logger";
//noinspection JSUnresolvedVariable
var moduleLogger = loggerCreator("SidebarMenuItem");

import React, { Component } from "react";
import { Image, StyleSheet, TouchableOpacity, View } from "react-native";
import { observer } from "mobx-react";
import NormalText from "app/shared_components/text/normal_text";
import { colors } from "app/styles/styles";

const styles = StyleSheet.create({
  itemContainer: { flexDirection: "row", height: 45, alignItems: "center" },
  itemText: { marginLeft: 5, color: colors.CYAN_BRIGHT },

  leftImage: { flex: 1 },
  leftImageContainer: { marginLeft: 10, height: 25, width: 25 },

  rightImage: { flex: 1 },
  rightImageContainer: { marginLeft: "auto", marginRight: 10, height: 25, width: 25 },
});

@observer
export default class SidebarMenuItem extends Component {
  render() {
    let itemContainerBackground = "transparent";
    if (this.props.isActive) {
      itemContainerBackground = colors.CONTAINER_BACKGROUND_ACTIVE;
    }

    return (
      <TouchableOpacity
        activeOpacity={1}
        style={[styles.itemContainer, { backgroundColor: itemContainerBackground }]}
        onMouseEnter={this.onMouseEnter}>
        <View style={styles.leftImageContainer}>
          <Image source={this.props.leftImage} resizeMode="contain" style={styles.leftImage} />
        </View>
        <NormalText style={styles.itemText}>
          {this.props.text}
        </NormalText>
        <View style={styles.rightImageContainer}>
          <Image source={this.props.rightImage} resizeMode="contain" style={styles.rightImage} />
        </View>
      </TouchableOpacity>
    );
  }
}

SidebarMenuItem.propTypes = {
  text: React.PropTypes.string.isRequired,
  leftImage: React.PropTypes.any.isRequired,
  rightImage: React.PropTypes.any,

  isActive: React.PropTypes.bool,
};
<commit_msg>sidebar items - hover styling<commit_after>import loggerCreator from "app/utils/logger";
//noinspection JSUnresolvedVariable
var moduleLogger = loggerCreator("SidebarMenuItem");

import React, { Component } from "react";
import { Image, StyleSheet, View } from "react-native";
import { observer } from "mobx-react";
import NormalText from "app/shared_components/text/normal_text";
import { colors } from "app/styles/styles";
import HoverableOpacity from "app/utils/hoverable_opacity";

const styles = StyleSheet.create({
  itemContainer: { flexDirection: "row", height: 45, alignItems: "center" },
  itemText: { marginLeft: 5, color: colors.CYAN_BRIGHT },

  leftImage: { flex: 1 },
  leftImageContainer: { marginLeft: 10, height: 25, width: 25 },

  rightImage: { flex: 1 },
  rightImageContainer: { marginLeft: "auto", marginRight: 10, height: 25, width: 25 },
});

@observer
export default class SidebarMenuItem extends Component {
  render() {
    let itemContainerBackground = "transparent";
    if (this.props.isActive) {
      itemContainerBackground = colors.CONTAINER_BACKGROUND_ACTIVE;
    }

    return (
      <HoverableOpacity
        activeOpacity={1}
        style={[styles.itemContainer, { backgroundColor: itemContainerBackground }]}
        hoverStyle={{ backgroundColor: colors.CONTAINER_BACKGROUND_HOVER }}
        onMouseEnter={this.onMouseEnter}>
        <View style={styles.leftImageContainer}>
          <Image source={this.props.leftImage} resizeMode="contain" style={styles.leftImage} />
        </View>
        <NormalText style={styles.itemText}>
          {this.props.text}
        </NormalText>
        <View style={styles.rightImageContainer}>
          <Image source={this.props.rightImage} resizeMode="contain" style={styles.rightImage} />
        </View>
      </HoverableOpacity>
    );
  }
}

SidebarMenuItem.propTypes = {
  text: React.PropTypes.string.isRequired,
  leftImage: React.PropTypes.any.isRequired,
  rightImage: React.PropTypes.any,

  isActive: React.PropTypes.bool,
};
<|endoftext|>


<commit_before>(function($){
    $.fn.x_x = function(config) {
        var defaults = {
            colors: [
                '#f09', '#f03', '#600',
                '#0f9', '#0f3', '#063',
                '#09f', '#03f', '#036'
            ],
            interval: 50
        };
        var options = $.extend(defaults, config);
        return this.each(function() {
          var def_color, timer;
          $(this).on('mouseover', function() {
            $this = $(this);
            def_color = $this.css('color');
            timer = setInterval(function() {
              var num = Math.floor(Math.random() * options.colors.length);
              $this.css('color', options.colors[num]);
            }, options.interval);
            $this.css('color', 'green');
          });
          $(this).on('mouseout', function() {
            $(this).css('color', def_color);
            clearInterval(timer);
          });
        });
    };
})(jQuery);
<commit_msg>omit needless code<commit_after>(function($){
    $.fn.x_x = function(config) {
        var defaults = {
            colors: [
                '#f09', '#f03', '#600',
                '#0f9', '#0f3', '#063',
                '#09f', '#03f', '#036'
            ],
            interval: 50
        };
        var options = $.extend(defaults, config);
        return this.each(function() {
          var def_color, timer;
          $(this).on('mouseover', function() {
            $this = $(this);
            def_color = $this.css('color');
            timer = setInterval(function() {
              var num = Math.floor(Math.random() * options.colors.length);
              $this.css('color', options.colors[num]);
            }, options.interval);
          });
          $(this).on('mouseout', function() {
            clearInterval(timer);
            $(this).css('color', def_color);
          });
        });
    };
})(jQuery);
<|endoftext|>


<commit_before>// Copyright 2002-2015, University of Colorado Boulder

/**
 * Object for actual element properties (symbol, radius, etc.)
 *
 * @author Jonathan Olson <jonathan.olson@colorado.edu>
 */

define( function( require ) {
  'use strict';

  // modules
  var inherit = require( 'PHET_CORE/inherit' );
  var PhetColorScheme = require( 'SCENERY_PHET/PhetColorScheme' );

  /**
   * @param symbol {string}
   * @param covalentRadius {number} Covalent radius, in picometers. For a quick chart,
   *        see http://en.wikipedia.org/wiki/Atomic_radii_of_the_elements_(data_page)
   * @param vanDerWaalsRadius {number} Van der Waals radius, in picometers. See chart at
   *        http://en.wikipedia.org/wiki/Atomic_radii_of_the_elements_(data_page)
   * @param electronegativity {number} in Pauling units, see https://secure.wikimedia.org/wikipedia/en/wiki/Electronegativity
   * @param atomicWeight {number} In atomic mass units (u). from http://www.webelements.com/periodicity/atomic_weight/
   * @param color {Color|string} Color used in visual representations
   * @constructor
   */
  var Element = function( symbol, covalentRadius, vanDerWaalsRadius, electronegativity, atomicWeight, color ) {
    this.symbol = symbol;
    this.covalentRadius = covalentRadius;
    this.vanDerWaalsRadius = vanDerWaalsRadius;
    this.electronegativity = electronegativity;
    this.atomicWeight = atomicWeight;
    this.color = color;
  };

  inherit( Object, Element, {

    isSameElement: function( element ) {
      return element.symbol === this.symbol;
    },

    isHydrogen: function() {
      return this.isSameElement( Element.H );
    },

    isCarbon: function() {
      return this.isSameElement( Element.C );
    },

    isOxygen: function() {
      return this.isSameElement( Element.O );
    },

    toString: function() {
      return this.symbol;
    }

  } );

  Element.Ar = new Element( 'Ar', 97, 188, null, 39.948, '#FFAFAF' );
  Element.B = new Element( 'B', 85, 192, 2.04, 10.811, 'rgb(255,170,119)' ); // peach/salmon colored, CPK coloring
  Element.Be = new Element( 'Be', 105, 153, 1.57, 9.012182, '#c2ff00' ); // beryllium
  Element.Br = new Element( 'Br', 114, 185, 2.96, 79.904, 'rgb(190,30,20)' ); // brown
  Element.C = new Element( 'C', 77, 170, 2.55, 12.0107, 'rgb(178,178,178)' );
  Element.Cl = new Element( 'Cl', 100, 175, 3.16, 35.4527, 'rgb(153,242,57)' );
  Element.F = new Element( 'F', 72, 147, 3.98, 18.9984032, 'rgb(247,255,74)' );
  Element.H = new Element( 'H', 37, 120, 2.20, 1.00794, '#ffffff' );
  Element.I = new Element( 'I', 133, 198, 2.66, 126.90447, '#940094' ); // dark violet, CPK coloring
  Element.N = new Element( 'N', 75, 155, 3.04, 14.00674, '#0000ff' );
  Element.Ne = new Element( 'Ne', 69, 154, null, 20.1797, '#1AFFFB' );
  Element.O = new Element( 'O', 73, 152, 3.44, 15.9994, PhetColorScheme.RED_COLORBLIND );
  Element.P = new Element( 'P', 110, 180, 2.19, 30.973762, 'rgb(255,128,0)' );
  Element.S = new Element( 'S', 103, 180, 2.58, 32.066, 'rgb(212,181,59)' );
  Element.Si = new Element( 'Si', 118, 210, 1.90, 28.0855, 'rgb(240,200,160)' ); // tan, Jmol coloring listed from https://secure.wikimedia.org/wikipedia/en/wiki/CPK_coloring
  Element.Sn = new Element( 'Sn', 145, 217, 1.96, 118.710, '#668080' ); // tin
  Element.Xe = new Element( 'Xe', 108, 216, 2.60, 131.293, '#429eb0' ); // radius is based on calculated (not empirical) data

  Element.elements = [
    Element.Ar, Element.B, Element.Be, Element.Br, Element.C, Element.Cl, Element.F, Element.H, Element.I, Element.N,
    Element.Ne, Element.O, Element.P, Element.S, Element.Si, Element.Sn, Element.Xe
  ];

  // maps symbol => element
  Element.elementMap = {};
  _.each( Element.elements, function( element ) {
    Element.elementMap[ element.symbol ] = element;
  } );

  Element.getElementBySymbol = function( symbol ) {
    assert && assert( Element.elementMap[ symbol ], 'Element not found: ' + symbol );
    return Element.elementMap[ symbol ];
  };

  return Element;
} );
<commit_msg>added documentation for electronegativity in cases where it is undifned, see https://github.com/phetsims/states-of-matter/issues/50<commit_after>// Copyright 2002-2015, University of Colorado Boulder

/**
 * Object for actual element properties (symbol, radius, etc.)
 *
 * @author Jonathan Olson <jonathan.olson@colorado.edu>
 */

define( function( require ) {
  'use strict';

  // modules
  var inherit = require( 'PHET_CORE/inherit' );
  var PhetColorScheme = require( 'SCENERY_PHET/PhetColorScheme' );

  /**
   * @param symbol {string}
   * @param covalentRadius {number} Covalent radius, in picometers. For a quick chart,
   *        see http://en.wikipedia.org/wiki/Atomic_radii_of_the_elements_(data_page)
   * @param vanDerWaalsRadius {number} Van der Waals radius, in picometers. See chart at
   *        http://en.wikipedia.org/wiki/Atomic_radii_of_the_elements_(data_page)
   * @param electronegativity {number|null} in Pauling units, see
   *        https://secure.wikimedia.org/wikipedia/en/wiki/Electronegativity, is null when undefined for an element
   *        (as is the case for noble gasses)
   * @param atomicWeight {number} In atomic mass units (u). from http://www.webelements.com/periodicity/atomic_weight/
   * @param color {Color|string} Color used in visual representations
   * @constructor
   */
  var Element = function( symbol, covalentRadius, vanDerWaalsRadius, electronegativity, atomicWeight, color ) {
    this.symbol = symbol;
    this.covalentRadius = covalentRadius;
    this.vanDerWaalsRadius = vanDerWaalsRadius;
    this.electronegativity = electronegativity;
    this.atomicWeight = atomicWeight;
    this.color = color;
  };

  inherit( Object, Element, {

    isSameElement: function( element ) {
      return element.symbol === this.symbol;
    },

    isHydrogen: function() {
      return this.isSameElement( Element.H );
    },

    isCarbon: function() {
      return this.isSameElement( Element.C );
    },

    isOxygen: function() {
      return this.isSameElement( Element.O );
    },

    toString: function() {
      return this.symbol;
    }

  } );

  Element.Ar = new Element( 'Ar', 97, 188, null, 39.948, '#FFAFAF' );
  Element.B = new Element( 'B', 85, 192, 2.04, 10.811, 'rgb(255,170,119)' ); // peach/salmon colored, CPK coloring
  Element.Be = new Element( 'Be', 105, 153, 1.57, 9.012182, '#c2ff00' ); // beryllium
  Element.Br = new Element( 'Br', 114, 185, 2.96, 79.904, 'rgb(190,30,20)' ); // brown
  Element.C = new Element( 'C', 77, 170, 2.55, 12.0107, 'rgb(178,178,178)' );
  Element.Cl = new Element( 'Cl', 100, 175, 3.16, 35.4527, 'rgb(153,242,57)' );
  Element.F = new Element( 'F', 72, 147, 3.98, 18.9984032, 'rgb(247,255,74)' );
  Element.H = new Element( 'H', 37, 120, 2.20, 1.00794, '#ffffff' );
  Element.I = new Element( 'I', 133, 198, 2.66, 126.90447, '#940094' ); // dark violet, CPK coloring
  Element.N = new Element( 'N', 75, 155, 3.04, 14.00674, '#0000ff' );
  Element.Ne = new Element( 'Ne', 69, 154, null, 20.1797, '#1AFFFB' );
  Element.O = new Element( 'O', 73, 152, 3.44, 15.9994, PhetColorScheme.RED_COLORBLIND );
  Element.P = new Element( 'P', 110, 180, 2.19, 30.973762, 'rgb(255,128,0)' );
  Element.S = new Element( 'S', 103, 180, 2.58, 32.066, 'rgb(212,181,59)' );
  Element.Si = new Element( 'Si', 118, 210, 1.90, 28.0855, 'rgb(240,200,160)' ); // tan, Jmol coloring listed from https://secure.wikimedia.org/wikipedia/en/wiki/CPK_coloring
  Element.Sn = new Element( 'Sn', 145, 217, 1.96, 118.710, '#668080' ); // tin
  Element.Xe = new Element( 'Xe', 108, 216, 2.60, 131.293, '#429eb0' ); // radius is based on calculated (not empirical) data

  Element.elements = [
    Element.Ar, Element.B, Element.Be, Element.Br, Element.C, Element.Cl, Element.F, Element.H, Element.I, Element.N,
    Element.Ne, Element.O, Element.P, Element.S, Element.Si, Element.Sn, Element.Xe
  ];

  // maps symbol => element
  Element.elementMap = {};
  _.each( Element.elements, function( element ) {
    Element.elementMap[ element.symbol ] = element;
  } );

  Element.getElementBySymbol = function( symbol ) {
    assert && assert( Element.elementMap[ symbol ], 'Element not found: ' + symbol );
    return Element.elementMap[ symbol ];
  };

  return Element;
} );
<|endoftext|>


<commit_before>// Copyright 2002-2014, University of Colorado Boulder

/**
 * Object for actual element properties (symbol, radius, etc.)
 *
 * @author Jonathan Olson <jonathan.olson@colorado.edu>
 */

define( function( require ) {
  'use strict';

  // modules
  var inherit = require( 'PHET_CORE/inherit' );
  var PhetColorScheme = require( 'SCENERY_PHET/PhetColorScheme' );

  /**
   * @param symbol {string}
   * @param radius {number} Covalent radius, in picometers. For a quick chart,
   *                        see http://en.wikipedia.org/wiki/Atomic_radii_of_the_elements_(data_page)
   * @param electronegativity {number} in Pauling units, see https://secure.wikimedia.org/wikipedia/en/wiki/Electronegativity
   * @param atomicWeight {number} In atomic mass units (u). from http://www.webelements.com/periodicity/atomic_weight/
   * @param color {Color|string} Color used in visual representations
   * @constructor
   */
  var Element = function( symbol, radius, electronegativity, atomicWeight, color ) {
    this.symbol = symbol;
    this.radius = radius;
    this.electronegativity = electronegativity;
    this.atomicWeight = atomicWeight;
    this.color = color;
  };

  inherit( Object, Element, {

    isSameElement: function( element ) {
      return element.symbol === this.symbol;
    },

    isHydrogen: function() {
      return this.isSameElement( Element.H );
    },

    isCarbon: function() {
      return this.isSameElement( Element.C );
    },

    isOxygen: function() {
      return this.isSameElement( Element.O );
    },

    toString: function() {
      return this.symbol;
    }

  } );

  Element.Ar = new Element( 'Ar', 97, null, 39.948, '#FFAFAF' );
  Element.B = new Element( 'B', 85, 2.04, 10.811, 'rgb(255,170,119)' ); // peach/salmon colored, CPK coloring
  Element.Be = new Element( 'Be', 105, 1.57, 9.012182, '#c2ff00' ); // beryllium
  Element.Br = new Element( 'Br', 114, 2.96, 79.904, 'rgb(190,30,20)' ); // brown
  Element.C = new Element( 'C', 77, 2.55, 12.0107, 'rgb(178,178,178)' );
  Element.Cl = new Element( 'Cl', 100, 3.16, 35.4527, 'rgb(153,242,57)' );
  Element.F = new Element( 'F', 72, 3.98, 18.9984032, 'rgb(247,255,74)' );
  Element.H = new Element( 'H', 37, 2.20, 1.00794, '#ffffff' );
  Element.I = new Element( 'I', 133, 2.66, 126.90447, '#940094' ); // dark violet, CPK coloring
  Element.N = new Element( 'N', 75, 3.04, 14.00674, '#0000ff' );
  Element.Ne = new Element( 'Ne', 69, null, 20.1797, '#70D4FF' );
  Element.O = new Element( 'O', 73, 3.44, 15.9994, PhetColorScheme.RED_COLORBLIND );
  Element.P = new Element( 'P', 110, 2.19, 30.973762, 'rgb(255,128,0)' );
  Element.S = new Element( 'S', 103, 2.58, 32.066, 'rgb(212,181,59)' );
  Element.Si = new Element( 'Si', 118, 1.90, 28.0855, 'rgb(240,200,160)' ); // tan, Jmol coloring listed from https://secure.wikimedia.org/wikipedia/en/wiki/CPK_coloring
  Element.Sn = new Element( 'Sn', 145, 1.96, 118.710, '#668080' ); // tin
  Element.Xe = new Element( 'Xe', 108, 2.60, 131.293, '#429eb0' ); // radius is based on calculated (not empirical) data

  Element.elements = [
    Element.B, Element.Be, Element.Br, Element.C, Element.Cl, Element.F, Element.H,
    Element.I, Element.N, Element.O, Element.P, Element.S, Element.Si, Element.Xe
  ];

  // maps symbol => element
  Element.elementMap = {};
  _.each( Element.elements, function( element ) {
    Element.elementMap[ element.symbol ] = element;
  } );

  Element.getElementBySymbol = function( symbol ) {
    assert && assert( Element.elementMap[ symbol ], 'Element not found: ' + symbol );
    return Element.elementMap[ symbol ];
  };

  return Element;
} );
<commit_msg>updated the color used for neon to be something a little brighter, see https://github.com/phetsims/states-of-matter/issues/49<commit_after>// Copyright 2002-2014, University of Colorado Boulder

/**
 * Object for actual element properties (symbol, radius, etc.)
 *
 * @author Jonathan Olson <jonathan.olson@colorado.edu>
 */

define( function( require ) {
  'use strict';

  // modules
  var inherit = require( 'PHET_CORE/inherit' );
  var PhetColorScheme = require( 'SCENERY_PHET/PhetColorScheme' );

  /**
   * @param symbol {string}
   * @param radius {number} Covalent radius, in picometers. For a quick chart,
   *                        see http://en.wikipedia.org/wiki/Atomic_radii_of_the_elements_(data_page)
   * @param electronegativity {number} in Pauling units, see https://secure.wikimedia.org/wikipedia/en/wiki/Electronegativity
   * @param atomicWeight {number} In atomic mass units (u). from http://www.webelements.com/periodicity/atomic_weight/
   * @param color {Color|string} Color used in visual representations
   * @constructor
   */
  var Element = function( symbol, radius, electronegativity, atomicWeight, color ) {
    this.symbol = symbol;
    this.radius = radius;
    this.electronegativity = electronegativity;
    this.atomicWeight = atomicWeight;
    this.color = color;
  };

  inherit( Object, Element, {

    isSameElement: function( element ) {
      return element.symbol === this.symbol;
    },

    isHydrogen: function() {
      return this.isSameElement( Element.H );
    },

    isCarbon: function() {
      return this.isSameElement( Element.C );
    },

    isOxygen: function() {
      return this.isSameElement( Element.O );
    },

    toString: function() {
      return this.symbol;
    }

  } );

  Element.Ar = new Element( 'Ar', 97, null, 39.948, '#FFAFAF' );
  Element.B = new Element( 'B', 85, 2.04, 10.811, 'rgb(255,170,119)' ); // peach/salmon colored, CPK coloring
  Element.Be = new Element( 'Be', 105, 1.57, 9.012182, '#c2ff00' ); // beryllium
  Element.Br = new Element( 'Br', 114, 2.96, 79.904, 'rgb(190,30,20)' ); // brown
  Element.C = new Element( 'C', 77, 2.55, 12.0107, 'rgb(178,178,178)' );
  Element.Cl = new Element( 'Cl', 100, 3.16, 35.4527, 'rgb(153,242,57)' );
  Element.F = new Element( 'F', 72, 3.98, 18.9984032, 'rgb(247,255,74)' );
  Element.H = new Element( 'H', 37, 2.20, 1.00794, '#ffffff' );
  Element.I = new Element( 'I', 133, 2.66, 126.90447, '#940094' ); // dark violet, CPK coloring
  Element.N = new Element( 'N', 75, 3.04, 14.00674, '#0000ff' );
  Element.Ne = new Element( 'Ne', 69, null, 20.1797, '#1AFFFB' );
  Element.O = new Element( 'O', 73, 3.44, 15.9994, PhetColorScheme.RED_COLORBLIND );
  Element.P = new Element( 'P', 110, 2.19, 30.973762, 'rgb(255,128,0)' );
  Element.S = new Element( 'S', 103, 2.58, 32.066, 'rgb(212,181,59)' );
  Element.Si = new Element( 'Si', 118, 1.90, 28.0855, 'rgb(240,200,160)' ); // tan, Jmol coloring listed from https://secure.wikimedia.org/wikipedia/en/wiki/CPK_coloring
  Element.Sn = new Element( 'Sn', 145, 1.96, 118.710, '#668080' ); // tin
  Element.Xe = new Element( 'Xe', 108, 2.60, 131.293, '#429eb0' ); // radius is based on calculated (not empirical) data

  Element.elements = [
    Element.B, Element.Be, Element.Br, Element.C, Element.Cl, Element.F, Element.H,
    Element.I, Element.N, Element.O, Element.P, Element.S, Element.Si, Element.Xe
  ];

  // maps symbol => element
  Element.elementMap = {};
  _.each( Element.elements, function( element ) {
    Element.elementMap[ element.symbol ] = element;
  } );

  Element.getElementBySymbol = function( symbol ) {
    assert && assert( Element.elementMap[ symbol ], 'Element not found: ' + symbol );
    return Element.elementMap[ symbol ];
  };

  return Element;
} );
<|endoftext|>


<commit_before>// Copyright 2002-2013, University of Colorado Boulder

/**
 * Horizontal slider.
 *
 * Moved from beers-law-lab/EvaporationSlider on 9/15/2013
 * see https://github.com/phetsims/sun/issues/9
 *
 * @author Chris Malley (PixelZoom, Inc.)
 */
define( function( require ) {
  'use strict';

  // modules
  var Dimension2 = require( 'DOT/Dimension2' );
  var FillHighlightListener = require( 'SCENERY_PHET/input/FillHighlightListener' );
  var inherit = require( 'PHET_CORE/inherit' );
  var LinearFunction = require( 'DOT/LinearFunction' );
  var Node = require( 'SCENERY/nodes/Node' );
  var Path = require( 'SCENERY/nodes/Path' );
  var Property = require( 'AXON/Property' );
  var Rectangle = require( 'SCENERY/nodes/Rectangle' );
  var Shape = require( 'KITE/Shape' );
  var SimpleDragHandler = require( 'SCENERY/input/SimpleDragHandler' );

  /**
   * @param {Property<Number>} valueProperty
   * @param { {min:Number, max:Number} } range
   * @param {*} options
   * @constructor
   */
  function HSlider( valueProperty, range, options ) {

    var thisSlider = this;
    Node.call( thisSlider );

    // default options, these will not be passed to supertype
    options = _.extend( {
      // track
      trackSize: new Dimension2( 100, 5 ),
      trackFill: 'white',
      trackStroke: 'black',
      trackLineWidth: 1,
      // thumb
      thumbSize: new Dimension2( 22, 45 ),
      thumbFillEnabled: 'rgb(50,145,184)',
      thumbFillHighlighted: 'rgb(71,207,255)',
      thumbFillDisabled: '#F0F0F0',
      thumbStroke: 'black',
      thumbLineWidth: 1,
      // ticks
      tickLabelSpacing: 6,
      majorTickLength: 25,
      majorTickStroke: 'black',
      majorTickLineWidth: 1,
      minorTickLength: 10,
      minorTickStroke: 'black',
      minorTickLineWidth: 1,
      // other
      cursor: 'pointer',
      enabledProperty: new Property( true ),
      startDrag: function() {}, // called when a drag sequence starts
      endDrag: function() {} // called when a drag sequence ends
    }, options );
    this.options = options; // @private TODO save only the options that are needed by prototype functions

    // @private ticks are added to this parent, so they are behind knob
    thisSlider.ticksParent = new Node();
    thisSlider.addChild( thisSlider.ticksParent );

    // @private mapping between value and track position
    thisSlider.valueToPosition = new LinearFunction( range.min, range.max, 0, options.trackSize.width, true /* clamp */ );

    // @private track
    thisSlider.track = new Rectangle( 0, 0, options.trackSize.width, options.trackSize.height,
      { fill: options.trackFill, stroke: options.trackStroke, lineWidth: options.trackLineWidth } );
    thisSlider.addChild( thisSlider.track );

    // click in the track to change the value, continue dragging if desired
    var trackHandler = new SimpleDragHandler( {
      handleTrackEvent: function( event ) {
        if ( options.enabledProperty.get() ) {
          var x = thisSlider.track.globalToLocalPoint( event.pointer.point ).x;
          valueProperty.set( thisSlider.valueToPosition.inverse( x ) );
        }
      },
      start: function( event ) {
        if ( options.enabledProperty.get() ) {
          options.startDrag();
        }
        this.handleTrackEvent( event );
      },
      drag: function( event ) {
        this.handleTrackEvent( event );
      },
      end: function() {
        if ( options.enabledProperty.get() ) {
          options.endDrag();
        }
      }
    } );
    thisSlider.track.addInputListener( trackHandler );

    // thumb, points up
    var arcWidth = 0.25 * options.thumbSize.width;
    var thumbFill = options.enabledProperty.get() ? options.thumbFillEnabled : options.thumbFillDisabled;
    var thumb = new Rectangle( -options.thumbSize.width / 2, -options.thumbSize.height / 2, options.thumbSize.width, options.thumbSize.height, arcWidth, arcWidth,
      { cursor: options.cursor, fill: thumbFill, stroke: options.thumbStroke, lineWidth: options.thumbLineWidth } );
    var centerLineYMargin = 3;
    thumb.addChild( new Path( Shape.lineSegment( 0, -( options.thumbSize.height / 2 ) + centerLineYMargin, 0, ( options.thumbSize.height / 2 ) - centerLineYMargin ), { stroke: 'white' } ) );
    thumb.centerY = thisSlider.track.centerY;
    thisSlider.addChild( thumb );

    // thumb touch area
    var dx = 0.5 * thumb.width;
    var dy = 0.25 * thumb.height;
    thumb.touchArea = Shape.rectangle( ( -thumb.width / 2 ) - dx, ( -thumb.height / 2 ) - dy, thumb.width + dx + dx, thumb.height + dy + dy );

    // highlight on mouse enter
    thumb.addInputListener( new FillHighlightListener( options.thumbFillEnabled, options.thumbFillHighlighted, options.enabledProperty ) );

    // update value when thumb is dragged
    var thumbHandler = new SimpleDragHandler( {
      clickXOffset: 0, // x-offset between initial click and thumb's origin
      allowTouchSnag: true,
      start: function( event ) {
        if ( options.enabledProperty.get() ) {
          options.startDrag();
        }
        this.clickXOffset = thumb.globalToParentPoint( event.pointer.point ).x - thumb.x;
      },
      drag: function( event ) {
        if ( options.enabledProperty.get() ) {
          var x = thumb.globalToParentPoint( event.pointer.point ).x - this.clickXOffset;
          valueProperty.set( thisSlider.valueToPosition.inverse( x ) );
        }
      },
      end: function() {
        if ( options.enabledProperty.get() ) {
          options.endDrag();
        }
      }
    } );
    thumb.addInputListener( thumbHandler );

    // enable/disable thumb
    options.enabledProperty.link( function( enabled ) {
      thumb.fill = enabled ? options.thumbFillEnabled : options.thumbFillDisabled;
      thumb.cursor = enabled ? 'pointer' : 'default';
      if ( !enabled ) {
        if ( thumbHandler.dragging ) { thumbHandler.endDrag(); }
        if ( trackHandler.dragging ) { trackHandler.endDrag(); }
      }
    } );

    // update thumb location when value changes
    valueProperty.link( function( value ) {
      thumb.centerX = thisSlider.valueToPosition( value );
    } );

    thisSlider.mutate( options );
  }

  inherit( Node, HSlider, {

    /**
     * Adds a major tick mark.
     * @param {Number} value
     * @param {Node} label optional
     */
    addMajorTick: function( value, label ) {
      this.addTick( value, label, this.options.majorTickLength, this.options.majorTickStroke, this.options.majorTickLineWidth );
    },

    /**
     * Adds a minor tick mark.
     * @param {Number} value
     * @param {Node} label optional
     */
    addMinorTick: function( value, label ) {
      this.addTick( value, label, this.options.minorTickLength, this.options.minorTickStroke, this.options.minorTickLineWidth );
    },

    /*
     * Adds a tick mark above the track.
     * @param {Number} value
     * @param {Node} label optional
     * @param {Number} length
     * @param {Number} stroke
     * @param {Number} lineWidth
     * @private
     */
    addTick: function( value, label, length, stroke, lineWidth ) {
      var labelX = this.valueToPosition( value );
      // ticks
      var tick = new Path( new Shape()
        .moveTo( labelX, this.track.top )
        .lineTo( labelX, this.track.top - length ),
        { stroke: stroke, lineWidth: lineWidth } );
      this.ticksParent.addChild( tick );
      // label
      if ( label ) {
        this.ticksParent.addChild( label );
        label.centerX = tick.centerX;
        label.bottom = tick.top - this.options.tickLabelSpacing;
      }
    }
  } );

  return HSlider;
} );<commit_msg>#113 replace vestigial doc about defaultOptions<commit_after>// Copyright 2002-2013, University of Colorado Boulder

/**
 * Horizontal slider.
 *
 * Moved from beers-law-lab/EvaporationSlider on 9/15/2013
 * see https://github.com/phetsims/sun/issues/9
 *
 * @author Chris Malley (PixelZoom, Inc.)
 */
define( function( require ) {
  'use strict';

  // modules
  var Dimension2 = require( 'DOT/Dimension2' );
  var FillHighlightListener = require( 'SCENERY_PHET/input/FillHighlightListener' );
  var inherit = require( 'PHET_CORE/inherit' );
  var LinearFunction = require( 'DOT/LinearFunction' );
  var Node = require( 'SCENERY/nodes/Node' );
  var Path = require( 'SCENERY/nodes/Path' );
  var Property = require( 'AXON/Property' );
  var Rectangle = require( 'SCENERY/nodes/Rectangle' );
  var Shape = require( 'KITE/Shape' );
  var SimpleDragHandler = require( 'SCENERY/input/SimpleDragHandler' );

  /**
   * @param {Property<Number>} valueProperty
   * @param { {min:Number, max:Number} } range
   * @param {*} options
   * @constructor
   */
  function HSlider( valueProperty, range, options ) {

    var thisSlider = this;
    Node.call( thisSlider );

    options = _.extend( {
      // track
      trackSize: new Dimension2( 100, 5 ),
      trackFill: 'white',
      trackStroke: 'black',
      trackLineWidth: 1,
      // thumb
      thumbSize: new Dimension2( 22, 45 ),
      thumbFillEnabled: 'rgb(50,145,184)',
      thumbFillHighlighted: 'rgb(71,207,255)',
      thumbFillDisabled: '#F0F0F0',
      thumbStroke: 'black',
      thumbLineWidth: 1,
      // ticks
      tickLabelSpacing: 6,
      majorTickLength: 25,
      majorTickStroke: 'black',
      majorTickLineWidth: 1,
      minorTickLength: 10,
      minorTickStroke: 'black',
      minorTickLineWidth: 1,
      // other
      cursor: 'pointer',
      enabledProperty: new Property( true ),
      startDrag: function() {}, // called when a drag sequence starts
      endDrag: function() {} // called when a drag sequence ends
    }, options );
    this.options = options; // @private TODO save only the options that are needed by prototype functions

    // @private ticks are added to this parent, so they are behind knob
    thisSlider.ticksParent = new Node();
    thisSlider.addChild( thisSlider.ticksParent );

    // @private mapping between value and track position
    thisSlider.valueToPosition = new LinearFunction( range.min, range.max, 0, options.trackSize.width, true /* clamp */ );

    // @private track
    thisSlider.track = new Rectangle( 0, 0, options.trackSize.width, options.trackSize.height,
      { fill: options.trackFill, stroke: options.trackStroke, lineWidth: options.trackLineWidth } );
    thisSlider.addChild( thisSlider.track );

    // click in the track to change the value, continue dragging if desired
    var trackHandler = new SimpleDragHandler( {
      handleTrackEvent: function( event ) {
        if ( options.enabledProperty.get() ) {
          var x = thisSlider.track.globalToLocalPoint( event.pointer.point ).x;
          valueProperty.set( thisSlider.valueToPosition.inverse( x ) );
        }
      },
      start: function( event ) {
        if ( options.enabledProperty.get() ) {
          options.startDrag();
        }
        this.handleTrackEvent( event );
      },
      drag: function( event ) {
        this.handleTrackEvent( event );
      },
      end: function() {
        if ( options.enabledProperty.get() ) {
          options.endDrag();
        }
      }
    } );
    thisSlider.track.addInputListener( trackHandler );

    // thumb, points up
    var arcWidth = 0.25 * options.thumbSize.width;
    var thumbFill = options.enabledProperty.get() ? options.thumbFillEnabled : options.thumbFillDisabled;
    var thumb = new Rectangle( -options.thumbSize.width / 2, -options.thumbSize.height / 2, options.thumbSize.width, options.thumbSize.height, arcWidth, arcWidth,
      { cursor: options.cursor, fill: thumbFill, stroke: options.thumbStroke, lineWidth: options.thumbLineWidth } );
    var centerLineYMargin = 3;
    thumb.addChild( new Path( Shape.lineSegment( 0, -( options.thumbSize.height / 2 ) + centerLineYMargin, 0, ( options.thumbSize.height / 2 ) - centerLineYMargin ), { stroke: 'white' } ) );
    thumb.centerY = thisSlider.track.centerY;
    thisSlider.addChild( thumb );

    // thumb touch area
    var dx = 0.5 * thumb.width;
    var dy = 0.25 * thumb.height;
    thumb.touchArea = Shape.rectangle( ( -thumb.width / 2 ) - dx, ( -thumb.height / 2 ) - dy, thumb.width + dx + dx, thumb.height + dy + dy );

    // highlight on mouse enter
    thumb.addInputListener( new FillHighlightListener( options.thumbFillEnabled, options.thumbFillHighlighted, options.enabledProperty ) );

    // update value when thumb is dragged
    var thumbHandler = new SimpleDragHandler( {
      clickXOffset: 0, // x-offset between initial click and thumb's origin
      allowTouchSnag: true,
      start: function( event ) {
        if ( options.enabledProperty.get() ) {
          options.startDrag();
        }
        this.clickXOffset = thumb.globalToParentPoint( event.pointer.point ).x - thumb.x;
      },
      drag: function( event ) {
        if ( options.enabledProperty.get() ) {
          var x = thumb.globalToParentPoint( event.pointer.point ).x - this.clickXOffset;
          valueProperty.set( thisSlider.valueToPosition.inverse( x ) );
        }
      },
      end: function() {
        if ( options.enabledProperty.get() ) {
          options.endDrag();
        }
      }
    } );
    thumb.addInputListener( thumbHandler );

    // enable/disable thumb
    options.enabledProperty.link( function( enabled ) {
      thumb.fill = enabled ? options.thumbFillEnabled : options.thumbFillDisabled;
      thumb.cursor = enabled ? 'pointer' : 'default';
      if ( !enabled ) {
        if ( thumbHandler.dragging ) { thumbHandler.endDrag(); }
        if ( trackHandler.dragging ) { trackHandler.endDrag(); }
      }
    } );

    // update thumb location when value changes
    valueProperty.link( function( value ) {
      thumb.centerX = thisSlider.valueToPosition( value );
    } );

    thisSlider.mutate( options );
  }

  inherit( Node, HSlider, {

    /**
     * Adds a major tick mark.
     * @param {Number} value
     * @param {Node} label optional
     */
    addMajorTick: function( value, label ) {
      this.addTick( value, label, this.options.majorTickLength, this.options.majorTickStroke, this.options.majorTickLineWidth );
    },

    /**
     * Adds a minor tick mark.
     * @param {Number} value
     * @param {Node} label optional
     */
    addMinorTick: function( value, label ) {
      this.addTick( value, label, this.options.minorTickLength, this.options.minorTickStroke, this.options.minorTickLineWidth );
    },

    /*
     * Adds a tick mark above the track.
     * @param {Number} value
     * @param {Node} label optional
     * @param {Number} length
     * @param {Number} stroke
     * @param {Number} lineWidth
     * @private
     */
    addTick: function( value, label, length, stroke, lineWidth ) {
      var labelX = this.valueToPosition( value );
      // ticks
      var tick = new Path( new Shape()
        .moveTo( labelX, this.track.top )
        .lineTo( labelX, this.track.top - length ),
        { stroke: stroke, lineWidth: lineWidth } );
      this.ticksParent.addChild( tick );
      // label
      if ( label ) {
        this.ticksParent.addChild( label );
        label.centerX = tick.centerX;
        label.bottom = tick.top - this.options.tickLabelSpacing;
      }
    }
  } );

  return HSlider;
} );<|endoftext|>


<commit_before>//Get Github Authorization Token with proper scope, print to console
var githubToken = null;
function getAuth(username, password) {
    var deferred = $.Deferred();
    var auth = username + ":" + password;
    $.ajax({
        url: 'https://api.github.com/authorizations',
        type: 'POST',
        beforeSend: function (xhr) {
            xhr.setRequestHeader("Authorization", "Basic " + btoa(auth));
        },
        data: '{"scopes":["gist"],"note":"Chocolaty and Boxstarter automation' + Math.ceil(Math.random() * 1000) + '"}'
    }).done(function (response) {
        deferred.resolve(response);
        githubToken = response.token;
        setCookie('token', githubToken, 7);
        $("#APIKey").val(githubToken);
        createGist(githubToken, JSON.stringify($("#autoGenerator").text()));
        githubToken ? $("#loginCredentials").hide() : $("#APICredentials").show();
        console.log(response);
    });

    return deferred;
}
function submitUnPw() {
    var token = $("#APIKey").val();
    token ? createGist(githubToken, JSON.stringify($("#autoGenerator").text())) :getAuth($("#GithubUsername").val(), $("#GithubPassword").val());
}
var gist = null;
//Create a Gist with token from above
function createGist(token, gist) {
    var body = '{"description": "a gist for a user with token api call via ajax","public": true,"files": {"boxstarter.ps1": {"content": ' + gist + '}}}';
    $.ajax({
        url: 'https://api.github.com/gists',
        type: 'POST',
        beforeSend: function (xhr) {
            xhr.setRequestHeader("Authorization", "token " + token);
        },
        data: body,
    }).done(function (response) {
        console.log(response);
        gist = response;
        var url = gist.files["boxstarter.ps1"].raw_url;
        $('#viewGist').append("
Start Installer

");
        $('#viewGist').append("View Gist");

    });

}
var queryResponse = null;
function randomApiSearch(query) {
    var deferred = $.Deferred();
    // var url = "https://chocolatey.org/api/v2/Search()?$filter=IsLatestVersion&$orderby=Id&$skip=0&$top=50&searchTerm='" + encodeURIComponent(query) + "'&targetFramework=''&includePrerelease=false";
    var url = "https://chocolatey.org/api/v2/Packages()?$filter=(IsPrerelease%20eq%20false%20or%20IsPrerelease%20eq%20false)%20and%20(IsLatestVersion%20or%20IsAbsoluteLatestVersion)%20and%20(substringof('" + encodeURIComponent(query) + "',Id)%20or%20substringof('" + encodeURIComponent(query) + "',Title))&$skip=0&$top=50"
    var yql = 'https://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent('select * from xml where url="' + url + '"') + '&format=xml&callback=?';

    // Request that YSQL string, and run a callback function.
    // Pass a defined function to prevent cache-busting.
    $.getJSON(yql, function (data) {
        var x2js = new X2JS();
        queryResponse = x2js.xml_str2json(data.results[0]);
        deferred.resolve(queryResponse);
        console.log(queryResponse);
        compileHtml();
    });

    return deferred;
}
function compileHtml() {
    var template = Handlebars.compile($('#search').html());
    var html = template(queryResponse);
    $('#results').html(html);
}
function searchQuery() {
    $("#results").html('
Loading...
');
    randomApiSearch($("#searchQuery").val());
}
var currentPrograms = []
function addToInstallScript(item, index) {
    var found = currentPrograms.indexOf(item);
    if (found > -1) {
        currentPrograms.splice(found, 1);
    } else {
        currentPrograms.push(item);
    }
    $("#searchResult" + index).html(checkInstall(item, null))
    var currentInstall = JSON.stringify(currentPrograms);
    setCookie('ChocoStarter', currentInstall, 7);
    updateCodeDisplay();
    console.log(currentPrograms);
}
function updateCodeDisplay() {
    var buffer = "\n#Install Script Generated by: https://dhruvb14.github.io\n";
    buffer += "# Inspiration borrowed from http://blog.zerosharp.com/provisioning-a-new-development-machine-with-boxstarter/\n";
    buffer += "# Boxstarter options\n";
    buffer += "$Boxstarter.RebootOk=$true # Allow reboots?\n";
    buffer += "$Boxstarter.NoPassword=$false # Is this a machine with no login password?\n";
    buffer += "$Boxstarter.AutoLogin=$true # Save my password securely and auto-login after a reboot\n";
    $.each(currentPrograms, function (index, value) {
        buffer += "if (Test-PendingReboot) { Invoke-Reboot }\n" + value + "\n";
    })
    $("#autoGenerator").text(buffer)
    Prism.highlightAll()
}
$(document).ready(function () {
    loadTemplates();
    var cookie = getCookie("ChocoStarter");
    currentPrograms = cookie ? JSON.parse(cookie) : [];
    cookie = getCookie('token');
    githubToken = cookie ? cookie : [];
    $("#APIKey").val(githubToken);
    githubToken ? $("#loginCredentials").hide() : $("#APICredentials").hide();
    updateCodeDisplay()
    $('#searchQuery').keypress(function (e) {
        if (e.which == 13) {
            searchQuery();
            return false;    //<---- Add this line
        }
    });
});
function loadTemplates() {
    $("#searchTemplate").load("search.html");
    $("#tabsTemplate").load("tabs.html", function () {
        getPredefinedPackages();
    });
}
function getPredefinedPackages(){
    $.ajax({
        url: 'predefinedpackages.json',
        type: 'get',
    }).done(function (response) {
        var template = Handlebars.compile($('#tabs').html());
        var html = template(response);
        $('#info').html(html);
    });
}

Handlebars.registerHelper('imageProxy', function (context, options) {
    var url = "www.acsu.buffalo.edu/~rslaine/imageNotFound.jpg"
    if (context) {
        url = context.replace("http://", "");
        url = url.replace("https://", "");
    }
    return "https://images.weserv.nl/?url=" + url + "&w=100&h=100&t=square&a=center&t=fitup";
});
function checkInstall(context, options) {
    var check = '';
    var ret = '';
    $.each(currentPrograms, function (index, value) {
        if (context == value) {
            ret = check;
        }
    })
    return ret;
}
Handlebars.registerHelper('checkInstall', checkInstall);
Handlebars.registerHelper("moduloIf", function(index_count,mod,block) {
  if(parseInt(index_count)%(mod)=== 0){
    return block.fn(this);}
});

Handlebars.registerHelper("DateFormatter", function(input,caller) {
return moment(input).format("dddd, MMMM Do YYYY, h:mm:ss a");
});

function setCookie(cname, cvalue, exdays) {
    var d = new Date();
    d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
    var expires = "expires=" + d.toUTCString();
    document.cookie = cname + "=" + cvalue + "; " + expires;
}
function getCookie(cname) {
    var name = cname + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') {
            c = c.substring(1);
        }
        if (c.indexOf(name) == 0) {
            return c.substring(name.length, c.length);
        }
    }
    return "";
}

//Using Gist ID from the response above, we edit the Gist with Ajax PATCH request
// $.ajax({
//     url: 'https://api.github.com/gists/GIST-ID-FROM-PREVIOUS-CALL',
//     type: 'PATCH',
//     beforeSend: function (xhr) {
//         xhr.setRequestHeader("Authorization", "token TOKEN-FROM-AUTHORIZATION-CALL");
//     },
//     data: '{"description": "updated gist via ajax","public": true,"files": {"file1.txt": {"content": "updated String file contents via ajax"}}}'
// }).done(function (response) {
//     console.log(response);
// });<commit_msg>Fix auth bug missed in last checkin<commit_after>//Get Github Authorization Token with proper scope, print to console
var githubToken = null;
function getAuth(username, password) {
    var deferred = $.Deferred();
    var auth = username + ":" + password;
    $.ajax({
        url: 'https://api.github.com/authorizations',
        type: 'POST',
        beforeSend: function (xhr) {
            xhr.setRequestHeader("Authorization", "Basic " + btoa(auth));
        },
        data: '{"scopes":["gist"],"note":"Chocolaty and Boxstarter automation' + Math.ceil(Math.random() * 1000) + '"}'
    }).done(function (response) {
        deferred.resolve(response);
        githubToken = response.token;
        setCookie('token', githubToken, 7);
        $("#APIKey").val(githubToken);
        createGist(githubToken, JSON.stringify($("#autoGenerator").text()));
        githubToken ? $("#loginCredentials").hide() : $("#APICredentials").show();
        console.log(response);
    });

    return deferred;
}
function submitUnPw() {
    var token = $("#APIKey").val();
    token ? createGist(githubToken, JSON.stringify($("#autoGenerator").text())) :getAuth($("#GithubUsername").val(), $("#GithubPassword").val());
}
var gist = null;
//Create a Gist with token from above
function createGist(token, gist) {
    var body = '{"description": "a gist for a user with token api call via ajax","public": true,"files": {"boxstarter.ps1": {"content": ' + gist + '}}}';
    $.ajax({
        url: 'https://api.github.com/gists',
        type: 'POST',
        beforeSend: function (xhr) {
            xhr.setRequestHeader("Authorization", "token " + token);
        },
        data: body,
    }).done(function (response) {
        console.log(response);
        gist = response;
        var url = gist.files["boxstarter.ps1"].raw_url;
        $('#viewGist').append("
Start Installer

");
        $('#viewGist').append("View Gist");

    });

}
var queryResponse = null;
function randomApiSearch(query) {
    var deferred = $.Deferred();
    // var url = "https://chocolatey.org/api/v2/Search()?$filter=IsLatestVersion&$orderby=Id&$skip=0&$top=50&searchTerm='" + encodeURIComponent(query) + "'&targetFramework=''&includePrerelease=false";
    var url = "https://chocolatey.org/api/v2/Packages()?$filter=(IsPrerelease%20eq%20false%20or%20IsPrerelease%20eq%20false)%20and%20(IsLatestVersion%20or%20IsAbsoluteLatestVersion)%20and%20(substringof('" + encodeURIComponent(query) + "',Id)%20or%20substringof('" + encodeURIComponent(query) + "',Title))&$skip=0&$top=50"
    var yql = 'https://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent('select * from xml where url="' + url + '"') + '&format=xml&callback=?';

    // Request that YSQL string, and run a callback function.
    // Pass a defined function to prevent cache-busting.
    $.getJSON(yql, function (data) {
        var x2js = new X2JS();
        queryResponse = x2js.xml_str2json(data.results[0]);
        deferred.resolve(queryResponse);
        console.log(queryResponse);
        compileHtml();
    });

    return deferred;
}
function compileHtml() {
    var template = Handlebars.compile($('#search').html());
    var html = template(queryResponse);
    $('#results').html(html);
}
function searchQuery() {
    $("#results").html('
Loading...
');
    randomApiSearch($("#searchQuery").val());
}
var currentPrograms = []
function addToInstallScript(item, index) {
    var found = currentPrograms.indexOf(item);
    if (found > -1) {
        currentPrograms.splice(found, 1);
    } else {
        currentPrograms.push(item);
    }
    $("#searchResult" + index).html(checkInstall(item, null))
    var currentInstall = JSON.stringify(currentPrograms);
    setCookie('ChocoStarter', currentInstall, 7);
    updateCodeDisplay();
    console.log(currentPrograms);
}
function updateCodeDisplay() {
    var buffer = "\n#Install Script Generated by: https://dhruvb14.github.io\n";
    buffer += "# Inspiration borrowed from http://blog.zerosharp.com/provisioning-a-new-development-machine-with-boxstarter/\n";
    buffer += "# Boxstarter options\n";
    buffer += "$Boxstarter.RebootOk=$true # Allow reboots?\n";
    buffer += "$Boxstarter.NoPassword=$false # Is this a machine with no login password?\n";
    buffer += "$Boxstarter.AutoLogin=$true # Save my password securely and auto-login after a reboot\n";
    $.each(currentPrograms, function (index, value) {
        buffer += "if (Test-PendingReboot) { Invoke-Reboot }\n" + value + "\n";
    })
    $("#autoGenerator").text(buffer)
    Prism.highlightAll()
}
$(document).ready(function () {
    loadTemplates();
    var cookie = getCookie("ChocoStarter");
    currentPrograms = cookie ? JSON.parse(cookie) : [];
    cookie = getCookie('token');
    githubToken = cookie ? cookie : undefined;
    $("#APIKey").val(githubToken);
    githubToken ? $("#loginCredentials").hide() : $("#APICredentials").hide();
    updateCodeDisplay()
    $('#searchQuery').keypress(function (e) {
        if (e.which == 13) {
            searchQuery();
            return false;    //<---- Add this line
        }
    });
});
function loadTemplates() {
    $("#searchTemplate").load("search.html");
    $("#tabsTemplate").load("tabs.html", function () {
        getPredefinedPackages();
    });
}
function getPredefinedPackages(){
    $.ajax({
        url: 'predefinedpackages.json',
        type: 'get',
    }).done(function (response) {
        var template = Handlebars.compile($('#tabs').html());
        var html = template(response);
        $('#info').html(html);
    });
}

Handlebars.registerHelper('imageProxy', function (context, options) {
    var url = "www.acsu.buffalo.edu/~rslaine/imageNotFound.jpg"
    if (context) {
        url = context.replace("http://", "");
        url = url.replace("https://", "");
    }
    return "https://images.weserv.nl/?url=" + url + "&w=100&h=100&t=square&a=center&t=fitup";
});
function checkInstall(context, options) {
    var check = '';
    var ret = '';
    $.each(currentPrograms, function (index, value) {
        if (context == value) {
            ret = check;
        }
    })
    return ret;
}
Handlebars.registerHelper('checkInstall', checkInstall);
Handlebars.registerHelper("moduloIf", function(index_count,mod,block) {
  if(parseInt(index_count)%(mod)=== 0){
    return block.fn(this);}
});

Handlebars.registerHelper("DateFormatter", function(input,caller) {
return moment(input).format("dddd, MMMM Do YYYY, h:mm:ss a");
});

function setCookie(cname, cvalue, exdays) {
    var d = new Date();
    d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
    var expires = "expires=" + d.toUTCString();
    document.cookie = cname + "=" + cvalue + "; " + expires;
}
function getCookie(cname) {
    var name = cname + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') {
            c = c.substring(1);
        }
        if (c.indexOf(name) == 0) {
            return c.substring(name.length, c.length);
        }
    }
    return "";
}

//Using Gist ID from the response above, we edit the Gist with Ajax PATCH request
// $.ajax({
//     url: 'https://api.github.com/gists/GIST-ID-FROM-PREVIOUS-CALL',
//     type: 'PATCH',
//     beforeSend: function (xhr) {
//         xhr.setRequestHeader("Authorization", "token TOKEN-FROM-AUTHORIZATION-CALL");
//     },
//     data: '{"description": "updated gist via ajax","public": true,"files": {"file1.txt": {"content": "updated String file contents via ajax"}}}'
// }).done(function (response) {
//     console.log(response);
// });<|endoftext|>


<commit_before>/**
 * Copyright (c) 2011 David Bruant & Damien Riccio
 * MIT Licence
 */

function Ludesik(renderer, menu){
    var map = new Map();
    var counter = 0;
    var soundPlayer;
    var intervalRef;
    var isPlaying = false;

    var playBtn;
    var pauseBtn;
    var slowFrequencyBtn;
    var frequencyInput;
    var speedFrequencyBtn;
    var saveBtn;
    var savedStateContainer;

    function addMobileAgentWithDirection(position, direction) {
        map.addMobileAgent(counter, position, direction);
        renderer.addMobileAgent(counter, position, direction);

        counter++;
    }

    function addMobileAgent(position) {
        var defaultDirection = {deltaX: 1, deltaY: 0};
        addMobileAgentWithDirection(position, defaultDirection);
    }

    function onMobileAgentInteraction(id) {
        return map.onMobileAgentInteraction(id);
    }

    function tick() {
        var result = map.nextStep();

        soundPlayer.playAll(result.wallsInCollision);

        renderer.refresh(result);
    }

    function play () {
        isPlaying = true;
        playBtn.disabled = true;
        pauseBtn.disabled = false;
        intervalRef = setInterval(tick, frequencyInput.value);
    }

    function pause () {
        isPlaying = false;
        playBtn.disabled = false;
        pauseBtn.disabled = true;
        clearInterval(intervalRef);
    }

    function slowFrequency() {
        frequencyInput.value = Number(frequencyInput.value) - 100;

        if (frequencyInput.value === 0) {
            slowFrequencyBtn.disabled = true;
        }

        if (isPlaying) {
            pause();
            play();
        }
    }

    function speedFrequency() {
        frequencyInput.value = Number(frequencyInput.value) + 100;

        if (isPlaying) {
            pause();
            play();
        }
    }

    function clear() {
        counter = 0;
        map.clear();
        renderer.clear();
    }

    function loadState(url) {
        clear();

        var split = url.split(";");
        frequencyInput.value = split[0];

        for (var i=3; i< split.length; i+=4) {
            addMobileAgentWithDirection({x: Number(split[i]), y: Number(split[i+1])}, {deltaX: Number(split[i+2]), deltaY: Number(split[i+3])});
        }
    }

    function addSavedStateIntoContainer(url) {
        var savedState =  document.createElement('div');
        savedState.textContent = 'Test ' + url;
        savedState.addEventListener('click', function (){loadState(url)}, false);
        savedStateContainer.appendChild(savedState);
    }

    function saveState() {
        var currentPositions = map.getPositions();

        var url = '';

        url += frequencyInput.value;
        url += ';9;9';

         currentPositions.positions.forEach(
			function (e, i, a) {
                url += ';' + e.position.x + ';' + e.position.y + ';' + e.direction.deltaX + ';' + e.direction.deltaY;
            }
        );

        addSavedStateIntoContainer(url)

        console.log(url);
    }

    renderer.setOnSquareInteraction(addMobileAgent);
    renderer.setOnMobileAgentInteraction(onMobileAgentInteraction);

    (function(){
        var ids = map.getWallIds();
        var soundsInit = {};

        ids.forEach(function(id, i){
            // not our files. Begging for people to create us awesome tones
            soundsInit[id] = "http://dl.dropbox.com/u/20485/otomata/sounds/" + i%9 + ".ogg";
        });

        soundPlayer = new SoundPlayer(document.getElementById('audios'), soundsInit);
    })();

    (function() {
        playBtn =  document.createElement('button');
        playBtn.textContent = 'Play';
        playBtn.disabled = false;
        playBtn.addEventListener('click', play, false);
        menu.appendChild(playBtn);

        pauseBtn =  document.createElement('button');
        pauseBtn.textContent = 'Pause';
        pauseBtn.disabled = true;
        pauseBtn.addEventListener('click', pause, false);
        menu.appendChild(pauseBtn);

        saveBtn =  document.createElement('button');
        saveBtn.textContent = 'Sauver';
        saveBtn.addEventListener('click', saveState, false);
        menu.appendChild(saveBtn);

        var frequencyContainer = document.createElement('div');

        slowFrequencyBtn =  document.createElement('button');
        slowFrequencyBtn.textContent = '-';
        slowFrequencyBtn.addEventListener('click', slowFrequency, false);
        frequencyContainer.appendChild(slowFrequencyBtn);

        frequencyInput = document.createElement('input');
        frequencyInput.value = 1000;
        frequencyContainer.appendChild(frequencyInput);

        speedFrequencyBtn =  document.createElement('button');
        speedFrequencyBtn.textContent = '+';
        speedFrequencyBtn.addEventListener('click', speedFrequency, false);
        frequencyContainer.appendChild(speedFrequencyBtn);

        menu.appendChild(frequencyContainer);

        savedStateContainer = document.createElement('div');
        menu.appendChild(savedStateContainer);
    }).call(this);
}
<commit_msg>changing millisencond frequency to tempo<commit_after>/**
 * Copyright (c) 2011 David Bruant & Damien Riccio
 * MIT Licence
 */

function Ludesik(renderer, menu){
    var map = new Map();
    var counter = 0;
    var soundPlayer;
    var intervalRef;
    var isPlaying = false;

    var playBtn;
    var pauseBtn;
    var slowFrequencyBtn;
    var frequencyInput;
    var speedFrequencyBtn;
    var saveBtn;
    var savedStateContainer;

    function addMobileAgentWithDirection(position, direction) {
        map.addMobileAgent(counter, position, direction);
        renderer.addMobileAgent(counter, position, direction);

        counter++;
    }

    function addMobileAgent(position) {
        var defaultDirection = {deltaX: 1, deltaY: 0};
        addMobileAgentWithDirection(position, defaultDirection);
    }

    function onMobileAgentInteraction(id) {
        return map.onMobileAgentInteraction(id);
    }

    function tick() {
        var result = map.nextStep();

        soundPlayer.playAll(result.wallsInCollision);

        renderer.refresh(result);
    }

    function play () {
        isPlaying = true;
        playBtn.disabled = true;
        pauseBtn.disabled = false;
        intervalRef = setInterval(tick, 60/parseInt(frequencyInput.value) * 1000);
    }

    function pause () {
        isPlaying = false;
        playBtn.disabled = false;
        pauseBtn.disabled = true;
        clearInterval(intervalRef);
    }

    function decreaseFrequency() {
        frequencyInput.value = parseInt(frequencyInput.value) - 1;

        if (frequencyInput.value === 0) {
            slowFrequencyBtn.disabled = true;
        }

        if (isPlaying) {
            pause();
            play();
        }
    }

    function increaseFrequency() {
        frequencyInput.value = parseInt(frequencyInput.value) + 1;

        if (isPlaying) {
            pause();
            play();
        }
    }

    function clear() {
        counter = 0;
        map.clear();
        renderer.clear();
    }

    function loadState(url) {
        clear();

        var split = url.split(";");
        frequencyInput.value = split[0];

        for (var i=3; i< split.length; i+=4) {
            addMobileAgentWithDirection({x: Number(split[i]), y: Number(split[i+1])}, {deltaX: Number(split[i+2]), deltaY: Number(split[i+3])});
        }
    }

    function addSavedStateIntoContainer(url) {
        var savedState =  document.createElement('div');
        savedState.textContent = 'Test ' + url;
        savedState.addEventListener('click', function (){loadState(url)}, false);
        savedStateContainer.appendChild(savedState);
    }

    function saveState() {
        var currentPositions = map.getPositions();

        var url = '';

        url += frequencyInput.value;
        url += ';9;9';

         currentPositions.positions.forEach(
			function (e, i, a) {
                url += ';' + e.position.x + ';' + e.position.y + ';' + e.direction.deltaX + ';' + e.direction.deltaY;
            }
        );

        addSavedStateIntoContainer(url)

        console.log(url);
    }

    renderer.setOnSquareInteraction(addMobileAgent);
    renderer.setOnMobileAgentInteraction(onMobileAgentInteraction);

    (function(){
        var ids = map.getWallIds();
        var soundsInit = {};

        ids.forEach(function(id, i){
            // not our files. Begging for people to create us awesome tones
            soundsInit[id] = "http://dl.dropbox.com/u/20485/otomata/sounds/" + i%9 + ".ogg";
        });

        soundPlayer = new SoundPlayer(document.getElementById('audios'), soundsInit);
    })();

    (function() {
        playBtn =  document.createElement('button');
        playBtn.textContent = 'Play';
        playBtn.disabled = false;
        playBtn.addEventListener('click', play, false);
        menu.appendChild(playBtn);

        pauseBtn =  document.createElement('button');
        pauseBtn.textContent = 'Pause';
        pauseBtn.disabled = true;
        pauseBtn.addEventListener('click', pause, false);
        menu.appendChild(pauseBtn);

        saveBtn =  document.createElement('button');
        saveBtn.textContent = 'Sauver';
        saveBtn.addEventListener('click', saveState, false);
        menu.appendChild(saveBtn);

        var frequencyContainer = document.createElement('div');

        slowFrequencyBtn =  document.createElement('button');
        slowFrequencyBtn.textContent = '-';
        slowFrequencyBtn.addEventListener('click', decreaseFrequency, false);
        frequencyContainer.appendChild(slowFrequencyBtn);

        frequencyInput = document.createElement('input');
        frequencyInput.type = "number";
        frequencyInput.value = 120;
        frequencyContainer.appendChild(frequencyInput);

        speedFrequencyBtn =  document.createElement('button');
        speedFrequencyBtn.textContent = '+';
        speedFrequencyBtn.addEventListener('click', increaseFrequency, false);
        frequencyContainer.appendChild(speedFrequencyBtn);

        menu.appendChild(frequencyContainer);

        savedStateContainer = document.createElement('div');
        menu.appendChild(savedStateContainer);
    }).call(this);
}
<|endoftext|>