| 10582 |
lgm |
1 |
function saveurl()
|
|
|
2 |
{
|
|
|
3 |
localStorage.path = document.URL;
|
|
|
4 |
}
|
|
|
5 |
|
|
|
6 |
function spliturl(url)
|
|
|
7 |
{
|
|
|
8 |
fullpath = url.substring(0, (url.indexOf("?") == -1) ? url.length : url.indexOf("?"));
|
|
|
9 |
params =fullpath.split('<?=base_url()?>');
|
|
|
10 |
//console.log(params[1]);
|
|
|
11 |
getparams = url.split('?');
|
|
|
12 |
//console.log(getparams[1]);
|
|
|
13 |
var output = new Array();
|
|
|
14 |
output[0] = params[1]; //data controller to parameters
|
|
|
15 |
output[1] = getparams[1];//get input
|
|
|
16 |
output[2]=fullpath; //full url expcept get input
|
|
|
17 |
//console.log(output);
|
|
|
18 |
return output;
|
|
|
19 |
}
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
function productSorting(category,sorttype)
|
|
|
23 |
{
|
|
|
24 |
//var cpage = document.getElementById('page').innerHTML;
|
|
|
25 |
//if(cpage != 1){cpage=1;} else {cpage = parseInt(cpage) +1;}
|
|
|
26 |
document.getElementById('page').innerHTML = 1;
|
|
|
27 |
var url = base_url+'products?category='+category+'&filter='+sorttype;
|
|
|
28 |
window.location.href = url;
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
}
|
|
|
32 |
var a;
|
|
|
33 |
var b;
|
|
|
34 |
function togglelist(e, id) {
|
|
|
35 |
|
|
|
36 |
var el = document.getElementById(id);
|
|
|
37 |
if ((a != undefined) && (b != null) && (a != el)) {
|
|
|
38 |
a.style.display = 'none';
|
|
|
39 |
b.innerHTML = '+';
|
|
|
40 |
}
|
|
|
41 |
if (el.style.display != 'none') {
|
|
|
42 |
el.style.display = 'none';
|
|
|
43 |
e.currentTarget.children[1].innerHTML = '+';
|
|
|
44 |
} else {
|
|
|
45 |
el.style.display = '';
|
|
|
46 |
e.currentTarget.children[1].innerHTML = '-';
|
|
|
47 |
}
|
|
|
48 |
a = el;
|
|
|
49 |
b = e.currentTarget.children[1];
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
function checkShipping(){
|
|
|
53 |
debugger;
|
| 10625 |
lgm |
54 |
var itemId ;
|
| 10582 |
lgm |
55 |
var color = document.getElementById('color');
|
| 10625 |
lgm |
56 |
if(color = null){
|
|
|
57 |
itemId = (color.options[color.selectedIndex].value);
|
|
|
58 |
}else{
|
|
|
59 |
itemId = items[0].id;
|
|
|
60 |
}
|
| 10582 |
lgm |
61 |
var pincode = document.getElementById('pincode').value;
|
| 10700 |
lgm |
62 |
if(pincode.match(/^\d+/) && pincode.length == 6){
|
|
|
63 |
var url = base_url+'productinfo/getDeliveryDetails/'+itemId+'/'+pincode;
|
| 10582 |
lgm |
64 |
microAjax(url, function(res)
|
|
|
65 |
{
|
|
|
66 |
debugger;
|
|
|
67 |
//console.log(res);
|
|
|
68 |
if(res!='')
|
|
|
69 |
{
|
|
|
70 |
data = JSON.parse(res);
|
|
|
71 |
days = data.business_days;
|
|
|
72 |
if(days >= 0){
|
| 10700 |
lgm |
73 |
document.getElementById('service').style.display = 'block';
|
|
|
74 |
document.getElementById('error').style.display = 'none';
|
| 10582 |
lgm |
75 |
if(document.getElementById('delivery'))
|
|
|
76 |
document.getElementById('delivery').innerHTML = data.delivery_estimate;
|
|
|
77 |
if(document.getElementById('cod')){
|
|
|
78 |
if(data.is_cod_available_for_location == true){
|
|
|
79 |
document.getElementById('cod').innerHTML = 'Cash On Delivery';
|
|
|
80 |
}
|
|
|
81 |
}
|
|
|
82 |
if(data.on_time_guarantee == true){
|
|
|
83 |
if(document.getElementById('guarantee').style.display == 'none'){
|
|
|
84 |
document.getElementById('guarantee').style.display == 'block';
|
|
|
85 |
}
|
|
|
86 |
//document.getElementById('guarantee').innerHTML = 'Yes';
|
|
|
87 |
}
|
|
|
88 |
|
|
|
89 |
}else{
|
|
|
90 |
document.getElementById('service').style.display = 'none';
|
|
|
91 |
document.getElementById('error').style.display = 'block';
|
| 10598 |
lgm |
92 |
document.getElementById('error').innerHTML = 'Location is not serviceable'
|
| 10582 |
lgm |
93 |
}
|
|
|
94 |
}
|
|
|
95 |
});
|
| 10700 |
lgm |
96 |
}else{
|
|
|
97 |
document.getElementById('error').style.display = 'block';
|
|
|
98 |
document.getElementById('error').innerHTML = 'Invalid pincode!'
|
|
|
99 |
}
|
| 10582 |
lgm |
100 |
}
|
|
|
101 |
function updateColor(value){
|
|
|
102 |
debugger;
|
|
|
103 |
if(document.getElementById('error').style.display == "block"){
|
|
|
104 |
document.getElementById('error').style.display = "none";
|
|
|
105 |
}
|
|
|
106 |
for(i=0;i<items.length;i++){
|
|
|
107 |
if(value.currentTarget.value == items[i].id){
|
|
|
108 |
document.getElementById('buy').innerHTML = items[i].buttonText;
|
|
|
109 |
var buttonText = items[i].buttonText;
|
|
|
110 |
if(buttonText.toUpperCase() == 'NOTIFY ME'){
|
|
|
111 |
document.getElementById('email').style.display = 'block';
|
|
|
112 |
}
|
|
|
113 |
else{
|
|
|
114 |
document.getElementById('email').style.display = 'none';
|
|
|
115 |
}
|
|
|
116 |
var mrp = parseInt(items[i].mrp);
|
|
|
117 |
if(mrp > 0){
|
|
|
118 |
document.getElementById('mrp').innerHTML = items[i].mrp;
|
|
|
119 |
}
|
|
|
120 |
if(items[i].discount != undefined && parseInt(items[i].discount) >0){
|
|
|
121 |
document.getElementById('discount').innerHTML = '('+items[i].discount+'% off)';
|
|
|
122 |
}
|
|
|
123 |
document.getElementById('sellingPrice').innerHTML = items[i].sellingPrice;
|
|
|
124 |
document.getElementById('emi').innerHTML = ' EMI from Rs. '+items[i].minEmi+' per month';
|
|
|
125 |
checkShipping();
|
|
|
126 |
return false;
|
|
|
127 |
}
|
|
|
128 |
}
|
|
|
129 |
}
|
|
|
130 |
function addToCart(){
|
|
|
131 |
debugger;
|
|
|
132 |
var itemId ;
|
|
|
133 |
var color = document.getElementById('color');
|
|
|
134 |
if(color = null){
|
|
|
135 |
itemId = (color.options[color.selectedIndex].value);
|
|
|
136 |
}else{
|
|
|
137 |
itemId = items[0].id;
|
|
|
138 |
}
|
|
|
139 |
if(document.getElementById('email').style.display == 'block'){
|
|
|
140 |
var email = document.getElementById('email').value;
|
|
|
141 |
email = email.trim();
|
|
|
142 |
var atpos = email.indexOf("@");
|
|
|
143 |
var dotpos = email.lastIndexOf(".");
|
|
|
144 |
if(email ==''){
|
|
|
145 |
document.getElementById('error').style.display = "block";
|
|
|
146 |
document.getElementById('error').innerHTML ='Please fill email field!';
|
|
|
147 |
window.scrollTo(0,0); return false;
|
|
|
148 |
}
|
|
|
149 |
if((atpos<1) || (dotpos < atpos+2) || (dotpos+2 >= email.length)){
|
|
|
150 |
document.getElementById('error').style.display = "block";
|
|
|
151 |
document.getElementById('error').innerHTML ='Please fill email in correct format!';
|
|
|
152 |
window.scrollTo(0,0); return false;
|
|
|
153 |
}
|
|
|
154 |
if(email.length> 50){
|
|
|
155 |
document.getElementById('error').style.display = "block";
|
|
|
156 |
document.getElementById('error').innerHTML ='Please enter less than 50 characters in email field!';
|
|
|
157 |
window.scrollTo(0,0); return false;
|
|
|
158 |
}
|
|
|
159 |
if(email.indexOf(' ') != -1){
|
|
|
160 |
document.getElementById('error').style.display = "block";
|
|
|
161 |
document.getElementById('error').innerHTML ='Please remove space from email field!';
|
|
|
162 |
window.scrollTo(0,0); return false;
|
|
|
163 |
}
|
|
|
164 |
var url = base_url+'cart/add/'+itemId+'/'+email;
|
|
|
165 |
}
|
|
|
166 |
else{
|
|
|
167 |
var url = base_url+'cart/add/'+itemId+'/null';
|
|
|
168 |
}
|
|
|
169 |
//window.location.href = url;
|
|
|
170 |
microAjax(url, function(res)
|
|
|
171 |
{
|
|
|
172 |
debugger;
|
|
|
173 |
if(res!='')
|
|
|
174 |
{
|
|
|
175 |
debugger;
|
|
|
176 |
data = JSON.parse(res);
|
|
|
177 |
if(data['addcart'][0].lines != undefined){
|
|
|
178 |
//window.history.replaceState("",document.title, base_url+'cart');
|
|
|
179 |
ga('send', 'event', 'Order', 'Add To Cart',itemId);
|
|
|
180 |
var ua = navigator.userAgent.toLowerCase();
|
|
|
181 |
var isIE = ua.indexOf('msie') !== -1;
|
|
|
182 |
if (isIE){
|
|
|
183 |
window.location.replace(base_url+'cart');
|
|
|
184 |
}else{
|
|
|
185 |
window.location.href = base_url+'cart';
|
|
|
186 |
}
|
|
|
187 |
}else if(data['addcart'][0].message != undefined){
|
|
|
188 |
message = data['addcart'][0].message;
|
|
|
189 |
document.getElementById('error').style.display = "block";
|
|
|
190 |
document.getElementById('error').innerHTML = message;
|
|
|
191 |
window.scrollTo(0,0);
|
|
|
192 |
}
|
|
|
193 |
}
|
|
|
194 |
});
|
|
|
195 |
}
|
|
|
196 |
function clearError(){
|
|
|
197 |
if(document.getElementById('error').style.display == "block"){
|
|
|
198 |
document.getElementById('error').style.display = "none";
|
|
|
199 |
}
|
|
|
200 |
}
|
|
|
201 |
function trackAccessories(title){
|
|
|
202 |
debugger;
|
|
|
203 |
ga('send', 'event', 'Widget', 'Accessory Click', title);
|
|
|
204 |
}
|