| 10582 |
lgm |
1 |
function toggleListview(e){
|
|
|
2 |
|
|
|
3 |
var a = document.getElementsByClassName('pd-list-hldr')[0];
|
|
|
4 |
if(a.className == 'pd-list-hldr clearfix'){
|
|
|
5 |
a.className += ' grid';
|
|
|
6 |
e.currentTarget.className = 'list-icon';
|
|
|
7 |
}else{
|
|
|
8 |
a.className = 'pd-list-hldr clearfix';
|
|
|
9 |
e.currentTarget.className = '';
|
|
|
10 |
}
|
|
|
11 |
|
|
|
12 |
}
|
|
|
13 |
var showmore;
|
|
|
14 |
var nextpageload = true;
|
|
|
15 |
function showMoreProducts()
|
|
|
16 |
{
|
|
|
17 |
debugger;
|
|
|
18 |
var cpage =document.getElementById('page').innerHTML;
|
|
|
19 |
var url = document.URL;
|
|
|
20 |
if(!cpage){cpage=2;} else {cpage = parseInt(cpage) +1;}
|
|
|
21 |
var data = spliturl(document.URL);
|
|
|
22 |
var cat = data[2].split('/');
|
|
|
23 |
cat = cat[cat.length-2];
|
|
|
24 |
var newUrl = base_url+'products/getSpecialProductList/'+cat+'/'+cpage;
|
|
|
25 |
microAjax(newUrl, function(res)
|
|
|
26 |
{
|
|
|
27 |
debugger;
|
|
|
28 |
if(res!='')
|
|
|
29 |
{
|
|
|
30 |
var appenddata =document.getElementById("appendlist");
|
|
|
31 |
var total = document.getElementById('count').value;
|
|
|
32 |
appenddata.innerHTML= appenddata.innerHTML + res;
|
|
|
33 |
document.getElementById('page').innerHTML = cpage;
|
|
|
34 |
if(cpage % 3 ==0){
|
|
|
35 |
showmore = 'block';
|
|
|
36 |
}
|
|
|
37 |
else{
|
|
|
38 |
showmore = 'none';
|
|
|
39 |
document.getElementById("showmorebutton").style.display='none';
|
|
|
40 |
}
|
|
|
41 |
if (parseInt(total) <= parseInt(cpage)) {
|
|
|
42 |
showmore = 'none';
|
|
|
43 |
nextpageload = false;
|
|
|
44 |
document.getElementById("showmorebutton").style.display='none';
|
|
|
45 |
}
|
|
|
46 |
var str = document.URL;
|
|
|
47 |
nextpageload = true;
|
|
|
48 |
if(str.indexOf("page") !== -1){
|
|
|
49 |
debugger;
|
|
|
50 |
data = spliturl(str);
|
|
|
51 |
newdata= data[1].split("&");
|
|
|
52 |
var a = newdata.length;
|
|
|
53 |
for(var i=0;i< a ;i++){
|
|
|
54 |
if(newdata[i].indexOf('page') != -1){
|
|
|
55 |
newdata[i]='page='+(parseInt(newdata[i].split('=')[1])+1);
|
|
|
56 |
}
|
|
|
57 |
}
|
|
|
58 |
var url = data[2]+'?'+newdata.join("&");
|
|
|
59 |
window.history.replaceState("",document.title, url);}
|
|
|
60 |
else{
|
|
|
61 |
if(str.indexOf('sortedBy') != -1 || str.indexOf('fq') != -1 || str.indexOf('minPrice') != -1){
|
|
|
62 |
window.history.replaceState("",document.title, window.location.href+"&page=2");
|
|
|
63 |
}
|
|
|
64 |
else{
|
|
|
65 |
window.history.replaceState("",document.title, window.location.href+"?page=2");
|
|
|
66 |
}
|
|
|
67 |
}
|
|
|
68 |
}
|
|
|
69 |
else
|
|
|
70 |
{
|
|
|
71 |
document.getElementById("showmorebutton").style.display='none';}
|
|
|
72 |
});
|
|
|
73 |
|
|
|
74 |
}
|
|
|
75 |
var startscroll = 0;
|
|
|
76 |
document.addEventListener("scroll", function (event) {
|
|
|
77 |
if(document.getElementsByClassName('refine-mask')[0].style.display == 'none' || document.getElementsByClassName('refine-mask')[0].style.display == ''){
|
|
|
78 |
var x = document.body.scrollTop;
|
|
|
79 |
var maxY = document.documentElement.scrollHeight - document.documentElement.clientHeight;
|
|
|
80 |
// when user reaches end of the page
|
|
|
81 |
if(x>startscroll)
|
|
|
82 |
{
|
|
|
83 |
startscroll = x;
|
|
|
84 |
}
|
|
|
85 |
else if(maxY==x)
|
|
|
86 |
{
|
|
|
87 |
startscroll=0;
|
|
|
88 |
window.scrollTo(0,0);
|
|
|
89 |
return false;
|
|
|
90 |
}
|
|
|
91 |
else
|
|
|
92 |
{
|
|
|
93 |
|
|
|
94 |
return false;
|
|
|
95 |
}
|
|
|
96 |
if (getDocHeight() <= getScrollXY()[1] + window.innerHeight + 300) {
|
|
|
97 |
debugger;
|
|
|
98 |
if(((document.getElementById('page').innerHTML%3) != 0) && nextpageload==true){
|
|
|
99 |
//console.log(x);
|
|
|
100 |
total = document.getElementById('count').value;
|
|
|
101 |
cpage = document.getElementById('page').innerHTML;
|
|
|
102 |
nextpageload=false;
|
|
|
103 |
if (parseInt(total) <= parseInt(cpage)) {
|
|
|
104 |
showmore = 'none';
|
|
|
105 |
nextpageload = false;
|
|
|
106 |
}else{
|
|
|
107 |
showMoreProducts();}
|
|
|
108 |
}
|
|
|
109 |
else{
|
|
|
110 |
if(showmore === 'block'){
|
|
|
111 |
document.getElementById('showmorebutton').style.display = 'block';
|
|
|
112 |
}
|
|
|
113 |
}
|
|
|
114 |
}
|
|
|
115 |
}});
|