<commit_before>$(function(){

//    $('body').tubular({videoId: '_A3i2KorZCk'}); // where idOfYourVideo is the YouTube ID.
var dateList = [];

$.ajax({
	type: "GET",
	dataType: "json",
	url: "date.php",
	success: function(data){
		console.log(data[0]);
		var date_no_time = data[0].split(" ");
		for(var i=0; i<data.length; i++){
			dateList.push(date_no_time[0]);
		}
		console.log(dateList);
		console.log(dateList);
		console.log(dateList[1]);
		$("#datepicker").datepicker({
		//showButtonPanel: "true"
		beforeShowDay: function(date) {
			for (var i = 0; i < dateList.length; i++) {
				console.log(dateList[i]);
				var set = Date.parse(dateList[i]);
				var task_day = new Date();
				task_day.setTime(set);
				console.log(date);
				if (date.getYear() == task_day.getYear() &&
					date.getMonth() == task_day.getMonth() &&
					date.getDate() == task_day.getDate()) {
					console.log(dateList);
				return [true, 'kigen', ''];
			}
			console.log("qqq");
		}
		return [true, "", ""];
		$(".kigen").parent().css("background", "red");

	},onSelect: function(){
		var selectedDate = $("#datepicker").datepicker().val();
		console.log(selectedDate);
	}
});
		$( "#datepicker" ).datepicker( "option", "dateFormat", "yy-mm-dd" );
	}
});

	/*$( "#datepicker" ).datepicker( "option", {beforeShowDay: function(date) {
	if (date.getDay() == 0) {
	  // クラス名を設定
	  return [false, 'kigen', ''];
	}
  }
});*/

$("#date").datepicker();
$(".taskCal").datepicker({
	onSelect: function(){
			//var selectedDate = $(".taskCal").datepicker().val();
			//console.log(selectedDate);
		}
	});
$( ".taskCal" ).datepicker( "option", "dateFormat", "yy-mm-dd" );

$(".title").width($("#box").width()+9);

$(document).on("click", "#create", function(){
	console.log("saveボタンが押された！");
	var t = $(this).parent().parent().find("#Avalue").val();
	var date = $(this).parent().parent().find(".taskCal").val();
	console.log(this);
	console.log(t);
	console.log(date);
	var dateArray = date.split("-");
	var term = dateArray[1] + "/" + dateArray[2];
	var data;
	if(t != "" && date != ""){
		var d = false;
		data = {'task' : t , 'date': date};
		if($("li").size() > 0){
			$("li").each(function(){
					//console.log($(this).text());
					console.log(t);
					if(t == $(this).text()){
						d = true;
					}
				});
		}
		if(!d){
			$("
" + t + "" + term + "
").prependTo("ul").hide().slideDown(900, function(){
				$(this).show();
			});
			if($("ul").height() >= 250){
				$("#box").css("overflow-y", "scroll");
			}
				//$("ul").prepend("
" + t + "
").hide();
				$("ul").append("
通信中...
");
				$.ajax({
					type: "POST",
					url: "add.php",
					data: data,
					success: function(){
						$('#tusin').remove();
					}
				});

				dateList.push(date);
				console.log(dateList);
				$("#datepicker").datepicker("destroy");
				$("#datepicker").datepicker({

					onSelect: function(){
						var selectedDate = $("#datepicker").datepicker().val();
						console.log(selectedDate);
					}, beforeShowDay: function(date) {
						for (var i = 0; i < dateList.length; i++) {
							var task_day = new Date();
							task_day.setTime(Date.parse(dateList[i]));
							console.log(task_day);

							if (task_day.getYear() == date.getYear() &&
								task_day.getMonth() == date.getMonth() &&
								task_day.getDate() == date.getDate()) {
								return [true, 'kigen', ''];
						}
					}
					return [true, "", ""];
				}
			});
				$( "#datepicker" ).datepicker( "option", "dateFormat", "yy-mm-dd" );
				$(this).parent().parent().find("#Avalue").val("");
				$(this).parent().parent().find(".taskCal").val("");
				$("#addTask").modal("toggle");
			}else{
				$("
違う名前を指定してください
").appendTo("#modal1").css("color", "red");
				$("#Avalue").focus(function(){
					$(".warning1").remove();
					$(this).select();
				}).on("click", function(){
					$(this).select();
				});
			}
		}
	});

$(document).on("click", "li", function(){
	console.log("リストが選択された");
	var flag = $(this).hasClass("selected");
	if(!(flag)){
		$(this).css("color", "white");
		$(this).addClass("selected");
	}else{
		$(this).css("color", "black");
		$(this).removeClass("selected");
	}
});

var before_t = "";
$("#edit").click(function(){
	console.log("editボタンが押された");
	var count = 0;
	var temp = "";
	var date;
	$("li").each(function(){
		console.log(this);
		var flag = $(this).hasClass("selected");
		if(flag){
			temp = $(this).find(".task").text();
			date = $(this).find(".term").text();
			console.log(date);
			console.log(temp);
			count++;
		}
	});
	if(count == 1){

		$("#Evalue").val(temp).focus(function(){
			$(this).select();
		}).on("click", function(){
			$(this).select();
		});
		var editDate;
		$.ajax({
			type: "POST",
			url: "edit_date.php",
			data: 'task=' + temp,
			success: function(data){
				editDate = data.split(" ");
				console.log(editDate);
				$(".taskCal").val(editDate[0]);
				$("#editTask").modal("show");
			}
		});

			//$( ".taskCal" ).datepicker( "setDate", "2012-10-12" );

			$(document).on("click", "#change", function(){
				console.log("edit taskボタンが押された！");
				var t = $(this).parent().parent().find("#Evalue").val();
				console.log(this);
				console.log(t);
				var date = $(this).parent().parent().find(".taskCal").val();
				var dateArray = date.split("-");
				var term = dateArray[1] + "/" + dateArray[2];
				console.log(date);
				console.log(term);

				if(t != null && date != null){
					$(".selected").replaceWith("
" + t + "" + term + "
").show();
					$(this).parent().parent().find("#Evalue").val("");
					$("#editTask").modal("hide");
					$("ul").append("
通信中...
");
					$.ajax({
						type: "POST",
						url: "edit.php",
						data: 'before=' + temp + '&after=' + t + "&date=" + date,
						success: function(data){
							$('#tusin').remove();
							console.log(data);
							var date_no_time = data.split(" ");
							for (var i = 0; i < dateList.length; i++) {
								if(dateList[i] == date_no_time[0]){
									dateList.splice(i, 1);
									dateList.push(date_no_time[0]);
								}
							}
							console.log(dateList);
							$("#datepicker").datepicker("destroy");
							$("#datepicker").datepicker({

								onSelect: function(){
									var selectedDate = $("#datepicker").datepicker().val();
									console.log(selectedDate);
								}, beforeShowDay: function(date) {
									for (var i = 0; i < dateList.length; i++) {
										var task_day = new Date();
										task_day.setTime(Date.parse(dateList[i]));
										console.log(task_day);

										if (task_day.getYear() == date.getYear() &&
											task_day.getMonth() == date.getMonth() &&
											task_day.getDate() == date.getDate()) {
											return [true, 'kigen', ''];
									}
								}
								return [true, "", ""];
							}
						});
							$( "#datepicker" ).datepicker( "option", "dateFormat", "yy-mm-dd" );
						}
					});

}
});
		//	$(".selected").css("color", "black");
		//	$(".selected").removeClass("selected");
	}
});

$("#trash").click(function(){
	console.log("trashボタンが押された");
	var temp;
	var array = [];
	$("li").each(function(){
		console.log(this);
		var flag = $(this).hasClass("selected");
		if(flag){
			temp = $(this).find(".task").text();
			console.log(temp);
			array.push(temp);
				//console.log(array);
				$(this).hide(700, function(){
					$(this).remove();
				});
			}
		});
	if (array.length != 0) {
		$("ul").append("
通信中...
");
		console.log(array);
		$.ajax({
			type: "POST",
			url: "trash.php",
			data: {'task' : array},
			success: function(data){
				$('#tusin').remove();
				console.log(data);
			}
		});
		array = [];
	};
	if($("ul").height() >= 250){
		$("#box").css("overflow", "hidden");
	}
});

$("#achieve").click(function(){
	console.log("achieveボタンが押された");
	var temp = '';
	$("li").each(function(){
		console.log(this);
		var flag = $(this).hasClass("selected");
		temp = $(this).text();
		if(flag){
			$(this).hide(700, function(){
				$(this).remove();
				$("ul").append("
通信中...
");
				$.ajax({
					type: "POST",
					url: "achieve.php",
					data: 'task=' + temp,
					success: function(){
						$('#tusin').remove();
					}
				});
			});
		}
	});
	if($("ul").height() >= 250){
		$("#box").css("overflow", "hidden");
	}
	if($(".boxSub").height() >= 250){
		$("#boxSub").css("overflow-y", "scroll");
	}
	$("#box").toggle(2000);
	$("#boxSub").toggle(2000);
});
});<commit_msg>trashchange<commit_after>$(function(){

//    $('body').tubular({videoId: '_A3i2KorZCk'}); // where idOfYourVideo is the YouTube ID.
var dateList = [];

$.ajax({
	type: "GET",
	dataType: "json",
	url: "date.php",
	success: function(data){
		console.log(data[0]);
		var date_no_time = data[0].split(" ");
		for(var i=0; i<data.length; i++){
			dateList.push(date_no_time[0]);
		}
		console.log(dateList);
		console.log(dateList);
		console.log(dateList[1]);
		$("#datepicker").datepicker({
		//showButtonPanel: "true"
		beforeShowDay: function(date) {
			for (var i = 0; i < dateList.length; i++) {
				console.log(dateList[i]);
				var set = Date.parse(dateList[i]);
				var task_day = new Date();
				task_day.setTime(set);
				console.log(date);
				if (date.getYear() == task_day.getYear() &&
					date.getMonth() == task_day.getMonth() &&
					date.getDate() == task_day.getDate()) {
					console.log(dateList);
				return [true, 'kigen', ''];
			}
			console.log("qqq");
		}
		return [true, "", ""];
		$(".kigen").parent().css("background", "red");

	},onSelect: function(){
		var selectedDate = $("#datepicker").datepicker().val();
		console.log(selectedDate);
	}
});
		$( "#datepicker" ).datepicker( "option", "dateFormat", "yy-mm-dd" );
	}
});

	/*$( "#datepicker" ).datepicker( "option", {beforeShowDay: function(date) {
	if (date.getDay() == 0) {
	  // クラス名を設定
	  return [false, 'kigen', ''];
	}
  }
});*/

$("#date").datepicker();
$(".taskCal").datepicker({
	onSelect: function(){
			//var selectedDate = $(".taskCal").datepicker().val();
			//console.log(selectedDate);
		}
	});
$( ".taskCal" ).datepicker( "option", "dateFormat", "yy-mm-dd" );

$(".title").width($("#box").width()+9);

$(document).on("click", "#create", function(){
	console.log("saveボタンが押された！");
	var t = $(this).parent().parent().find("#Avalue").val();
	var date = $(this).parent().parent().find(".taskCal").val();
	console.log(this);
	console.log(t);
	console.log(date);
	var dateArray = date.split("-");
	var term = dateArray[1] + "/" + dateArray[2];
	var data;
	if(t != "" && date != ""){
		var d = false;
		data = {'task' : t , 'date': date};
		if($("li").size() > 0){
			$("li").each(function(){
					//console.log($(this).text());
					console.log(t);
					if(t == $(this).text()){
						d = true;
					}
				});
		}
		if(!d){
			$("
" + t + "" + term + "
").prependTo("ul").hide().slideDown(900, function(){
				$(this).show();
			});
			if($("ul").height() >= 250){
				$("#box").css("overflow-y", "scroll");
			}
				//$("ul").prepend("
" + t + "
").hide();
				$("ul").append("
通信中...
");
				$.ajax({
					type: "POST",
					url: "add.php",
					data: data,
					success: function(){
						$('#tusin').remove();
					}
				});

				dateList.push(date);
				console.log(dateList);
				$("#datepicker").datepicker("destroy");
				$("#datepicker").datepicker({

					onSelect: function(){
						var selectedDate = $("#datepicker").datepicker().val();
						console.log(selectedDate);
					}, beforeShowDay: function(date) {
						for (var i = 0; i < dateList.length; i++) {
							var task_day = new Date();
							task_day.setTime(Date.parse(dateList[i]));
							console.log(task_day);

							if (task_day.getYear() == date.getYear() &&
								task_day.getMonth() == date.getMonth() &&
								task_day.getDate() == date.getDate()) {
								return [true, 'kigen', ''];
						}
					}
					return [true, "", ""];
				}
			});
				$( "#datepicker" ).datepicker( "option", "dateFormat", "yy-mm-dd" );
				$(this).parent().parent().find("#Avalue").val("");
				$(this).parent().parent().find(".taskCal").val("");
				$("#addTask").modal("toggle");
			}else{
				$("
違う名前を指定してください
").appendTo("#modal1").css("color", "red");
				$("#Avalue").focus(function(){
					$(".warning1").remove();
					$(this).select();
				}).on("click", function(){
					$(this).select();
				});
			}
		}
	});

$(document).on("click", "li", function(){
	console.log("リストが選択された");
	var flag = $(this).hasClass("selected");
	if(!(flag)){
		$(this).css("color", "white");
		$(this).addClass("selected");
	}else{
		$(this).css("color", "black");
		$(this).removeClass("selected");
	}
});

var before_t = "";
$("#edit").click(function(){
	console.log("editボタンが押された");
	var count = 0;
	var temp = "";
	var date;
	$("li").each(function(){
		console.log(this);
		var flag = $(this).hasClass("selected");
		if(flag){
			temp = $(this).find(".task").text();
			date = $(this).find(".term").text();
			console.log(date);
			console.log(temp);
			count++;
		}
	});
	if(count == 1){

		$("#Evalue").val(temp).focus(function(){
			$(this).select();
		}).on("click", function(){
			$(this).select();
		});
		var editDate;
		$.ajax({
			type: "POST",
			url: "edit_date.php",
			data: 'task=' + temp,
			success: function(data){
				editDate = data.split(" ");
				console.log(editDate);
				$(".taskCal").val(editDate[0]);
				$("#editTask").modal("show");
			}
		});

			//$( ".taskCal" ).datepicker( "setDate", "2012-10-12" );

			$(document).on("click", "#change", function(){
				console.log("edit taskボタンが押された！");
				var t = $(this).parent().parent().find("#Evalue").val();
				console.log(this);
				console.log(t);
				var date = $(this).parent().parent().find(".taskCal").val();
				var dateArray = date.split("-");
				var term = dateArray[1] + "/" + dateArray[2];
				console.log(date);
				console.log(term);

				if(t != null && date != null){
					$(".selected").replaceWith("
" + t + "" + term + "
").show();
					$(this).parent().parent().find("#Evalue").val("");
					$("#editTask").modal("hide");
					$("ul").append("
通信中...
");
					$.ajax({
						type: "POST",
						url: "edit.php",
						data: 'before=' + temp + '&after=' + t + "&date=" + date,
						success: function(data){
							$('#tusin').remove();
							console.log(data);
							var date_no_time = data.split(" ");
							for (var i = 0; i < dateList.length; i++) {
								if(dateList[i] == date_no_time[0]){
									dateList.splice(i, 1);
									dateList.push(date_no_time[0]);
								}
							}
							console.log(dateList);
							$("#datepicker").datepicker("destroy");
							$("#datepicker").datepicker({

								onSelect: function(){
									var selectedDate = $("#datepicker").datepicker().val();
									console.log(selectedDate);
								}, beforeShowDay: function(date) {
									for (var i = 0; i < dateList.length; i++) {
										var task_day = new Date();
										task_day.setTime(Date.parse(dateList[i]));
										console.log(task_day);

										if (task_day.getYear() == date.getYear() &&
											task_day.getMonth() == date.getMonth() &&
											task_day.getDate() == date.getDate()) {
											return [true, 'kigen', ''];
									}
								}
								return [true, "", ""];
							}
						});
							$( "#datepicker" ).datepicker( "option", "dateFormat", "yy-mm-dd" );
						}
					});

}
});
		//	$(".selected").css("color", "black");
		//	$(".selected").removeClass("selected");
	}
});

$("#trash").click(function(){
	console.log("trashボタンが押された");
	var temp;
	var array = [];
	$("li").each(function(){
		console.log(this);
		var flag = $(this).hasClass("selected");
		if(flag){
			temp = $(this).find(".task").text();
			console.log(temp);
			array.push(temp);
				//console.log(array);
				$(this).hide(700, function(){
					$(this).remove();
				});
			}
		});
	if (array.length != 0) {
		$("ul").append("
通信中...
");
		console.log(array);
		$.ajax({
			type: "POST",
			url: "trash.php",
			data: {'task' : array},
			success: function(data){
				$('#tusin').remove();
				console.log(data);
				var date_no_time = data.split(" ");
							for (var i = 0; i < dateList.length; i++) {
								if(dateList[i] == date_no_time[0]){
									dateList.splice(i, 1);
								}
							}
							console.log(dateList);
							$("#datepicker").datepicker("destroy");
							$("#datepicker").datepicker({

								onSelect: function(){
									var selectedDate = $("#datepicker").datepicker().val();
									console.log(selectedDate);
								}, beforeShowDay: function(date) {
									for (var i = 0; i < dateList.length; i++) {
										var task_day = new Date();
										task_day.setTime(Date.parse(dateList[i]));
										console.log(task_day);

										if (task_day.getYear() == date.getYear() &&
											task_day.getMonth() == date.getMonth() &&
											task_day.getDate() == date.getDate()) {
											return [true, 'kigen', ''];
									}
								}
								return [true, "", ""];
							}
						});
							$( "#datepicker" ).datepicker( "option", "dateFormat", "yy-mm-dd" );
			}
		});
		array = [];
	};
	if($("ul").height() >= 250){
		$("#box").css("overflow", "hidden");
	}
});

$("#achieve").click(function(){
	console.log("achieveボタンが押された");
	var temp = '';
	$("li").each(function(){
		console.log(this);
		var flag = $(this).hasClass("selected");
		temp = $(this).text();
		if(flag){
			$(this).hide(700, function(){
				$(this).remove();
				$("ul").append("
通信中...
");
				$.ajax({
					type: "POST",
					url: "achieve.php",
					data: 'task=' + temp,
					success: function(){
						$('#tusin').remove();
					}
				});
			});
		}
	});
	if($("ul").height() >= 250){
		$("#box").css("overflow", "hidden");
	}
	if($(".boxSub").height() >= 250){
		$("#boxSub").css("overflow-y", "scroll");
	}
	$("#box").toggle(2000);
	$("#boxSub").toggle(2000);
});
});<|endoftext|>


<commit_before>// makes cat appear from the left
function appear() {
  $('.cat').velocity({translateX: '-1000px'}, {duration: 1, display: 'hidden'});
  $('.cat').velocity({translateX: '100px'}, {duration: 500, display: 'visible'});
}
$(function() {
  appear();

  // controls audio playback
  Mousetrap.bind('a', function() {
    document.getElementById('nyansong').play();
  });
  Mousetrap.bind('m', function() {
    document.getElementById('nyansong').pause();
  });
  Mousetrap.bind('up', function() {
    document.getElementById('nyansong').volume+=0.1;
  });
  Mousetrap.bind('down', function() {
    document.getElementById('nyansong').volume-=0.1;
  });

  // displays number of trips cat has taken
  var trips = 0;
  function incrementTrips() {
    trips++;
    $('p').velocity({
      opacity: 1
    },{
      duration: 2000
    });
    $('.counter')[0].textContent = trips;
    console.log(trips);
  }

  $('html').click(function() {
    // makes cat fly away to the right then return from left
    $('.cat').velocity({
      // properties and values
      translateX: '5000px'
    }, {
      // options
      duration: 500,
      complete: function() {
        appear();
        incrementTrips();
      }
    });
  });
});
<commit_msg>Refactor reference to audio as a variable<commit_after>
// makes cat appear from the left
function appear() {
  $('.cat').velocity({translateX: '-1000px'}, {duration: 1, display: 'hidden'});
  $('.cat').velocity({translateX: '100px'}, {duration: 500, display: 'visible'});
}

$(function() {
  // audio
  var nyansong = document.getElementById('nyansong');

  appear();

  // controls audio playback
  Mousetrap.bind('a', function() {
    nyansong.play();
  });
  Mousetrap.bind('m', function() {
    nyansong.pause();
  });
  Mousetrap.bind('up', function() {
    nyansong.volume+=0.1;
  });
  Mousetrap.bind('down', function() {
    nyansong.volume-=0.1;
  });

  // displays number of trips cat has taken
  var trips = 0;
  function incrementTrips() {
    trips++;
    $('p').velocity({
      opacity: 1
    },{
      duration: 2000
    });
    $('.counter')[0].textContent = trips;
    console.log(trips);
  }

  $('html').click(function() {
    // makes cat fly away to the right then return from left
    $('.cat').velocity({
      // properties and values
      translateX: '5000px'
    }, {
      // options
      duration: 500,
      complete: function() {
        appear();
        incrementTrips();
      }
    });
  });
});
<|endoftext|>


<commit_before>$(document).ready(function() {
  $( '#current-year' ).text( (new Date).getFullYear() );
})

$(window).on("load", function() {
  $('body').fadeIn(1000);
})
<commit_msg>Formatting<commit_after>$(document).ready( function() {
  $( '#current-year' ).text( (new Date).getFullYear() );
});

$(window).on( 'load' , function() {
  $( 'body' ).fadeIn(1000);
});
<|endoftext|>


<commit_before>/**
 * Created by azu.
 * Date: 11/05/25 18:04
 * License: MIT License
 */

$(function () {
    var app = window.app || {};
    var vm = new app.model.JSerModel();
    ko.bindingHandlers.sortable.afterMove = function (arg) {
        var article = arg.item;
        window.app.visited.setItem(article.url, new Date());
    };
    ko.applyBindings(vm);

    Handlebars.registerHelper('auto_format_html', function (text) {
        // autolinkTwitter 内でHTMLエスケープされているためHandlebarではしない
        var linkedText = window.autolinkTwitter(text);
        return linkedText.replace(/\n/g, "
");
    });
    Handlebars.registerHelper('auto_format_md', function (text) {
        // autolinkTwitter 内でHTMLエスケープされているためHandlebarではしない
        var linkedText = window.autolinkTwitter(text);
        return linkedText.replace(/\n/g, "\n\n").trim();
    });
    Handlebars.registerHelper('format_tags', function (tags) {
        return tags.map(function (tag) {
            return '' + tag + '';
        }).join(" ");
    });
    Handlebars.registerHelper('escape_md', function (text) {
        var markdown_literal = /[\\`\*_\{\}\[\]\#\|!]/g;
        return text.replace(markdown_literal, "\\$&");
    });
    Handlebars.registerHelper('ttp', function (text) {
        return text.replace(/https?:\/\//i, "");
    });
    function getOutputJSON() {
        var json = ko.toJS(vm.outputModels);
        return json.filter(function (model) {
            return model.articles.length > 0;
        });
    }

    $("#fullscreen-button").button().on("click", function (evt) {
        if (screenfull.enabled) {
            screenfull.request(document.querySelector("#content"));
        }
    });
    $("#jq-dialog").on("dialogfocus", function (evt, ui) {
        $("#js-dialog-textarea").select();
    });
    $('#copy-markdown').button().on("click", function () {
        var filteredJSON = getOutputJSON();
        var source = $("#article-markdown-template").html();
        var template = Handlebars.compile(source);
        var result = template({
            Groups: filteredJSON
        });
        $("#js-dialog-textarea").text(result.trim());
        $("#jq-dialog").dialog({
            title: "Markdown",
            width: 700,
            height: 500
        });
    });
    $('#copy-html').button().on("click", function () {
        var source = $("#article-template").html();
        var template = Handlebars.compile(source);
        var result = template({
            Groups: getOutputJSON()
        });
        $("#js-dialog-textarea").text(result.trim());
        $("#jq-dialog").dialog({
            title: "HTML",
            width: 700,
            height: 500
        });
    });
    function format0(str, len) {
        return ('_' + Math.pow(10, len) + str).slice(-len);
    }

    var pickedCalendarHandler = function (cal) {
        var date = cal.currentDate;
        var fileDirPath = "data/" + date.getFullYear() + '/' + format0((date.getMonth() + 1), 2);
        var JSONFilePath = fileDirPath + "/index.json?" + new Date().getTime();
        window.app.client.load(JSONFilePath).done(function (data) {
            var list = data.list;
            vm.reloadInput(list);
            $("#content").data("file-dir-path", fileDirPath);
        }).fail(function (err) {
            $.WsGrowl.show({content: 'その月のアーカイブはないです'});
        });
    };
    $("#date-picker").calendarPicker({
        monthNames: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
        dayNames: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
        //useWheel:true,
        //callbackDelay:500,
        //years:1,
        months: 4,
        //days:4,
        showDayArrows: false,
        callback: pickedCalendarHandler
    });
});
<commit_msg>fix(escape): remove 過剰なエスケープ<commit_after>/**
 * Created by azu.
 * Date: 11/05/25 18:04
 * License: MIT License
 */

$(function () {
    var app = window.app || {};
    var vm = new app.model.JSerModel();
    ko.bindingHandlers.sortable.afterMove = function (arg) {
        var article = arg.item;
        window.app.visited.setItem(article.url, new Date());
    };
    ko.applyBindings(vm);

    Handlebars.registerHelper('auto_format_html', function (text) {
        // autolinkTwitter 内でHTMLエスケープされているためHandlebarではしない
        var linkedText = window.autolinkTwitter(text);
        return linkedText.replace(/\n/g, "
");
    });
    Handlebars.registerHelper('auto_format_md', function (text) {
        // autolinkTwitter 内でHTMLエスケープされているためHandlebarではしない
        var linkedText = window.autolinkTwitter(text);
        return linkedText.replace(/\n/g, "\n\n").trim();
    });
    Handlebars.registerHelper('format_tags', function (tags) {
        return tags.map(function (tag) {
            return '' + tag + '';
        }).join(" ");
    });
    Handlebars.registerHelper('escape_md', function (text) {
        var markdown_literal = /[\\`\*_\{\}\[\]]/g;
        return text.replace(markdown_literal, "\\$&");
    });
    Handlebars.registerHelper('ttp', function (text) {
        return text.replace(/https?:\/\//i, "");
    });
    function getOutputJSON() {
        var json = ko.toJS(vm.outputModels);
        return json.filter(function (model) {
            return model.articles.length > 0;
        });
    }

    $("#fullscreen-button").button().on("click", function (evt) {
        if (screenfull.enabled) {
            screenfull.request(document.querySelector("#content"));
        }
    });
    $("#jq-dialog").on("dialogfocus", function (evt, ui) {
        $("#js-dialog-textarea").select();
    });
    $('#copy-markdown').button().on("click", function () {
        var filteredJSON = getOutputJSON();
        var source = $("#article-markdown-template").html();
        var template = Handlebars.compile(source);
        var result = template({
            Groups: filteredJSON
        });
        $("#js-dialog-textarea").text(result.trim());
        $("#jq-dialog").dialog({
            title: "Markdown",
            width: 700,
            height: 500
        });
    });
    $('#copy-html').button().on("click", function () {
        var source = $("#article-template").html();
        var template = Handlebars.compile(source);
        var result = template({
            Groups: getOutputJSON()
        });
        $("#js-dialog-textarea").text(result.trim());
        $("#jq-dialog").dialog({
            title: "HTML",
            width: 700,
            height: 500
        });
    });
    function format0(str, len) {
        return ('_' + Math.pow(10, len) + str).slice(-len);
    }

    var pickedCalendarHandler = function (cal) {
        var date = cal.currentDate;
        var fileDirPath = "data/" + date.getFullYear() + '/' + format0((date.getMonth() + 1), 2);
        var JSONFilePath = fileDirPath + "/index.json?" + new Date().getTime();
        window.app.client.load(JSONFilePath).done(function (data) {
            var list = data.list;
            vm.reloadInput(list);
            $("#content").data("file-dir-path", fileDirPath);
        }).fail(function (err) {
            $.WsGrowl.show({content: 'その月のアーカイブはないです'});
        });
    };
    $("#date-picker").calendarPicker({
        monthNames: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
        dayNames: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
        //useWheel:true,
        //callbackDelay:500,
        //years:1,
        months: 4,
        //days:4,
        showDayArrows: false,
        callback: pickedCalendarHandler
    });
});
<|endoftext|>


<commit_before>import { VNode } from "./vnode";

import { q } from "./qname";

import { prettyXML } from "./pretty";

import { forEach, foldLeft, range, drop } from "./transducers";

import * as multimap from "./multimap";

// import self!
import * as cx from "./inode";

// helpers ---------------
if(!Object.values){
	const objUtil = (obj,f) => {
		const keys = Object.keys(obj);
		var entries = [];
		for (let i = 0; i < keys.length; i++) {
			const key = keys[i];
			entries.push(f(key));
		}
		return entries;
	};
	Object.values = function(o){
		return objUtil(o, key => o[key]);
	};
	Object.entries = function(o){
		return objUtil(o,key => [key, o[key]]);
	};
}
function _inferType(inode){
	if(inode === null) return 12;
	var cc = inode.constructor;
	if(cc == Array) {
		return 5;
	} else if(cc == Object){
		if(inode.$children) {
			return inode.$name == "#document" ? 9 : 1;
		} else if(inode.$value){
			return 2;
		} else if(inode.$comment){
			return 8;
		} else {
			return 6;
		}
	} else if(cc == Number || cc == Boolean) {
		return 12;
	}
	return 3;
}

/*
function* _get(children, idx) {
	let len = children.length;
	for (let i = 0; i < len; i++) {
		if ((children[i].$name || i + 1) == idx) {
			yield children[i];
		}
	}
}
*/
function _last(a){
	return drop(a,a.length-1);
}

function _elemToString(e){
	const attrFunc = (z,kv) => {
		return z += " "+kv[0]+"=\""+kv[1]+"\"";
	};
	let str = "<"+e.$name;
	let ns = e.$ns;
	if(ns) str += " xmlns" + (ns.prefix ? ":" + ns.prefix : "") + "=\"" + ns.uri + "\"";
	str = foldLeft(Object.entries(e.$attrs),str,attrFunc);
	if(e.$children.length > 0){
		str += ">";
		for(let c of e.$children){
			str += stringify(c);
		}
		str += "</"+e.$name+">";
	} else {
		str += "/>";
	}
	return str;
}

// -----------------------

export function ivalue(type, name, value){
	if(type == 2) {
		return {$name:name,$value:value};
	} else if(type == 8) {
		return {$comment:value};
	}
	return value;
}

export function vnode(inode, parent, depth, indexInParent, type) {
	type = type || _inferType(inode);
	var name,value;
	if(type == 1 || type == 9){
		name = inode.$name;
	} else if(type == 2) {
		name = inode.$name;
		value = inode.$value;
	} else if (type == 5) {
		name = parent ? parent.keys()[indexInParent] : "#";
	} else if (type == 6) {
		name = parent ? parent.keys()[indexInParent] : "#";
	} else if (type == 8) {
		value = inode.$comment;
	} else if(type == 3 || type == 12){
		value = inode;
		name = parent ? parent.keys()[indexInParent] : "#";
	}
	// return vnode
	return new VNode(
		cx,
		inode,
		type,
		inode && inode.$ns ? q(inode.$ns.uri, name) : name,
		value,
		parent,
		depth,
		indexInParent
	);
}

export function emptyINode(type, name, attrs, ns) {
	var inode = type == 5 ? [] : {};
	if(type == 1 || type == 9){
		inode.$name = name;
		inode.$attrs = attrs;
		inode.$ns = ns;
		inode.$children = [];
	}
	return inode;
}

export function emptyAttrMap(init){
	return init || {};
}

/*
export function get(inode,idx,type,cache){
	type = type || _inferType(inode);
	if(type == 1 || type == 9){
		if(cache) return cache[idx];
		return _get(inode.$children,idx);
	}
	return inode[idx];
}
*/
export function next(inode, node, type){
	type = type || _inferType(inode);
	var idx = node.indexInParent;
	if(type == 1 || type == 9) {
		return inode.$children[idx+1];
	}
	if(type == 5) return inode[idx+1];
	if(type == 6) {
		var vals = Object.values(inode);
		return vals[idx+1];
	}
}

export function push(inode,val,type){
	type = type || _inferType(inode);
	if(type == 1 || type == 9){
		inode.$children.push(val[1]);
	} else if(type == 5) {
		inode.push(val);
	} else if(type == 6){
		inode[val[0]] = val[1];
	}
	return inode;
}

export function set(inode /*,key,val,type*/){
	// used to restore immutable parents, never modifies mutable
	return inode;
}

export function removeChild(inode,child,type){
	type = type || _inferType(inode);
	if(type == 1 || type == 9){
		inode.$children.splice(child.indexInParent,1);
	} else if(type == 5) {
		inode.splice(child.indexInParent,1);
	} else if(type == 6){
		delete inode[child.name];
	}
	return inode;
}

export function cached(inode,type){
	type = type || _inferType(inode);
	if(type == 1 || type == 9) {
		let children = inode.$children, len = children.length, cache = multimap.default();
		for(let i = 0; i<len; i++){
			cache.push([children[i].$name || i + 1,children[i]]);
		}
		return cache;
	}
	if(type == 5) {
		return {
			keys : function(){
				return range(inode.length).toArray();
			}
		};
	}
	if(type == 6) {
		return {
			keys : function(){
				return Object.keys(inode);
			}
		};
	}
}

export function keys(inode,type){
	type = type || _inferType(inode);
	if(type == 1 || type == 9) {
		let children = inode.$children, len = children.length, keys = [];
		for(let i = 0; i<len; i++){
			keys[i] = children[i].$name || i + 1;
		}
		return keys;
	}
	if(type == 5) return range(inode.length).toArray();
	if(type == 6) return Object.keys(inode);
	return [];
}

export function values(inode,type){
	type = type || _inferType(inode);
	if(type == 1 || type == 9) return inode.$children;
	if (type == 2) return [[inode.$name,inode.$value]];
	if(type == 6) return Object.values(inode);
	if (type == 8) return [inode.$comment];
	return inode;
}

export function finalize(inode){
	return inode;
}

export function setAttribute(inode,key,val){
	if(inode.$attrs) inode.$attrs[key]  = val;
	return inode;
}

export function getAttribute(inode,key){
	if(inode.$attrs) return inode.$attrs[key];
}

export function count(inode, type){
	type = type || _inferType(inode);
	if(type == 1 || type == 9){
		return inode.$children.length;
	} else if(type == 5) {
		return inode.length;
	} else if(type == 6){
		return Object.keys(inode).length;
	}
	return 0;
}

export function first(inode,type){
	type = type || _inferType(inode);
	if(type == 1 || type == 9){
		return inode.$children[0];
	} else if(type == 5) {
		return inode[0];
	} else if(type == 6){
		return Object.values(inode)[0];
	}
}

export function last(inode,type){
	type = type || _inferType(inode);
	if(type == 1 || type == 9) return _last(inode.$children);
	if(type == 5) return _last(inode);
	if(type == 6) {
		return _last(Object.values(inode));
	}
}

export function attrEntries(inode){
	if(inode.$attrs) return Object.entries(inode.$attrs);
	return [];
}

export function modify(inode, node, ref, type){
	type = type || _inferType(inode);
	if(type == 1 || type == 9){
		if (ref !== undefined) {
			inode.$children.splice(ref.indexInParent,0,node.inode);
		} else {
			inode.$children.push(node.inode);
		}
	} else if(type == 5){
		if (ref !== undefined) {
			inode.splice(ref.indexInParent,0,node.inode);
		} else {
			inode.push(node.inode);
		}
	} else if(type == 6){
		inode[node.name] = node.inode;
	}
	return inode;
}

export function stringify(inode, type, root = true, key) {
	var str = "";
	type = type || _inferType(inode);
	if (type == 1 || type == 9) {
		str += _elemToString(inode);
	} else if (type == 5) {
		let val = forEach(inode, c => stringify(c)).join("");
		if(key) {
			str += "<" + key + " json:type=\"array\"" + (val ? ">" + val + "</" + key + ">" : "/>");
		} else {
			str += "<json:array" + (val ? ">" + val + "</json:array>" : "/>");
		}
	} else if (type == 6) {
		let val = forEach(Object.entries(inode), c => stringify(c[1], null, false, c[0])).join("");
		if(key) {
			str += "<" + key + " json:type=\"map\"" + (val ? ">" + val + "</" + key + ">" : "/>");
		} else {
			str += "<json:map" + (val ? ">" + val + "</json:map>" : "/>");
		}
	} else {
		let val = inode === null ? "null" : inode.toString();
		if(key) {
			str += "<" + key + (type == 12 ? " json:type=\"literal\"" : "") + (val ? ">" + val + "</" + key + ">" : "/>");
		} else {
			str += type == 12 ? "<json:literal>" + val + "</json:literal>" : val;
		}
	}
	return root ? prettyXML(str) : str;
}

export const getType = _inferType;
<commit_msg>use qname for now<commit_after>import { VNode } from "./vnode";

//import { q } from "./qname";

import { prettyXML } from "./pretty";

import { forEach, foldLeft, range, drop } from "./transducers";

import * as multimap from "./multimap";

// import self!
import * as cx from "./inode";

// helpers ---------------
if(!Object.values){
	const objUtil = (obj,f) => {
		const keys = Object.keys(obj);
		var entries = [];
		for (let i = 0; i < keys.length; i++) {
			const key = keys[i];
			entries.push(f(key));
		}
		return entries;
	};
	Object.values = function(o){
		return objUtil(o, key => o[key]);
	};
	Object.entries = function(o){
		return objUtil(o,key => [key, o[key]]);
	};
}
function _inferType(inode){
	if(inode === null) return 12;
	var cc = inode.constructor;
	if(cc == Array) {
		return 5;
	} else if(cc == Object){
		if(inode.$children) {
			return inode.$name == "#document" ? 9 : 1;
		} else if(inode.$value){
			return 2;
		} else if(inode.$comment){
			return 8;
		} else {
			return 6;
		}
	} else if(cc == Number || cc == Boolean) {
		return 12;
	}
	return 3;
}

/*
function* _get(children, idx) {
	let len = children.length;
	for (let i = 0; i < len; i++) {
		if ((children[i].$name || i + 1) == idx) {
			yield children[i];
		}
	}
}
*/
function _last(a){
	return drop(a,a.length-1);
}

function _elemToString(e){
	const attrFunc = (z,kv) => {
		return z += " "+kv[0]+"=\""+kv[1]+"\"";
	};
	let str = "<"+e.$name;
	let ns = e.$ns;
	if(ns) str += " xmlns" + (ns.prefix ? ":" + ns.prefix : "") + "=\"" + ns.uri + "\"";
	str = foldLeft(Object.entries(e.$attrs),str,attrFunc);
	if(e.$children.length > 0){
		str += ">";
		for(let c of e.$children){
			str += stringify(c);
		}
		str += "</"+e.$name+">";
	} else {
		str += "/>";
	}
	return str;
}

// -----------------------

export function ivalue(type, name, value){
	if(type == 2) {
		return {$name:name,$value:value};
	} else if(type == 8) {
		return {$comment:value};
	}
	return value;
}

export function vnode(inode, parent, depth, indexInParent, type) {
	type = type || _inferType(inode);
	var name = "#",qname,value;
	if(parent && parent.type == 6) name = parent.keys()[indexInParent];
	if(type == 1 || type == 9){
		qname = inode.$name;
	} else if(type == 2) {
		// TODO tuple under map, attr under elem
		name = inode.$name;
		value = inode.$value;
	//} else if (type == 5) {
		// no-op
	//} else if (type == 6) {
		// no-op
	} else if (type == 8) {
		value = inode.$comment;
	} else if(type == 3 || type == 12){
		value = inode;
	}
	// return vnode
	return new VNode(
		cx,
		inode,
		type,
		//inode && inode.$ns ? q(inode.$ns.uri, name) : name,
		name,
		qname,
		value,
		parent,
		depth,
		indexInParent
	);
}

export function emptyINode(type, name, qname, attrs, ns) {
	var inode = type == 5 ? [] : {};
	if(type == 1 || type == 9){
		inode.$name = qname;
		inode.$attrs = attrs;
		inode.$ns = ns;
		inode.$children = [];
	}
	return inode;
}

export function emptyAttrMap(init){
	return init || {};
}

/*
export function get(inode,idx,type,cache){
	type = type || _inferType(inode);
	if(type == 1 || type == 9){
		if(cache) return cache[idx];
		return _get(inode.$children,idx);
	}
	return inode[idx];
}
*/
export function next(inode, node, type){
	type = type || _inferType(inode);
	var idx = node.indexInParent;
	if(type == 1 || type == 9) {
		return inode.$children[idx+1];
	}
	if(type == 5) return inode[idx+1];
	if(type == 6) {
		var vals = Object.values(inode);
		return vals[idx+1];
	}
}

export function push(inode,val,type){
	type = type || _inferType(inode);
	if(type == 1 || type == 9){
		inode.$children.push(val[1]);
	} else if(type == 5) {
		inode.push(val);
	} else if(type == 6){
		inode[val[0]] = val[1];
	}
	return inode;
}

export function set(inode /*,key,val,type*/){
	// used to restore immutable parents, never modifies mutable
	return inode;
}

export function removeChild(inode,child,type){
	type = type || _inferType(inode);
	if(type == 1 || type == 9){
		inode.$children.splice(child.indexInParent,1);
	} else if(type == 5) {
		inode.splice(child.indexInParent,1);
	} else if(type == 6){
		delete inode[child.name];
	}
	return inode;
}

export function cached(inode,type){
	type = type || _inferType(inode);
	if(type == 1 || type == 9) {
		let children = inode.$children, len = children.length, cache = multimap.default();
		for(let i = 0; i<len; i++){
			cache.push([children[i].$name || i + 1,children[i]]);
		}
		return cache;
	}
	if(type == 5) {
		return {
			keys : function(){
				return range(inode.length).toArray();
			}
		};
	}
	if(type == 6) {
		return {
			keys : function(){
				return Object.keys(inode);
			}
		};
	}
}

export function keys(inode,type){
	type = type || _inferType(inode);
	if(type == 1 || type == 9) {
		let children = inode.$children, len = children.length, keys = [];
		for(let i = 0; i<len; i++){
			keys[i] = children[i].$name || i + 1;
		}
		return keys;
	}
	if(type == 5) return range(inode.length).toArray();
	if(type == 6) return Object.keys(inode);
	return [];
}

export function values(inode,type){
	type = type || _inferType(inode);
	if(type == 1 || type == 9) return inode.$children;
	if (type == 2) return [[inode.$name,inode.$value]];
	if(type == 6) return Object.values(inode);
	if (type == 8) return [inode.$comment];
	return inode;
}

export function finalize(inode){
	return inode;
}

export function setAttribute(inode,key,val){
	if(inode.$attrs) inode.$attrs[key]  = val;
	return inode;
}

export function getAttribute(inode,key){
	if(inode.$attrs) return inode.$attrs[key];
}

export function count(inode, type){
	type = type || _inferType(inode);
	if(type == 1 || type == 9){
		return inode.$children.length;
	} else if(type == 5) {
		return inode.length;
	} else if(type == 6){
		return Object.keys(inode).length;
	}
	return 0;
}

export function first(inode,type){
	type = type || _inferType(inode);
	if(type == 1 || type == 9){
		return inode.$children[0];
	} else if(type == 5) {
		return inode[0];
	} else if(type == 6){
		return Object.values(inode)[0];
	}
}

export function last(inode,type){
	type = type || _inferType(inode);
	if(type == 1 || type == 9) return _last(inode.$children);
	if(type == 5) return _last(inode);
	if(type == 6) {
		return _last(Object.values(inode));
	}
}

export function attrEntries(inode){
	if(inode.$attrs) return Object.entries(inode.$attrs);
	return [];
}

export function modify(inode, node, ref, type){
	type = type || _inferType(inode);
	if(type == 1 || type == 9){
		if (ref !== undefined) {
			inode.$children.splice(ref.indexInParent,0,node.inode);
		} else {
			inode.$children.push(node.inode);
		}
	} else if(type == 5){
		if (ref !== undefined) {
			inode.splice(ref.indexInParent,0,node.inode);
		} else {
			inode.push(node.inode);
		}
	} else if(type == 6){
		inode[node.name] = node.inode;
	}
	return inode;
}

export function stringify(inode, type, root = true, key) {
	var str = "";
	type = type || _inferType(inode);
	if (type == 1 || type == 9) {
		str += _elemToString(inode);
	} else if (type == 5) {
		let val = forEach(inode, c => stringify(c)).join("");
		if(key) {
			str += "<" + key + " json:type=\"array\"" + (val ? ">" + val + "</" + key + ">" : "/>");
		} else {
			str += "<json:array" + (val ? ">" + val + "</json:array>" : "/>");
		}
	} else if (type == 6) {
		let val = forEach(Object.entries(inode), c => stringify(c[1], null, false, c[0])).join("");
		if(key) {
			str += "<" + key + " json:type=\"map\"" + (val ? ">" + val + "</" + key + ">" : "/>");
		} else {
			str += "<json:map" + (val ? ">" + val + "</json:map>" : "/>");
		}
	} else {
		let val = inode === null ? "null" : inode.toString();
		if(key) {
			str += "<" + key + (type == 12 ? " json:type=\"literal\"" : "") + (val ? ">" + val + "</" + key + ">" : "/>");
		} else {
			str += type == 12 ? "<json:literal>" + val + "</json:literal>" : val;
		}
	}
	return root ? prettyXML(str) : str;
}

export const getType = _inferType;
<|endoftext|>


<commit_before>"use strict";

const qBtnSubmit = document.querySelector("#button-submit");
const qAnswerArea = document.querySelector("#full-answer");
const qImageContainer = document.querySelector("#captcha-image-container");

const input_box = `<input type="text" id="input-box" autocomplete="off" autofocus>`
const questions = [
  {
    "prompt": `Look over ${input_box}.`,
    "answer": "there",
    "images": ["there.png", "their.png", "theyre.png"]
  },
  {
    "prompt": `${input_box} the only one who can prevent forest fires.`,
    "answer": "you're",
    "images": ["your.png", "youre.png"]
  }
];

function selectRandom(arr) {
  return arr[Math.floor(Math.random() * arr.length)];
}

function isCorrectAnswer(user, correct) {
  return user.trim().toLowerCase() === correct;
}

function evaluateAnswer(e) {
  const user_input = e.value || e.target.value;
  if (isCorrectAnswer(user_input, selected_question.answer)) {
    window.location.replace("https://www.google.com");
  } else {
    document.body.remove();
  }
}

// Pick a prompt to display to the user
const selected_question = selectRandom(questions);

// Generate the HTML for the image-based answer options
selected_question.images.forEach(img => {
  qImageContainer.insertAdjacentHTML(
    "beforeend",
    `<img class='captcha-image' width='200' height='116' src='img/${img}'>`
  );
});

// Display the prompt to be answered
qAnswerArea.insertAdjacentHTML("afterbegin", selected_question.prompt);
const qInput = document.querySelector("#input-box");

qBtnSubmit.addEventListener("click", evaluateAnswer);
qInput.addEventListener("keyup", function(e) {
  // Only react on enter key press
  if (e.key === "Enter") {
    evaluateAnswer(this);
    return false;
  }
});
<commit_msg>Make page less likely to break on page load<commit_after>"use strict";

const qBtnSubmit = document.querySelector("#button-submit");
const qAnswerArea = document.querySelector("#full-answer");
const qImageContainer = document.querySelector("#captcha-image-container");

const input_box = `<input type="text" id="input-box" autocomplete="off" autofocus>`
const questions = [
  {
    "prompt": `Look over ${input_box}.`,
    "answer": "there",
    "images": ["there.png", "their.png", "theyre.png"]
  },
  {
    "prompt": `${input_box} the only one who can prevent forest fires.`,
    "answer": "you're",
    "images": ["your.png", "youre.png"]
  }
];

function selectRandom(arr) {
  return arr[Math.floor(Math.random() * arr.length)];
}

function isCorrectAnswer(user, correct) {
  return user.trim().toLowerCase() === correct;
}

function evaluateAnswer(e) {
  const user_input = e.value || e.target.value;
  if (isCorrectAnswer(user_input, selected_question.answer)) {
    window.location.replace("https://www.google.com");
    return false;
  } else {
    document.body.remove();
    return false;
  }
}

// Pick a prompt to display to the user
const selected_question = selectRandom(questions);

// Generate the HTML for the image-based answer options
selected_question.images.forEach(img => {
  qImageContainer.insertAdjacentHTML(
    "beforeend",
    `<img class='captcha-image' width='200' height='116' src='img/${img}'>`
  );
});

// Display the prompt to be answered
qAnswerArea.insertAdjacentHTML("afterbegin", selected_question.prompt);
const qInput = document.querySelector("#input-box");

qBtnSubmit.addEventListener("click", evaluateAnswer);
qInput.addEventListener("keyup", function(e) {
  // Only react on enter key press
  if (e.key === "Enter") {
    evaluateAnswer(this);
    return false;
  }
});
<|endoftext|>


<commit_before>var base = 'https://api.github.com/users/';
var rData = {},
	uData = {};

// Run on load
$(document).ready(function() {
	$('#username').focus();
	$('#data').hide();
	$('.spinner').hide();
});

//Detect 'Enter' key being pressed
$('#username').keyup(function (e) {
	if (e.keyCode === 13) {
		$('#content').empty();
		$('#top-bar').empty();
		$('#data').hide();
		$('#messages').empty();
		var enteredText = $('#username').val();
		if (enteredText.length === 0) alert('Please enter a name!');
		else {
			if (enteredText == 'git help git') showHelp();
			else {
				$('.spinner').show();
				getUser(enteredText);
			}
			$('#username').val('');
		}
	}
});

//Get user data using GitHub API
function getUser(userName) {
	$.get(base + userName, function (userData) {
		uData = userData;
		$('#search').fadeOut(750, function () {
			$('#data').fadeIn(500);
		});
		//$('#content').append('');
		$('#content').append(''+uData.name+'');
		$('#content').append(' member since '+(uData.created_at).substring(0,10)+'');
	});
	getRepos(userName);
}

//Get users' repo data using GitHub API
function getRepos(user) {
	var rCount = 0;
	$.get(base + user + '/repos', function (repoData) {
		rData = repoData;
		for (var repo in rData) {
			rCount++;
			//$('#repos').append('
'+rData[repo].name+'
');
		}
		//$('#content').append('
'+rCount+'
');
	});
}

//Help message
function showHelp() {
	var help = 'Enter the username of the GitHub member you are looking for.
Search filters coming soon.';
	$('#messages').append('
'+help+'
');
	$('#messages').show();
	setTimeout(function() {
        $("#messages").fadeOut("slow", function() {
            $("#messages").hide();
        });
    }, 5000);
}

//Error message - not implemented fully yet
function unrecognized() {
	var error = 'That user could not be found! Try again!';
	$('#messages').append('
'+error+'
');
	$('#messages').show();
	setTimeout(function() {
        $("#messages").fadeOut("slow", function() {
            $("#messages").hide();
        });
    }, 5000);
}

// Take user back to search screen
$( '#go-back' ).click(function() {
		$('#data').fadeOut(500, function () {
			$('#search').fadeIn(500);
			$('.spinner').hide();
			$('#username').focus();
		});
});
<commit_msg>Optimization!<commit_after>var base = 'https://api.github.com/users/';
var rData = {},
	uData = {};

// Run on load
$(document).ready(function() {
	$('#username').focus();
	$('#data').hide();
	$('.spinner').hide();
});

//Detect 'Enter' key being pressed
$('#username').keyup(function (e) {
	if (e.keyCode === 13) {
		$('#content').empty();
		$('#top-bar').empty();
		$('#data').hide();
		$('#messages').empty();
		var enteredText = $('#username').val();
		if (enteredText.length === 0) alert('Please enter a name!');
		else {
			if (enteredText == 'git help git') showHelp();
			else {
				$('.spinner').show();
				getUser(enteredText);
			}
			$('#username').val('');
		}
	}
});

//Get user data using GitHub API
function getUser(userName) {
	$.get(base + userName, function (userData) {
		uData = userData;
		$('#search').fadeOut(750, function () {
			$('#data').fadeIn(500);
		});
		$('#top-bar').append(''+uData.name+'');
		$('#top-bar').append(' committing since '+(uData.created_at).substring(0,10)+'');

		$("#home").wrap('');
		$("#code").wrap('');
	});
	getRepos(userName);
}

//Get users' repo data using GitHub API
function getRepos(user) {
	var rCount = 0;
	$.get(base + user + '/repos', function (repoData) {
		rData = repoData;
		for (var repo in rData) {
			rCount++;
			//$('#repos').append('
'+rData[repo].name+'
');
		}
		//$('#content').append('
'+rCount+'
');
	});
}

//Help message
function showHelp() {
	var help = 'Enter the username of the GitHub member you are looking for.
Search filters coming soon.';
	$('#messages').append('
'+help+'
');
	$('#messages').show();
	setTimeout(function() {
        $("#messages").fadeOut("slow", function() {
            $("#messages").hide();
        });
    }, 5000);
}

//Error message - not implemented fully yet
function unrecognized() {
	var error = 'That user could not be found! Try again!';
	$('#messages').append('
'+error+'
');
	$('#messages').show();
	setTimeout(function() {
        $("#messages").fadeOut("slow", function() {
            $("#messages").hide();
        });
    }, 5000);
}

// Take user back to search screen
$( '#go-back' ).click(function() {
		$('#data').fadeOut(500, function () {
			$('#search').fadeIn(500);
			$('.spinner').hide();
			$('#username').focus();
		});
});
<|endoftext|>


<commit_before>function processPoint(point) {
    var marker = new google.maps.Marker({
        position: {lat: point[1], lng: point[2]},
        icon: {
            url: Map.types[point[3]].icon,
            scaledSize: new google.maps.Size(Map.types[point[3]].size[0], Map.types[point[3]].size[1]),
            origin: new google.maps.Point(Map.types[point[3]].origin[0], Map.types[point[3]].origin[1]),
            anchor: new google.maps.Point(Map.types[point[3]].anchor[0], Map.types[point[3]].anchor[1])
        },
        title: Map.sources[point[0]].label
    });

    marker.type = point[3];

    marker.searchData = $.friendly_id(Map.sources[point[0]].label); // Source title
    marker.searchData += ' ' + $.friendly_id(point[4]); // Date
    for (var key in point[5]) {
        marker.searchData += ' ' + $.friendly_id(point[5][key]); // Extra data
    }

    marker.addListener('click', function () {
        var content = $('
');

        var source;
        if (typeof Map.sources[point[0]].logo !== 'undefined' && Map.sources[point[0]].logo)
            source = $('', {src: Map.sources[point[0]].logo}).css('height', '50px');
        else
            source = $('').text(Map.sources[point[0]].label);
        if (typeof Map.sources[point[0]].link !== 'undefined' && Map.sources[point[0]].link)
            source = source.wrap($('', {href: Map.sources[point[0]].link, target: '_blank'})).parent();

        content.append(source);

        content.append($('').text(point[4]).css({display: 'block', color: '#999999'}));

        var extra = $('
');
        var hasExtra = false;

        for (var key in point[5]) {
            if (hasExtra)
                extra.append($('
'));
            extra.append($('').text(point[5][key]).prepend($('').text(key + ': ')));
            hasExtra = true;
        }

        if (hasExtra)
            content.append(extra);

        Map.infoWindow.setContent(content.html());
        Map.infoWindow.open(Map.map, marker);
    });

    return marker;
}

function toggleLegend() {
    var legend = document.getElementById('legend');

    if (!legend.hasAttribute('data-content')) {
        legend.setAttribute('data-content', legend.innerHTML);
    }

    if (legend.className == 'collapsed') {
        legend.className = '';
        legend.innerHTML = legend.getAttribute('data-content');
        updateLegendCounts();
    } else {
        legend.className = 'collapsed';
        legend.innerHTML = '?';
    }
}

function updateLegendCounts() {
    var legend = $('#legend');
    if (legend.hasClass('collapsed'))
        return;

    var counts = {};
    window.markerClusterer.getMarkers().map(function(marker) {
        if (typeof counts[marker.type] === 'undefined')
            counts[marker.type] = 0;
        counts[marker.type]++;
    });

    $('li[data-type]', legend).each(function() {
        var type = $(this).attr('data-type');
        $('i', this).text('(' + (typeof counts[type] === 'undefined' ? 0 : counts[type]) + ')');
    });
}

function doSearch() {
    var query = $.friendly_id(document.getElementById('search').value.trim());

    var filteredMarkers = query ? window.allMarkers.filter(function (marker) {
        return marker.searchData.indexOf(query) !== -1;
    }) : window.allMarkers;

    if ($('#search').hasClass('empty') && filteredMarkers.length > 0)
        $('#search').removeClass('empty');
    else if (!$('#search').hasClass('empty') && filteredMarkers.length === 0)
        $('#search').addClass('empty');

    window.markerClusterer.clearMarkers();
    window.markerClusterer.addMarkers(filteredMarkers);
    updateLegendCounts();
}

var searchThrottle;
function searchChanged() {
    if (searchThrottle)
        clearTimeout(searchThrottle);

    searchThrottle = setTimeout(doSearch, 300);
}
<commit_msg>Search by type<commit_after>function processPoint(point) {
    var marker = new google.maps.Marker({
        position: {lat: point[1], lng: point[2]},
        icon: {
            url: Map.types[point[3]].icon,
            scaledSize: new google.maps.Size(Map.types[point[3]].size[0], Map.types[point[3]].size[1]),
            origin: new google.maps.Point(Map.types[point[3]].origin[0], Map.types[point[3]].origin[1]),
            anchor: new google.maps.Point(Map.types[point[3]].anchor[0], Map.types[point[3]].anchor[1])
        },
        title: Map.sources[point[0]].label
    });

    marker.type = point[3];

    marker.searchData = $.friendly_id(Map.sources[point[0]].label); // Source title
    marker.searchData += ' ' + $.friendly_id(Map.types[point[3]].label); // Type
    marker.searchData += ' ' + $.friendly_id(point[4]); // Date
    for (var key in point[5]) {
        marker.searchData += ' ' + $.friendly_id(point[5][key]); // Extra data
    }

    marker.addListener('click', function () {
        var content = $('
');

        var source;
        if (typeof Map.sources[point[0]].logo !== 'undefined' && Map.sources[point[0]].logo)
            source = $('', {src: Map.sources[point[0]].logo}).css('height', '50px');
        else
            source = $('').text(Map.sources[point[0]].label);
        if (typeof Map.sources[point[0]].link !== 'undefined' && Map.sources[point[0]].link)
            source = source.wrap($('', {href: Map.sources[point[0]].link, target: '_blank'})).parent();

        content.append(source);

        content.append($('').text(point[4]).css({display: 'block', color: '#999999'}));

        var extra = $('
');
        var hasExtra = false;

        for (var key in point[5]) {
            if (hasExtra)
                extra.append($('
'));
            extra.append($('').text(point[5][key]).prepend($('').text(key + ': ')));
            hasExtra = true;
        }

        if (hasExtra)
            content.append(extra);

        Map.infoWindow.setContent(content.html());
        Map.infoWindow.open(Map.map, marker);
    });

    return marker;
}

function toggleLegend() {
    var legend = document.getElementById('legend');

    if (!legend.hasAttribute('data-content')) {
        legend.setAttribute('data-content', legend.innerHTML);
    }

    if (legend.className == 'collapsed') {
        legend.className = '';
        legend.innerHTML = legend.getAttribute('data-content');
        updateLegendCounts();
    } else {
        legend.className = 'collapsed';
        legend.innerHTML = '?';
    }
}

function updateLegendCounts() {
    var legend = $('#legend');
    if (legend.hasClass('collapsed'))
        return;

    var counts = {};
    window.markerClusterer.getMarkers().map(function(marker) {
        if (typeof counts[marker.type] === 'undefined')
            counts[marker.type] = 0;
        counts[marker.type]++;
    });

    $('li[data-type]', legend).each(function() {
        var type = $(this).attr('data-type');
        $('i', this).text('(' + (typeof counts[type] === 'undefined' ? 0 : counts[type]) + ')');
    });
}

function doSearch() {
    var query = $.friendly_id(document.getElementById('search').value.trim());

    var filteredMarkers = query ? window.allMarkers.filter(function (marker) {
        return marker.searchData.indexOf(query) !== -1;
    }) : window.allMarkers;

    if ($('#search').hasClass('empty') && filteredMarkers.length > 0)
        $('#search').removeClass('empty');
    else if (!$('#search').hasClass('empty') && filteredMarkers.length === 0)
        $('#search').addClass('empty');

    window.markerClusterer.clearMarkers();
    window.markerClusterer.addMarkers(filteredMarkers);
    updateLegendCounts();
}

var searchThrottle;
function searchChanged() {
    if (searchThrottle)
        clearTimeout(searchThrottle);

    searchThrottle = setTimeout(doSearch, 300);
}
<|endoftext|>


<commit_before>$(function(){
  var parser = new Parser()
    , visuals = new Visuals('graph')
    , $repository = $('#repository')
    , $repoTitle = $('#repo-title')
    , $repoDescription = $('#repo-description')
    , loadingText = 'Loading...'
    , errorText = 'Error'

  parser.beforeParse = function(){
    $repoTitle.text(loadingText)
    $repoDescription.text(loadingText)

    visuals.showLoading()
  }

  parser.afterParse = function(data){
    $repoTitle.text(data.name || '')
    $repoDescription.text(data.description || '')

    visuals.showData(data)
  }

  parser.onError = function(){
    $repoTitle.text(errorText)
    $repoDescription.text(errorText)

    visuals.showError()
  }

  parser.onProgress = function(progress){
    console.log('Progress', progress)
  }

  // On form submit
  $('#repository-form').submit(function(ev){
    ev.preventDefault()

    if ($repository.val()) {
      parser.parse($repository.val())
    }
  })

  $('#examples').on('click', 'a', function(ev){
    ev.preventDefault()

    var $this = $(this)

    $repository.val($this.data('github'))
    parser.parse($this.data('github'))
  })

  // If initial form has a value
  if ($repository.val()) {
    parser.parse($repository.val())
  }

  // Init authentication
  hello.init({github : "baf32f7bbb8d975e64f3"})

  // Show the popup with auth
  var repo_uri = ''
  parser.onAuthRequired = function(repository_uri) {
    $("#login-popup").show()
    repo_uri = repository_uri
  }

  // Authenticate with github
  $("#login").on("click", function(event) {
    hello('github').login({redirect_uri:'redirect.html'}, function(ev) {
      if (!ev.hasOwnProperty("error")) {
        var github = hello("github").getAuthResponse()
        parser.token = github.access_token
        document.cookie = "token=" + github.access_token
        parser.parse(repo_uri)
      }
    })
  })
})
<commit_msg>:sagittarius: Parse input value. Allow inserting full url<commit_after>$(function(){
  var parser = new Parser()
    , visuals = new Visuals('graph')
    , $repository = $('#repository')
    , $repoTitle = $('#repo-title')
    , $repoDescription = $('#repo-description')
    , loadingText = 'Loading...'
    , errorText = 'Error'

  /*
    Parser callbacks
  */
  parser.beforeParse = function(){
    $repoTitle.text(loadingText)
    $repoDescription.text(loadingText)

    visuals.showLoading()
  }

  parser.afterParse = function(data){
    $repoTitle.text(data.name || '')
    $repoDescription.text(data.description || '')

    visuals.showData(data)
  }

  parser.onError = function(){
    $repoTitle.text(errorText)
    $repoDescription.text(errorText)

    visuals.showError()
  }

  parser.onProgress = function(progress){
    console.log('Progress', progress)
  }

  /*
    On page processing
  */

  var lastInputValue = null

  function parseInput(str) {
    var fullRegexp = /^https?\:\/\/github.com\/([a-z0-9\-\_\.]+\/[a-z0-9\-\_\.]+)\/?/i
      , simpleRegexp = /([a-z0-9\-\_\.]+\/[a-z0-9\-\_\.]+)\/?/i
      , match

    // Check if full repo url was passed (http://github.com/user/name)
    if ((match = fullRegexp.exec(str)) != null) {
      return match[1]
    } else if ((match = simpleRegexp.exec(str)) != null) {
      return match[1]
    } else {
      return null
    }
  }

  // On form submit
  $('#repository-form').submit(function(ev){
    ev.preventDefault()

    var val = parseInput($repository.val())
    console.log(val)

    if (val != null && val !== lastInputValue) {
      // Cache last value
      lastInputValue = val

      // Update input value with parsed value
      if ($repository.val() !== val) {
        $repository.val(val)
      }

      // Run parser
      parser.parse(val)
    }
  })

  $('#examples').on('click', 'a', function(ev){
    ev.preventDefault()

    var $this = $(this)

    $repository.val($this.data('github'))
    parser.parse($this.data('github'))
  })

  // If initial form has a value
  if ($repository.val()) {
    parser.parse($repository.val())
  }

  // Init authentication
  hello.init({github : "baf32f7bbb8d975e64f3"})

  // Show the popup with auth
  var repo_uri = ''
  parser.onAuthRequired = function(repository_uri) {
    $("#login-popup").show()
    repo_uri = repository_uri
  }

  // Authenticate with github
  $("#login").on("click", function(event) {
    hello('github').login({redirect_uri:'redirect.html'}, function(ev) {
      if (!ev.hasOwnProperty("error")) {
        var github = hello("github").getAuthResponse()
        parser.token = github.access_token
        document.cookie = "token=" + github.access_token
        parser.parse(repo_uri)
      }
    })
  })
})
<|endoftext|>


<commit_before>var $doc = $(document),
	$inputs = $(".btn--inputs"),
	$signup_btn = $("input[name='signup']"),
	$login_btn = $("input[name='login']"),
	$signup_form = $("#signup_form > .btn--inputs"),
	$login_form = $("#login_form");

$doc.ready(function() {
	$('.btn--inputs').hide();

	$signup_btn.click(function(event){
			console.log('yolo');
			$signup_form.slideToggle();
		}
	);
});
<commit_msg>Update accordian<commit_after>var $doc = $(document),
	$inputs = $(".btn--inputs"),
	$signup_btn = $("input[name='signup']"),
	$login_btn = $("input[name='login']"),
	$signup_form = $("#signup_form > .btn--inputs"),
	$login_form = $("#login_form > .btn--inputs");

$doc.ready(function() {
	$('.btn--inputs').hide();

	$signup_btn.click(function(event){
			$signup_form.slideToggle("slow");
		}
	);

	$login_btn.click(function(event){
			$login_form.slideToggle("slow");
		}
	);
});
<|endoftext|>


<commit_before>var keys = document.getElementsByClassName("key");
var display = document.getElementById("display_result_inline");
var keyCode = 0;
var key = '';
var firstNum = 0;
var secondNum = 0;
var operator = '';

for (var i = 0; i < keys.length; i++) {
	keys[i].addEventListener("click", function() {
		keyCode = this.innerHTML.charCodeAt(0);
		mainEvent(false);
	});
}

function removeBoxShadow(div){
	div.style.boxShadow = "none";
}

function setBoxShadow(div) {
	div.style.boxShadow = "2px 2px 5px 2px orange";
}

function isNumber() {
	return ['', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'].findIndex(function(arg) { return arg == key; }) > 0;
}

function isOperator() {
	return ['', '+', '-', '*', '/'].findIndex(function(arg) { return arg == key; }) > 0;
}

function getResult() {
	switch (operator) {
	case '+':
		return firstNum + secondNum;
		break;
	case '-':
		return firstNum - secondNum;
		break;
	case '*':
		return firstNum * secondNum;
		break;
	case '/':
		return firstNum / secondNum;
		break;
	}
}

document.addEventListener("keypress", mainEvent);

function mainEvent(keyPressed = true) {
	if (keyPressed)
		keyCode = (window.event.keyCode || window.event.which);

	key = String.fromCharCode(keyCode).toUpperCase();
	console.log(key);

	if (isNumber()) {
		if (firstNum == 0) {
			firstNum = parseInt(key);
			display.innerHTML = firstNum;
		} else if (operator == '' && secondNum == 0) {
			firstNum *= 10;
			firstNum += parseInt(key);
			display.innerHTML = firstNum;
		} else if (operator != '' && secondNum == 0) {
			secondNum = parseInt(key);
			display.innerHTML = firstNum + " " + operator + " " + secondNum + " = " + getResult();
		} else if (firstNum != 0 && operator != '' && secondNum != 0) {
			secondNum *= 10;
			secondNum += parseInt(key);
			display.innerHTML = firstNum + " " + operator + " " + secondNum + " = " + getResult();
		}
	} else if (isOperator()) {
		operator = key;
		if (firstNum != 0 && secondNum == 0)
			display.innerHTML = firstNum + " " + operator;
		else if (firstNum != 0 && operator != '' && secondNum != 0)
			display.innerHTML = firstNum + " " + operator + " " + secondNum + " = " + getResult();
	} else if (key == 'E') {
		firstNum = 0;
		secondNum = 0;
		operator = '';
		display.innerHTML = "Result";
	} else if (key == 'U') {
		if (firstNum != 0 && operator != '' && secondNum != 0) {
			secondNum = Math.floor(secondNum / 10);
			if (secondNum == 0)
				display.innerHTML = firstNum + " " + operator;
			else
				display.innerHTML = firstNum + " " + operator + " " + secondNum + " = " + getResult();
		} else if (firstNum != 0 && operator != '') {
			operator = '';
			display.innerHTML = firstNum;
		} else {
			firstNum = Math.floor(firstNum/10);
			if (firstNum == 0)
				display.innerHTML = "Result";
			else
				display.innerHTML = firstNum;
		}
	}
}
<commit_msg>Re-add box shadow effect<commit_after>var keys = document.getElementsByClassName("key");
var display = document.getElementById("display_result_inline");
var keyCode = 0;
var key = '';
var firstNum = 0;
var secondNum = 0;
var operator = '';

for (var i = 0; i < keys.length; i++) {
	keys[i].addEventListener("click", function() {
		var elem = this;
		removeBoxShadow(elem);
		setTimeout(function(){ setBoxShadow(elem); }, 200);
		keyCode = this.innerHTML.charCodeAt(0);
		mainEvent(false);
	});
}

function removeBoxShadow(div){
	div.style.boxShadow = "none";
}

function setBoxShadow(div) {
	div.style.boxShadow = "2px 2px 5px 2px orange";
}

function isNumber() {
	return ['', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'].findIndex(function(arg) { return arg == key; }) > 0;
}

function isOperator() {
	return ['', '+', '-', '*', '/'].findIndex(function(arg) { return arg == key; }) > 0;
}

function getResult() {
	switch (operator) {
	case '+':
		return firstNum + secondNum;
		break;
	case '-':
		return firstNum - secondNum;
		break;
	case '*':
		return firstNum * secondNum;
		break;
	case '/':
		return firstNum / secondNum;
		break;
	}
}

document.addEventListener("keypress", mainEvent);

function mainEvent(keyPressed = true) {
	if (keyPressed)
		keyCode = (window.event.keyCode || window.event.which);

	key = String.fromCharCode(keyCode).toUpperCase();

	if (isNumber()) {
		if (firstNum == 0) {
			firstNum = parseInt(key);
			display.innerHTML = firstNum;
		} else if (operator == '' && secondNum == 0) {
			firstNum *= 10;
			firstNum += parseInt(key);
			display.innerHTML = firstNum;
		} else if (operator != '' && secondNum == 0) {
			secondNum = parseInt(key);
			display.innerHTML = firstNum + " " + operator + " " + secondNum + " = " + getResult();
		} else if (firstNum != 0 && operator != '' && secondNum != 0) {
			secondNum *= 10;
			secondNum += parseInt(key);
			display.innerHTML = firstNum + " " + operator + " " + secondNum + " = " + getResult();
		}
	} else if (isOperator()) {
		operator = key;
		if (firstNum != 0 && secondNum == 0)
			display.innerHTML = firstNum + " " + operator;
		else if (firstNum != 0 && operator != '' && secondNum != 0)
			display.innerHTML = firstNum + " " + operator + " " + secondNum + " = " + getResult();
	} else if (key == 'E') {
		firstNum = 0;
		secondNum = 0;
		operator = '';
		display.innerHTML = "Result";
	} else if (key == 'U') {
		if (firstNum != 0 && operator != '' && secondNum != 0) {
			secondNum = Math.floor(secondNum / 10);
			if (secondNum == 0)
				display.innerHTML = firstNum + " " + operator;
			else
				display.innerHTML = firstNum + " " + operator + " " + secondNum + " = " + getResult();
		} else if (firstNum != 0 && operator != '') {
			operator = '';
			display.innerHTML = firstNum;
		} else {
			firstNum = Math.floor(firstNum/10);
			if (firstNum == 0)
				display.innerHTML = "Result";
			else
				display.innerHTML = firstNum;
		}
	}
}
<|endoftext|>


<commit_before>(function(window, document, undefined) {
    window.onload = init;
    function init() {
        //get the canvas
        var canvas = document.getElementById("mapcanvas");
        var c = canvas.getContext("2d");
        var width = 640;
        var height = 360;
        var levelSize = 45;
        var leftright = "none";
        var updown = "none";
        var levelCount = 3;
        var lookupDir = {
            u: [1,2,3],
            ur: [3,4,5,6],
            r: [6,7,8],
            dr: [8,9,10,11],
            d: [11,12,13],
            dl: [13,14,15,16],
            l: [16,17,18],
            ul: [18,19,0,1]
        };
        var lookupOff = {
            0: [-2,-3],
            1: [-1,-3],
            2: [0,-3],
            3: [1,-3],
            4: [2,-3],
            5: [3,-2],
            6: [3,-1],
            7: [3,0],
            8: [3,1],
            9: [3,2],
            10: [2,3],
            11: [1,3],
            12: [0,3],
            13: [-1,3],
            14: [-2,3],
            15: [-3,2],
            16: [-3,1],
            17: [-3,0],
            18: [-3,-1],
            19: [-3,-2]
        };

        document.getElementById("paintbtn").onclick = paint;

        function reset(){
            c.clearRect ( 0 , 0 , canvas.width, canvas.height );
            c.beginPath();

        }

        function createNext(updown, leftright, prevX, prevY){
            var rand4 = Math.floor((Math.random() * 4) );
            var rand3 = Math.floor((Math.random() * 3) );
            var dir = -1;
            var multiX = 0;
            var multiY = 0;
            switch(updown){
                case "up":
                    switch(leftright){
                        case "left":
                            dir = lookupDir.ul[rand4];
                            multiX = lookupOff[dir][0];
                            multiY = lookupOff[dir][1];
                            //alert("18, 19, 0, 1");
                            break;
                        case "right":
                            dir = lookupDir.ur[rand4];
                            multiX = lookupOff[dir][0];
                            multiY = lookupOff[dir][1];
                            //alert("3, 4, 5, 6");
                            break;
                        default:
                            dir = lookupDir.u[rand3];
                            multiX = lookupOff[dir][0];
                            multiY = lookupOff[dir][1];
                        //alert("1, 2 ,3");
                    }
                    break;
                case "down":
                    switch(leftright){
                        case "left":
                            dir = lookupDir.dl[rand4];
                            multiX = lookupOff[dir][0];
                            multiY = lookupOff[dir][1];
                            //alert("13, 14, 15, 16");
                            break;
                        case "right":
                            dir = lookupDir.dr[rand4];
                            multiX = lookupOff[dir][0];
                            multiY = lookupOff[dir][1];
                            //alert("8, 9, 10, 11");
                            break;
                        default:
                        dir = lookupDir.d[rand3];
                            multiX = lookupOff[dir][0];
                            multiY = lookupOff[dir][1];
                        //alert("11, 12, 13");
                    }
                    break;
                default:
                    switch(leftright){
                        case "left":
                            dir = lookupDir.l[rand3];
                            multiX = lookupOff[dir][0];
                            multiY = lookupOff[dir][1];
                            //alert("16, 17, 18");
                            break;
                        case "right":
                            dir = lookupDir.r[rand3];
                            multiX = lookupOff[dir][0];
                            multiY = lookupOff[dir][1];
                            //alert("6, 7, 8");
                            break;
                        default:
                        //alert("none");
                    }
            }
            var newX = prevX + multiX*(levelSize/3);
            var newY = prevY + multiY*(levelSize/3);
            return [newX, newY];
        }

        function drawLevel(x, y){
            c.rect(x,y,levelSize,levelSize);
            for(var i = 0; i< 3; i++){
                for(var j = 0; j< 3; j++){
                    c.rect((x) + i*(levelSize/3), (y) + j*(levelSize/3), (levelSize/3), (levelSize/3));
                    c.stroke();
                }
            }
        }

        //paint the map
        function paint() {
            reset();

            var lvlselect = document.getElementById("levelcount");
            var dir1 = document.getElementsByName("leftright");
            var dir2 = document.getElementsByName("updown");

            for(var i = 0, length = dir1.length; i < length; i++){
                if (dir1[i].checked) {
                    // do whatever you want with the checked radio
                    leftright = dir1[i].value;
                    // only one radio can be logically checked, don't check the rest
                    break;
                }
            }

            for(var i = 0, length = dir2.length; i < length; i++){
                if (dir2[i].checked) {
                    // do whatever you want with the checked radio
                    updown = dir2[i].value;
                    // only one radio can be logically checked, don't check the rest
                    break;
                }
            }

            levelCount = lvlselect.options[lvlselect.selectedIndex].value;

            //alert(updown+","+ leftright+","+ levelCount);

            var current = 0;
            var prevX = width/2;
            var prevY = height/2;
            drawLevel(prevX, prevY);
            current++;
            while(current < levelCount){
                var newCords = createNext(updown, leftright, prevX, prevY);
                var newX = newCords[0];
                var newY = newCords[1];
                drawLevel(newX, newY);
                prevX = newX;
                prevY = newY;
                current++;
            }
        }
    }
})(window, document, undefined);
<commit_msg>Update script.js<commit_after>(function(window, document, undefined) {
    window.onload = init;
    function init() {
        //get the canvas
        var canvas = document.getElementById("mapcanvas");
        var c = canvas.getContext("2d");
        var width = 640;
        var height = 360;
        var levelSize = 45;
        var leftright = "none";
        var updown = "none";
        var levelCount = 3;
        var lookupDir = {
            u: [1,2,3],
            ur: [3,4,5,6],
            r: [6,7,8],
            dr: [8,9,10,11],
            d: [11,12,13],
            dl: [13,14,15,16],
            l: [16,17,18],
            ul: [18,19,0,1]
        };
        var lookupOff = {
            0: [-2,-3],
            1: [-1,-3],
            2: [0,-3],
            3: [1,-3],
            4: [2,-3],
            5: [3,-2],
            6: [3,-1],
            7: [3,0],
            8: [3,1],
            9: [3,2],
            10: [2,3],
            11: [1,3],
            12: [0,3],
            13: [-1,3],
            14: [-2,3],
            15: [-3,2],
            16: [-3,1],
            17: [-3,0],
            18: [-3,-1],
            19: [-3,-2]
        };

        document.getElementById("paintbtn").onclick = paint;

        function reset(){
            c.clearRect ( 0 , 0 , canvas.width, canvas.height );
            c.beginPath();

        }

        function createNext(updown, leftright, prevX, prevY){
            var rand4 = Math.floor((Math.random() * 4) );
            var rand3 = Math.floor((Math.random() * 3) );
            var dir = -1;
            var multiX = 0;
            var multiY = 0;
            switch(updown){
                case "up":
                    switch(leftright){
                        case "left":
                            dir = lookupDir.ul[rand4];
                            multiX = lookupOff[dir][0];
                            multiY = lookupOff[dir][1];
                            //alert("18, 19, 0, 1");
                            break;
                        case "right":
                            dir = lookupDir.ur[rand4];
                            multiX = lookupOff[dir][0];
                            multiY = lookupOff[dir][1];
                            //alert("3, 4, 5, 6");
                            break;
                        default:
                            dir = lookupDir.u[rand3];
                            multiX = lookupOff[dir][0];
                            multiY = lookupOff[dir][1];
                        //alert("1, 2 ,3");
                    }
                    break;
                case "down":
                    switch(leftright){
                        case "left":
                            dir = lookupDir.dl[rand4];
                            multiX = lookupOff[dir][0];
                            multiY = lookupOff[dir][1];
                            //alert("13, 14, 15, 16");
                            break;
                        case "right":
                            dir = lookupDir.dr[rand4];
                            multiX = lookupOff[dir][0];
                            multiY = lookupOff[dir][1];
                            //alert("8, 9, 10, 11");
                            break;
                        default:
                        dir = lookupDir.d[rand3];
                            multiX = lookupOff[dir][0];
                            multiY = lookupOff[dir][1];
                        //alert("11, 12, 13");
                    }
                    break;
                default:
                    switch(leftright){
                        case "left":
                            dir = lookupDir.l[rand3];
                            multiX = lookupOff[dir][0];
                            multiY = lookupOff[dir][1];
                            //alert("16, 17, 18");
                            break;
                        case "right":
                            dir = lookupDir.r[rand3];
                            multiX = lookupOff[dir][0];
                            multiY = lookupOff[dir][1];
                            //alert("6, 7, 8");
                            break;
                        default:
                        //alert("none");
                    }
            }
            var newX = prevX + multiX*(levelSize/3);
            var newY = prevY + multiY*(levelSize/3);
            return [newX, newY];
        }

        function drawLevel(x, y){
            c.rect(x,y,levelSize,levelSize);
            for(var i = 0; i< 3; i++){
                for(var j = 0; j< 3; j++){
                    c.rect((x) + i*(levelSize/3), (y) + j*(levelSize/3), (levelSize/3), (levelSize/3));
                    c.stroke();
                }
            }
        }

        //paint the map
        function paint() {
            reset();

            var lvlselect = document.getElementById("levelcount");
            var dir1 = document.getElementsByName("leftright");
            var dir2 = document.getElementsByName("updown");

            for(var i = 0, length = dir1.length; i < length; i++){
                if (dir1[i].checked) {
                    // do whatever you want with the checked radio
                    leftright = dir1[i].value;
                    // only one radio can be logically checked, don't check the rest
                    break;
                }
            }

            for(var i = 0, length = dir2.length; i < length; i++){
                if (dir2[i].checked) {
                    // do whatever you want with the checked radio
                    updown = dir2[i].value;
                    // only one radio can be logically checked, don't check the rest
                    break;
                }
            }

            levelCount = lvlselect.options[lvlselect.selectedIndex].value;

            //alert(updown+","+ leftright+","+ levelCount);

            var current = 0;
            var prevX = width/2 - (levelSize/2);
            var prevY = height/2 - (levelSize/2);
            drawLevel(prevX, prevY);
            current++;
            while(current < levelCount){
                var newCords = createNext(updown, leftright, prevX, prevY);
                var newX = newCords[0];
                var newY = newCords[1];
                drawLevel(newX, newY);
                prevX = newX;
                prevY = newY;
                current++;
            }
        }
    }
})(window, document, undefined);
<|endoftext|>


<commit_before>/*
 * Created 2014 Triangle717
 * <http://Triangle717.WordPress.com/>
 *
 * Licensed under The MIT License
 * <http://opensource.org/licenses/MIT/>
 */

function showSidebar() {
  "use strict";
  /* Display the site sidebar */
  $("#sidebar").toggleClass("sidebar-hidden");
}

function showSidebarBtn() {
  "use strict";
  /* Display the site sidebar button */

  $(window).resize(function() {
    if (($(window).width() >= 320 || $(window).width() <= 320) && $(window).width() <= 720) {
      $("#sidebar-btn").addClass("sidebar-btn-visible");
      $("#sidebar").addClass("sidebar-hidden");

    } else {
      $("#sidebar-btn").removeClass("sidebar-btn-visible");
      $("#sidebar").removeClass("sidebar-hidden");
    }
  });
}

function shrinkImages() {
  "use strict";
  /* Resize images on mobile devices */

  $("body").find("img").each(function() {
    var $this = $(this);

    // If this is a mobile browser, third non-exempt image sizes
    if ($.browser.mobile) {
      if (!$this.hasClass("no-mobile-resize") && !$this.hasClass("emoji")) {
        // However, do it only if the image is wider than the screen
        console.log($this.width());
        console.log($(window).width());
        if ($this.width() >= $(window).width()) {
          $this.width($this.width() / 3);
          $this.height($this.height() / 3);
        }
      }
    }
  });
}

$(function() {
  "use strict";

  // Display sidebar toggle button if needed
  showSidebarBtn();

  shrinkImages();

  // Replace the SVG with a PNG on IE (IE HATES SVGs)
  if ($.browser.msie) {
    var $imgSrc = $(".ie-svg").attr("src");
    $(".ie-svg").attr("src", $imgSrc.substring(0, $imgSrc.length - 3) + "png");
  }

  // Hide non-mobile-ready elements
  if ($.browser.mobile) {
    $(".no-mobile").css("display", "none");
  }

  // Fully center the items that need centering
  var $centered = $(".fully-centered");
  $centered.css("margin-left", -$centered.width() / 2);
  $centered.css("margin-top", -$centered.height() / 2);

//  // Get date of last commit using GitHub Pages API
//  $.getJSON("https://api.github.com/repos/le717/le717.github.io", function(data) {
//      var lastUpdate = data.updated_at.replace(/(T(.*))$/g, "");
//      //var lastUpdate = "Right now";
//      $("#last-update").text("Last update: {0}".format(lastUpdate));
//    });
});
<commit_msg>Debugging sidebar on mobile [ci skip]<commit_after>/*
 * Created 2014 Triangle717
 * <http://Triangle717.WordPress.com/>
 *
 * Licensed under The MIT License
 * <http://opensource.org/licenses/MIT/>
 */

function showSidebar() {
  "use strict";
  /* Display the site sidebar */
  $("#sidebar").toggleClass("sidebar-hidden");
}

function showSidebarBtn() {
  "use strict";
  /* Display the site sidebar button */

  $(window).resize(function() {
    if (($(window).width() >= 320 || $(window).width() <= 320) && $(window).width() <= 720) {
      alert("Hide sidebar");
      $("#sidebar-btn").addClass("sidebar-btn-visible");
      $("#sidebar").addClass("sidebar-hidden");

    } else {
      alert("Show sidebar");
      $("#sidebar-btn").removeClass("sidebar-btn-visible");
      $("#sidebar").removeClass("sidebar-hidden");
    }
  });
}

function shrinkImages() {
  "use strict";
  /* Resize images on mobile devices */

  $("body").find("img").each(function() {
    var $this = $(this);

    // If this is a mobile browser, third non-exempt image sizes
    if ($.browser.mobile) {
      if (!$this.hasClass("no-mobile-resize") && !$this.hasClass("emoji")) {
        // However, do it only if the image is wider than the screen
        console.log($this.width());
        console.log($(window).width());
        if ($this.width() >= $(window).width()) {
          $this.width($this.width() / 3);
          $this.height($this.height() / 3);
        }
      }
    }
  });
}

$(function() {
  "use strict";

  // Display sidebar toggle button if needed
  showSidebarBtn();

  shrinkImages();

  // Replace the SVG with a PNG on IE (IE HATES SVGs)
  if ($.browser.msie) {
    var $imgSrc = $(".ie-svg").attr("src");
    $(".ie-svg").attr("src", $imgSrc.substring(0, $imgSrc.length - 3) + "png");
  }

  // Hide non-mobile-ready elements
  if ($.browser.mobile) {
    $(".no-mobile").css("display", "none");
  }

  // Fully center the items that need centering
  var $centered = $(".fully-centered");
  $centered.css("margin-left", -$centered.width() / 2);
  $centered.css("margin-top", -$centered.height() / 2);

//  // Get date of last commit using GitHub Pages API
//  $.getJSON("https://api.github.com/repos/le717/le717.github.io", function(data) {
//      var lastUpdate = data.updated_at.replace(/(T(.*))$/g, "");
//      //var lastUpdate = "Right now";
//      $("#last-update").text("Last update: {0}".format(lastUpdate));
//    });
});
<|endoftext|>


<commit_before>var sssheet = (function() {
	var style = document.createElement("style");
	style.appendChild(document.createTextNode(""));
	document.head.appendChild(style);
	return style.sheet;
})();

var isPixnet = false;
if (window.location.href.indexOf('pixnet')!=-1) {
	isPixnet = true;
}
if (window.location.href.indexOf('paulyear.com')!=-1) {
	isPixnet = true;
}
if (window.location.href.indexOf('nellydyu.tw')!=-1) {
	isPixnet = true;
}
if (window.location.href.indexOf('timmyblog.cc')!=-1) {
	isPixnet = true;
}
if (window.location.href.indexOf('mecocute.com')!=-1) {
	isPixnet = true;
}

if (isPixnet) {
	jQuery('#pixad1101d').css('overflow', 'hidden');jQuery('.sticky-box').remove();
	jQuery('#main').css('overflow', 'hidden');jQuery('.article-body iframe').remove();
	jQuery('.article-body .adsbygoogle').remove();jQuery('.article-body').removeClass('show-summary');
	jQuery('.article-header .adsbygoogle').remove();
	jQuery('.header-ad').css({height: '120px'});

	jQuery('a img').parent().css('pointer-events', 'none');
	jQuery("iframe[src*='maps.google.com']").remove();
	jQuery("iframe[src*='www.google.com/maps']").remove();
	jQuery("iframe[src*='facebook.com']").remove();
	jQuery('#main .relative-article').remove();jQuery('.article-body').css('overflow-x', 'hidden');
	jQuery('#recommend-tools').remove();jQuery('#main .comment-form').remove();
	jQuery('#main .article-comments').remove(); jQuery('#header-bar__share-tools').remove();
	jQuery('#header .bar--reading span').remove();

	jQuery('#sb-site #logo').remove(); jQuery('#wrapper #toggleMenu').remove(); jQuery('#float_fb_plugin').remove();

	sssheet.insertRule("#scupio_interstitialad { display: none !important; }", 0);
	sssheet.insertRule(".pop-ad-cover { display: none !important; }", 0);
	sssheet.insertRule(".pi-ad-mobile-tag-outer { display: none !important; }", 0);

	if (window.location.href.indexOf('bluehero.pixnet')!=-1) {
		jQuery('table,embed').width('100%');
	}

}
else if (window.location.href.indexOf('yukiblog.tw')!=-1) {
	$('.adsbygoogle').remove();$('.postad').remove();$("iframe").remove();
}
else if (window.location.href.indexOf('wiselyview.cc')!=-1) {
	sssheet.insertRule("#top-btn { display: none !important; }", 0);
}
else if (window.location.href.indexOf('wiselyview.cc')!=-1) {
	jQuery("iframe").remove();jQuery("#aswift_0_expand").remove();jQuery("#aswift_3_expand").remove();
}
else if (window.location.href.indexOf('candicecity.com')!=-1) {
	jQuery('.adsbygoogle, .sharedaddy').remove();
	sssheet.insertRule(".pi-ad-mobile-tag-outer { display: none !important; }", 0);
	sssheet.insertRule(".pi-Ad-mb-stick { display: none !important; }", 0);
}
else if (window.location.href.indexOf('starwing.cc')!=-1) {
	sssheet.insertRule(".adsbygoogle { display: none !important; }", 0);
}
else if (window.location.href.indexOf('yuann.tw')!=-1) {
	jQuery("a[href='http://radarurl.com/monitor']").remove();
}
else if (window.location.href.indexOf('ladymoko.com')!=-1) {
	jQuery('.adsbygoogle').remove();
}
else if (window.location.href.indexOf('xuite.net')!=-1) {
	jQuery('#rmiad').remove();
	sssheet.insertRule("#rmiad { display: none !important; }", 0);
}

sssheet.insertRule(".pi-ad-mobile-tag-outer { display: none !important; }", 0);
sssheet.insertRule(".pi-Ad-mb-stick { display: none !important; }", 0);
// sssheet.insertRule(".adsbygoogle ins { display: none !important; }", 0);
sssheet.insertRule(".nc_wrapper .floatBottom { display: none !important; }", 0);

// Yuki
// jQuery('.article-header .adsbygoogle').css({height: '120px', overflow: 'hidden'});<commit_msg>update script<commit_after>var sssheet = (function() {
	var style = document.createElement("style");
	style.appendChild(document.createTextNode(""));
	document.head.appendChild(style);
	return style.sheet;
})();

var isPixnet = false;
if (window.location.href.indexOf('pixnet')!=-1) {
	isPixnet = true;
}
if (window.location.href.indexOf('paulyear.com')!=-1) {
	isPixnet = true;
}
if (window.location.href.indexOf('nellydyu.tw')!=-1) {
	isPixnet = true;
}
if (window.location.href.indexOf('timmyblog.cc')!=-1) {
	isPixnet = true;
}
if (window.location.href.indexOf('mecocute.com')!=-1) {
	isPixnet = true;
}

if (isPixnet) {
	jQuery('#pixad1101d').css('overflow', 'hidden');jQuery('.sticky-box').remove();
	jQuery('#main').css('overflow', 'hidden');jQuery('.article-body iframe').remove();
	jQuery('.article-body .adsbygoogle').remove();jQuery('.article-body').removeClass('show-summary');
	jQuery('.article-header .adsbygoogle').remove();
	jQuery('.header-ad').css({height: '120px'});

	jQuery('a img').parent().css('pointer-events', 'none');
	jQuery("iframe[src*='maps.google.com']").remove();
	jQuery("iframe[src*='www.google.com/maps']").remove();
	jQuery("iframe[src*='facebook.com']").remove();
	jQuery('#main .relative-article').remove();jQuery('.article-body').css('overflow-x', 'hidden');
	jQuery('#recommend-tools').remove();jQuery('#main .comment-form').remove();
	jQuery('#main .article-comments').remove(); jQuery('#header-bar__share-tools').remove();
	jQuery('#header .bar--reading span').remove();

	jQuery('#sb-site #logo').remove(); jQuery('#wrapper #toggleMenu').remove(); jQuery('#float_fb_plugin').remove();

	sssheet.insertRule(".pi-ad-mobile-tag-outer { display: none !important; }", 0);
	if (Math.random() > 0.2) {
		sssheet.insertRule(".pop-ad-cover { display: none !important; }", 0);
		sssheet.insertRule("#scupio_interstitialad { display: none !important; }", 0);
	}

	if (window.location.href.indexOf('bluehero.pixnet')!=-1) {
		jQuery('table,embed').width('100%');
	}

}
else if (window.location.href.indexOf('yukiblog.tw')!=-1) {
	$('.adsbygoogle').remove();$('.postad').remove();$("iframe").remove();
}
else if (window.location.href.indexOf('wiselyview.cc')!=-1) {
	sssheet.insertRule("#top-btn { display: none !important; }", 0);
}
else if (window.location.href.indexOf('wiselyview.cc')!=-1) {
	jQuery("iframe").remove();jQuery("#aswift_0_expand").remove();jQuery("#aswift_3_expand").remove();
}
else if (window.location.href.indexOf('candicecity.com')!=-1) {
	jQuery('.adsbygoogle, .sharedaddy').remove();
	sssheet.insertRule(".pi-ad-mobile-tag-outer { display: none !important; }", 0);
	sssheet.insertRule(".pi-Ad-mb-stick { display: none !important; }", 0);
}
else if (window.location.href.indexOf('starwing.cc')!=-1) {
	sssheet.insertRule(".adsbygoogle { display: none !important; }", 0);
}
else if (window.location.href.indexOf('yuann.tw')!=-1) {
	jQuery("a[href='http://radarurl.com/monitor']").remove();
}
else if (window.location.href.indexOf('ladymoko.com')!=-1) {
	jQuery('.adsbygoogle').remove();
}
else if (window.location.href.indexOf('xuite.net')!=-1) {
	jQuery('#rmiad').remove();
	sssheet.insertRule("#rmiad { display: none !important; }", 0);
}

sssheet.insertRule(".pi-ad-mobile-tag-outer { display: none !important; }", 0);
sssheet.insertRule(".pi-Ad-mb-stick { display: none !important; }", 0);
// sssheet.insertRule(".adsbygoogle ins { display: none !important; }", 0);
sssheet.insertRule(".nc_wrapper .floatBottom { display: none !important; }", 0);

// Yuki
// jQuery('.article-header .adsbygoogle').css({height: '120px', overflow: 'hidden'});<|endoftext|>