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];
//console.log(cartdata);
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 OpenPlace order before 5pm');
} else {
$("#market").html(''+apmcname+' is ClosedPlace 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+'
`;
}
$("#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}
${upi}
`;
}
$("#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=918867361454&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=8867361454;
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://dfrozen.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=`
`;
}
}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 48hour";//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='
`;
}
}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='