var alert_db=[]; var last_alert=""; function alert_(type="confirm",heading="EmaChat",description="Enter",yes="Accept",no="Cancel",fun=function(r){console.log(r)}){ alert_db.push([type,heading,description,yes,no,fun]); runalert(); } var pend_ex=[];var runalert_st=0; function alertyes(){ data=pend_ex;pend_ex=[]; var type=data[0];var heading=data[1];var des=data[2];var yes=data[3];var no=data[4];var ex=data[5]; if(type=="confirm"){ex(true);}else if(type=="prompt"){ex( $("#alertbox #input").val());}else if(type=="alert"){ex(true);} $("#alertbox").fadeOut(200);runalert_st=0; } function alertno(){ data=pend_ex;pend_ex=[]; var type=data[0];var heading=data[1];var des=data[2];var yes=data[3];var no=data[4];var ex=data[5]; ex(false);$("#alertbox").fadeOut(200);runalert_st=0; } function runalert(){ if(alert_db.length!=0){ if(runalert_st==0){ runalert_st=1; var data=alert_db[0];alert_db.shift(); pend_ex=data;var type=data[0];var heading=data[1];var des=data[2];var yes=data[3];var no=data[4];var ex=data[5]; $("#alertbox #input").val("");$("#alertbox").fadeIn(200);$("#alertbox #h3").html(heading);$("#alertbox #yes").text(yes);$("#alertbox #no").text(no); if(type=="confirm"){ $("#alertbox #input").hide();$("#alertbox #input2").show();$("#alertbox #input2").html(des);$("#alertbox #no").show();$("#alertbox #yes").show(); }else if(type=="prompt"){ $("#alertbox #no").show();$("#alertbox #yes").show(); $("#alertbox #input").show();$("#alertbox #input2").hide();$("#alertbox #input").attr("placeholder",des); }else if(type=="alert"){$("#alertbox #input").hide();$("#alertbox #input2").show();$("#alertbox #input2").html(des);$("#alertbox #no").hide();$("#alertbox #yes").show(); } } } } $(document).ready(function(){ $(".tab").click(function(r){ $(".tab").css({ 'color':'#25265f' }) console.log(this.id) $(this).css({ 'color':'#17b188'}) }) checkMarketStatus(); $("#alertbox #no").on("click",function(){ alertno(); }) $("#alertbox #yes").click(function(){ alertyes(); }) setInterval(() => { runalert(); }, 100); }) function session(){ return localStorage.getItem('user_session'); } var user_session=session(); var pages=[]; function openpage(hash,run){ var data = window.location.hash; if(data){ data=data.split("#"); data=data[1].split("FFKART"); if(data[0]=="viewcart"){ //register pages pages[hash]=run; //execute history.pushState(null, null, hash); pages[hash](); setTimeout(() => { var cartdata=data[1]; associativeArray=JSON.parse(atob(cartdata)); localStorage.setItem("mycart","{}"); for (let key in associativeArray) { if (associativeArray.hasOwnProperty(key)) { addtocart(key,associativeArray[key]); } } history.pushState(null, null, "#home"); viewcart(); }, 500); }else{ //register pages pages[hash]=run; //execute history.pushState(null, null, hash); pages[hash](); } }else{ //register pages pages[hash]=run; //execute history.pushState(null, null, hash); pages[hash](); } } function back(hash){ pages[hash](); } $(document).ready(function(){ $(window).on("popstate", function() { var hash = window.location.hash; back(hash); }); if(localStorage.getItem('pin')!=null){ if(localStorage.getItem('pin').length==6){ openpage("#home",function(){getcat(localStorage.getItem('pin'))}); }else{ openpage("#home",function(){getcat(areapincode)}); } }else{ openpage("#home",function(){getcat(areapincode)}); } }) var apmcname="Yeshwanthapur APMC"; function checkMarketStatus() { const now = new Date(); const currentHour = now.getHours(); const currentDay = now.getDay(); // Get the current day of the week (0-6, 0=Sunday, 1=Monday, ...) // Define market hours const marketOpenHour = 10; const marketCloseHour = 18; // Check if the current time is within market hours and not a government holiday if ( currentHour >= marketOpenHour && currentHour < marketCloseHour && !isGovernmentHoliday(now) ) { $("#market").html(''+apmcname+' is Open Place order before 5pm'); } else { $("#market").html(''+apmcname+' is Closed Place order before 5pm'); // Similar to the above comment, you can display this on a webpage using DOM manipulation } } // Function to check if it's a government holiday function isGovernmentHoliday(date) { // Define your list of government holidays as an array of Date objects or strings representing dates const governmentHolidays = [ '01-15', '01-26', '02-18', '03-08', '03-22', '03-30', '04-03', '04-07', '04-14', '04-23', '05-01', '05-05', '06-29', '07-29', '08-15', '08-25', '09-06', '09-18', '09-28', '10-02', '10-14', '10-23', '10-24', '11-01', '11-12', '11-14', '11-30', '12-25' ]; // Get the current date in MM-DD format const dateString = `${date.getMonth() + 1}-${date.getDate()}`; // Check if the current date is a Sunday or in the government holidays list return date.getDay() === 0 || governmentHolidays.includes(dateString); } // Check market status every minute (adjust the time interval as needed) setInterval(checkMarketStatus, 10000); // 60000 milliseconds = 1 minute var allshops=[]; function shopsearch(keyword) { // Convert keyword to lowercase for case-insensitive search keyword = keyword.toLowerCase(); // Iterate over the array allshops.forEach(function(item) { // Check if name or knownfor matches the keyword if (item.name.toLowerCase().includes(keyword) || item.knownfor.toLowerCase().includes(keyword)) { // Show the matching item by ID $("#shopid" + item.id).show(); } else { // Hide the non-matching item by ID $("#shopid" + item.id).hide(); } }); } function getcat(pin="560022"){ $("#shopviewss").hide(); $("#shopviewss2").hide(); $("#category").show(); $("#freesample").show(); $('#subitemsdiv').hide(); $('.items').hide(); if(shopid==''){ if(pin){ areapincode=pin; }else{ areapincode=prompt("Enter area Pin Code"); } if(areapincode.length==6){ $.post("app/api.json",{fun:"fetch-pincode",session:session(),pincode:areapincode},function(d,e){ if(d.data.length!=0){ localStorage.setItem("pin",areapincode); $("#apmcinfo").html('
Welcome to eAPMC Bangalore
'); var html=''; var html2=' Home'; for(var i=0;i'+dd.name+'' html=html+'
'+dd.name+'
'; } $("#category").html(html); $("#catagory23").html(html2); }else{ alert(d.msz); } }) }else{ alert("Wrong pincode"); } }else{ openshop(shopid,"cat"); } } var mobile=""; var run=function(){} function removeParam(parameter) { var url=document.location.href; var urlparts= url.split('?'); if (urlparts.length>=2) { var urlBase=urlparts.shift(); var queryString=urlparts.join("?"); var prefix = encodeURIComponent(parameter)+'='; var pars = queryString.split(/[&;]/g); for (var i= pars.length; i-->0;) if(pars[i].lastIndexOf(prefix, 0)!==-1) pars.splice(i, 1); url = urlBase+'?'+pars.join('&'); window.history.pushState('',document.title,url); // added this line to push the new url directly to url bar . } return url; } var maq=100; var item_data=[]; try{ if(localStorage.getItem("cart").length!=0){ item_data=JSON.parse(localStorage.getItem("cart")); } }catch(e){} var shop=[]; function openshop(id,what){ var a="9547551208";//prompt("Enter Your WhatsApp Number"); var sellerid=localStorage.getItem('sellerid'); var sellerpass=localStorage.getItem('sellerpass'); if(a.length==10){ $.post("/app/api.json",{ id:id, fun:'fetch-shop', session:session(), customer:a, what:what },function(d,e){ shop=d; $(".fixedfooter").show(); $("#shopprofile").show(); $("#shopprofile2").show(); $("#shopprofile2 name span").text(shop.info[0].name); $("#shoplupi").attr("href","upi://pay?pa="+shop.info[0].upi+"&tn=eAPMC"); $("#category").css({ 'margin-top':'20px' }) $("#shoplivechat2").text(shop.info[0].mobile); $("#shoplivechat").attr("href","https://api.whatsapp.com/send/?phone=91"+shop.info[0].mobile+"&text=Hi_got_your_number_from_eAPMC") $("#shopprofile2 regd").text(shop.info[0].regd); $("#shopprofile").css({ 'background-image':'url('+shop.info[0].img+')' }) $("#freesample").css("margin-top","0px"); displayshopcat(); }) }else{ alert("Wrong Mobile Number"); openshop(id,what); } } function openshop2(id,what){ var a="9547551208";//prompt("Enter Your WhatsApp Number"); if(a.length==10){ $.post("/app/api.json",{ id:id, sid:localStorage.getItem('sellerid'), spass:localStorage.getItem('sellerpass'), fun:'seller', session:session(), sfun:'fetch-shop', customer:a, what:what },function(d,e){ shop=d; $(".fixedfooter").show(); $("#shopprofile").show(); $("#shopprofile2").show(); $("#shopprofile2 name span").text(shop.info[0].name); $("#shoplupi").attr("href","upi://pay?pa="+shop.info[0].upi+"&tn=eAPMC"); $("#category").css({ 'margin-top':'20px' }) $("#shoplivechat2").text(shop.info[0].mobile); $("#shoplivechat").attr("href","https://api.whatsapp.com/send/?phone=91"+shop.info[0].mobile+"&text=Hi_got_your_number_from_eAPMC") $("#shopprofile2 regd").text(shop.info[0].regd); $("#shopprofile").css({ 'background-image':'url('+shop.info[0].img+')' }) $("#freesample").css("margin-top","0px"); displayshopcat(); }) }else{ alert("Wrong Mobile Number"); openshop(id,what); } } function shopgetCategoryData(jsonData) { let categories = []; for (let key in jsonData.category) { let category = jsonData.category[key]; categories.push({ id: category.info.id, name: category.info.name, img: category.info.image }); } return categories; } // Function to get subitems data function shopgetSubitemsData(jsonData, categoryId) { let subitems = []; let category = jsonData.category[categoryId]; if (category && category.subitems) { for (let subitem of category.subitems) { subitems.push({ id: subitem.info.id, name: subitem.info.name, img: subitem.info.image }); } } return subitems; } // Function to get items data function shopgetItemsData(jsonData, categoryId, subitemId) { let itemsData = []; let category = jsonData.category[categoryId]; if (category && category.subitems) { let subitem = category.subitems.find(item => item.info.id === subitemId); if (subitem && subitem.items) { for (let item of subitem.items) { itemsData.push({ name: item.name, image: item.image, id: item.id, price: item.price, multiply: item.multiply, description2: item.description2, img: item.img, loose:item.loose, looseunit:item.looseunit, quality:item.quality, supplier:item.supplier, supplierid:item.supplierid, unit: item.unit, quantity: item.quantity, brand: item.brand, kg: item.kg, totalkg: item.totalkg, hide: item.hide, type: item.type, stock: item.stock, metaphone:item.metaphone, changes:item.changes, metadata: item.metadata, rank: item.rank, }); } } } return { data: itemsData }; } function getAllItemsData(jsonData) { let allItems = []; // Iterate over each category for (let catKey in jsonData.category) { let category = jsonData.category[catKey]; // Iterate over each subitem within a category if (category.subitems) { for (let subitem of category.subitems) { // Iterate over each item within a subitem if (subitem.items) { for (let item of subitem.items) { allItems.push({ name: item.name, image: item.image, id: item.id, price: item.price, multiply: item.multiply, description2: item.description2, img: item.img, loose:item.loose, looseunit:item.looseunit, quality:item.quality, supplier:item.supplier, supplierid:item.supplierid, unit: item.unit, quantity: item.quantity, brand: item.brand, kg: item.kg, totalkg: item.totalkg, hide: item.hide, type: item.type, stock: item.stock, metadata: item.metadata, changes:item.changes, metaphone:item.metaphone, rank: item.rank, }); } } } } } return { data: allItems }; } function displayshopcat(){ var d=[]; apmcname=shop.info[0].name; checkMarketStatus(); d.data=shopgetCategoryData(shop); if(d.data.length!=0){ var html=''; var html2=' Home'; for(var i=0;i'+dd.name+'' html=html+'
'+dd.name+'
'; } $("#category").html(html); $("#catagory23").html(html2); } } // $("#apmcinfo").html('
Welcome to eAPMC Bangalore
'); // var html=''; // var html2=' Home'; // for(var i=0;i'+dd.name+'' // html=html+'
'+dd.name+'
'; // } // $("#category").html(html); // $("#catagory23").html(html2); function opensub2(id){ $('.items').hide(); $(".catagoryscroll").css("color","gray"); $("#catagoryscroll"+id).css("color","black"); $("#subitemsdiv").show(); $("#subitems").html(`
`); var d=[]; d.data=shopgetSubitemsData(shop,id); var html=''; if(d.data.length!=0){ for(var i=0;i
'+data1.name+''; } $("#subitems").html(html); }else{ $("#subitems").html("
"); } } function globalsearch2(){ $(".items").show(); $("#ordercopy").hide(); $("#cartcopy").show(); var d=getAllItemsData(shop); // current_subcat=id; //current_subcat=id; if(d.data.length!=0){ var html=''; d=sortby("rank",d); for(var i=0;i"); } total(); } var loadingg=`
Tomorrow
Fine

Tomorrow
Fine

Tomorrow
Fine

Tomorrow
Fine

Tomorrow
Fine

`; function allitems(id,srt="rank"){ $(".items").show(); $("#ordercopy").hide(); $("#cartcopy").show(); //navigateout("#subcategoryFFKART"+id); $(".itemlist new").html(loadingg); $.post("/app/api.json",{ cat:id, session:session(), pass:profitamount, fun:'allitemsshow' },function(d,e){ var html=''; current_subcat="allitems"; var newdata = d.data2; html=html+ itemdisplay(d,srt); if(html==''){ $(".itemlist new").html("
"); }else{ $(".itemlist new").html(html); } total(); }); } function allitems2(id,srt="rank"){ $(".items").show(); $("#ordercopy").hide(); $("#cartcopy").show(); //navigateout("#subcategoryFFKART"+id); $(".itemlist new").html(loadingg); $.post("/app/api.json",{ cat:id, session:session(), pass:profitamount, fun:'allitemsshow2' },function(d,e){ var html=''; current_subcat="allitems"; var newdata = d.data2; // sortby(srt,d); html=html+ itemdisplay(d,srt); if(html==''){ $(".itemlist new").html("
"); }else{ $(".itemlist new").html(html); } total(); }); } function opencat2(maincat,id,srt="rank",command='fetch-items'){ $(".items").show(); $("#ordercopy").hide(); $("#cartcopy").show(); //navigateout("#subcategoryFFKART"+id); var d=shopgetItemsData(shop,maincat,id); current_subcat=id; current_subcat=id; if(d.data.length!=0){ var html=''; sortby(srt,d); for(var i=0;i"); } total(); } var current_maincat=0; function opensub(id,img,name){ $('.items').hide(); $(".catagoryscroll").css("color","gray"); $("#catagoryscroll"+id).css("color","black"); $("#subitemsdiv").show(); $("#subitems").html(`
`); // navigateout("#categoryFFKART"+id); $.post("/app/api.json",{ catagory:id, session:session(), fun:'fetch-subcat' },function(d,e){ if(d.data.length!=0){ current_maincat=id; if(id=="-1"){ var html=''; }else{ var html='
See All '+name+'
'; } for(var i=0;i
'+data1.name+'' }else{ html=html+'
'+data1.name+'
' } //html=html+'
'+data1.name+''+data1.name+'
'; } $("#subitems").html(html); }else{ $("#subitems").html("
"); } }); } function viewcata(){ if(shopid==''){ getcat("560022"); }else{ window.location.replace("/app"); } } function viewshopss(){ if(shopid==''){ $("#shopviewss").show(); $("#shopviewss2").hide(); $("#freesample").hide(); $("#category").hide(); $.post("/app/api.json",{ fun:'viewshops', session:session() },function(d,e){ var html=''; allshops=d.html; $("#shopviewss data").html("
Loading...
"); for(var i=0;i
${sh.name}
Live Chat
View Store
${sh.knownfor}
`; } $("#shopviewss data").html(html); }) }else{ window.location.replace("/app?view=shop") } } function myorders(){ $(".my_orders").show(); $.post("/app/api.json",{ fun:'myorders', session:session() },function(d,e){ var html=''; var total_weight=0; var total_amount=0; for(var i=0;i`; } var st=order.status; var status='Pending'; if(st=="1"){ status='Pending'; }else if(st=="2"){ status='Confirmed'; }else if(st=="3"){ status='On way'; }else if(st=="4"){ status='Delivered'; } html=html+`
# ${order.id}
${order.supplier}
${payment} ${timeIntervalFrom(order.date)}
₹${order.total}
${order.weight}
Your Order is ${status}
`; } $("#my_ordersdata").html(html); }) } function updatesupplierorder(id){ var sellerid=localStorage.getItem('sellerid'); var sellerpass=localStorage.getItem('sellerpass'); var promo=$("#supplierorder_promo_"+id).val(); var payment=$("#supplierorder_payment_"+id).val(); var status=$("#supplierorder_status_"+id).val(); $('.my_orders2').show(); $.post('/app/api.json',{ sid:sellerid, spass:sellerpass, fun:'seller', promo1:promo, status:status, payment:payment, oid:id, sfun:'updatesupplierorder', session:session() },function(d,e){ }) } function deliveryview(){ $(".my_delivery").show(); } function helpview(){ $(".my_help").show(); viewcart(); } function calculatefare(){ $("#driverdetails").hide(); var deliverydistance=$("#deliverydistance").val(); var deliveryweight=$("#deliveryweight").val(); $.post("/app/api.json",{ fun:'calculatefare', deliverydistance:deliverydistance, deliveryweight:deliveryweight, session:session() },function(d,e){ var code='*I need transport service.*\n\n*Weight:* '+deliveryweight+'kg\n*Distance:* '+deliverydistance+'km\n*Expected Fare:* ₹'+d.driver.fare+'\n\nPlease contact me ASAP.'; code=encodeURIComponent(code); code="https://api.whatsapp.com/send/?phone=917026711223&text="+code; $("#driverdetails").show(); $("#driverdetailskm").text(deliverydistance); $("#driverdetailsweight").text(deliveryweight); $("#driverpropic").css({ 'background-image':'url('+d.driver.propic+')' }) $("#numberplate").text(d.driver.vannumber); $("#drivername").text(d.driver.name); $("#drivertotalfare").text(d.driver.fare); $("#drivermobileno").text(d.driver.mobile); $("#drivermobile").attr('href',code); }) } function makeCall(number) { window.location.href = `tel:${number}`; } function placeordertotrader(ekart){ var shopmobile=7026711223; if(shopid!=''){ shopmobile=shop.info[0].mobile; } $.post("/app/api.json",{ fun:'placeorder', ekart:ekart, supplier:shopmobile, session:session() },function(d,e){ a="Hi,\nI have ordered some items. My Order ID is "+d.orderid+" link is "+d.link+". The total Item value is Rs. "+$("#total").text()+". Please confirm my order.\n Thank you.\n\n"; a=encodeURIComponent(a); var cd=encodeURIComponent('https://eapmc.com'); a="https://api.whatsapp.com/send/?phone=91"+shopmobile+"&text="+a+'&source_url='+cd; window.open(a); //$("#ordercopy").attr("href",a); }) } function editprice(id,code){ var price=$("#sku_"+id).val(); $.post("/app/api.json",{ id:id, price:price, session:session(), name:$("#skuname_"+id).val(), minqt1:$("#skuminq"+id).val(), img:$("#skuimg_"+id).val(), descrip:$("#skudes"+id).val(), auth:code, fun:'update-price' },function(d,e){ alert(d.msz); }) } var current_subcat=0; const calculateFinalPrice = (item) => { var metadata=item.metadata; const pattern = /₹(\d+)/; // Regular expression pattern to match the price after ₹ symbol const matches = metadata.match(pattern); if (matches && matches[1]) { return parseFloat(matches[1]); // Convert the matched price to an integer }else{ return 0; } }; function sortby(d, jsonData) { if (d == "lowtohigh") { jsonData.data.sort((a, b) => { let finalPriceA = calculateFinalPrice(a); let finalPriceB = calculateFinalPrice(b); // Move items with finalPrice 0 to the end if (finalPriceA === 0) return 1; // a is moved towards the end if (finalPriceB === 0) return -1; // b is moved towards the end // Normal ascending sort for non-zero values return finalPriceA - finalPriceB; }); return jsonData; } else if (d == "hightolow") { jsonData.data.sort((a, b) => { let finalPriceA = calculateFinalPrice(a); let finalPriceB = calculateFinalPrice(b); // Move items with finalPrice 0 to the end if (finalPriceA === 0 && finalPriceB !== 0) return 1; // Move 'a' towards the end if (finalPriceB === 0 && finalPriceA !== 0) return -1; // Move 'b' towards the end // Normal descending sort for non-zero values return finalPriceB - finalPriceA; }); } else if (d == "rank") { jsonData.data.sort((a, b) => { let rankA = a.rank; let rankB = b.rank; // Move items with rank 0 to the end if (rankA === 0 && rankB !== 0) return 1; // Move 'a' towards the end if (rankB === 0 && rankA !== 0) return -1; // Move 'b' towards the end // Normal descending sort for non-zero values return rankB - rankA; }); return jsonData; } } function sortchange(id){ var srt=$("#sortid").val(); if(srt!="0"){ if(current_subcat=="allitems"){ allitems(current_maincat,srt); }else{ opencat(id,srt,"fetch-items"); } }else{ opencat(id); } } function globalsearch(){ if(shopid==''){ opencat(1,"rank",'globalsearch') }else{ globalsearch2(); } } function logout() { alert_("confirm","Are you sure?","Logout","Yes","No",function(r){ if(r){ localStorage.clear(); // Reload the page window.location.reload(); } }) // Clear all items from localStorage } function opencat(id,srt="rank",command='fetch-items'){ $(".items").show(); $("#ordercopy").hide(); $("#cartcopy").show(); //navigateout("#subcategoryFFKART"+id); $(".itemlist new").html(loadingg); $.post("/app/api.json",{ subitem:id, session:session(), pass:profitamount, fun:command },function(d,e){ var html=''; current_subcat=id; var newdata = d.data2; console.log("Hi") // sortby(srt,d); html=html+ itemdisplay(d,srt); // } if(html==''){ $(".itemlist new").html("
"); }else{ $(".itemlist new").html(html); } total(); }); } var ads=[];//["https://i.ibb.co/YXc8zpH/20240520-145932-min.jpg"];//["https://i.ibb.co/4SCSjXv/Whats-App-Image-2024-05-15-at-17-48-25-min.jpg","sharebutton()"] function adsshow(){ var html=''; if(ads.length>0){ html=`
`; } return html; } function sortData(data, sortBy = "lowtohigh") { // Convert data object to array for sorting const categories = Object.entries(data); // Helper functions to get the lowest non-zero price and the highest price of a category const getLowestNonZeroPrice = items => { const prices = items.map(item => parseFloat(item.loose)).filter(price => price !== 0); return prices.length ? Math.min(...prices) : Infinity; }; const getHighestPrice = items => { const prices = items.map(item => parseFloat(item.loose)); return Math.max(...prices); }; const getRank = items => { const ranks = items.map(item => parseFloat(item.rank)); return Math.min(...ranks); }; const getHighestRank = items => { const ranks = items.map(item => parseFloat(item.rank)); return Math.max(...ranks); }; // Sort categories based on the specified criteria if (sortBy === "lowtohigh") { categories.sort((a, b) => getLowestNonZeroPrice(a[1]) - getLowestNonZeroPrice(b[1])); } else if (sortBy === "hightolow") { categories.sort((a, b) => getHighestPrice(b[1]) - getHighestPrice(a[1])); } else if (sortBy === "rank") { categories.sort((a, b) => getHighestRank(b[1]) - getHighestRank(a[1])); } // Sort items within each category categories.forEach(category => { category[1].sort((a, b) => { const priceA = parseFloat(a.loose); const priceB = parseFloat(b.loose); // if (sortBy === "lowtohigh") { if (priceA === 0) return 1; // Zero prices go last if (priceB === 0) return -1; // Zero prices go last return priceA - priceB; // } else if (sortBy === "hightolow") { // return priceB - priceA; // } else if (sortBy === "rank") { // return parseFloat(b.rank) - parseFloat(a.rank); // } }); }); // Convert back to an object const sortedData = Object.fromEntries(categories); return sortedData; } function addBreaks(str) { // Check if the string length is less than or equal to 30 if (str.length <= 30) { return str; } // Regular expression to match every 30 characters const regex = /.{1,30}/g; // Split the string into chunks of 30 characters const chunks = str.match(regex); // Join the chunks with
tag return chunks.join('
'); } function itemdisplay(d,srt){ d=sortData(d.data2, srt); var html=''; var products=d; Object.keys(products).forEach(key => { if(products[key].length>1){ html=html+'
'; var d1=products[key]; for(var k=0;k'; }else{ var data1=products[key][0]; var tempcart2=getcart(); if(tempcart2!=null){ if(tempcart2[data1.id]!=undefined){ data1.quantity=tempcart2[data1.id]; } } item_data[data1.id]=data1; if(data1.hide=="0"){ html=html+product(data1); } } }); // var html=''; // if(d.data.length!=0){ // //sortby(srt,d); // // for(var i=0;iClose"; $(".immhub").show(); $(".immhub").html(html); } function viewimghub(d){ d1=d.split(","); html=""; for(var i=0;i"; } $(".immhub").show(); $(".immhub").html(html); } function decodeHtml(encodedString) { var parser = new DOMParser(); var dom = parser.parseFromString( '' + encodedString, 'text/html'); return dom.body.textContent; } function dataexchange(id,id2){ if(item_data[id2].price!=0){ var sk=` #${id2}`; $("#itemid_"+id+" .productname").html(item_data[id2].name + sk); $("#itemid_"+id+" .productprice div").html("₹"+item_data[id2].price+" / "+item_data[id2].unit); // $("#itemid_"+id+" p").html(item_data[id2].description2); // $("#itemid_"+id+" p").html(item_data[id2].description2+decodeHtml(item_data[id2].metadata)); $("#itemid_"+id+" skuidd").html("#"+id2); $("#itemid_"+id+" .looseprice").html(item_data[id2].loose); $("#itemid_"+id+" .qualityt").html(qualitytag1st(item_data[id2].quality)); //$("#itemid_"+id+" .lazy-background").removeClass("loaded"); $("#itemid_"+id+" .productimg").css("background-image","url("+item_data[id2].image+")") // $("#itemid_"+id+" .lazy-background").attr("data-bg",item_data[id2].image) var varcart=`
${item_data[id2].quantity}
`; $("#itemid_"+id+" .productaddtocart").html(varcart); }else{ alert("Product is out of Stock"); } } function qualitytag1st(q) { if(q=="1"){ q="Fine"; } if(q=="2"){ q="Medium"; } if(q=="3"){ q="Mix"; } if(q=="0"){ q="Okay"; } return q; } function qualitytag2nd(originalText) { var searchText = '(2ndq)'; // Check if the text is present in the original text if (originalText.includes(searchText)) { // Replace the original text with the bold version var formattedText = 'Medium'; return formattedText; } // Return the original text if the search text is not found return qualitytag3rd(originalText); } function qualitytag3rd(originalText) { var searchText = '(3rdq)'; // Check if the text is present in the original text if (originalText.includes(searchText)) { // Replace the original text with the bold version var formattedText = 'Mix'; return formattedText; }else{ var formattedText = 'Okay'; return formattedText; } // Return the original text if the search text is not found return ''; } var showeditbtn=0; function timeIntervalFrom(dateString) { const givenDate = new Date(dateString); const currentDate = new Date(); const diffInMilliseconds = currentDate - givenDate; const diffInMinutes = Math.floor(diffInMilliseconds / 60000); if (diffInMinutes < 1) { return "Just now"; } else if (diffInMinutes === 1) { return "1 minute ago"; } const diffInHours = Math.floor(diffInMinutes / 60); if (diffInHours < 1) { return `${diffInMinutes} minutes ago`; } else if (diffInHours === 1) { return "1 hour ago"; } const diffInDays = Math.floor(diffInHours / 24); if (diffInDays < 1) { return `${diffInHours} hours ago`; } else if (diffInDays === 1) { return "1 day ago"; } return `${diffInDays} days ago`; } function product(data1){ q=data1.quantity; var outofstock=''; var mypricediv=data1.price; if(showeditbtn==0){ if(data1.price==0){ // mypricediv=`
Out of Stock
`; mypricediv=`
Price on request
`; outofstock='display:grid'; if(data1.image==""){ outofstock='display:none'; } }else{ //mypricediv=`
₹${data1.price}/${data1.unit}
`; mypricediv=`
₹${data1.price}/${data1.unit}
`; } }else{ mypricediv=``; } var name_edit=data1.name; var image_edit=''; var minq=''+q+''; var description2=data1.description2+decodeHtml(data1.metadata); var variant=''; if(data1.type.length!=0){ var tt=data1.type.split(","); variant='' } let currentDateTime = new Date(); // Example usage with current date and time let deliverySlot = "within 4hour";//getDeliverySlot(currentDateTime); var bestsellingtag=''; if(data1.tag==1){ bestsellingtag='';//'' } // onclick="alert2('+data1.id+')" var changes=timeIntervalFrom(data1.changes); var deliveryhtml=' '+deliverySlot+' '; var loose=''+data1.looseunit+' '+data1.totalkg+' '; var quality=' '+qualitytag1st(data1.quality)+' '; // var addtocarthtml='
'+minq+'
'; // var addtocarthtml=``; // addtocarthtml=`
// //
//
${minq}
//
// //
`; var addtocarthtml=``; if(shopid>0){ // addtocarthtml=`
// //
//
${minq}
//
// //
`; addtocarthtml=``; } if(showeditbtn==1){ addtocarthtml=``; } html=`
${bestsellingtag}
${name_edit} #${data1.id}
${loose}
${deliveryhtml}
${quality}
${variant}
${mypricediv}
${addtocarthtml}

Get Fixed Price & Best Price for Bulk Orders `; //${changes} return html; } function myrequirement(){ $.post("/app/api.json",{ fun:"myrequirement", session:session() },function(d,e){ console.log(d); }) } function product2(data1){ q=data1.quantity; var outofstock=''; var mypricediv=data1.price; if(showeditbtn==0){ if(data1.price==0){ mypricediv=`
Out of Stock
`; outofstock='display:grid'; if(data1.image==""){ outofstock='display:none'; } }else{ mypricediv=`
₹${data1.price}/${data1.unit}
`; } }else{ mypricediv=``; } var name_edit=data1.name; var image_edit=''; var minq=''+q+''; var description2=data1.description2+decodeHtml(data1.metadata); var variant=''; if(data1.type.length!=0){ var tt=data1.type.split(","); variant='' } let currentDateTime = new Date(); // Example usage with current date and time let deliverySlot = "Tomorrow";//getDeliverySlot(currentDateTime); var bestsellingtag=''; if(data1.tag==1){ bestsellingtag='';//'' } // onclick="alert2('+data1.id+')" var changes=timeIntervalFrom(data1.changes); var deliveryhtml=' '+deliverySlot+' '; var loose=''+data1.looseunit+' ₹'+data1.loose+' '; var quality=' '+qualitytag1st(data1.quality)+' '; // var addtocarthtml='
'+minq+'
'; var addtocarthtml=``; addtocarthtml=`
${minq}
`; if(shopid>0){ addtocarthtml=`
${minq}
`; } if(showeditbtn==1){ addtocarthtml=``; } html=`
${bestsellingtag}
${name_edit} #${data1.id}
${loose}
${deliveryhtml}
${quality}
${variant}
${mypricediv}
${addtocarthtml}

${changes}
`; return html; } var mycart=new Object(); setInterval(() => { itemlazyload(); }, 1000); function getDeliverySlot(orderPlacingTime) { let orderPlacingDateTime = new Date(orderPlacingTime); let day = orderPlacingDateTime.getDay(); let time = orderPlacingDateTime.getHours(); let delivery = {}; if ((day === 1 && time >= 15) || (day === 2 && time < 15)) { delivery.slot = "MT"; delivery.day = "Wednesday"; } if ((day === 2 && time >= 15) || (day === 3 && time < 15)) { delivery.slot = "TW"; delivery.day = "Thursday"; } if ((day === 3 && time >= 15) || (day === 4 && time < 15)) { delivery.slot = "WT"; delivery.day = "Friday"; } if ((day === 4 && time >= 15) || (day === 5 && time < 15)) { delivery.slot = "TF"; delivery.day = "Saturday"; } if ((day === 5 && time >= 15) || (day === 6 && time < 15)) { delivery.slot = "FS"; delivery.day = "Sunday"; } if ((day === 6 && time >= 15) || (day === 0 && time < 15)) { delivery.slot = "SM"; delivery.day = "Tuesday"; } return delivery; } function itemlazyload(){ var lazyBackgrounds = document.querySelectorAll(".lazy-background"); if ("IntersectionObserver" in window) { var lazyBackgroundObserver = new IntersectionObserver(function(entries, observer) { entries.forEach(function(entry) { if (entry.isIntersecting) { preloadImage(entry.target.getAttribute("data-bg"), function() { entry.target.style.backgroundImage = "url('" + entry.target.getAttribute("data-bg") + "')"; entry.target.classList.add("loaded"); lazyBackgroundObserver.unobserve(entry.target); }); } }); }); lazyBackgrounds.forEach(function(lazyBackground) { lazyBackgroundObserver.observe(lazyBackground); }); } else { // Fallback for older browsers lazyBackgrounds.forEach(function(lazyBackground) { preloadImage(lazyBackground.getAttribute("data-bg"), function() { lazyBackground.style.backgroundImage = "url('" + lazyBackground.getAttribute("data-bg") + "')"; lazyBackground.classList.add("loaded"); }); }); } } function preloadImage(url, callback) { var img = new Image(); img.onload = callback; img.src = url; } function getcart(){ var tempcart=new Object(); if(localStorage.getItem("mycart")!="" || localStorage.getItem("mycart")!=null){ tempcart=JSON.parse(localStorage.getItem("mycart")); } return tempcart; } function addtocart(id,q){ if(getcart()==null){ mycart=new Object(); }else{ mycart=getcart(); } if(q>0){ mycart[id]=q; localStorage.setItem("mycart",JSON.stringify(mycart)); }else{ delete mycart[id] localStorage.setItem("mycart",JSON.stringify(mycart)); } } function plus(id){ var data=item_data[id]; if(data.price!=0){ var quantity=item_data[id].quantity; if(quantity>=0){ quantity=parseInt(quantity); }else{ quantity=0; } var multiply=parseInt(item_data[id].multiply); quantity=quantity+multiply; $("#item_q_"+id).text(quantity); data["quantity"]=quantity; total(); addtocart(id,quantity); } } function minas(id){ var data=item_data[id]; if(data.price!=0){ var quantity=item_data[id].quantity; if(quantity>=0){ quantity=parseInt(quantity); }else{ quantity=0; } var multiply=parseInt(item_data[id].multiply); quantity=quantity-multiply; if(quantity<0){ quantity=0; } $("#item_q_"+id).text(quantity); data["quantity"]=quantity; total(); addtocart(id,quantity); } } var profitamount=""; function fetchitemsbyid(ids){ $.post("/app/api.json",{ list:ids, pass:profitamount, session:session(), shopid:shopid, fun:'fetch-items-by-id' },function(d,e){ if(d.data.length!=0){ var html=''; for(var i=0;i"); } total(); }) } function removeDataBySkuId(skuId) { // Retrieve the data from localStorage const dataStr = localStorage.getItem('mycart'); if (dataStr) { // Parse the string into an object const dataObj = JSON.parse(dataStr); // Check if the SKU ID exists in the object and remove it if (dataObj.hasOwnProperty(skuId)) { delete dataObj[skuId]; // Save the updated object back to localStorage localStorage.setItem('mycart', JSON.stringify(dataObj)); } else { } } else { } } // Example usage: ; function ekartlink(){ var hash="#viewcartFFKART"+btoa(localStorage.getItem("mycart")); history.pushState(null, null, hash); } function viewcart(){ var tempcart3=getcart(); var b=new Array(); if(tempcart3!=null){ for (const id in tempcart3) { b.push(id); } fetchitemsbyid(JSON.stringify(b)); //navigateout("#viewcartFFKART"+btoa(localStorage.getItem("mycart"))); }else{ fetchitemsbyid(); } $(".my_help").show(); $("#ordercopy").show(); $("#cartcopy").hide(); } var global_order=''; var global_percen=0; var deliverycharges=0; function transport(kg, km) { return Math.max(kg * (5400 / 4000), km * (5400 / 75)); } function calculateCharge2(){ var a= userkm * 72; const kg = parseFloat(document.getElementById('totalweight').innerText); } function calculateCharge() { const kg = parseFloat(document.getElementById('totalweight').innerText); const km = parseFloat((userkm)); var tf=Math.round(((km*72) - (kg*1.35))); if(tf<1){ tf=0; } console.log(km); if (isNaN(kg) || isNaN(km) || kg <= 0 || km <= 0 || km > 75) { document.getElementById('result').innerText = '0'; document.getElementById('suggestion').style.display = 'none'; return; } const totalCharges = 4400; const profit = 1000; const total = totalCharges + profit; const perKmCharge = total / 75; const perKgCharge = total / 4000; const chargeBasedOnKg = kg * perKgCharge; const chargeBasedOnKm = km * perKmCharge; // Add loading charges const loadingCharge = 0;kg * 0.2; const maxCharge = Math.max(chargeBasedOnKg, chargeBasedOnKm) + loadingCharge; let suggestions = ''; let waitingTimeInfo = ''; // Suggestion for additional kg or km if (maxCharge === chargeBasedOnKm + loadingCharge) { // The charge is based on distance (km) const remainingKg = (maxCharge - loadingCharge) / perKgCharge - kg; suggestions = `Add up to ${Math.floor(remainingKg)} kg more for free delivery.`; } else { // The charge is based on weight (kg) const remainingKm = (maxCharge - loadingCharge) / perKmCharge - km; //suggestions = `You can travel up to ${Math.floor(remainingKm)} km more at the same price.`; } // Calculate waiting time based on remaining capacity const maxCapacity = 4000; const remainingCapacity = maxCapacity - kg; if (remainingCapacity > 0) { waitingTimeInfo = `Waiting for additional ${remainingCapacity} kg before dispatch.`; } deliverycharges=tf;//maxCharge.toFixed(2); document.getElementById('result').innerText = tf;//`${maxCharge.toFixed(2)}`; if (suggestions) { document.getElementById('suggestion').style.display = 'block'; document.getElementById('suggestion').innerHTML = suggestions; } else { document.getElementById('suggestion').style.display = 'none'; } } function total(){ var order_data=''; var total=0; var total_plate=0; var past_car=[]; var totalweight=0; for(var i=0;i0){ past_car[data1.id]=data1.quantity; var tempt=((parseInt(data1.price))*parseInt(data1.quantity)); var tempkg=((parseInt(data1.totalkg))*parseInt(data1.quantity)); total=total+tempt; totalweight=totalweight+tempkg; total_plate=total_plate+parseInt(data1.quantity); if(tempt>0){ order_data=order_data+','+data1.id+'-'+data1.quantity; } } }catch(e){} } global_order=order_data; var percen=total_plate/maq*100; global_percen=percen; // $(".fixedfooter button").css({background:'linear-gradient(90deg, #00b207 '+percen+'%, #dcdcdc 0%)'}) total=parseInt(total)+parseInt(deliverycharges); $("#total").html(total); $("#total2").html(total); $("#totalweight").html(totalweight); // generatelink(); calculateCharge(); } function generatelink(){ var totalw=parseInt($("#totalweight").text()); if(totalw>26){ var a=global_order.substring(1) a=`*Order Request:* Cart Link: https://eapmc.com/app#viewcartFFKART${btoa(localStorage.getItem("mycart"))}. Weight: ${$("#totalweight").text()} kg Distance from APMC: ${userkm} km Transport Charges: ₹${$("#result").text()} Total Amount: ₹${$("#total").text()} Please confirm my order. Thank you!`; // a="Hi eAPMC,\nI have ordered some items. My e-cart link is https://eapmc.com/app#viewcartFFKART"+btoa(localStorage.getItem("mycart"))+". The total Item value is Rs. "+$("#total").text()+". Please confirm my order.\n Thank you.\n\n #DID"+deviceid+" \n "+ref; a=encodeURIComponent(a); var cd=encodeURIComponent('https://eapmc.com'); if(shopid!=''){ a="https://api.whatsapp.com/send/?phone=91"+shop.info[0].mobile+"&text="+a+'&source_url='+cd; placeordertotrader(btoa(localStorage.getItem("mycart"))); }else{ a="https://api.whatsapp.com/send/?phone=917026711223&text="+a+'&source_url='+cd; $("#ordercopy").attr("href",a); // placeordertotrader(btoa(localStorage.getItem("mycart"))); } //$("#ordercopy").attr("href",a); //ekartlink(); }else{ $.notify('Minimum Order 26kg','error') } } function order_now(){ if(global_percen>=100){ captcha(); run=function(){$.post("/app/api.json",{ token:localStorage.getItem("token"), fun:'order-now', order:global_order, cap_id:captcha_id,cap_value:captcha_value },function(d,e){ if(d.msz=="Order Done! Deliver within One Hour"){ localStorage.setItem("cart",""); $('.items').hide(); item_data=[]; alert("Order Done! Deliver within One Hour"); }else{ alert(d.msz); if(d.msz=="Login First"){ login(); } } }); } }else{ alert(global_percen+"% Done. Add few more items."); } } let debounceTimeout; function debounceSearch() { clearTimeout(debounceTimeout); debounceTimeout = setTimeout(() => { search(); }, 500); // Adjust delay as needed } function metaphone(input) { var length = input.length, result = '', lastChar = '', currentChar = '', nextChar = '', nextChar2 = '', subvalue = ''; // Normalize the input string input = input.toUpperCase().replace(/[^A-Z]/g, ''); if (!input) return result; // Rules dependent on the first character if (input.startsWith('KN') || input.startsWith('GN') || input.startsWith('PN') || input.startsWith('AE') || input.startsWith('WR')) { input = input.substr(1); } else if (input.startsWith('WH')) { input = 'W' + input.substr(2); } for (var i = 0; i < length; i++) { currentChar = input[i]; nextChar = input[i + 1] || ''; nextChar2 = input[i + 2] || ''; if (currentChar === 'X') { result += 'KS'; continue; } if (currentChar === 'G') { subvalue = ''; if (nextChar === 'H') { if (i + 2 < length && !/[AEIOU]/.test(nextChar2)) { subvalue = 'K'; i++; } } else if (nextChar === 'N') { if (i + 2 < length && nextChar2 !== 'E') { subvalue = 'KN'; } } else if (/[EIY]/.test(nextChar)) { subvalue = 'J'; } else { subvalue = 'K'; } if (subvalue) { if (lastChar !== subvalue.charAt(0)) { result += subvalue; } lastChar = subvalue.charAt(subvalue.length - 1); continue; } } switch (currentChar) { case 'B': if (lastChar !== 'B') { result += 'B'; } break; case 'C': if (/[IEY]/.test(nextChar)) { result += 'S'; } else if (nextChar === 'H') { result += 'X'; i++; } else { result += 'K'; } break; case 'D': if (nextChar === 'G' && /[IEY]/.test(nextChar2)) { result += 'J'; i += 2; } else { result += 'T'; } break; case 'F': case 'J': case 'L': case 'M': case 'N': case 'R': result += currentChar; break; case 'K': if (lastChar !== 'K') { result += 'K'; } break; case 'P': if (nextChar === 'H') { result += 'F'; i++; } else { result += 'P'; } break; case 'Q': result += 'K'; break; case 'S': if (nextChar === 'H') { result += 'X'; i++; } else { result += 'S'; } break; case 'T': if (nextChar === 'H') { result += '0'; i++; } else { result += 'T'; } break; case 'V': result += 'F'; break; case 'W': case 'Y': if (/[AEIOU]/.test(nextChar)) { result += currentChar; } break; case 'Z': result += 'S'; break; default: break; } lastChar = result[result.length - 1] || ''; } // Return the resulting Metaphone key return result; } function search(){ var word=$("#search_word").val(); word=word.toLowerCase(); $(".itemlist new").html(""); var word2=metaphone(word); if(word2==''){ var filteredItems = item_data.filter(item => (item.id+item.name).toLowerCase().includes(word)); }else{ var filteredItems = item_data.filter(item => item.metaphone.includes(word2)); } //var //console.log(filteredItems); if(filteredItems.length>0){ }else{ filteredItems = item_data.filter(item => (item.id+item.name).toLowerCase().includes(word)); } for(var i=0;iInvoice ID '+orders.id+' is '; if(orders.status==0){ html=html+' processing. Deliver on '+orders.delivery; }else if(orders.status==1){ html=html+' Packing... Deliver Soon.'; } else if(orders.status==2){ html=html+' packed. Going to Ship.'; } else if(orders.status==3){ html=html+' shipped. Deliver within an hour.'; } else if(orders.status==4){ html=html+' Delivered'; if(orders.pay==0){ html=html+'. But Payment is due'; }else if(orders.pay==1){ html=html+' & Paid.'; } } html=html+" View
" } $(".my_orders data").html(html); } }) } function handleTouchStart(event) { // Check if the number of touches is equal to 2 (double-tap) if (event.touches.length === 2) { event.preventDefault(); // Prevent default zoom behavior } } // Attach the handleTouchStart function to the touchstart event document.addEventListener('touchstart', handleTouchStart, { passive: false }); function showbyid(id){ var html=''; var data1=item_data[id]; if(data1.id==id){ html=html+product(data1); } $(".itemlist new").append(html); } document.addEventListener('captcha', (e) => { run(); run=function(){} }, false); // if ('serviceWorker' in navigator) { // window.addEventListener('load', () => { // navigator.serviceWorker.register('/sw.js').then((registration) => { // console.log('ServiceWorker registration successful with scope: ', registration.scope); // }, (err) => { // console.log('ServiceWorker registration failed: ', err); // }); // }); // } //navigatein(window.location.hash); function navigatein(data){ data=data.split("#"); data=data[1].split("FFKART"); if(data[0]=="viewcart"){ var cartdata=data[1]; associativeArray=JSON.parse(atob(cartdata)); localStorage.setItem("mycart","{}"); for (let key in associativeArray) { if (associativeArray.hasOwnProperty(key)) { addtocart(key,associativeArray[key]); } } viewcart(); } } function navigateout(id){ history.pushState(null, null, id); // window.location.href = id; } function notificationid(){ var bn=navigator.userAgent; bn=bn.split("Android-v-ffkart/"); bn=bn[1] return bn; } function savenot(){ $(document).ready(function(){ var bn=navigator.userAgent; if(bn.includes("Android-v-ffkart/")){ bn=notificationid(); if(localStorage.getItem("bn")!=bn){ $.post("/app/api.json",{ fun:"savenotification", session:session(), bn:bn },function(d,e){ localStorage.setItem("bn",bn) }) } } }) } function determineRegion(lat, lon) { // Center coordinates const centerLat = 13.019365; const centerLon = 77.546769; // Calculating the change in latitude and longitude for 40 km const distance = 40; // distance in km from the center to each side of the square const latChange = distance / 111; // 111 km per degree of latitude const lonChange = distance / (111 * Math.cos(deg2rad(centerLat))); // Adjust for longitude // Helper function to convert degrees to radians function deg2rad(deg) { return deg * (Math.PI / 180); } // Define the bounds of each region const topLeftLat = centerLat + latChange; const topLeftLon = centerLon - lonChange; const bottomRightLat = centerLat - latChange; const bottomRightLon = centerLon + lonChange; // Determine the region if (lat >= centerLat && lon <= centerLon) { return "1"; // Top Left } else if (lat >= centerLat && lon >= centerLon) { return "2"; // Top Right } else if (lat <= centerLat && lon <= centerLon) { return "3"; // Bottom Left } else if (lat <= centerLat && lon >= centerLon) { return "4"; // Bottom Right } else { return "0"; } } function getCurrentLocationAndDetermineRegion() { if ("geolocation" in navigator) { navigator.geolocation.getCurrentPosition(function(position) { const lat = position.coords.latitude; const lon = position.coords.longitude; const region = determineRegion(lat, lon); alert(`Your current location (${lat}, ${lon}) falls in Region: ${region}`); }, function(error) { console.error("Error Code = " + error.code + " - " + error.message); }); } else { } } // Call the function to get the current location and determine the region //getCurrentLocationAndDetermineRegion(); function sharebutton(){ var mobile=alert_("prompt","WhatsApp Number :","10 digit whatsapp number","Share","Cancel",function(r){ if(r){ if(r.length==10){ var content=`I order from eAPMC for my shop!\n *Benefits*: Lowest Prices, 2000+ Items Available, Always Active Customer Support, On-Time Delivery\n Share with friends and earn up to 1% of their orders. Don’t miss out!\n *Referral Link*: https://eapmc.com?ref=${r}`; a="https://api.whatsapp.com/send/?text="+encodeURIComponent(content); window.location.href =a; } else{ alert("Wrong Whatsapp Number."); } } console.log(r)}); } function userlogin(){ } function sellerlogin(){ var mobile=alert_("prompt","Seller Login :","10 digit whatsapp number","Get OTP","Cancel",function(r){ if(r){ if(r.length==10){ localStorage.setItem('sellerid',r); seller_getotp(); }else{ sellerlogin(); } }else{ sellerlogin(); } } ) } function seller_getotp(){ $.post('/app/api.json',{ sid:localStorage.getItem('sellerid'), spass:localStorage.getItem('sellerpass'), fun:'seller', session:session(), sfun:'sendotp' },function(d,e){ if(d.sellerotp=="1"){ var mobile=alert_("prompt","Enter OTP","Four Digit OTP","Login","Cancel",function(r){ if(r){ if(r.length==4){ localStorage.setItem('sellerpass',r); seller_checkotp(); }else{ seller_getotp(); } }else{ seller_getotp() } }) }else{ sellerlogin(); } }) } function seller_checkotp(){ $.post('/app/api.json',{ sid:localStorage.getItem('sellerid'), spass:localStorage.getItem('sellerpass'), fun:'seller', session:session(), sfun:'checkotp' },function(d,e){ if(d.sellerotpcheck=="1"){ sellerdashboard(d.shopid); }else{ sellerlogin(); } }) } function sellerdashboard(id){ showeditbtn=1; shopid=id; openshop2(id,"cat") } function supplier_edit(id){ $.notify('Updating...','info'); value=$("#newprice_"+id).val(); $.post('/app/api.json',{ sid:localStorage.getItem('sellerid'), spass:localStorage.getItem('sellerpass'), fun:'seller', iid:id, session:session(), ivalue:value, sfun:'editprice' },function(d,e){ $.notify('Updated','success') }) } function selleraction(){ $.post('/app/api.json',{ sid:localStorage.getItem('sellerid'), spass:localStorage.getItem('sellerpass'), fun:'seller', session:session(), sfun:'logincheck' },function(d,e){ if(d.seller_login=='0'){ } }) } userlogincheck(); var userkm=1; function userlogincheck(){ $.post('/app/api.json',{ session:session() },function(d,e){ if(d.user_login==true){ userkm=d.km; if(userkm==0 || userkm=="0"){ alert_("prompt","Distance from APMC to Your Location :","(in KM)","Set","Cancel",function(r){ a="Please update the distance between APMC to my Location."; a=encodeURIComponent(a); var cd=encodeURIComponent('https://eapmc.com'); userkm=r; //window.open("https://api.whatsapp.com/send/?phone=917026711223&text="+a+'&source_url='+cd) }) userkm=1; } $(".loginscreen").fadeOut(); }else{ $(".loginscreen").fadeIn(); } }) } function usergetotp(){ var usermobile=$("#usermobile").val(); if(usermobile.length==10){ $("sc1").hide(); $("sc2").fadeIn(); $.post('/app/api.json',{ session:session(), fun:'userotp', usermobile:usermobile },function(d,e){ if(d.userotp=="0"){ $(".notreg").show(); $('sc2').hide();$('sc1').fadeIn(); $.notify('Account not found','error'); }else if(d.userotp=="1"){ $(".notreg").hide(); $.notify('OTP sent on your WhatsApp','success'); } }) } } function usercheckotp(){ var usermobile=$("#usermobile").val(); var userotp=$("#user_otp").val(); if(usermobile.length==10 && userotp.length==4){ $.post('/app/api.json',{ session:session(), fun:'userotpcheck', userotp:userotp, usermobile:usermobile },function(d,e){ if(d.userotpcheck=="1"){ $.notify('Login Success','success'); localStorage.setItem("user_session",d.session); userlogincheck(); }else{ $.notify('Failed','error'); } }) }else{ } } function stringToUrlSlug(string) { // Convert the string to lowercase string = string.toLowerCase(); // Replace spaces and special characters with hyphens string = string.replace(/[^a-z0-9\s-]/g, ''); string = string.replace(/[\s-]+/g, '-'); // Trim any leading or trailing hyphens string = string.replace(/^-+|-+$/g, ''); return string; }