<commit_before>define(
// Requirements
["lib/jquery"],

// Module definition
function () {

var MiniMap = function (config) {
    var self = this
        defaultConfig = {
            container : $("body"),
            cellSize  : 10,
            viewRadius: 5
        };

    config = $.extend({}, defaultConfig, config);

    // Make sure our container element is wrapped in jQuery.
    config.container = $(config.container);

    var _tiles;

    /**
     * Draw the map centering around the given position.
     *
     * @param {Number} x - X position.
     * @param {Number} y - Y position.
     * @param {Object} map - The Map Object to draw.
     */
    self.draw = function (x, y, map) {
        var tiles = map.getTilesInArea(x, y, config.viewRadius);
        var xi, yi, xlen, ylen;
        for(xi=0, xlen=_tiles.length; xi<xlen; xi++) {
            for(yi=0, ylen=_tiles[xi].length; yi<ylen; yi++) {
                self.drawTile(_tiles[xi][yi], tiles[xi][yi]);
            }
        }
    };

    /**
     * Draw an individual tile.
     *
     * @param {Object} tile - A Tile object.
     */
    self.drawTile = function (tileSprite, tileData) {
        if (tileData.passable) {
            tileSprite.css({
                "background": "white"
            });
        } else {
            tileSprite.css({
                "background": "black"
            });
        }
    }

    /**
     * Initializes the mini-map container and gets it ready to display a cross-
     * section of a map.
     * @private
     */
    function _initContainer () {
        // Set size of the view.
        config.container.css({
            width : ((config.viewRadius * 2) * config.cellSize) + "px",
            height: ((config.viewRadius * 2) * config.cellSize) + "px"
        });

        var xi = 0, xlen = (config.viewRadius * 2),
            yi = 0, ylen = (config.viewRadius * 2),
            tileEl = $("

");

        _tiles = [];

        for(; xi<xlen; xi++) {
            _tiles[xi] = [];
            for(yi=0; yi<ylen; yi++) {
                var t = tileEl.clone();
                t.css({
                    "top" : (yi * config.cellSize) + "px",
                    "left": (xi * config.cellSize) + "px",
                    "width" : config.cellSize + "px",
                    "height": config.cellSize + "px"
                });
                config.container.append(t);
                _tiles[xi][yi] = t;
            }
        }
    }

    // Initialize the MiniMap instance.
    _initContainer();
}

return MiniMap;

});<commit_msg>Rename _tiles to _tileSprites in mini-map.js<commit_after>define(
// Requirements
["lib/jquery"],

// Module definition
function () {

var MiniMap = function (config) {
    var self = this
        defaultConfig = {
            container : $("body"),
            cellSize  : 10,
            viewRadius: 5
        };

    config = $.extend({}, defaultConfig, config);

    // Make sure our container element is wrapped in jQuery.
    config.container = $(config.container);

    var _tileSprites;

    /**
     * Draw the map centering around the given position.
     *
     * @param {Number} x - X position.
     * @param {Number} y - Y position.
     * @param {Object} map - The Map Object to draw.
     */
    self.draw = function (x, y, map) {
        var tiles = map.getTilesInArea(x, y, config.viewRadius);
        var xi, yi, xlen, ylen;
        for(xi=0, xlen=_tileSprites.length; xi<xlen; xi++) {
            for(yi=0, ylen=_tileSprites[xi].length; yi<ylen; yi++) {
                self.drawTile(_tileSprites[xi][yi], tiles[xi][yi]);
            }
        }
    };

    /**
     * Draw an individual tile.
     *
     * @param {Object} tile - A Tile object.
     */
    self.drawTile = function (tileSprite, tileData) {
        if (tileData.passable) {
            tileSprite.css({
                "background": "white"
            });
        } else {
            tileSprite.css({
                "background": "black"
            });
        }
    }

    /**
     * Initializes the mini-map container and gets it ready to display a cross-
     * section of a map.
     * @private
     */
    function _initContainer () {
        // Set size of the view.
        config.container.css({
            width : ((config.viewRadius * 2) * config.cellSize) + "px",
            height: ((config.viewRadius * 2) * config.cellSize) + "px"
        });

        var xi = 0, xlen = (config.viewRadius * 2),
            yi = 0, ylen = (config.viewRadius * 2),
            tileEl = $("

");

        _tileSprites = [];

        for(; xi<xlen; xi++) {
            _tileSprites[xi] = [];
            for(yi=0; yi<ylen; yi++) {
                var t = tileEl.clone();
                t.css({
                    "top" : (yi * config.cellSize) + "px",
                    "left": (xi * config.cellSize) + "px",
                    "width" : config.cellSize + "px",
                    "height": config.cellSize + "px"
                });
                config.container.append(t);
                _tileSprites[xi][yi] = t;
            }
        }
    }

    // Initialize the MiniMap instance.
    _initContainer();
}

return MiniMap;

});<|endoftext|>


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

    function init() {
        trackPageView();
    }

    function trackPageView() {
        mixpanel.track('page viewed', {
            'page name' : document.title,
            'url' : window.location.pathname
        });
    }

    init();
})();<commit_msg>Track link clicks<commit_after>new (function() {
    "use strict";

    function init() {
        trackPageView();
        trackLinkClicks();
    }

    function trackPageView() {
        mixpanel.track('Page Viewed', {
            'Title' : document.title,
            'Url' : window.location.pathname
        });
    }

    function trackLinkClicks() {
        var anchors = document.getElementsByTagName("a");

        for (var i = 0; i < anchors.length ; i++) {
            anchors[i].addEventListener("click", linkClicked);
        }
    }

    function linkClicked() {
        mixpanel.track('Link Clicked', {
            'Title' : this.innerText,
            'Url' : this.href
        });
    }

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


<commit_before>window.Wind = (function (undefined) {
    'use strict';

    function _calculateRotate (p_touch_x, p_touch_y, p_target_x, p_target_y) {
        var _PI = Math.atan2(p_touch_x - p_target_x, p_touch_y - p_target_y);
        return (2 - (_PI/Math.PI + 1))*180;
    }

    return function (opt) {
        var options = {
            rotate: function () {},
            tap: function () {},
            panel: document.querySelector('.time-panel'),
            plate: document.querySelector('.upside'),
            main: document.querySelector('.main'),
            alarmPointer: document.querySelector('.time-alarm')
        };

        if (typeof opt === 'function') {
            options.tap = opt;
        } else {
            for (var key in opt) {
                options[key] = opt[key];
            }
        }

        var touch = false;

        options.main.addEventListener('touchmove', rotate, false);
        options.main.addEventListener('touchend', touchUp, false);
        options.main.addEventListener('touchcancel', touchUp, false);
        options.panel.addEventListener('click', touchUp, false);

        // to rotate the alarm pointer on move touch.
        function rotate (p_event) {
            p_event.preventDefault();

            touch = true;
            options.alarmPointer.style.display = 'block';
            var touchPos = p_event.touches[0];
            var rotate = _calculateRotate(touchPos.pageX, touchPos.pageY, options.plate.clientWidth*0.5, options.plate.clientHeight*0.5);
            _setRotateStyle(rotate);

        }

        function touchUp (p_event) {
            p_event.preventDefault();

            if (touch) {
                _touch(p_event);
            } else {
                _tap(p_event);
            }
        }

        function _touch (p_event) {
            touch = false;
            options.alarmPointer.style.display = 'none';
            var _transform = options.alarmPointer.style.transform;
            var _rotate = /(rotate[\s]*\()([\d.]+)/.exec(_transform);
            if (_rotate && _rotate[2]) {
                var angle = _rotate[2];
                options.rotate(angle);
            }
        }

        function _tap (p_event) {
            options.tap(p_event);
        }

        function _setRotateStyle (p_rotate) {
            var _prefix = ['webkit', 'moz', 'ms', 'o', ''];
            for (var i = 0; i < _prefix.length; i++) {
                if (_prefix[i].length > 0) {
                    _prefix[i] = '-' + _prefix[i] + '-';
                }
                options.pointer.style[_prefix[i] + 'transform'] = 'rotate(' + p_rotate + 'deg)';
            }
        }
    }
})();<commit_msg>rename pointer on wind<commit_after>window.Wind = (function (undefined) {
    'use strict';

    function _calculateRotate (p_touch_x, p_touch_y, p_target_x, p_target_y) {
        var _PI = Math.atan2(p_touch_x - p_target_x, p_touch_y - p_target_y);
        return (2 - (_PI/Math.PI + 1))*180;
    }

    return function (opt) {
        var options = {
            rotate: function () {},
            tap: function () {},
            panel: document.querySelector('.time-panel'),
            plate: document.querySelector('.upside'),
            main: document.querySelector('.main'),
            pointer: document.querySelector('.time-alarm')
        };

        if (typeof opt === 'function') {
            options.tap = opt;
        } else {
            for (var key in opt) {
                options[key] = opt[key];
            }
        }

        var touch = false;

        options.main.addEventListener('touchmove', rotate, false);
        options.main.addEventListener('touchend', touchUp, false);
        options.main.addEventListener('touchcancel', touchUp, false);
        options.panel.addEventListener('click', touchUp, false);

        // to rotate the alarm pointer on move touch.
        function rotate (p_event) {
            p_event.preventDefault();

            touch = true;
            options.pointer.style.display = 'block';
            var touchPos = p_event.touches[0];
            var rotate = _calculateRotate(touchPos.pageX, touchPos.pageY, options.plate.clientWidth*0.5, options.plate.clientHeight*0.5);
            _setRotateStyle(rotate);

        }

        function touchUp (p_event) {
            p_event.preventDefault();

            if (touch) {
                _touch(p_event);
            } else {
                _tap(p_event);
            }
        }

        function _touch (p_event) {
            touch = false;
            options.pointer.style.display = 'none';
            var _transform = options.pointer.style.transform;
            var _rotate = /(rotate[\s]*\()([\d.]+)/.exec(_transform);
            if (_rotate && _rotate[2]) {
                var angle = _rotate[2];
                options.rotate(angle);
            }
        }

        function _tap (p_event) {
            options.tap(p_event);
        }

        function _setRotateStyle (p_rotate) {
            var _prefix = ['webkit', 'moz', 'ms', 'o', ''];
            for (var i = 0; i < _prefix.length; i++) {
                if (_prefix[i].length > 0) {
                    _prefix[i] = '-' + _prefix[i] + '-';
                }
                options.pointer.style[_prefix[i] + 'transform'] = 'rotate(' + p_rotate + 'deg)';
            }
        }
    }
})();<|endoftext|>


<commit_before>$(function() {

  var elementHeader = document.getElementById('header');

  if (screen.width > 640) {

    // debugger;
    window.addEventListener('scroll', function(e) {

      var position = document.body.scrollTop;

      if (position < 800) {
        elementHeader.style.backgroundPositionY = (position / 1.5).toFixed(1) + 'px';
      }

    });
  }
});<commit_msg>removing debugger<commit_after>$(function() {

  var elementHeader = document.getElementById('header');

  if (screen.width > 640) {

    window.addEventListener('scroll', function(e) {

      var position = document.body.scrollTop;

      if (position < 800) {
        elementHeader.style.backgroundPositionY = (position / 1.5).toFixed(1) + 'px';
      }

    });
  }
});<|endoftext|>


<commit_before>
var bg = document.getElementById('bg');
var parallax = new Parallax(bg);

require('./lib/ruler.js');
require('./lib/dom.js');

var img1 = Qid('img1');
var img2 = Qid('img2');
var img3 = Qid('img3');
var img4 = Qid('img4');
addEvent(window , 'scroll' , function(){
	var persentage = scroller.getY() / scroller.getMaxY();
	img1.style.top = (-10 - 2*persentage).toString() + '%';
	img3.style.top = (-10 - 4*persentage).toString() + '%';
	img2.style.bottom = (-14 + 2*persentage).toString() + '%';
	img4.style.bottom = (-14 + 4*persentage).toString() + '%';
});<commit_msg>optimize scoll parallax<commit_after>
var bg = document.getElementById('bg');
var parallax = new Parallax(bg);

require('./lib/ruler.js');
require('./lib/dom.js');

var img1 = Qid('img1');
var img2 = Qid('img2');
var img3 = Qid('img3');
var img4 = Qid('img4');
addEvent(window , 'scroll' , function(){
	var persentage = scroller.getY() / scroller.getMaxY();
	img1.style.top = (-10 - 4*persentage).toString() + '%';
	img3.style.top = (-10 - 8*persentage).toString() + '%';
	img2.style.bottom = (-14 + 4*persentage).toString() + '%';
	img4.style.bottom = (-14 + 8*persentage).toString() + '%';
});<|endoftext|>


<commit_before>var pinBoard = (function($) {
	var pinBoardCover,
		canvas,
		context,
		height,
		width,
		pinPos=[],
		pencilPos=[],

		//Default pencil size
		pencilSize = 1,
		//Default Color
		color = "#2ecc71",
		//Default function (change between pin or pencil)
		functionality = "pencil",
		//Dynamic Color Panel (From Flat UI Color)
		optionColor = ["#2ecc71", "#27ae60", "#3498db", "#2980b9", "#9b59b6", "#8e44ad", "#f1c40f", "#f39c12", "#e67e22", "#d35400",
				"#e74c3c", "#c0392b", "#34495e", "#ecf0f1", "#bdc3c7", "#95a5a6", "#7f8c8d"];

	/*Prepare Stage
	** Build the infrastructure
	*/

	var Environment = {
		colorOptions : function() {
			var optionTemplate = "";
				for (var i = 0; i < optionColor.length; i++) {
					optionTemplate += '

';
				}
			return optionTemplate;
		},
		toolTemplate : function() {
			var content = "";
				content +='
'+
					'<button functionality="pin"></button>'+
					'<button functionality="pencil"></button>'+
					'<button functionality="backward"></button>'+
					'<button functionality="trashcan"></button>'+
					'<button functionality="download"></button>'+
					'<button functionality="upload"></button>'+
					'<input type="file">'+
					'<input type="range" min="1" max="10" value="1" />'+
					'
';

				content += this.colorOptions();

				content+='

';
				return content;
		},

		canvasTemplate : function() {
			return '<canvas width="'+width+'" height="'+height+'"></canvas>';
		},

		//Create Pinboard Canvas
		buildCanvas : function() {

			pinBoardCover.append(this.toolTemplate());
			pinBoardCover.append(this.canvasTemplate());

		    canvas = pinBoardCover.find("canvas");
		    context = canvas[0].getContext('2d');
		}
	};

	/*Utitliy Function
	*/
	function getMousePos(canvas, evt) {
        var rect = canvas.getBoundingClientRect();
        return {
          x: evt.clientX - rect.left,
          y: evt.clientY - rect.top
        };
    }

    /* =========================    User Interaction (Events) =================================*/
	function Init() {
		    //Pick Functionality
		    pinBoardCover.on("click", "button", function () {
		    	switch($(this).attr("functionality")) {
		    		case "backward":
		    			Tools.backward();
		    		break;

		    		case "trashcan":
		    			Tools.trashcan();
		    		break;

		    		case "download":
		    			Tools.download();
		    		break;

		    		case "upload":
		    			$('input[type=file]').trigger('click');
		    		break;

		    		default:
		    		functionality = $(this).attr("functionality");
		    	}
		    });

		    //Handle image Upload
		    pinBoardCover.on("change", "input[type=file]", function () {
		    		Tools.upload(this.files[0]);
		    });

		    //Select Pencil Size
		    pinBoardCover.on("mouseup", "input[type=range]", function () {
		    	pencilSize = $(this).val();
		    });

			//Pick Color
			pinBoardCover.on("click", ".pinBoard-color li", function () {
				color = $(this).attr("value");
				$(".pinBoard-color li").css("border", "none");
				$(this).css("border-right", "5px solid black");
		    });

		    //CORE FUNCTION
			pinBoardCover.on("mousedown", "canvas",function (evt) {
				var mousePos = getMousePos(this, evt);

				switch(functionality) {
					case 'pin' :
					    //Pin Something
					    Tools.createPin(mousePos.x, mousePos.y, color);
						pinPos.push({ 'x' : mousePos.x, 'y': mousePos.y, 'color': color});
					break;

					case 'pencil' :
						//Set pos to tempPencilPos and push it topencilpos when mouseUp
							isDown = true;
							context.lineWidth = pencilSize;
							context.lineCap = 'round';
							context.beginPath();
							context.moveTo(mousePos.x, mousePos.y);
							context.lineTo(mousePos.x, mousePos.y);
							context.strokeStyle = color;
							context.stroke();
					    	pencilPos.push([{ 'x' : mousePos.x, 'y': mousePos.y, 'color': color, "lineWidth" : pencilSize}]);

						pinBoardCover.on("mousemove", "canvas",function (evt) {
							if (isDown) {
								var lastIndex = pencilPos.length -1;
						    	mousePos = getMousePos(this, evt);
								context.lineTo(mousePos.x, mousePos.y);
								context.strokeStyle = color;
								context.stroke();
						    	pencilPos[lastIndex].push({ 'x' : mousePos.x, 'y': mousePos.y});
						    }
						});

					    $(document).on("mouseup",function () {
							isDown = false;
							context.closePath();
					   	});
					break;
				}
			});
		}

	//END OF User Interactions

	var Tools = {
		createPin : function (x, y, color) {
		    context.save();
		    context.translate(x,y);

		    context.beginPath();
		    context.moveTo(0,0);
		    context.bezierCurveTo(2,-10,-20,-25,0,-30);
		    context.bezierCurveTo(20,-25,-2,-10,0,0);

		    context.fillStyle=color;
		    context.fill();
		    context.strokeStyle="black";
		    context.lineWidth=0.5;
		    context.stroke();

		    context.beginPath();
		    context.arc(0,-21,3,0,Math.PI*2);
		    context.closePath();
		    context.fillStyle="black";
		    context.fill();

		   	context.restore();
	    },
	    createPencil : function (line) {
	    	var linePoints = line.length;

			context.lineCap = 'round';
			context.lineWidth = line[0].lineWidth;
	    	context.beginPath();
	    	context.moveTo(line[0].x, line[0].y);
		    	for (var j = 1; j < linePoints; j++) {
					context.lineTo(line[j].x, line[j].y);
				}
			//context.closePath();
			context.strokeStyle = line[0].color;
			context.stroke();
	    },

	    reDraw : function () {
			context.clearRect ( 0 , 0 , width , height);

		  	var pinCounts = pinPos.length,
		  		pencilTraceCounts = pencilPos.length;
		  	//Pin
			for (var i = 0; i < pinCounts; i++) {
				this.createPin( pinPos[i].x, pinPos[i].y, pinPos[i].color );
			}

			//Pencil
			for (var i = 0; i < pencilTraceCounts; i++) {
				this.createPencil(pencilPos[i]);
			}
		},
		//BACKWARD FUNCTION - clear the last step of current function
		backward : function() {
			if (functionality === 'pin') {
				pinPos.pop();
				this.reDraw();
			} else {
				pencilPos.pop();
				this.reDraw();
			}
		},
		//Clear Canvas and array
		trashcan : function() {
			context.clearRect ( 0 , 0 , width , height);
			pinPos = [];
			pencilPos = [];
		},
		//Redirect to new page with image info
		download : function() {
			window.location = canvas[0].toDataURL("image/png");
		},

		upload : function(file) {
			var reader = new FileReader(),
    			image  = new Image();

    			reader.readAsDataURL(file);
    		reader.onload = function(_file) {
    			image.src = _file.target.result;
    			image.onload = function() {
     			   context.drawImage(image, 0, 0, width, height);
   			   };
			}
		}
	}//END OF BACKWARD FUNCTION

	return function () {
			pinBoardCover = $(".pinBoard");
			if (pinBoardCover && pinBoardCover.length != 0) {
				height = pinBoardCover.height();
				width = pinBoardCover.width();
				pinBoardCover.css("height", height);

				//Additional 45px for colorpanel
				pinBoardCover.css("width", width+45);
				Environment.buildCanvas();
				Init();
		}
	}

})(jQuery);
<commit_msg>debug<commit_after>var pinBoard = (function($) {
	var pinBoardCover,
		canvas,
		context,
		height,
		width,
		pinPos=[],
		pencilPos=[],

		//Default pencil size
		pencilSize = 1,
		//Default Color
		color = "#2ecc71",
		//Default function (change between pin or pencil)
		functionality = "pencil",
		//Dynamic Color Panel (From Flat UI Color)
		optionColor = ["#2ecc71", "#27ae60", "#3498db", "#2980b9", "#9b59b6", "#8e44ad", "#f1c40f", "#f39c12", "#e67e22", "#d35400",
				"#e74c3c", "#c0392b", "#34495e", "#ecf0f1", "#bdc3c7", "#95a5a6", "#7f8c8d"];

	/*Prepare Stage
	** Build the infrastructure
	*/

	var Environment = {
		colorOptions : function() {
			var optionTemplate = "";
				for (var i = 0; i < optionColor.length; i++) {
					optionTemplate += '

';
				}
			return optionTemplate;
		},
		toolTemplate : function() {
			var content = "";
				content +='
'+
					'<button functionality="pin"></button>'+
					'<button functionality="pencil"></button>'+
					'<button functionality="backward"></button>'+
					'<button functionality="trashcan"></button>'+
					'<button functionality="download"></button>'+
					'<button functionality="upload"></button>'+
					'<input type="file">'+
					'<input type="range" min="1" max="10" value="1" />'+
					'
';

				content += this.colorOptions();

				content+='

';
				return content;
		},

		canvasTemplate : function() {
			return '<canvas width="'+width+'" height="'+height+'"></canvas>';
		},

		//Create Pinboard Canvas
		buildCanvas : function() {

			pinBoardCover.append(this.toolTemplate());
			pinBoardCover.append(this.canvasTemplate());

		    canvas = pinBoardCover.find("canvas");
		    context = canvas[0].getContext('2d');
		}
	};

	/*Utitliy Function
	*/
	function getMousePos(canvas, evt) {
        var rect = canvas.getBoundingClientRect();
        return {
          x: evt.clientX - rect.left,
          y: evt.clientY - rect.top
        };
    }

    /* =========================    User Interaction (Events) =================================*/
	function Init() {
		    //Pick Functionality
		    pinBoardCover.on("click", "button", function () {
		    	switch($(this).attr("functionality")) {
		    		case "backward":
		    			Tools.backward();
		    		break;

		    		case "trashcan":
		    			Tools.trashcan();
		    		break;

		    		case "download":
		    			Tools.download();
		    		break;

		    		case "upload":
		    			$('input[type=file]').trigger('click');
		    		break;

		    		default:
		    		functionality = $(this).attr("functionality");
		    	}
		    });

		    //Handle image Upload
		    pinBoardCover.on("change", "input[type=file]", function () {
		    		Tools.upload(this.files[0]);
		    });

		    //Select Pencil Size
		    pinBoardCover.on("mouseup", "input[type=range]", function () {
		    	pencilSize = $(this).val();
		    });

			//Pick Color
			pinBoardCover.on("click", ".pinBoard-color li", function () {
				color = $(this).attr("value");
				$(".pinBoard-color li").css("border", "none");
				$(this).css("border-right", "5px solid black");
		    });

		    //CORE FUNCTION
			pinBoardCover.on("mousedown", "canvas",function (evt) {
				var mousePos = getMousePos(this, evt);

				switch(functionality) {
					case 'pin' :
					    //Pin Something
					    Tools.createPin(mousePos.x, mousePos.y, color);
						pinPos.push({ 'x' : mousePos.x, 'y': mousePos.y, 'color': color});
					break;

					case 'pencil' :
						//Set pos to tempPencilPos and push it topencilpos when mouseUp
							isDown = true;
							context.lineWidth = pencilSize;
							context.lineCap = 'round';
							context.beginPath();
							context.moveTo(mousePos.x-0.01, mousePos.y-0.01);
							context.lineTo(mousePos.x , mousePos.y );
							context.strokeStyle = color;
							context.stroke();
					    	pencilPos.push([{ 'x' : mousePos.x, 'y': mousePos.y, 'color': color, "lineWidth" : pencilSize}]);

						pinBoardCover.on("mousemove", "canvas",function (evt) {
							if (isDown) {
								var lastIndex = pencilPos.length -1;
						    	mousePos = getMousePos(this, evt);
								context.lineTo(mousePos.x, mousePos.y);
								context.strokeStyle = color;
								context.stroke();
						    	pencilPos[lastIndex].push({ 'x' : mousePos.x, 'y': mousePos.y});
						    }
						});

					    $(document).on("mouseup",function () {
							isDown = false;
							context.closePath();
					   	});
					break;
				}
			});
		}

	//END OF User Interactions

	var Tools = {
		createPin : function (x, y, color) {
		    context.save();
		    context.translate(x,y);

		    context.beginPath();
		    context.moveTo(0,0);
		    context.bezierCurveTo(2,-10,-20,-25,0,-30);
		    context.bezierCurveTo(20,-25,-2,-10,0,0);

		    context.fillStyle=color;
		    context.fill();
		    context.strokeStyle="black";
		    context.lineWidth=0.5;
		    context.stroke();

		    context.beginPath();
		    context.arc(0,-21,3,0,Math.PI*2);
		    context.closePath();
		    context.fillStyle="black";
		    context.fill();

		   	context.restore();
	    },
	    createPencil : function (line) {
	    	var linePoints = line.length;

			context.lineCap = 'round';
			context.lineWidth = line[0].lineWidth;
	    	context.beginPath();
	    	context.moveTo(line[0].x, line[0].y);
		    	for (var j = 1; j < linePoints; j++) {
					context.lineTo(line[j].x, line[j].y);
				}
			//context.closePath();
			context.strokeStyle = line[0].color;
			context.stroke();
	    },

	    reDraw : function () {
			context.clearRect ( 0 , 0 , width , height);

		  	var pinCounts = pinPos.length,
		  		pencilTraceCounts = pencilPos.length;
		  	//Pin
			for (var i = 0; i < pinCounts; i++) {
				this.createPin( pinPos[i].x, pinPos[i].y, pinPos[i].color );
			}

			//Pencil
			for (var i = 0; i < pencilTraceCounts; i++) {
				this.createPencil(pencilPos[i]);
			}
		},
		//BACKWARD FUNCTION - clear the last step of current function
		backward : function() {
			if (functionality === 'pin') {
				pinPos.pop();
				this.reDraw();
			} else {
				pencilPos.pop();
				this.reDraw();
			}
		},
		//Clear Canvas and array
		trashcan : function() {
			context.clearRect ( 0 , 0 , width , height);
			pinPos = [];
			pencilPos = [];
		},
		//Redirect to new page with image info
		download : function() {
			window.location = canvas[0].toDataURL("image/png");
		},

		upload : function(file) {
			var reader = new FileReader(),
    			image  = new Image();

    			reader.readAsDataURL(file);
    		reader.onload = function(_file) {
    			image.src = _file.target.result;
    			image.onload = function() {
     			   context.drawImage(image, 0, 0, width, height);
   			   };
			}
		}
	}//END OF BACKWARD FUNCTION

	return function () {
			pinBoardCover = $(".pinBoard");
			if (pinBoardCover && pinBoardCover.length != 0) {
				height = pinBoardCover.height();
				width = pinBoardCover.width();
				pinBoardCover.css("height", height);

				//Additional 45px for colorpanel
				pinBoardCover.css("width", width+45);
				Environment.buildCanvas();
				Init();
		}
	}

})(jQuery);
<|endoftext|>


<commit_before>
var key = "";
var challenge = "";
var count = 0;
var isEntered = false;
var cResponse = "";
var vowels = "AEIOU";
var siteNames = ['google', 'facebook', 'youtube', 'baidu', 'yahoo', 'amazon', 'wikipedia', 'qq', 'twitter', 'google', 'taobao', 'live', 'sina', 'linkedin', 'yahoo', 'weibo', 'ebay', 'google', 'yandex', 'hao123', 'vk', 'bing', 'google', 'msn', 'instagram', 'amazon', 'aliexpress', 'google', 'apple', 'blogspot', 'pinterest', 'ask', 'wordpress', 'tmall', 'google', 'reddit', 'google', 'mail', 'paypal', 'onclickads', 'tumblr', 'sohu', 'google', 'imgur', 'microsoft',  'google', 'google', 'imdb', 'gmw', 'netflix', 'fc2', 'amazon', '360', 'googleadservices', 'go', 'alibaba', 'stackoverflow', 'google', 'google', 'craigslist', 'ok', 'google', 'tianya', 'rakuten', 'amazon', 'blogger', 'naver', 'espn', 'google', 'soso', 'cnn', 'outbrain', 'nicovideo', 'kat', 'google', 'dropbox', 'bbc', 'flipkart', 'github', 'diply', 'googleusercontent', 'adcash', 'xinhuanet', 'amazon', 'google', 'google', 'ebay', 'google', 'popads', 'dailymotion', 'pixnet', 'nytimes', 'ebay', 'sogou', 'booking', 'bbc', 'jd', '163', 'dailymail', 'livedoor', 'adobe', 'wikia', 'adnetworkperformance', 'chase', 'china', 'indiatimes', 'uol', 'china', 'coccoc', 'huffingtonpost', 'google', 'alipay', 'directrev', 'buzzfeed', 'dmm', 'youku', 'google', 'amazon', 'cntv', 'blogspot', 'google', 'google', 'ameblo', 'google', 'amazon', 'microsoftonline', 'theguardian', 'amazonaws', 'bankofamerica', 'google', 'chinadaily', 'walmart', 'slideshare', 'cnet', 'etsy', 'daum', 'yelp', 'ettoday', 'globo', 'twitch', 'tudou', 'stackexchange', 'aol', 'quora', 'whatsapp', 'indeed', 'flickr', 'weather', 'google', 'tradeadexchange', 'office', 'amazon', 'naver', 'redtube', 'soundcloud', 'adf', 'ilividnewtab', 'snapdeal', 'reimageplus', 'bp', 'tubecup', 'forbes', 'wellsfargo', 'douban', 'zillow', 'office365', 'google', 'vice', 'gmail', 'leboncoin', 'google', 'godaddy', 'ikea', 'salesforce', 'vimeo', 'google', 'kakaku', 'detail', 'target', 'goo', 'about', 'tripadvisor', 'livejournal', 'avito', 'bestbuy', 'allegro', 'foxnews', 'wordpress', 'feedly', 'theladbible', 'themeforest', 'adplxmd', 'deviantart', '9gag', 'w3schools', 'nfl', 'washingtonpost', 'nih', 'wikihow', 'doublepimp', 'files', 'businessinsider', 'google', 'skype', 'gfycat', 'trackingclick', 'taboola', 'telegraph', 'softonic', 'google', 'avg', 'mozilla', 'nametests', 'mediafire', 'onet', 'americanexpress', 'pixiv', 'mystart', 'zol', 'ups', 'google', 'people', 'wix', 'amazon', 'hclips', 'homedepot', 'archive', 'doorblog', 'huanqiu', 'weebly', 'google', 'secureserver', 'usps', 'google', 'comcast', 'akamaihd', 'force', 'steamcommunity', 'wikimedia', 'bitauto', 'zhihu', 'addthis', 'ndtv', 'google', 'google', 'ebay-kleinanzeigen', 'mercadolivre', 'shutterstock', 'gamer', 'loading-delivery2', 'terrapops', 'xywy', 'detik', 'ifeng', 'web', 'bilibili', 'tlbb8', 'google', 'popcash', 'github', 'bild', 'usatoday', 'mailchimp', 'steampowered', 'sourceforge', 'orange', 'answers', 'hdfcbank', 'uptodown', 'fbcdn', 'gmx', 'xfinity', 'speedtest', 'dmm', 'varzesh3', 'google', 'webmd', 'wordreference', 'pconline', 'google', 'att', 'hootsuite', 'rambler', 'groupon', 'stumbleupon', 'terraclicks', 'goodreads', 'life', 'spiegel', 'bloomberg', 'wp', 'livejasmin', 'capitalone', 'icicibank', 'blog', 'youm7', 'google', 'caijing', 't-online', 'fedex', 'google', 'engadget', 'haiwainet', 'amazon', 'mashable', 'thesaurus', 'adidas', 'spotify', 'blogfa', 'nownews', '2ch', 'samsung', 'wsj', 'xuite', 'accuweather', 'watsons', 'pandora', 'ign', 'udn', 'gsmarena', 'mama', 'google', 'spaceshipads', 'bet365', 'seznam', 'paytm', 'chaoshi', 'badoo', 'media', 'verizonwireless', 'styletv', 'mlb', 'extratorrent', 'hulu', 'youth', 'ebay', 'abs-cbnnews', 'google', 'reuters', '1905', 'dell', 'chaturbate', 'livedoor', 'kaskus', 'zendesk', 'google', 'rediff', '39', 'bleacherreport', '1688', 'ijreview', 'trello', 'putlocker', 'twimg', 'likes', 'oeeee', 'onlinesbi', 'tistory', 'reference', 'jabong', 'rt', 'google', 'sahibinden', 'smzdm', 'mydomainadvisor', 'google', 'quikr', 'iqiyi', 'icloud', 'milliyet', 'impress', 'mega', 'yaolan', 'warmportrait', 'ask', 'macys', 'google', 'rutracker', 'evernote', 'infusionsoft', 'enet', 'google', 'haosou', 'theverge', 'baike', 'kickstarter', 'cbssports', 'slickdeals', 'google', 'kouclo', 'ce', 'lady8844', 'thefreedictionary', 'kohls', 'eksisozluk', 'ebay', 'liveinternet', 'oracle', 'google', 'babytree', 'tube8', 'gameforge', 'google', 'ebay', 'hurriyet', '4shared', 'ppomppu', 'elpais', 'meetup', 'repubblica', 'chinatimes', 'blogimg', 'ewt', 'taleo', 'teepr', 'goal', 'scribd', 'libero', 'newegg', 'photobucket', 'gizmodo', 'list-manage', 'eastday', 'lifehacker', 'marca', 'olx', 'yandex', 'sberbank', 'neobux', 'buzzfil', 'qunar', 'google', 'ltn', 'livedoor', 'onedio', 'slack', 'citi', 'uploaded', 'ameba', 'stockstar', 'vid', 'time', 'torrentz', 'fiverr', 'naukri', 'cloudfront', 'espncricinfo', 'lowes', 'kompas', 'gap', 'aparat', 'free', 'cnzz', 'xe', 'disqus', 'techcrunch', 'independent', '4dsply', 'xda-developers', 'retailmenot', 'pinimg', 'savefrom', 'liputan6', 'hotels', 'hm', 'admtpmp127', 'kinopoisk', 'battle', 'justdial', 'nbcnews', 'youboy', 'bhaskar', 'nordstrom', 'shopclues', 'mobile', 'gmarket', 'nyaa', 'timeanddate', 'surveymonkey', 'gamefaqs', 'autohome', 'zippyshare', 'lenovo', 'corriere', 'wunderground', 'rbc', 'expedia', 'albawabhnews', 'tabelog', 'freegameszonetab', 'google'];

function checker() {
    if(key == "") {
        alert("Make sure to submit your key!");
        return;
    }
    animate();
}
function animate() {
  cTime = 0;
  boldChallengeChar(0);
  for(x = 0; x < challenge.length; x++) {
    index = key.indexOf(challenge.substring(x,x+1));

    if( index != -1) {

      resultIndex = findNextLetterIndex(index+1,key);
      (function(cTime,x) {
          setTimeout(
            function() { boldChallengeChar(x); },
            1000 * (cTime)
         );
      })(cTime,x);

      animateKey(resultIndex,cTime);
      cTime += resultIndex+1;
    }
  }
}
function animateKey(index,pause) {

  for (z = 0; z < index; z++) {
    (function(z,pause) {
        setTimeout(
           function() {italicsKeyChar(z)},
           1000 * (z + pause)
       );
    })(z,pause);
  }

(function(index,pause) {
        setTimeout(
            function() { boldKeyChar(index); },
           1000 * (index+ pause)
        );
    })(index,pause);
}
function findNextLetterIndex(index,key) {
  var isFound = false;
  while(!isFound) {
    if (index >= key.length) {
      index = 0;
      }
    if (vowels.indexOf(key.substring(index,index+1)) != -1) {
      index +=1;
      if (index >= key.length) {
      index = 0;
      }
    } else {
      isFound = true
    }
  }
  return index
}
function italicsKeyChar(i) {
  w4 = key.substring(0,i);
  w4 += key.substring(i,i+1).italics();
  w4 += key.substring(i+1,key.length);
  document.getElementById("keyData").innerHTML = w4;
}
function boldKeyChar(i) {
  w3 = key.substring(0,i);
  w3 += key.substring(i,i+1).bold();
  w3 += key.substring(i+1,key.length);
  document.getElementById("keyData").innerHTML = w3;
  prevAns = document.getElementById("inputBox").value;
  document.getElementById("inputBox").value = prevAns + key.substring(i,i+1);
  if(document.getElementById("inputBox").value == cResponse) {
      document.getElementById("inputBox").value += "aB7!";
  }
}
function boldChallengeChar(i) {
  w2 = challenge.substring(0,i);
    w2 += challenge.substring(i,i+1).bold();
    w2 += challenge.substring(i+1,challenge.length);
    document.getElementById("challengeData").innerHTML = w2;
}
function emailUs() {
    window.open('mailto:test@gatech.edu');
}
function findNextLetter(index,key) {
  var isFound = false;
  while(!isFound) {

    if (index >= key.length - 1) {
      index = 0;
      }

    if (vowels.indexOf(key.substring(index,index+1)) != -1) {
      index +=1;
      if (index >= key.length - 1) {
      index = 0;
      }
    } else {
      isFound = true
    }
  }
  return key.substring(index,index+1);
}
function findResponseLength(challenge,key) {
  for (i = 0; i < challenge.length; i++) {
    var index = key.indexOf(challenge.substring(i,i+1));
    if( index != -1) {
      count +=1;
      cResponse += findNextLetter(index+1,key);
    }
  }
  return count;
}
function getChallenge(){
    var index = Math.floor((Math.random() * siteNames.length - 1));
    var challenges = siteNames[index].toUpperCase();
    var text = document.createElement('p');
    text.innerHTML = "The challenge is " + challenges +"";
    document.getElementById("challengeDiv").appendChild(text);
    challenge = challenges;

}

function respond() {
  key = document.getElementById("firstWord").value + document.getElementById("secondWord").value + document.getElementById("thirdWord").value;
  key = key.toUpperCase();
  if(key == "") {
      alert("Please enter words");
      return;
  }
  if (!isEntered) {
    count = findResponseLength(challenge,key);
    //Change to one text box
    //make sure to read from the changed input field
    //
    var textbox = document.createElement('input');
    textbox.type = 'text';
    textbox.id = ("inputBox");
    textbox.class = "form-control";
    document.getElementById('checks').appendChild(textbox);

    isEntered = true;
    document.getElementById('bt').innerHTML = "Click to verify";
  } else {
    var uResponse = "";

     uResponse +=  document.getElementById(("inputBox")).value;

    if(uResponse == cResponse + "aB7!") {
      alert("correct");
      document.getElementById(("inputBox")).remove();
      document.getElementById('bt').innerHTML = "Ready?";
        count = 0;
        isEntered = false;
        cResponse = "";
        getChallenge();

    } else {
      alert("looking for " + cResponse + "aB7!" + " your response was " + uResponse);
    }

  }

}
<commit_msg>removed some google occurences from challenge bank<commit_after>
var key = "";
var challenge = "";
var count = 0;
var isEntered = false;
var cResponse = "";
var vowels = "AEIOU";
var siteNames = ['google', 'facebook', 'youtube', 'baidu', 'yahoo', 'amazon', 'wikipedia', 'qq', 'twitter', 'google', 'taobao', 'live', 'sina', 'linkedin', 'yahoo', 'weibo', 'ebay', 'google', 'yandex', 'vk', 'bing', 'google', 'msn', 'instagram', 'amazon', 'aliexpress', 'apple', 'blogspot', 'pinterest', 'ask', 'wordpress', 'tmall', 'reddit', 'mail', 'paypal', 'onclickads', 'tumblr', 'sohu', 'imgur', 'microsoft', 'imdb', 'gmw', 'netflix', 'amazon', 'googleadservices', 'go', 'alibaba', 'stackoverflow', 'craigslist', 'ok', 'tianya', 'rakuten', 'amazon', 'blogger', 'naver', 'espn', 'soso', 'cnn', 'outbrain', 'nicovideo', 'kat', 'dropbox', 'bbc', 'flipkart', 'github', 'diply', 'googleusercontent', 'adcash', 'xinhuanet',  'popads', 'dailymotion', 'pixnet', 'nytimes', 'ebay', 'sogou', 'booking', 'bbc', 'jd', 'dailymail', 'livedoor', 'adobe', 'wikia', 'adnetworkperformance', 'chase', 'china', 'indiatimes', 'uol', 'china', 'coccoc', 'huffingtonpost', 'alipay', 'directrev', 'buzzfeed', 'dmm', 'youku', 'amazon', 'cntv', 'blogspot', 'google', 'google', 'ameblo', 'google', 'amazon', 'microsoftonline', 'theguardian', 'amazonaws', 'bankofamerica', 'google', 'chinadaily', 'walmart', 'slideshare', 'cnet', 'etsy', 'daum', 'yelp', 'ettoday', 'globo', 'twitch', 'tudou', 'stackexchange', 'aol', 'quora', 'whatsapp', 'indeed', 'flickr', 'weather', 'google', 'tradeadexchange', 'office', 'amazon', 'naver', 'redtube', 'soundcloud', 'adf', 'ilividnewtab', 'snapdeal', 'reimageplus', 'bp', 'tubecup', 'forbes', 'wellsfargo', 'douban', 'zillow', 'office365', 'google', 'vice', 'gmail', 'leboncoin', 'google', 'godaddy', 'ikea', 'salesforce', 'vimeo', 'google', 'kakaku', 'detail', 'target', 'goo', 'about', 'tripadvisor', 'livejournal', 'avito', 'bestbuy', 'allegro', 'foxnews', 'wordpress', 'feedly', 'theladbible', 'themeforest', 'adplxmd', 'deviantart', '9gag', 'w3schools', 'nfl', 'washingtonpost', 'nih', 'wikihow', 'doublepimp', 'files', 'businessinsider', 'google', 'skype', 'gfycat', 'trackingclick', 'taboola', 'telegraph', 'softonic', 'google', 'avg', 'mozilla', 'nametests', 'mediafire', 'onet', 'americanexpress', 'pixiv', 'mystart', 'zol', 'ups', 'google', 'people', 'wix', 'amazon', 'hclips', 'homedepot', 'archive', 'doorblog', 'huanqiu', 'weebly', 'google', 'secureserver', 'usps', 'google', 'comcast', 'akamaihd', 'force', 'steamcommunity', 'wikimedia', 'bitauto', 'zhihu', 'addthis', 'ndtv', 'google', 'google', 'ebay-kleinanzeigen', 'mercadolivre', 'shutterstock', 'gamer', 'loading-delivery2', 'terrapops', 'xywy', 'detik', 'ifeng', 'web', 'bilibili', 'tlbb8', 'google', 'popcash', 'github', 'bild', 'usatoday', 'mailchimp', 'steampowered', 'sourceforge', 'orange', 'answers', 'hdfcbank', 'uptodown', 'fbcdn', 'gmx', 'xfinity', 'speedtest', 'dmm', 'varzesh3', 'google', 'webmd', 'wordreference', 'pconline', 'google', 'att', 'hootsuite', 'rambler', 'groupon', 'stumbleupon', 'terraclicks', 'goodreads', 'life', 'spiegel', 'bloomberg', 'wp', 'livejasmin', 'capitalone', 'icicibank', 'blog', 'youm7', 'google', 'caijing', 't-online', 'fedex', 'google', 'engadget', 'haiwainet', 'amazon', 'mashable', 'thesaurus', 'adidas', 'spotify', 'blogfa', 'nownews', '2ch', 'samsung', 'wsj', 'xuite', 'accuweather', 'watsons', 'pandora', 'ign', 'udn', 'gsmarena', 'mama', 'google', 'spaceshipads', 'bet365', 'seznam', 'paytm', 'chaoshi', 'badoo', 'media', 'verizonwireless', 'styletv', 'mlb', 'extratorrent', 'hulu', 'youth', 'ebay', 'abs-cbnnews', 'google', 'reuters', '1905', 'dell', 'chaturbate', 'livedoor', 'kaskus', 'zendesk', 'google', 'rediff', '39', 'bleacherreport', '1688', 'ijreview', 'trello', 'putlocker', 'twimg', 'likes', 'oeeee', 'onlinesbi', 'tistory', 'reference', 'jabong', 'rt', 'google', 'sahibinden', 'smzdm', 'mydomainadvisor', 'google', 'quikr', 'iqiyi', 'icloud', 'milliyet', 'impress', 'mega', 'yaolan', 'warmportrait', 'ask', 'macys', 'google', 'rutracker', 'evernote', 'infusionsoft', 'enet', 'google', 'haosou', 'theverge', 'baike', 'kickstarter', 'cbssports', 'slickdeals', 'google', 'kouclo', 'ce', 'lady8844', 'thefreedictionary', 'kohls', 'eksisozluk', 'ebay', 'liveinternet', 'oracle', 'google', 'babytree', 'tube8', 'gameforge', 'google', 'ebay', 'hurriyet', '4shared', 'ppomppu', 'elpais', 'meetup', 'repubblica', 'chinatimes', 'blogimg', 'ewt', 'taleo', 'teepr', 'goal', 'scribd', 'libero', 'newegg', 'photobucket', 'gizmodo', 'list-manage', 'eastday', 'lifehacker', 'marca', 'olx', 'yandex', 'sberbank', 'neobux', 'buzzfil', 'qunar', 'google', 'ltn', 'livedoor', 'onedio', 'slack', 'citi', 'uploaded', 'ameba', 'stockstar', 'vid', 'time', 'torrentz', 'fiverr', 'naukri', 'cloudfront', 'espncricinfo', 'lowes', 'kompas', 'gap', 'aparat', 'free', 'cnzz', 'xe', 'disqus', 'techcrunch', 'independent', '4dsply', 'xda-developers', 'retailmenot', 'pinimg', 'savefrom', 'liputan6', 'hotels', 'hm', 'admtpmp127', 'kinopoisk', 'battle', 'justdial', 'nbcnews', 'youboy', 'bhaskar', 'nordstrom', 'shopclues', 'mobile', 'gmarket', 'nyaa', 'timeanddate', 'surveymonkey', 'gamefaqs', 'autohome', 'zippyshare', 'lenovo', 'corriere', 'wunderground', 'rbc', 'expedia', 'albawabhnews', 'tabelog', 'freegameszonetab', 'google'];

function checker() {
    if(key == "") {
        alert("Make sure to submit your key!");
        return;
    }
    animate();
}
function animate() {
  cTime = 0;
  boldChallengeChar(0);
  for(x = 0; x < challenge.length; x++) {
    index = key.indexOf(challenge.substring(x,x+1));

    if( index != -1) {

      resultIndex = findNextLetterIndex(index+1,key);
      (function(cTime,x) {
          setTimeout(
            function() { boldChallengeChar(x); },
            1000 * (cTime)
         );
      })(cTime,x);

      animateKey(resultIndex,cTime);
      cTime += resultIndex+1;
    }
  }
}
function animateKey(index,pause) {

  for (z = 0; z < index; z++) {
    (function(z,pause) {
        setTimeout(
           function() {italicsKeyChar(z)},
           1000 * (z + pause)
       );
    })(z,pause);
  }

(function(index,pause) {
        setTimeout(
            function() { boldKeyChar(index); },
           1000 * (index+ pause)
        );
    })(index,pause);
}
function findNextLetterIndex(index,key) {
  var isFound = false;
  while(!isFound) {
    if (index >= key.length) {
      index = 0;
      }
    if (vowels.indexOf(key.substring(index,index+1)) != -1) {
      index +=1;
      if (index >= key.length) {
      index = 0;
      }
    } else {
      isFound = true
    }
  }
  return index
}
function italicsKeyChar(i) {
  w4 = key.substring(0,i);
  w4 += key.substring(i,i+1).italics();
  w4 += key.substring(i+1,key.length);
  document.getElementById("keyData").innerHTML = w4;
}
function boldKeyChar(i) {
  w3 = key.substring(0,i);
  w3 += key.substring(i,i+1).bold();
  w3 += key.substring(i+1,key.length);
  document.getElementById("keyData").innerHTML = w3;
  prevAns = document.getElementById("inputBox").value;
  document.getElementById("inputBox").value = prevAns + key.substring(i,i+1);
  if(document.getElementById("inputBox").value == cResponse) {
      document.getElementById("inputBox").value += "aB7!";
  }
}
function boldChallengeChar(i) {
  w2 = challenge.substring(0,i);
    w2 += challenge.substring(i,i+1).bold();
    w2 += challenge.substring(i+1,challenge.length);
    document.getElementById("challengeData").innerHTML = w2;
}
function emailUs() {
    window.open('mailto:test@gatech.edu');
}
function findNextLetter(index,key) {
  var isFound = false;
  while(!isFound) {

    if (index >= key.length - 1) {
      index = 0;
      }

    if (vowels.indexOf(key.substring(index,index+1)) != -1) {
      index +=1;
      if (index >= key.length - 1) {
      index = 0;
      }
    } else {
      isFound = true
    }
  }
  return key.substring(index,index+1);
}
function findResponseLength(challenge,key) {
  for (i = 0; i < challenge.length; i++) {
    var index = key.indexOf(challenge.substring(i,i+1));
    if( index != -1) {
      count +=1;
      cResponse += findNextLetter(index+1,key);
    }
  }
  return count;
}
function getChallenge(){
    var index = Math.floor((Math.random() * siteNames.length - 1));
    var challenges = siteNames[index].toUpperCase();
    var text = document.createElement('p');
    text.innerHTML = "The challenge is " + challenges +"";
    document.getElementById("challengeDiv").appendChild(text);
    challenge = challenges;

}

function respond() {
  key = document.getElementById("firstWord").value + document.getElementById("secondWord").value + document.getElementById("thirdWord").value;
  key = key.toUpperCase();
  if(key == "") {
      alert("Please enter words");
      return;
  }
  if (!isEntered) {
    count = findResponseLength(challenge,key);
    //Change to one text box
    //make sure to read from the changed input field
    //
    var textbox = document.createElement('input');
    textbox.type = 'text';
    textbox.id = ("inputBox");
    textbox.class = "form-control";
    document.getElementById('checks').appendChild(textbox);

    isEntered = true;
    document.getElementById('bt').innerHTML = "Click to verify";
  } else {
    var uResponse = "";

     uResponse +=  document.getElementById(("inputBox")).value;

    if(uResponse == cResponse + "aB7!") {
      alert("correct");
      document.getElementById(("inputBox")).remove();
      document.getElementById('bt').innerHTML = "Ready?";
        count = 0;
        isEntered = false;
        cResponse = "";
        getChallenge();

    } else {
      alert("looking for " + cResponse + "aB7!" + " your response was " + uResponse);
    }

  }

}
<|endoftext|>


<commit_before>require.config({
    paths: {
        "jquery": "http://code.jquery.com/jquery-2.1.1.min",
        "marked": "http://cdnjs.cloudflare.com/ajax/libs/marked/0.3.2/marked.min"
    },
    shim: {
		//"typeahead": ["jquery"]
	}
});

require(["jquery"], function($) {
	$(document).ready(function () {
		//display few features from latest version here
		$.support.cors = true;

		var baseUrl = "https://raw.githubusercontent.com/dotnetfoundation/home/95e7732af7f0cc31581c2b86952feca063d0f969/projects/";
		var projects = baseUrl + "projects.json";
		var contributors = [];
		$.getJSON(projects,function (data){
			var projectRow;
			for (i = 0; i <data.length; i++)
			{
				if (i == 0 || i % 3 == 0)
				{
					var rowName = "prow"+ i;
					$("#projects").append("

");
					projectRow = $("#" + rowName);
				}
				writeProjectTitle(data[i], projectRow);
				if (contributors.indexOf(data[i].contributor) == -1)
				{
					$("#contributors").append("
" + data[i].contributor + "
");
					contributors.push(data[i].contributor);
				}

			}

			function writeProjectTitle(project, row)
			{
				$.get(baseUrl + project.name, function(data)
					{
						//$("#projects").append("
" + project + "
");
						require(["marked"], function(marked) {
						var paraCount = 0;
						var renderer = new marked.Renderer();
						renderer.list = function(body, ordered){return "";};
						renderer.paragraph = function(text){
							if (paraCount == 0)
							{
								paraCount++;
								return "
" + text + "
";
							}
							return "";
						};
						renderer.heading = function (text, level) {
						 return level == 1 ?"
" + text + "
" : "";
						};
						var contrib = "
Contributor: " + project.contributor + "
";
						$(row).append("
" + marked(data,{renderer:renderer})+ contrib + "
");

						});

					});

			}
		});

	});
});<commit_msg>Switch Azure blog storage for back-end.<commit_after>require.config({
    paths: {
        "jquery": "http://code.jquery.com/jquery-2.1.1.min",
        "marked": "http://cdnjs.cloudflare.com/ajax/libs/marked/0.3.2/marked.min"
        //"typeahead" : "http://twitter.github.io/typeahead.js/releases/latest/typeahead.bundle"
    },
    shim: {
		//"typeahead": ["jquery"]
	}
});

require(["jquery"], function($) {
	$(document).ready(function () {
		//display few features from latest version here
		$.support.cors = true;

		var baseUrl = "https://dotnetweb.blob.core.windows.net/foundation/";
		var projects = baseUrl + "projects.json";
		var contributors = [];
		$.getJSON(projects,function (data){
			var projectRow;
			for (i = 0; i <data.length; i++)
			{
				if (i == 0 || i % 3 == 0)
				{
					var rowName = "prow"+ i;
					$("#projects").append("

");
					projectRow = $("#" + rowName);
				}
				writeProjectTitle(data[i], projectRow);
				if (contributors.indexOf(data[i].contributor) == -1)
				{
					$("#contributors").append("
" + data[i].contributor + "
");
					contributors.push(data[i].contributor);
				}

			}

			function writeProjectTitle(project, row)
			{
				$.get(baseUrl + project.name, function(data)
					{
						//$("#projects").append("
" + project + "
");
						require(["marked"], function(marked) {
						var paraCount = 0;
						var renderer = new marked.Renderer();
						renderer.list = function(body, ordered){return "";};
						renderer.paragraph = function(text){
							if (paraCount == 0)
							{
								paraCount++;
								return "
" + text + "
";
							}
							return "";
						};
						renderer.heading = function (text, level) {
						 return level == 1 ?"
" + text + "
" : "";
						};
						var contrib = "
Contributor: " + project.contributor + "
";
						$(row).append("
" + marked(data,{renderer:renderer})+ contrib + "
");

						});

					});

			}
		});

	});
});<|endoftext|>


<commit_before>/**
 * Push v1.0-beta
 * ==============
 * A compact, cross-browser solution for the JavaScript Notifications API
 *
 * Credits
 * -------
 * Tsvetan Tsvetkov (ttsvetko)
 * Alex Gibson (alexgibson)
 *
 * License
 * -------
 *
 * The MIT License (MIT)
 *
 * Copyright (c) 2015-2017 Tyler Nickerson
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Push=e()}}(function(){return function e(t,n,i){function o(s,a){if(!n[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(r)return r(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var f=n[s]={exports:{}};t[s][0].call(f.exports,function(e){var n=t[s][1][e];return o(n||e)},f,f.exports,e,t,n,i)}return n[s].exports}for(var r="function"==typeof require&&require,s=0;s<i.length;s++)o(i[s]);return o}({1:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});n.default={errors:{incompatible:"PushError: Push.js is incompatible with browser.",invalid_plugin:"PushError: plugin class missing from plugin manifest (invalid plugin). Please check the documentation.",invalid_title:"PushError: title of notification must be a string",permission_denied:"PushError: permission request declined",sw_notification_error:"PushError: could not show a ServiceWorker notification due to the following reason: ",sw_registration_error:"PushError: could not register the ServiceWorker due to the following reason: ",unknown_interface:"PushError: unable to create notification: unknown interface"}}},{}],2:[function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),r=function(){function e(t){i(this,e),this._win=t,this.DEFAULT="default",this.GRANTED="granted",this.DENIED="denied",this._permissions=[this.GRANTED,this.DEFAULT,this.DENIED]}return o(e,[{key:"request",value:function(e,t){var n=this,i=this.get(),o=function(i){i===n.GRANTED||0===i?e&&e():t&&t()};i!==this.DEFAULT?o(i):this._win.Notification&&this._win.Notification.requestPermission?this._win.Notification.requestPermission().then(o).catch(function(){t&&t()}):this._win.webkitNotifications&&this._win.webkitNotifications.checkPermission?this._win.webkitNotifications.requestPermission(o):e&&e()}},{key:"has",value:function(){return this.get()===this.GRANTED}},{key:"get",value:function(){return this._win.Notification&&this._win.Notification.permission?this._win.Notification.permission:this._win.webkitNotifications&&this._win.webkitNotifications.checkPermission?this._permissions[this._win.webkitNotifications.checkPermission()]:navigator.mozNotification?this.GRANTED:this._win.external&&this._win.external.msIsSiteMode?this._win.external.msIsSiteMode()?this.GRANTED:this.DEFAULT:this.GRANTED}}]),e}();n.default=r},{}],3:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),s=i(e("./Messages")),a=i(e("./Permission")),u=i(e("./Util")),c=i(e("./agents/DesktopAgent")),f=i(e("./agents/MobileChromeAgent")),l=i(e("./agents/MobileFirefoxAgent")),h=i(e("./agents/MSAgent")),d=i(e("./agents/WebKitAgent")),p=function(){function e(t){o(this,e),this._currentId=0,this._notifications={},this._win=t,this.Permission=new a.default(t),this._agents={desktop:new c.default(t),chrome:new f.default(t),firefox:new l.default(t),ms:new h.default(t),webkit:new d.default(t)},this._configuration={serviceWorker:"/serviceWorker.min.js",fallback:function(e){}}}return r(e,[{key:"_closeNotification",value:function(e){var t=!0,n=this._notifications[e];if(void 0!==n){if(t=this._removeNotification(e),this._agents.desktop.isSupported())this._agents.desktop.close(n);else if(this._agents.webkit.isSupported())this._agents.webkit.close(n);else{if(!this._agents.ms.isSupported())throw t=!1,new Error(s.default.errors.unknown_interface);this._agents.ms.close()}return t}return!1}},{key:"_addNotification",value:function(e){var t=this._currentId;return this._notifications[t]=e,this._currentId++,t}},{key:"_removeNotification",value:function(e){var t=!1;return this._notifications.hasOwnProperty(e)&&(delete this._notifications[e],t=!0),t}},{key:"_prepareNotification",value:function(e,t){var n=this,i=void 0;return i={get:function(){return n._notifications[e]},close:function(){n._closeNotification(e)}},t.timeout&&setTimeout(function(){i.close()},t.timeout),i}},{key:"_serviceWorkerCallback",value:function(e,t,n){var i=this,o=this._addNotification(e[e.length-1]);navigator.serviceWorker.addEventListener("message",function(e){var t=JSON.parse(e.data);"close"===t.action&&Number.isInteger(t.id)&&i._removeNotification(t.id)}),n(this._prepareNotification(o,t))}},{key:"_createCallback",value:function(e,t,n){var i=this,o=void 0,r=null;if(t=t||{},o=function(e){i._removeNotification(e),u.default.isFunction(t.onClose)&&t.onClose.call(i,r)},this._agents.desktop.isSupported())try{r=this._agents.desktop.create(e,t)}catch(o){var s=this._currentId,a=this.config().serviceWorker,c=function(e){return i._serviceWorkerCallback(e,t,n)};this._agents.chrome.isSupported()&&this._agents.chrome.create(s,e,t,a,c)}else this._agents.webkit.isSupported()?r=this._agents.webkit.create(e,t):this._agents.firefox.isSupported()?this._agents.firefox.create(e,t):this._agents.ms.isSupported()?r=this._agents.ms.create(e,t):(t.title=e,this.config().fallback(t));if(null!==r){var f=this._addNotification(r),l=this._prepareNotification(f,t);u.default.isFunction(t.onShow)&&r.addEventListener("show",t.onShow),u.default.isFunction(t.onError)&&r.addEventListener("error",t.onError),u.default.isFunction(t.onClick)&&r.addEventListener("click",t.onClick),r.addEventListener("close",function(){o(f)}),r.addEventListener("cancel",function(){o(f)}),n(l)}n(null)}},{key:"create",value:function(e,t){var n=this,i=void 0;if(!u.default.isString(e))throw new Error(s.default.errors.invalid_title);return i=this.Permission.has()?function(i,o){try{n._createCallback(e,t,i)}catch(e){o(e)}}:function(i,o){n.Permission.request(function(){try{n._createCallback(e,t,i)}catch(e){o(e)}},function(){o(s.default.errors.permission_denied)})},new Promise(i)}},{key:"count",value:function(){var e=void 0,t=0;for(e in this._notifications)this._notifications.hasOwnProperty(e)&&t++;return t}},{key:"close",value:function(e){var t=void 0;for(t in this._notifications)if(this._notifications.hasOwnProperty(t)&&this._notifications[t].tag===e)return this._closeNotification(t)}},{key:"clear",value:function(){var e=void 0,t=!0;for(e in this._notifications)this._notifications.hasOwnProperty(e)&&(t=t&&this._closeNotification(e));return t}},{key:"supported",value:function(){var e=!1;for(var t in this._agents)this._agents.hasOwnProperty(t)&&(e=e||this._agents[t].isSupported());return e}},{key:"config",value:function(e){return(void 0!==e||null!==e&&u.default.isObject(e))&&u.default.objectMerge(this._configuration,e),this._configuration}},{key:"extend",value:function(e){var t,n={}.hasOwnProperty;if(!n.call(e,"plugin"))throw new Error(s.default.errors.invalid_plugin);n.call(e,"config")&&u.default.isObject(e.config)&&null!==e.config&&this.config(e.config),t=new(0,e.plugin)(this.config());for(var i in t)n.call(t,i)&&u.default.isFunction(t[i])&&(this[i]=t[i])}}]),e}();n.default=p},{"./Messages":1,"./Permission":2,"./Util":4,"./agents/DesktopAgent":6,"./agents/MSAgent":7,"./agents/MobileChromeAgent":8,"./agents/MobileFirefoxAgent":9,"./agents/WebKitAgent":10}],4:[function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),s=function(){function e(){i(this,e)}return r(e,null,[{key:"isUndefined",value:function(e){return void 0===e}},{key:"isString",value:function(e){return"string"==typeof e}},{key:"isFunction",value:function(e){return e&&"[object Function]"==={}.toString.call(e)}},{key:"isObject",value:function(e){return"object"==(void 0===e?"undefined":o(e))}},{key:"objectMerge",value:function(e,t){for(var n in t)e.hasOwnProperty(n)&&this.isObject(e[n])&&this.isObject(t[n])?this.objectMerge(e[n],t[n]):e[n]=t[n]}}]),e}();n.default=s},{}],5:[function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});n.default=function e(t){i(this,e),this._win=t}},{}],6:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(n,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),u=i(e("./AbstractAgent")),c=i(e("../Util")),f=function(e){function t(){return o(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return s(t,u.default),a(t,[{key:"isSupported",value:function(){return void 0!==this._win.Notification}},{key:"create",value:function(e,t){return new this._win.Notification(e,{icon:c.default.isString(t.icon)||c.default.isUndefined(t.icon)?t.icon:t.icon.x32,body:t.body,tag:t.tag,requireInteraction:t.requireInteraction})}},{key:"close",value:function(e){e.close()}}]),t}();n.default=f},{"../Util":4,"./AbstractAgent":5}],7:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(n,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),u=i(e("./AbstractAgent")),c=i(e("../Util")),f=function(e){function t(){return o(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return s(t,u.default),a(t,[{key:"isSupported",value:function(){return void 0!==this._win.external&&void 0!==this._win.external.msIsSiteMode}},{key:"create",value:function(e,t){return this._win.external.msSiteModeClearIconOverlay(),this._win.external.msSiteModeSetIconOverlay(c.default.isString(t.icon)||c.default.isUndefined(t.icon)?t.icon:t.icon.x16,e),this._win.external.msSiteModeActivate(),null}},{key:"close",value:function(){this._win.external.msSiteModeClearIconOverlay()}}]),t}();n.default=f},{"../Util":4,"./AbstractAgent":5}],8:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(n,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),u=i(e("./AbstractAgent")),c=i(e("../Util")),f=i(e("../Messages")),l=function(e){function t(){return o(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return s(t,u.default),a(t,[{key:"isSupported",value:function(){return void 0!==this._win.navigator&&void 0!==this._win.navigator.serviceWorker}},{key:"getFunctionBody",value:function(e){return e.toString().match(/function[^{]+{([\s\S]*)}$/)[1]}},{key:"create",value:function(e,t,n,i,o){var r=this;this._win.navigator.serviceWorker.register(i),this._win.navigator.serviceWorker.ready.then(function(i){var s={id:e,link:n.link,origin:document.location.href,onClick:c.default.isFunction(n.onClick)?r.getFunctionBody(n.onClick):"",onClose:c.default.isFunction(n.onClose)?r.getFunctionBody(n.onClose):""};void 0!==n.data&&null!==n.data&&(s=Object.assign(s,n.data)),i.showNotification(t,{icon:n.icon,body:n.body,vibrate:n.vibrate,tag:n.tag,data:s,requireInteraction:n.requireInteraction,silent:n.silent}).then(function(){i.getNotifications().then(function(e){i.active.postMessage(""),o(e)})}).catch(function(e){throw new Error(f.default.errors.sw_notification_error+e.message)})}).catch(function(e){throw new Error(f.default.errors.sw_registration_error+e.message)})}},{key:"close",value:function(){}}]),t}();n.default=l},{"../Messages":1,"../Util":4,"./AbstractAgent":5}],9:[function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(n,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),a=function(e){return e&&e.__esModule?e:{default:e}}(e("./AbstractAgent")),u=function(e){function t(){return i(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return r(t,a.default),s(t,[{key:"isSupported",value:function(){return void 0!==this._win.navigator.mozNotification}},{key:"create",value:function(e,t){var n=this._win.navigator.mozNotification.createNotification(e,t.body,t.icon);return n.show(),n}}]),t}();n.default=u},{"./AbstractAgent":5}],10:[function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(n,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),a=function(e){return e&&e.__esModule?e:{default:e}}(e("./AbstractAgent")),u=function(e){function t(){return i(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return r(t,a.default),s(t,[{key:"isSupported",value:function(){return void 0!==this._win.webkitNotifications}},{key:"create",value:function(e,t){var n=this._win.webkitNotifications.createNotification(t.icon,e,t.body);return n.show(),n}},{key:"close",value:function(e){e.cancel()}}]),t}();n.default=u},{"./AbstractAgent":5}],11:[function(e,t,n){"use strict";var i=function(e){return e&&e.__esModule?e:{default:e}}(e("./classes/Push"));t.exports=new i.default("undefined"!=typeof window?window:void 0)},{"./classes/Push":3}]},{},[11])(11)});
//# sourceMappingURL=push.min.js.map<commit_msg>Delete push.min.js<commit_after><|endoftext|>


<commit_before>var ipcRenderer = require('electron').ipcRenderer
//require('remote').getCurrentWindow().toggleDevTools();

//functions
var set_songs_num = function(){
	var buttons = $(".select_category > button");

	var querys = [];
	buttons.each(function(i, obj){
		querys.push($(obj).data("query"));
	});

	var nums = ipcRenderer.sendSync("get_all_songs_num", querys);

	buttons.each(function(i, obj){
		$(obj).text($(obj).text() + "[" + nums[i] + "]");
	});
}

//set event handler
$(".select_category > button").click(function(){
	selector_query = $(this).data("query");
	$(".select_category").fadeOut(300);
	$(".ignore_tja_list").fadeOut(300);
	$(".times_selector").fadeIn(300);
});

$(".times_selector > button").click(function(){
	ipcRenderer.send("start_random_select", selector_query, $(this).data("times"));
	$(".times_selector").fadeOut(300);
	$(".info_view").fadeIn(300);
});

$(".info_view > .skip_song").click(function(){
	ipcRenderer.send("skip_song");
});

$(".info_view > .skip_and_add_tjaignore").click(function(){
	ipcRenderer.send("skip_and_add_tjaignore");
});

$(window).keydown(function(key){
	if(key.keyCode == 27){
		if($(".select_category").css("display") == "block"){
			ipcRenderer.send("quit");
		}
		if($(".times_selector").css("display") == "block"){
			$(".times_selector").fadeOut(300);
			$(".select_category").fadeIn(300);
			$(".ignore_tja_list").fadeIn(300);
		}
		if($(".info_view").css("display") == "block"){
			ipcRenderer.send("escape_run_tja");

			$(".info_view").fadeOut(300);
			$(".select_category").fadeIn(300);
			$(".ignore_tja_list").fadeIn(300);
		}
	};
});

var selector_query = "";

//ipc handlers
ipcRenderer.on("alert", function(event, text){
	alert(text);
});

ipcRenderer.on("set_songs_num", function(event){
	set_songs_num();
});

ipcRenderer.on("set_info", function(event, info){
	$(".info_view > .title").html(info.title);
	$(".info_view > .subtitle").html(info.subtitle);
	$(".info_view > .dir_info").html(info.dir_info);
	$(".info_view > .level").html(info.level);
	$(".info_view > .bpm_info").html(info.bpm_info);
	$(".info_view > .songs_num").html(info.songs_num);
});

ipcRenderer.on("reset_view", function(event){
	$(".info_view").fadeOut(300);
	$(".select_category").fadeIn(300);
	$(".ignore_tja_list").fadeIn(300);
});

ipcRenderer.on("add_ignore_tja_list", function(event, string){
	$(".ignore_tja_list > p").css({
		display: "none"
	});

	var new_li = $("<li>");
	new_li.text(string);
	$(".ignore_tja_list > ul").append(new_li);
});

<commit_msg>文法を修正<commit_after>var ipcRenderer = require('electron').ipcRenderer;
//require('remote').getCurrentWindow().toggleDevTools();

//functions
var set_songs_num = function(){
	var buttons = $(".select_category > button");

	var querys = [];
	buttons.each(function(i, obj){
		querys.push($(obj).data("query"));
	});

	var nums = ipcRenderer.sendSync("get_all_songs_num", querys);

	buttons.each(function(i, obj){
		$(obj).text($(obj).text() + "[" + nums[i] + "]");
	});
};

//set event handler
$(".select_category > button").click(function(){
	selector_query = $(this).data("query");
	$(".select_category").fadeOut(300);
	$(".ignore_tja_list").fadeOut(300);
	$(".times_selector").fadeIn(300);
});

$(".times_selector > button").click(function(){
	ipcRenderer.send("start_random_select", selector_query, $(this).data("times"));
	$(".times_selector").fadeOut(300);
	$(".info_view").fadeIn(300);
});

$(".info_view > .skip_song").click(function(){
	ipcRenderer.send("skip_song");
});

$(".info_view > .skip_and_add_tjaignore").click(function(){
	ipcRenderer.send("skip_and_add_tjaignore");
});

$(window).keydown(function(key){
	if(key.keyCode == 27){
		if($(".select_category").css("display") == "block"){
			ipcRenderer.send("quit");
		}
		if($(".times_selector").css("display") == "block"){
			$(".times_selector").fadeOut(300);
			$(".select_category").fadeIn(300);
			$(".ignore_tja_list").fadeIn(300);
		}
		if($(".info_view").css("display") == "block"){
			ipcRenderer.send("escape_run_tja");

			$(".info_view").fadeOut(300);
			$(".select_category").fadeIn(300);
			$(".ignore_tja_list").fadeIn(300);
		}
	}
});

var selector_query = "";

//ipc handlers
ipcRenderer.on("alert", function(event, text){
	alert(text);
});

ipcRenderer.on("set_songs_num", function(event){
	set_songs_num();
});

ipcRenderer.on("set_info", function(event, info){
	$(".info_view > .title").html(info.title);
	$(".info_view > .subtitle").html(info.subtitle);
	$(".info_view > .dir_info").html(info.dir_info);
	$(".info_view > .level").html(info.level);
	$(".info_view > .bpm_info").html(info.bpm_info);
	$(".info_view > .songs_num").html(info.songs_num);
});

ipcRenderer.on("reset_view", function(event){
	$(".info_view").fadeOut(300);
	$(".select_category").fadeIn(300);
	$(".ignore_tja_list").fadeIn(300);
});

ipcRenderer.on("add_ignore_tja_list", function(event, string){
	$(".ignore_tja_list > p").css({
		display: "none"
	});

	var new_li = $("<li>");
	new_li.text(string);
	$(".ignore_tja_list > ul").append(new_li);
});

<|endoftext|>