$(function() {
category = Array();
category['profile'] = Array();
category['profile'][0] = "プロフィール";
category['profile'][1] = "市川義一プロフィール";
category['hitsuboku'] = Array();
category['hitsuboku'][0] = "筆墨日記365";
category['hitsuboku'][1] = "毎日墨を磨り半紙に筆で認(したた)めること9年目。この5月で100冊になりました。日記とは名ばかり、新聞の切り抜きやいただいた個展案内状を貼るなどして紙面を埋めて、まるで落書き帳かスクラップ帳と言った方がよいのかもしれません。";
category['exhibition-365'] = Array();
category['exhibition-365'][0] = "筆墨365展";
category['exhibition-365'][1] = "「市川義一 筆墨365展」のアーカイブ。期間:2013年10月5日(土)-10月15日(火) (10/9は休み)場所:MORIHICO. Plantation(札幌市白石区菊水8条2丁目1-32)";
history_counter = 0;
past_href = location.href;
memorize_scrolltop = $(window).scrollTop();
memorize_lastvisit = "entry";
if( $("div#index > article").length === 0 ){
memorize_lastindex = "";
}else{
memorize_lastindex = $("div#index > article").attr("class").replace( " ", "/" );
}
memorize_lasturl = location.href;
profile_url = "profile";
$(window).bind('load', function() {
if( memorize_lastvisit == "index" ){
$("#container").css({"min-height" : "150%"});
memorize_scrolltop = $(window).height() - $("#header").height() + 140;
$('html,body').animate({
scrollTop: memorize_scrolltop
}, 1000);
}
if( memorize_lastvisit == "entry" ){
$("#container").css({"min-height" : "150%"});
memorize_scrolltop = $(window).height() - $("#header").height() + 140;
}
});
var target_nav = $(".class_" + "hitsuboku".replace( "/", "_" ));
target_nav.removeClass("over");
target_nav.addClass("active");
function PJAX_hrefchange( href, onpop ) {
if( typeof ajax_request != "undefined" ){
ajax_request.abort();
}
if( href && past_href != href ){
past_href = href;
var id = href.replace( "https://giichi.jp/", "" );
var id = id.replace( "?mode=preview", "" );
ajax_request = $.ajax({
url: "https://giichi.jp/pjax_readtitle_json.php",
data: "id=" + id + "&type=json" + "",
dataType: "json",
success:
function(data, dataType){
if(!onpop){
PJAX_pushState( href, data.title );
}
document.title = data.title;
},
error:
function(XMLHttpRequest, textStatus, errorThrown){
}
});
if (id.match(/\d{4}$/)) {
var entry_id = id.match(/\d{4}$/);
var category_filter = id.replace("/" + entry_id ,"");
if( entry_id != "" && category_filter != "" ){
$("body").append("
");
if( memorize_lastvisit == "entry"){
$('html,body').animate({
scrollTop: memorize_scrolltop
}, '200');
}else{
memorize_scrolltop = $(window).scrollTop();
}
ajax_request = $.ajax({
url: "https://giichi.jp/ajax_entry.php",
data: "id=" + category_filter + "/" + entry_id + "",
success:
function(data, dataType){
$("div#entry").empty().append(data);
$("div#entry > article").css("top", memorize_scrolltop + "px");
memorize_lastvisit = "entry";
memorize_lasturl = href;
memorize_lastindex = category_filter;
$("div#loading").fadeOut(1000).remove();
},
error:
function(XMLHttpRequest, textStatus, errorThrown){
}
});
if( history_counter == 0 ){
ajax_request = $.ajax({
url: "https://giichi.jp/ajax_index.php",
data: "id=" + category_filter + "",
success:
function(data, dataType){
$("div#index").empty().append(data);
memorize_lastindex = category_filter;
},
error:
function(XMLHttpRequest, textStatus, errorThrown){
}
});
}
}else if( entry_id != "" ){
$("body").append("");
ajax_request = $.ajax({
url: "https://giichi.jp/ajax_entry.php",
data: "id=" + entry_id + "",
success:
function(data, dataType){
$("div#entry").empty().append(data);
$("div#entry > article").css("top", $(window).scrollTop() + "px");
memorize_lastvisit = "entry";
memorize_lasturl = href;
memorize_scrolltop = 0;
memorize_lastindex = "";
$("div#loading").fadeOut(1000).remove();
},
error:
function(XMLHttpRequest, textStatus, errorThrown){
}
});
}
}
if ( id == profile_url ) {
$("body").append("");
ajax_request = $.ajax({
url: "https://giichi.jp/ajax_profile.php",
data: "id=" + id + "",
success:
function(data, dataType){
$("div#entry").empty().append(data);
$("div#entry > a.modal_overlay, div#entry > a.close").attr("href", memorize_lasturl);
$("div#entry > article").css("top", $(window).scrollTop() + "px");
memorize_lastvisit = "profile";
memorize_lasturl = href;
memorize_scrolltop = $(window).scrollTop();
$("div#loading").fadeOut(1000).remove();
},
error:
function(XMLHttpRequest, textStatus, errorThrown){
}
});
}else if( typeof entry_id == "undefined" && id != "" ){
$("#container").css({"min-height" : "150%"});
if( memorize_lastvisit == "entry" || memorize_lastvisit == "profile" ){
$('html,body').animate({
scrollTop: memorize_scrolltop
}, 200);
$("div#entry").stop().animate({
opacity : 0
},200,
function(){
$("div#entry").empty().stop().animate({opacity : 1},200);
memorize_lastvisit = "index";
memorize_lasturl = href;
memorize_scrolltop = 0;
memorize_lastindex = id;
}
);
if( memorize_lastindex != id ){
$("div#index").stop().animate({
opacity : 0
},200,
function(){
var set_class = id.replace( "/", " " );
$("div#index").empty().append(''+ category[id][0] +'
'+ category[id][1] +'
').stop().animate({opacity : 1},200);
$("div#index article header h1").stop().animate({opacity : 1},1000);
memorize_lastvisit = "index";
memorize_lasturl = href;
memorize_scrolltop = 0;
memorize_lastindex = id;
ajax_request = $.ajax({
url: "https://giichi.jp/ajax_index.php",
data: "id=" + id + "",
success:
function(data, dataType){
var get_html = $("").append(data).find("ul");
var get_js = $("").append(data).find("script");
$("div#index > article").append(get_html).append(get_js);
},
error:
function(XMLHttpRequest, textStatus, errorThrown){
}
});
}
);
}
}else{
memorize_scrolltop = $(window).height() - $("#header").height() + 140;
$('html,body').animate({
scrollTop: memorize_scrolltop
}, 1000);
$("div#index").stop().animate({
opacity : 0
},200,
function(){
var set_class = id.replace( "/", " " );
$("div#index").empty().append(''+ category[id][0] +'
'+ category[id][1] +'
').stop().animate({opacity : 1},200);
$("div#index article header h1").stop().animate({opacity : 1},1000);
memorize_lastvisit = "index";
memorize_lasturl = href;
memorize_lastindex = id;
ajax_request = $.ajax({
url: "https://giichi.jp/ajax_index.php",
data: "id=" + id + "",
success:
function(data, dataType){
var get_html = $("").append(data).find("ul");
var get_js = $("").append(data).find("script");
$("div#index > article").append(get_html).append(get_js);
},
error:
function(XMLHttpRequest, textStatus, errorThrown){
}
});
}
);
}
}
if( id == "" ){
memorize_scrolltop = 0;
$('html,body').animate({
scrollTop: memorize_scrolltop
}, 200,
function(){
$("#container").css({"min-height" : "0px"});
}
);
if( memorize_lastvisit == "profile" ){
$("div#entry").stop().animate({
opacity : 0
},200,
function(){
$("div#entry").empty().stop().animate({opacity : 1},200);
memorize_lastvisit = "root";
memorize_lasturl = href;
}
);
}else{
$("div#entry").stop().animate({
opacity : 0
},500,
function(){
$("div#entry").empty().stop().animate({opacity : 1},200);
}
);
$("div#index").stop().animate({
opacity : 0
},500,
function(){
$("div#index").empty().stop().animate({opacity : 1},200);
}
);
memorize_lastvisit = "root";
memorize_lasturl = href;
memorize_scrolltop = 0;
}
}
ajax_request = $.ajax({
url: "https://giichi.jp/ajax_social.php",
data: "id=" + id + "",
success:
function(data, dataType){
$("div.social").empty().append(data);
},
error:
function(XMLHttpRequest, textStatus, errorThrown){
}
});
if( typeof entry_id == "undefined" ){
$("#navi nav li a").css({
"background-color" : "",
"color" : ""
});
$("#navi nav li a").removeClass("active");
$("#navi nav li a").addClass("over");
var target_nav = $(".class_" + id.replace( "/", "_" ));
target_nav.removeClass("over");
target_nav.addClass("active");
}
}else{
var id = href.replace( "https://giichi.jp/", "" );
var id = id.replace( "?mode=preview", "" );
if( id != profile_url && typeof entry_id == "undefined" && id != "" ){
$("#container").css({"min-height" : "150%"});
memorize_scrolltop = $(window).height() - $("#header").height() + 140;
$('html,body').animate({
scrollTop: memorize_scrolltop
}, 1000);
}
}
}
function PJAX_pushState( href, title ) {
if ( window.history.pushState ) {
window.history.pushState( title, null, href );
} else {
}
}
window.onpopstate = function(event){
var onpop = true;
if( history_counter != 0 ){
if (event.state) {
} else {
}
var href = location.href;
if ( window.history.pushState ) {
PJAX_hrefchange( href, onpop );
history_counter++;
} else {
var href = "https://giichi.jp/#!/" + href.replace( /^.\//, '' );
window.location = href;
history_counter++;
}
}
history_counter++;
}
$(document).on("click", "a.pjax", function(){
var href = $(this).attr("href");
if ( window.history.pushState ) {
PJAX_hrefchange( href );
history_counter++;
} else {
var href = href.replace( "https://giichi.jp/", "" );
var href = "https://giichi.jp/#!/" + href.replace( /^.\//, '' );
window.location = href;
history_counter++;
}
return false;
});
$(window).hashchange( function(){
var hash = location.hash;
if( hash.indexOf( "#!/" ) != -1 ){
var href = hash.replace( /^#!\//, '' );
if( href == "" ){
var href = "https://giichi.jp/";
}
}
PJAX_hrefchange( href );
})
$(window).bind('load', function() {
var hash = location.hash;
if( hash.indexOf( "#!/" ) != -1 ){
var href = hash.replace( /^#!\//, '' );
if ( window.history.pushState ) {
window.location = href;
}else{
PJAX_hrefchange( href );
}
}
});
});