$(function() { var date,hours,minutes,seconds; function time(){ date = new Date(); hours = date.getHours(); minutes = date.getMinutes(); seconds = date.getSeconds(); $("#watch .hours").css("transform","rotate(" + (hours * 3600 + minutes * 60 + seconds) / 120 + "deg)"); $("#watch .minutes").css("transform","rotate(" + (hours * 3600 + minutes * 60 + seconds)/ 10 + "deg)"); $("#watch .seconds").css("transform","rotate(" + (hours * 3600 + minutes * 60 + seconds) * 6 + "deg)"); setTimeout(function(){ time(); },1000); } $("document").ready(function(){ time(); $("#watch").fadeIn(1000); }); var LOADMORE_index_i = 0; var LOADMORE_loadmore_flag = false; function LOADMORE_initialize(LOADMORE_index_i){ var LOADMORE_set_index_count_i = LOADMORE_index_i; LOADMORE_thumb_i_max = $("ul#index > li.thm").length + 1; LOADMORE_loadmore_flag = true; thmArr = []; LOADMORE_thumb_i = 0; $("ul#index > li.thm").each(function(){ thmArr.push($(this)); LOADMORE_thumb_i ++; }); LOADMORE_index_thumbs_fade(LOADMORE_set_index_count_i); } function LOADMORE_index_thumbs_fade(LOADMORE_set_index_count_i) { var i = LOADMORE_set_index_count_i; if( i < LOADMORE_thumb_i ){ thmArr[i].find(".img > *").imagesLoaded(function(){ thmArr[i].find("a").stop().animate({ "opacity": 1 },400) setTimeout(function(){ i++; LOADMORE_index_thumbs_fade(i); },10); }); }else{ LOADMORE_loadmore_flag = true; $("li.load_more").fadeIn(300); } } function LOADMORE_loadmore_index( index_filter, set_category, index_count_i, index_count_limit, href ){ $("li.load_more > a > div").fadeOut(300, function() { $(this).remove(); }); $("li.load_more > div.spinner").stop().animate({"opacity": 1},400); $.ajax({ url: "https://www.renovationcraft.jp/ajax_index_load.php", data: "index_filter=" + index_filter + "&set_category=" + set_category + "&index_count_i=" + index_count_i + "&index_count_limit=" + index_count_limit + "", success: function(data, dataType){ var container = $("ul#index"); container.imagesLoaded(function(){ $("ul#index .load_more").fadeOut(300, function() { $(this).remove(); var elm = $(data); elm.css('display', 'none'); container.append(elm); container.imagesLoaded(function(){ elm.css('display', 'block'); container.masonry('appended', elm, true); LOADMORE_loadmore_flag = true; LOADMORE_initialize(index_count_i); }); }); }); }, complete: function(XMLHttpRequest, textStatus){ }, error: function(XMLHttpRequest, textStatus, errorThrown){ } }); } $(window).bind('load', function() { setTimeout(function(){ LOADMORE_initialize(0); },100); }); $(document).on("click", ".load_more > a", function(){ if( LOADMORE_loadmore_flag == true ){ LOADMORE_loadmore_flag = false; var index_filter = $(this).attr("data-index_filter"); var set_category = $(this).attr("data-set_category"); var index_count_i = $(this).attr("data-index_count_i"); var index_count_limit = $(this).attr("data-index_count_limit"); var href = $(this).attr("href").replace( "https://www.renovationcraft.jp/", "" ); LOADMORE_loadmore_index( index_filter, set_category, index_count_i, index_count_limit, href ); } return false; }); $(window).scroll(function(){ var window_height = $(window).height(); var scroll_val = $(window).scrollTop(); if( LOADMORE_loadmore_flag == true && $("li.load_more > a > div").length ){ var target = $(".load_more > a"); var margin = 500; var load_more_top = target.offset().top; if( scroll_val > load_more_top - window_height - margin ){ var index_filter = target.attr("data-index_filter"); var set_category = target.attr("data-set_category"); var index_count_i = target.attr("data-index_count_i"); var index_count_limit = target.attr("data-index_count_limit"); var href = target.attr("href").replace( "https://www.renovationcraft.jp/", "" ); LOADMORE_loadmore_flag = false; LOADMORE_loadmore_index( index_filter, set_category, index_count_i, index_count_limit, href ); } } }); function LOADMORE_initialize_masonry(){ var container = $('ul#index'); container.masonry({ itemSelector: '.thm', isAnimated: false, animationOptions: { duration: 10 } }); } LOADMORE_initialize_masonry(); function htmlEncode(value){ return $('
').text(value).html(); } function htmlDecode(value){ return $('
').html(value).text(); } });