var running_prev = running = 'no'; var getstart = 10; var currentloct = location.href; if (!currentloct.match('www.')) { site_base_url = site_base_url.replace('www.', ''); } var newscroll = lastscroll = ''; var heightcheck = 0; var currentpage = 1; var last_scroll = 0; var toppageid = ''; function getPageVisibility(element) { // if ca 25% of element is visible var scroll_pos = $(window).scrollTop(); var window_height = $(window).height(); var el_top = $(element).offset().top; var el_height = $(element).height(); var el_bottom = el_top + el_height; currentpage = parseInt($(element).attr('id').replace('pagedno_', '')); //console.log((el_bottom - el_height*0.25 > scroll_pos)+'=='+(el_top < (scroll_pos+0.2*window_height))); return ((el_bottom - el_height * 0.10 > scroll_pos) && (el_top < (scroll_pos + 0.2 * window_height))); } var scrollcheck = ''; var startscroll = 'no'; $(document).ready(function (e) { //alert(location.origin+'='+location.pathname+'='+"?page="); if (getParameterByName('page') !== undefined && getParameterByName('page') != '') { currentpage = parseInt(getParameterByName('page')); } else { currentpage = 1; } /*var itstories = parseInt($('#top_highlight').height()); if(isNaN(itstories)) itstories = 0; var header_new_h = parseInt($('.header-new').height()); if(isNaN(header_new_h)) header_new_h = 0; var menues_h = parseInt($('.menues').height()); if(isNaN(menues_h)) menues_h = 0; var header_h = parseInt($('#header').height()); if(isNaN(header_h)) header_h = 0; var search_box = parseInt($('#search-box').height()); if(isNaN(search_box)) search_box = 0; var slider_section_h = parseInt($('#slider-section').height()); if(isNaN(slider_section_h)) slider_section_h = 0; var top_containt = parseInt($('#top_containt').height()); if(isNaN(top_containt)) top_containt = 0; heightcheck = 220 + header_new_h + menues_h + header_h + slider_section_h + search_box + itstories ;*/ $(window).scroll(function () { if (startscroll == 'yes') { if (($(window).scrollTop() + $(window).height()) >= (parseInt($(document).height()) - 100)) { getNextStoryListNew(); } // if($(window).scrollTop()>5000) {alert(($(window).scrollTop() + $(window).height()) +'=='+ (parseInt($(document).height())-100));} var scroll_pos = $(window).scrollTop(); scrollcheck = Math.abs(scroll_pos - last_scroll); if (currentpage > 1) { var toppageid_no = parseInt($('.pagedno:first').attr('id').replace('pagedno_', '')); if (toppageid_no > 1) { if (scroll_pos < last_scroll && scroll_pos <= ($('#story_container').offset().top - 70)) { getPreviousStoryList(); } } } scrollcheck = Math.abs(scroll_pos - last_scroll); if (scrollcheck > $(window).height() * 0.1 && $('#story_container').html() != '') { last_scroll = scroll_pos; $(".pagedno").each(function (index) { if (getPageVisibility(this)) { var seftitle = ''; if (getParameterByName('sef') !== undefined && getParameterByName('sef') != '') { seftitle = '&sef=' + getParameterByName('sef'); } if (getParameterByName('page') !== undefined && currentpage != getParameterByName('page')) { var createHref = location.origin + location.pathname + "?page=" + currentpage + seftitle; window.history.pushState({"pageTitle": $('title').html()}, $('title').html(), createHref); try { createHref = createHref.replace(site_base_url, "/"); } catch (err) { } ga('send', 'pageview', createHref); } return false; } }); } } }); if (currentpage > 1) { window.scrollTo(0, ($('#story_container').offset().top - 90)); } setTimeout(function () { startscroll = 'yes'; }, 1000); }); var getstart_prev = 0; function getPreviousStoryList() { var toppageid_no = parseInt($('.pagedno:first').attr('id').replace('pagedno_', '')); if (toppageid_no > 1) { currentpage = toppageid_no; if (getid2 == '' || getid2 == undefined) { getid2 = ''; } if (gettype == '' || gettype == undefined) { gettype = ''; } if (getuser == '' || getuser == undefined) { getuser = ''; } if (getstart_prev == undefined && getstart_prev == '') { getstart_prev = '0'; } else { getstart_prev = parseInt($('.pagedno:first').attr('id').replace('pagedno_', '')) * 10; } if (getstartdate == '' || getstartdate == undefined) { getstartdate = ''; } if (getenddate == '' || getenddate == undefined) { getenddate = ''; } if (getkeyword == '' || getkeyword == undefined) { getkeyword = ''; } if (getsearch_type == '' || getsearch_type == undefined) { getsearch_type = ''; } if (getsearch_by == '' || getsearch_by == undefined) { getsearch_by = ''; } getstart_prev = (toppageid_no - 2) * 10; if (running_prev == 'no' && (getpage2 != '' || getpage2 != undefined)) { $('#loader').show(10); running_prev = 'yes'; $.ajax({ type: 'GET', url: site_base_url + 'get_next_storylist.php', data: "page=" + encodeURIComponent(getpage2) + "&nid=" + encodeURIComponent(getid2) + "&start=" + encodeURIComponent(getstart_prev) + "&startdate=" + encodeURIComponent(getstartdate) + "&enddate=" + encodeURIComponent(getenddate) + "&keyword=" + encodeURIComponent(getkeyword) + "&search_type=" + encodeURIComponent(getsearch_type) + "&search_by=" + encodeURIComponent(getsearch_by) + "&type=" + encodeURIComponent(gettype) + "&user=" + encodeURIComponent(getuser), success: function (data) { $('#loader').hide(10); if (data.match('No More Story')) { $('.next-story').hide(); //$('#loader').html('');//No More Stories //$('#story_container').append('');//No More Stories $('#loader').hide(10); running_prev = 'yes'; } else if (data != '') { $('#story_container').prepend(data); window.scrollTo(0, $(window).scrollTop() + $("#pagedno_" + toppageid_no).height()); // adjust scroll sharingIcon(); //getstart = parseInt(getstart)+10; running_prev = 'no'; $('#loader').hide(10); $('#left-nav').css('height', $(document).height()); ga('send', 'event', 'PREV_STORYLIST', 'click', location.href, getstart_prev, {'nonInteraction': 1}); var pageurll = location.href; try { pageurll = pageurll.replace(site_base_url, "/"); } catch (err) { } ga('send', 'pageview', pageurll); } }, error: function () { $('#loader').hide(10); running_prev = 'no'; alert('Error retreiving data reload and try again.'); } }); } } } //next story list function getNextStoryListNew() { var getid1 = $("#getid1").val(); console.log('getid1---' + getid1); // var getid1=$("#getid1").val(); if (getid2 == '' || getid2 == undefined) { getid2 = ''; } if (gettype == '' || gettype == undefined) { gettype = ''; } if (getuser == '' || getuser == undefined) { getuser = ''; } if (getstart == '' || getstart == undefined) { getstart = '1'; } else { if (getstart == 0) { getstart = '1'; } else { getstart = parseInt($('.pagedno:last').attr('id').replace('pagedno_', '')) * 10; } } if (getstartdate == '' || getstartdate == undefined) { getstartdate = ''; } if (getenddate == '' || getenddate == undefined) { getenddate = ''; } if (getkeyword == '' || getkeyword == undefined) { getkeyword = ''; } if (getsearch_type == '' || getsearch_type == undefined) { getsearch_type = ''; } if (getsearch_by == '' || getsearch_by == undefined) { getsearch_by = ''; } var gettype2 = $("#getvideotype").val(); if (gettype2 != '' || gettype2 != undefined) { gettype = gettype2; } if (running == 'no' && (getpage2 != '' || getpage2 != undefined)) { $('#loader').show(10); running = 'yes'; $.ajax({ type: 'GET', url: site_base_url + 'get_next_storylist.php', data: "page=category&nid=" + encodeURIComponent(getid1) + "&start=" + encodeURIComponent(getstart) + "&startdate=" + encodeURIComponent(getstartdate) + "&enddate=" + encodeURIComponent(getenddate) + "&keyword=" + encodeURIComponent(getkeyword) + "&search_type=" + encodeURIComponent(getsearch_type) + "&search_by=" + encodeURIComponent(getsearch_by) + "&type=" + encodeURIComponent(gettype) + "&user=" + encodeURIComponent(getuser), success: function (data) { $('#loader').hide(10); if (data.match('No More Story')) { $('.next-story').hide(); //$('#loader').html('');//No More Stories //$('#story_container').append('');//No More Stories $('#loader').hide(10); running = 'yes'; } else if (data != '') { $('#story_container').append(data); sharingIcon(); getstart = parseInt(getstart) + 10; running = 'no'; $('#loader').hide(10); $('#left-nav').css('height', $(document).height()); ga('send', 'event', 'NEXT_STORYLIST', 'click', location.href, getstart, {'nonInteraction': 1}); var pageurll = location.href; try { pageurll = pageurll.replace(site_base_url, "/"); } catch (err) { } ga('send', 'pageview', pageurll); } }, error: function () { $('#loader').hide(10); alert('Error retreiving data reload and try again.'); } }); } } /* menu code */ window.onload = function() { if(detectMobile()){ if(is_iPad()){ //console.log('ipad'); ipadMenu(); } else{ subMenu = $('.more_list').html(); $('.drop_down_arrow').remove(); $('.main-nav').append(subMenu); } } $('.drop_down_arrow').click(function(){ $(this).children('ul').slideToggle('slow'); }); } function detectMobile() { return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino|android|ipad|playbook|silk/i.test(navigator.userAgent || navigator.vendor || window.opera) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test((navigator.userAgent || navigator.vendor || window.opera).substr(0, 4)) } function ipadMenu(){ otherMenu = ''; menuCount = $('.main-nav>li').length; sunMenu = $('.main-nav>li')[menuCount-1] var ipadMenu = ''; $('.main-nav>li').each(function(k,v ){ if(k >=5&& k