$(function() {
category = Array();
category['contact'] = Array();
category['contact'][0] = "CONTACT";
category['contact'][1] = "ゲンカンパニー/コンタクト";
category['news'] = Array();
category['news'][0] = "NEWS";
category['news'][1] = "ゲンカンパニーに関するニュース";
category['about'] = Array();
category['about'][0] = "ABOUT";
category['about'][1] = "ゲンカンパニーとは?";
category['project'] = Array();
category['project'][0] = "PROJECT";
category['project'][1] = "ゲンカンパニーによるプロジェクト";
category['profile'] = Array();
category['profile'][0] = "PROFILE";
category['profile'][1] = "ゲンカンパニーのメンバーについて";
category['law'] = Array();
category['law'][0] = "特定商取引法に基づく表記";
category['law'][1] = "";
category['privacy'] = Array();
category['privacy'][0] = "プライバシーポリシー";
category['privacy'][1] = "";
product = Array();
product['products/AR-01'] = "products/9750";
product['products/AR-02'] = "products/8662";
product['products/AR-03'] = "products/2711";
product['products/AR-04'] = "products/3007";
product['products/AR-05'] = "products/5179";
product['products/AR-06'] = "products/2064";
function htmlEncode(value){
return $('
').text(value).html();
}
function htmlDecode(value){
return $('').html(value).text();
}
scroll_action_flag = false;
root_site_title = "ゲンカンパニー Gen&Co.";
history_counter = 0;
past_href = location.href;
memorize_scrolltop = $(window).scrollTop();
memorize_lastvisit = "entry";
memorize_lasturl = location.href;
profile_url = "contact";
now_viewing = "news";
memorize_lastindex = "";
$(window).bind('load', function() {
if( memorize_lastvisit == "entry" ){
scroll_action_flag = false;
$("#entry > article").css({"margin-top": $(window).scrollTop()+10 - parseInt($("#container").offset().top)});
$("div#entry").fadeIn(400);
memorize_lastvisit_article_type = "";
}else if( memorize_lastvisit == "index" || memorize_lastvisit == "profile" ){
scroll_action_flag = false;
var target_nav = $(".class_" + "news".replace( "/", "_" ) + " a");
target_nav.removeClass("over");
target_nav.addClass("active");
target_nav.css({"opacity" : 0});
//article_type(ground・modal)の読み取り
var article_type = $( "article#" + now_viewing ).attr("class");
if( article_type == "ground" ){
var scrollto = $('#' + now_viewing ).offset().top-0;
$('html,body').animate({
scrollTop: scrollto
}, 1000,
function(){
scroll_action_flag = true;
});
}else if( article_type == "modal" ){
$( "article#" + now_viewing ).css({"margin-top": $(window).scrollTop()+10 - parseInt($("#container").offset().top)});
$( "article#" + now_viewing ).parent().fadeIn(
400,function(){
var appendto = $(this).find(".load_content");
var url = appendto.attr("data-load");
PJAX_load_content( url, appendto );
}
);
}
memorize_lastvisit_article_type = article_type;
}else{
scroll_action_flag = false;
setTimeout(
function(){
scroll_action_flag = true;
}
, 1000);
memorize_lastvisit_article_type = "";
}
});
function PJAX_hrefchange( href, onpop ) {
scroll_action_flag = false;
if( typeof ajax_request != "undefined" ){
ajax_request.abort();
}
if( typeof scroll_action_limiter != "undefined" ){
clearTimeout( scroll_action_limiter );
}
if( href && past_href != href ){
past_href = href;
var id = href.replace( "https://archive.gencompany.net/", "" );
var id = id.replace( "?mode=preview", "" );
now_viewing = id;
ajax_request = $.ajax({
url: "https://archive.gencompany.net/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 (typeof product[id] != "undefined") {
id = product[id];
}
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',
function(){
scroll_action_flag = false;
});
}else{
scroll_action_flag = false;
memorize_scrolltop = $(window).scrollTop();
}
ajax_request = $.ajax({
url: "https://archive.gencompany.net/ajax_entry.php",
data: "id=" + category_filter + "/" + entry_id + "",
success:
function(data, dataType){
$("div#entry").fadeOut(
400,
function(){
$(this).empty().append(data).fadeIn(
400,function(){
$("#entry > article").css({"margin-top": $(window).scrollTop()+10 - parseInt($("#container").offset().top)});
$("div#loading").fadeOut(1500).remove();
}
);
}
);
memorize_lastvisit = "entry";
memorize_lastvisit_article_type = "";
memorize_lasturl = href;
memorize_lastindex = category_filter;
},
error:
function(XMLHttpRequest, textStatus, errorThrown){
}
});
}else if( entry_id != "" ){
$("body").append("");
ajax_request = $.ajax({
url: "https://archive.gencompany.net/ajax_entry.php",
data: "id=" + entry_id + "",
success:
function(data, dataType){
$("div#entry").fadeOut(
400,
function(){
$(this).empty().append(data).fadeIn(
400,function(){
$("#entry > article").css({"margin-top": $(window).scrollTop()+10 - parseInt($("#container").offset().top)});
$("div#loading").fadeOut(1500).remove();
}
);
}
);
memorize_lastvisit = "entry";
memorize_lastvisit_article_type = "";
memorize_lasturl = href;
memorize_scrolltop = 0;
memorize_lastindex = "";
},
error:
function(XMLHttpRequest, textStatus, errorThrown){
}
});
}
}
if( typeof entry_id == "undefined" && ( id != "" || id == profile_url ) ){
//article_type(ground・modal)の読み取り
var article_type = $( "article#" + id ).attr("class");
if( memorize_lastvisit == "entry" ){
$('html,body').animate({
scrollTop: memorize_scrolltop
}, 200);
$("div#entry").fadeOut(
400,
function(){
$(this).empty();
scroll_action_flag = true;
memorize_lastvisit = "index";
memorize_lasturl = href;
memorize_scrolltop = 0;
memorize_lastindex = id;
}
);
if( memorize_lastindex != id ){
if( article_type == "ground" ){
var scrollto = $('#' + id).offset().top-0;
$('html,body').animate({
scrollTop: scrollto
}, 1000,
function(){
scroll_action_flag = true;
});
}else if( article_type == "modal" ){
$( "article#" + id ).css({"margin-top": $(window).scrollTop()+10 - parseInt($("#container").offset().top)});
$( "article#" + id ).parent().fadeIn(
400,function(){
$("div#loading").fadeOut(1500).remove();
var appendto = $(this).find(".load_content");
var url = appendto.attr("data-load");
PJAX_load_content( url, appendto );
}
);
}
memorize_lastvisit = "index";
memorize_lastvisit_article_type = article_type;
memorize_lasturl = href;
memorize_scrolltop = $(window).scrollTop();
memorize_lastindex = id;
}
}else{
$( "article.modal" ).parent().fadeOut(400);
if( article_type == "ground" ){
var scrollto = $('#' + id).offset().top-0;
$('html,body').animate({
scrollTop: scrollto
}, 1000,
function(){
scroll_action_flag = true;
});
}else if( article_type == "modal" ){
$( "article#" + id ).css({"margin-top": $(window).scrollTop()+10 - parseInt($("#container").offset().top)});
$( "article#" + id ).parent().fadeIn(
400,function(){
$("div#loading").fadeOut(1500).remove();
var appendto = $(this).find(".load_content");
var url = appendto.attr("data-load");
PJAX_load_content( url, appendto );
}
);
}
memorize_lastvisit = "index";
memorize_lastvisit_article_type = article_type;
memorize_lasturl = href;
memorize_scrolltop = $(window).scrollTop();
memorize_lastindex = id;
}
}
if( id == "" ){
$( "article.modal" ).parent().fadeOut(
400,function(){
scroll_action_flag = true;
}
);
$("div#entry").fadeOut(
400,
function(){
$(this).empty();
}
);
if( memorize_lastvisit_article_type != "modal" ){
var scrollto = 0;
$('html,body').animate({
scrollTop: scrollto
}, 1000,
function(){
scroll_action_flag = true;
});
}
memorize_lastvisit = "root";
memorize_lastvisit_article_type = "";
memorize_lasturl = href;
memorize_scrolltop = 0;
memorize_lastindex = "";
}
if( typeof entry_id == "undefined" ){
$("#navi nav li a").removeClass("active");
$("#navi nav li a").addClass("over");
$("#navi nav li a").css({"opacity" : 1});
var target_nav = $(".class_" + id.replace( "/", "_" ) + " a");
target_nav.removeClass("over");
target_nav.addClass("active");
target_nav.css({"opacity" : 0});
}
}else{
if ( href.replace( "https://archive.gencompany.net/", "" ) == "" ){
$('html,body').animate({
scrollTop: 0
}, 500);
scroll_action_flag = true;
}
}
}
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://archive.gencompany.net/#!/" + 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://archive.gencompany.net/", "" );
var href = "https://archive.gencompany.net/#!/" + href.replace( /^.\//, '' );
var past_href = location.href;
if ( href == "https://archive.gencompany.net/#!/" && past_href == "https://archive.gencompany.net/#!/" ) {
$('html,body').animate({
scrollTop: 0
}, 1000);
memorize_lastvisit_article_type = "";
}
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://archive.gencompany.net/";
}
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 );
}
}
});
$(window).scroll(function(){
if( scroll_action_flag === true ){
scroll_action_flag = false;
if( typeof scroll_action_limiter != "undefined" ){
clearTimeout( scroll_action_limiter );
}
scroll_action_limiter = setTimeout(
function(){
var menu_list = [];
var count_i = 0;
$(".ground").each(function(){
if( $(this).attr("id") != null ){
var push_val_id = $(this).attr("id");
var push_val_offset = $("#" + push_val_id).offset().top;
var push_val_height = $("#" + push_val_id).height();
menu_list[count_i] = [];
menu_list[count_i]["id"] = push_val_id;
menu_list[count_i]["offset"] = push_val_offset;
menu_list[count_i]["height"] = push_val_height;
count_i++;
}
});
var scroll_val = $(window).scrollTop();
$.each( menu_list, function(i){
if( scroll_val >= menu_list[i]["offset"] && scroll_val <= menu_list[i]["offset"]+menu_list[i]["height"] ){
if( now_viewing != menu_list[i]["id"] ){
var id = menu_list[i]["id"];
now_viewing = id;
past_href = "https://archive.gencompany.net/" + id;
var page_title = category[id][0] + "|" + root_site_title;
PJAX_pushState( "https://archive.gencompany.net/" + id, page_title );
document.title = page_title;
$("#navi nav li a").removeClass("active");
$("#navi nav li a").addClass("over");
$("#navi nav li a").css({"opacity" : 1});
var target_nav = $(".class_" + id + " a");
target_nav.removeClass("over");
target_nav.addClass("active");
target_nav.css({"opacity" : 0});
}
}else if( scroll_val < menu_list[0]["offset"] ){
if( now_viewing != "" ){
var id = "";
now_viewing = id;
past_href = "https://archive.gencompany.net/";
PJAX_pushState( "https://archive.gencompany.net/", root_site_title );
document.title = root_site_title;
$("#navi nav li a").removeClass("active");
$("#navi nav li a").addClass("over");
$("#navi nav li a").css({"opacity" : 1});
}
}
});
scroll_action_flag = true;
}
, 2000);
}
});
function PJAX_load_content( url, appendto ) {
if( ! appendto.find("*")[0] ){
$.ajax({
url: url,
type: 'GET',
cache: false,
success: function(data) {
appendto.empty();
var content = $(data.responseText).find('#container').html();
appendto.append(content);
}
});
}
}
});