var scrolling_check = ''; $(document).ready(function(){ if($(".entry_preview").attr("class")){ $("body").prepend("<div class=\"switch_source\" style=\"visibility: hidden;\"><a id=\"source\"" + (!read_cookie("switch_source") || read_cookie("switch_source") == "source" ? " class=\"switch_source_selected\"" : "") + ">Quelle</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a id=\"cache\"" + (read_cookie("switch_source") == "cache" ? " class=\"switch_source_selected\"" : "") + ">Cache</a>"); $(".switch_source a").click(function(){ if((!read_cookie("switch_source") && $(this).attr("id") == "cache") || (read_cookie("switch_source") && $(this).attr("id") != read_cookie("switch_source"))){ $(".switch_source a").attr("class",""); $(".switch_source a[id=" + $(this).attr("id") + "]").attr("class","switch_source_selected"); document.cookie = "switch_source=" + $(this).attr("id"); if($(this).attr("id") == "cache") var new_url = "http://www.acsearch.info/ext_record.html?url=" + encodeURIComponent($(".entry_preview").attr("src")); else var new_url = decodeURIComponent($(".entry_preview").attr("src").split("url=")[1]); $(".entry_preview").attr("src",new_url); } }); $("body").append("<div class=\"loading\"></div><img src=\"http://www.acsearch.info/style/images/design/loading.gif\" width=\"120\" height=\"120\" border=\"0\" class=\"loading_img\">"); loading_div("off"); $(".footer").remove(); fix_elements(); $(window).resize(function(){ fix_elements(); }); $(".entry_list div").click(function(){ preview(this); }); preview($(".entry_list div[class!=page_numbers]:eq(0)")); var open_url; var result_start; var records = 25; $(".entry_list").scroll(function(){ if(scrolling_check == ''){ if($(".entry_list").scrollTop() < 1 && $("#shown_results_1").text()*1 > 1) scrolling_check = 'top'; else if(($(".entry_list")[0].scrollHeight-$(".entry_list").height()-$(".entry_list").scrollTop()) < 1 && $("#shown_results_2").text()*1 < $("#all_results").text()*1) scrolling_check = 'bottom'; if(scrolling_check != ''){ loading_div("on",$(".entry_list").position().left,$(".entry_list").position().top,$(".entry_list").width(),$(".entry_list").height()); open_url = window.location.href.split("?")[1]; open_url = open_url.split("#")[0]; open_url = "http://www.acsearch.info/ext_search_ajax_entries.html?" + open_url; result_start = (scrolling_check == 'top' ? (($("#shown_results_1").text()*1)-1-records) : $("#shown_results_2").text()*1); get_more_results(open_url,result_start,records,scrolling_check); } } }); } }); function fix_elements(){ var list_position_top = $(".entry_list").position().top; var list_height = $(window).height()-list_position_top-1; $(".entry_list").css("height",list_height+"px"); $(".entry_preview").css("height",list_height+"px"); $(".preview_search_table").css("width",$(window).width()+"px"); $(".switch_source").css({ "top" : list_position_top+"px", "right" : "50px" }); } function preview(objct){ $(".entry_list div[class!=page_numbers]").css({ "padding" : "2px 2px 2px 2px;", "background-color" : "transparent", "border-width" : "0px;" }); $(objct).css({ "padding" : "1px 1px 1px 1px;", "background-color" : "#E4E2D7", "border-width" : "1px;" }); var this_url = $(objct).find("font[id!=]").attr("id"); if(read_cookie("switch_source") && read_cookie("switch_source") == "cache") this_url = "http://www.acsearch.info/ext_record.html?url=" + encodeURIComponent(this_url); $(".entry_preview").attr("src",this_url); window.location.href = window.location.href.split("#")[0] + "#" + (($(".entry_list div:has(font[id!=])").length-1)-$(objct).nextAll("div:has(font[id!=])").length); } function read_cookie(c_name){ var c_value = document.cookie; var c_split = c_value.split(";"); for(i=0;i<c_split.length;i++){ var c_s_split = c_split[i].split("="); if(c_name == $.trim(c_s_split[0])) return c_s_split[1]; } return false; } function loading_div(c_switch,c_left,c_top,c_width,c_height){ if(c_switch == "on"){ $(".loading").css({ 'left' : c_left + 'px', 'width' : c_width + 'px', 'top' : c_top + 'px', 'height' : c_height + 'px' }); $(".loading_img").css({ 'left' : c_left-(-((c_width/2)-60)) + 'px', 'top' : c_top-(-((c_height/2)-60)) + 'px' }); $(".loading, .loading_img").show(); } else $(".loading, .loading_img").hide(); } function get_more_results(c_url,c_start,c_length,c_position){ var return_true = false; $.ajax({ url: c_url + "&ajax=" + c_start, cache: false, success: function(html){ if(c_position == 'top') $(".entry_list").prepend(html); else $(".entry_list").append(html); if(($("#shown_results_2").text()*1)-(($("#shown_results_1").text()*1)-1) > c_length){ var scroll_position = ''; var entry_position = ''; if(c_position == 'top'){ entry_position = $(".entry_list div:first").position().top; scroll_position = $(".entry_list").scrollTop(); $(".entry_list div:gt(" + ((c_length*2)-1) + ")").remove(); $(".entry_list").scrollTop(scroll_position-(entry_position-$(".entry_list div:eq(" + c_length + ")").position().top)); } else{ entry_position = $(".entry_list div:eq(" + c_length + ")").position().top; scroll_position = $(".entry_list").scrollTop(); $(".entry_list div:lt(" + c_length + ")").remove(); $(".entry_list").scrollTop(scroll_position-(entry_position-$(".entry_list div:first").position().top)); } } var shown_results_1 = $("#shown_results_1").text()*1; var shown_results_2 = $("#shown_results_2").text()*1; var all_results = $("#all_results").text()*1; if(c_position == 'top'){ var new_shown_results_1 = (shown_results_1 > 1 ? shown_results_1-c_length : shown_results_1); var new_shown_results_2 = new_shown_results_1-1-(-c_length*2); } else{ var new_shown_results_1 = (shown_results_2-shown_results_1-1 > c_length ? shown_results_1-(-c_length) : shown_results_1); var new_shown_results_2 = (shown_results_2-(-c_length) > all_results ? all_results : shown_results_2-(-c_length)); } $("#shown_results_1").text(new_shown_results_1); $("#shown_results_2").text(new_shown_results_2); scrolling_check = ''; loading_div("off"); } }); }