function open(){
window.location.href="https://manjilas.com/memories/";
}
//GetProductCategories();
//GetRecipes();
//GetMemories();
var productCategories = [];
var recipeCategories = [];
var memoriesList = [];
var productCategorySelectionIndex = 0;
var productCategoriesLength = 0;
var recipeCategorySelectionIndex = 0;
var recipeCategoriesLength = 0;
var productCarousalItemCount = 4;
var productCarousalSpeed = 2000;
if ($(window).width() 0 && productCategorySelectionIndex >= 0){
var selected_cat_name = productCategories[productCategorySelectionIndex].split('|')[0];
var selected_cat_slug = productCategories[productCategorySelectionIndex].split('|')[1];
var selected_category = '
'+selected_cat_name+'';
//lbl_product_cat_selected.innerHTML = selected_category;
if(productCategorySelectionIndex > 0){
productCategorySelectionIndex = productCategorySelectionIndex - 1;
}
}
}
function SelectCategoryRight(){
if(productCategoriesLength > 0 && productCategorySelectionIndex <= productCategoriesLength){
var selected_cat_name = productCategories[productCategorySelectionIndex].split('|')[0];
var selected_cat_slug = productCategories[productCategorySelectionIndex].split('|')[1];
var selected_category = '
'+selected_cat_name+'';
//lbl_product_cat_selected.innerHTML = selected_category;
if(productCategorySelectionIndex 0 && recipeCategorySelectionIndex >= 0){
var selected_cat_name = productCategories[recipeCategorySelectionIndex].split('|')[0];
var selected_cat_slug = productCategories[recipeCategorySelectionIndex].split('|')[1];
var selected_category = '
'+selected_cat_name+'';
lbl_recipes_cat_selected.innerHTML = selected_category;
if(recipeCategorySelectionIndex > 0){
recipeCategorySelectionIndex = recipeCategorySelectionIndex - 1;
}
}
}
function SelectRecipeCategoryRight(){
if(recipeCategoriesLength > 0 && recipeCategorySelectionIndex <= recipeCategoriesLength){
var selected_cat_name = productCategories[recipeCategorySelectionIndex].split('|')[0];
var selected_cat_slug = productCategories[recipeCategorySelectionIndex].split('|')[1];
var selected_category = '
'+selected_cat_name+'';
lbl_recipes_cat_selected.innerHTML = selected_category;
if(recipeCategorySelectionIndex < recipeCategoriesLength){
recipeCategorySelectionIndex = recipeCategorySelectionIndex + 1;
}
}
}
function SelectProductsByCategory(slug){
//alert(slug);
var urlToSearch = "https://manjilas.com/wp-json/wl/v1/products_by_cat/"+slug;
$.get(urlToSearch, function(data, status){
var resultSet = '';
$.each(data, function (index, element) {
var description = element.title;
if(description == null){
description ="";
}
var product_level_img = element.featured_image.thumbnail;
if(product_level_img == ""){
product_level_img = "https://manjilas.com/sites/default/files/styles/product_listing_image/public/MCB01-1.png?itok=QZjc0VF2";
}
resultSet += '
';
resultSet += '
';
resultSet +='
';
resultSet +='
';
resultSet += '
';
resultSet +='
';
resultSet +=''+element.title+'';
resultSet +='';
//resultSet +='
By Double Horse';
resultSet +='
';
resultSet +='
';
});
//console.log(resultSet);
var dvProductCategories = document.getElementById("dvProductCategories");
dvProductCategories.innerHTML=resultSet;
var $owl = $('.owl-carousel');
$owl.trigger('destroy.owl.carousel');
// After destory, the markup is still not the same with the initial.
// The differences are:
// 1. The initial content was wrapped by a 'div.owl-stage-outer';
// 2. The '.owl-carousel' itself has an '.owl-loaded' class attached;
// We have to remove that before the new initialization.
$owl.html($owl.find('.owl-stage-outer').html()).removeClass('owl-loaded');
$(".owl-carousel").owlCarousel({
animateOut: 'slideOutDown',
animateIn: 'flipInX',
items:productCarousalItemCount,
stagePadding:0,
smartSpeed:450,
nav: false,
dots:false,
dotsData: false,
loop:true,
margin:10,
autoplay:true,
autoplayTimeout:productCarousalSpeed,
autoplayHoverPause:true
});
});
}
function SelectProductsByBestselling(){
//alert(slug);
var urlToSearch = "https://manjilas.com/wp-json/wl/v1/products_best_selling/";
$.get(urlToSearch, function(data, status){
var resultSet = '';
$.each(data, function (index, element) {
var description = element.title;
if(description == null){
description ="";
}
var product_level_img = element.featured_image.thumbnail;
if(product_level_img == ""){
product_level_img = "https://manjilas.com/sites/default/files/styles/product_listing_image/public/MCB01-1.png?itok=QZjc0VF2";
}
resultSet += '
';
resultSet += '
';
resultSet +='
';
resultSet +='
';
resultSet += '
';
resultSet +='
';
resultSet +=''+element.title+'';
resultSet +='';
//resultSet +='
By Double Horse';
resultSet +='
';
resultSet +='
';
});
//console.log(resultSet);
var dvProductCategories = document.getElementById("dvProductCategories");
dvProductCategories.innerHTML=resultSet;
var $owl = $('.owl-carousel');
$owl.trigger('destroy.owl.carousel');
// After destory, the markup is still not the same with the initial.
// The differences are:
// 1. The initial content was wrapped by a 'div.owl-stage-outer';
// 2. The '.owl-carousel' itself has an '.owl-loaded' class attached;
// We have to remove that before the new initialization.
$owl.html($owl.find('.owl-stage-outer').html()).removeClass('owl-loaded');
$(".owl-carousel").owlCarousel({
animateOut: 'slideOutDown',
animateIn: 'flipInX',
items:productCarousalItemCount,
stagePadding:0,
smartSpeed:450,
nav: false,
dots:false,
dotsData: false,
loop:true,
margin:10,
autoplay:true,
autoplayTimeout:productCarousalSpeed,
autoplayHoverPause:true
});
});
}
function SelectProductsByNewArrival(){
//alert(slug);
var urlToSearch = "https://manjilas.com/wp-json/wl/v1/products_new_arrival/";
$.get(urlToSearch, function(data, status){
var resultSet = '';
$.each(data, function (index, element) {
var description = element.title;
if(description == null){
description ="";
}
var product_level_img = element.featured_image.thumbnail;
if(product_level_img == ""){
product_level_img = "https://manjilas.com/sites/default/files/styles/product_listing_image/public/MCB01-1.png?itok=QZjc0VF2";
}
resultSet += '
';
resultSet += '
';
resultSet +='
';
resultSet +='
';
resultSet += '
';
resultSet +='
';
resultSet +=''+element.title+'';
resultSet +='';
//resultSet +='
By Double Horse';
resultSet +='
';
resultSet +='
';
});
//console.log(resultSet);
var dvProductCategories = document.getElementById("dvProductCategories");
dvProductCategories.innerHTML=resultSet;
var $owl = $('.owl-carousel');
$owl.trigger('destroy.owl.carousel');
// After destory, the markup is still not the same with the initial.
// The differences are:
// 1. The initial content was wrapped by a 'div.owl-stage-outer';
// 2. The '.owl-carousel' itself has an '.owl-loaded' class attached;
// We have to remove that before the new initialization.
$owl.html($owl.find('.owl-stage-outer').html()).removeClass('owl-loaded');
$(".owl-carousel").owlCarousel({
animateOut: 'slideOutDown',
animateIn: 'flipInX',
items:productCarousalItemCount,
stagePadding:0,
smartSpeed:450,
nav: false,
dots:false,
dotsData: false,
loop:true,
margin:10,
autoplay:true,
autoplayTimeout:productCarousalSpeed,
autoplayHoverPause:true
});
});
}
function GetProductCategories(){
var urlToSearch = "https://manjilas.com/wp-json/wl/v1/product_categories";
$.get(urlToSearch, function(data, status){
var resultSet = '';
$.each(data, function (index, element) {
var description = element.name;
if(description == null){
description ="";
}
//var product_level_img = element.featured_image.thumbnail;
var product_level_img = element.featured_image;
if(product_level_img == ""){
product_level_img = "https://manjilas.com/sites/default/files/styles/product_listing_image/public/MCB01-1.png?itok=QZjc0VF2";
}
resultSet += '
';
resultSet += '
';
resultSet +='
';
resultSet +='
';
resultSet += '
';
//resultSet +='
'+element.name+'';
resultSet +='
';
resultSet +=''+element.name+'';
resultSet +='';
//resultSet +='
By Double Horse';
resultSet +='
';
resultSet +='
';
productCategories.push(element.name+'|'+element.slug);
});
productCategoriesLength = productCategories.length;
recipeCategoriesLength = productCategories.length;
//var lbl_product_cat_selected = document.getElementById("lbl_product_cat_selected");
var lbl_recipes_cat_selected = document.getElementById("lbl_recipes_cat_selected");
if(productCategoriesLength > 0){
//Set default category
var selected_cat_name = productCategories[0].split('|')[0];
var selected_cat_slug = productCategories[0].split('|')[1];
var selected_category = '
'+selected_cat_name+'';
var selected_recipe_category = '
'+selected_cat_name+'';
//lbl_product_cat_selected.innerHTML = selected_category;
lbl_recipes_cat_selected.innerHTML = selected_recipe_category;
}
//console.log(resultSet);
var dvProductCategories = document.getElementById("dvProductCategories");
dvProductCategories.innerHTML=resultSet;
var $owl = $('.owl-carousel');
$owl.trigger('destroy.owl.carousel');
// After destory, the markup is still not the same with the initial.
// The differences are:
// 1. The initial content was wrapped by a 'div.owl-stage-outer';
// 2. The '.owl-carousel' itself has an '.owl-loaded' class attached;
// We have to remove that before the new initialization.
$owl.html($owl.find('.owl-stage-outer').html()).removeClass('owl-loaded');
$(".owl-carousel").owlCarousel({
animateOut: 'slideOutDown',
animateIn: 'flipInX',
items:productCarousalItemCount,
stagePadding:0,
smartSpeed:450,
nav: false,
dots:false,
dotsData: false,
loop:true,
margin:10,
autoplay:true,
autoplayTimeout:productCarousalSpeed,
autoplayHoverPause:true
});
});
}
function ViewAllProducts(){
window.location.href = "https://manjilas.com/shop/";
}
function FindRecipes(){
var ing1 = document.getElementById("tb_ing1").value;
var ing2 = document.getElementById("tb_ing2").value;
var ing3 = document.getElementById("tb_ing3").value;
var dtype = document.getElementById("ddl_dtype").value;
var ctime = document.getElementById("ddl_ctime").value;
var ing_exclude = document.getElementById("tb_exclude").value;
if(dtype == 0 || dtype == "0"){
dtype = '';
}
if(ctime == 0 || ctime == "0"){
ctime = '';
}
window.location.href = "https://manjilas.com/search-result/?ing1="+ing1+"&ing2="+ing2+"&ing3="+ing3+"&dtype="+dtype+"&ctime="+ctime+"&exclude="+ing_exclude;
}
function CustomerStories(){
window.location.href = "https://manjilas.com/user-stories/";
}
function GetRecipes(){
//alert(slug);
var urlToSearch = "https://manjilas.com/wp-json/wl/v1/recipes";
$.get(urlToSearch, function(data, status){
var resultSet = '';
$.each(data, function (index, element) {
var title = element.title;
if(title == null){
title ="";
}
var content = element.content;
if(content == null){
content ="";
}else if(content.length > 150){
content = content.substring(0,150)+" ...";
}
var product_level_img = element.featured_image.medium;
if(product_level_img == ""){
product_level_img = "https://manjilas.com/sites/default/files/styles/product_listing_image/public/MCB01-1.png?itok=QZjc0VF2";
}
resultSet += '
';
resultSet += '
';
resultSet += '
';
//resultSet +='
';
resultSet +='
';
//resultSet += '
';
//resultSet +='';
//resultSet +='By Adam 0 Reviews';
//resultSet +='
';
//resultSet +='
';
resultSet += '
';
resultSet +='
';
resultSet +='';
resultSet +='';
resultSet +='';
resultSet +='';
resultSet +='';
resultSet +='
';
resultSet +='
'+content+'
';
resultSet +='
';
resultSet +='
';
});
//console.log(resultSet);
var dvReceipesCategories = document.getElementById("dvReceipesCategories");
dvReceipesCategories.innerHTML=resultSet;
});
}
function SelectRecipesByCategory(slug){
//alert(slug);
var urlToSearch = "https://manjilas.com/wp-json/wl/v1/recipes";
$.get(urlToSearch, function(data, status){
var resultSet = '';
$.each(data, function (index, element) {
var title = element.title;
if(title == null){
title ="";
}
var content = element.content;
if(content == null){
content ="";
}else if(content.length > 150){
content = content.substring(0,150)+" ...";
}
var product_level_img = element.featured_image.medium;
if(product_level_img == ""){
product_level_img = "https://manjilas.com/sites/default/files/styles/product_listing_image/public/MCB01-1.png?itok=QZjc0VF2";
}
resultSet += '
';
resultSet += '
';
resultSet += '
';
//resultSet +='
';
resultSet +='
';
resultSet += '
';
resultSet +='';
resultSet +='By Adam 0 Reviews';
resultSet +='
';
resultSet +='
';
resultSet += '
';
resultSet +='
'+content+'
';
resultSet +='
';
resultSet +='';
resultSet +='';
resultSet +='';
resultSet +='';
resultSet +='';
resultSet +='
';
resultSet +='
';
resultSet +='
';
});
//console.log(resultSet);
var dvReceipesCategories = document.getElementById("dvReceipesCategories");
dvReceipesCategories.innerHTML=resultSet;
});
}
function GetMemories(){
//alert(slug);
var urlToSearch = "https://manjilas.com/wp-json/wl/v1/memories";
$.get(urlToSearch, function(data, status){
var resultSet = '';
var rowCounter = 0;
$.each(data, function (index, element) {
memoriesList.push(element);
var title = element.title;
if(title == null){
title ="";
}
var content = element.content;
if(content == null){
content ="";
}else if(content.length > 250){
content = content.substring(0,250)+" ...";
}
var product_level_img = element.featured_image.medium;
if(product_level_img == ""){
product_level_img = "https://manjilas.com/sites/default/files/styles/product_listing_image/public/MCB01-1.png?itok=QZjc0VF2";
}
if(rowCounter == 0){
$("#dvMemory-main").css("background-image","url('"+product_level_img+"')");
$("#hdnMemory-main").val(element.content);
var title = element.title;
var content = element.content;
$("#dvMemoryTitle").text('');
$("#dvMemoryDescription").html('Good food is a good memory.
Good food is a great inspiration.
Good food is a moment of happiness, togetherness and friendships');
}else if(rowCounter == 1){
$("#dvMemory-1").css("background-image","url('"+product_level_img+"')");
$("#hdnMemory-1").val(element.content);
}else if(rowCounter == 2){
$("#dvMemory-2").css("background-image","url('"+product_level_img+"')");
$("#hdnMemory-2").val(element.content);
}else if(rowCounter == 3){
$("#dvMemory-3").css("background-image","url('"+product_level_img+"')");
$("#hdnMemory-3").val(element.content);
}else{
$("#dvMemory-4").css("background-image","url('"+product_level_img+"')");
$("#hdnMemory-4").val(element.content);
}
rowCounter++;
});
});
}
function SelectMemory(selectionId){
var title = 'Hello';
var content = '';
var slug = '';
if(selectionId == 0){
content = $("#hdnMemory-main").val();
title = memoriesList[0].title;
content = memoriesList[0].content;
slug = memoriesList[0].slug;
}else if(selectionId == 1){
content = $("#hdnMemory-1").val();
title = memoriesList[1].title;
content = memoriesList[1].content;
slug = memoriesList[1].slug;
}if(selectionId == 2){
content = $("#hdnMemory-2").val();
title = memoriesList[2].title;
content = memoriesList[2].content;
slug = memoriesList[2].slug;
}if(selectionId == 3){
content = $("#hdnMemory-3").val();
title = memoriesList[3].title;
content = memoriesList[3].content;
slug = memoriesList[3].slug;
}if(selectionId == 4){
content = $("#hdnMemory-4").val();
title = memoriesList[4].title;
content = memoriesList[4].content;
slug = memoriesList[4].slug;
}
$("#dvMemoryTitle").text('');
$("#dvMemoryDescription").html('Good food is a good memory.
Good food is a great inspiration.
Good food is a moment of happiness, togetherness and friendships');
window.location.href = "https://manjilas.com/recipes/"+slug;
}
function GetCategories(id) {
var parent_name ="";
var product_view_count = 0;
var inputRequest = {
'organization_id': organization_id,
'product_level_id': id
};
var jsonRequest = JSON.stringify(inputRequest);
$.ajax({
type: "POST",
data: jsonRequest,
url: service_url+"product/GetProductLevelWithNextSubLevel",
success:function(data){
RenderCategoriesToUI(data, id);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert("Status: " + textStatus);
console.log("Error: " + errorThrown);
}
});
}
function RenderCategoriesToUI(data, parentLevelID = 0){
var json_obj = $.parseJSON(data);
var selectedCategories = [];
for (var i in json_obj){
if(json_obj[i].parent == parentLevelID){
selectedCategories.push(json_obj[i]);
}
}
if(selectedCategories.length > 0)
{
//product_level_id, organization_id, level_name, parent, image_url FROM product_level;
var product_level_view = "";
var baseAdminUrl = service_url+"adminPanel/";
for (var i in selectedCategories)
{
var description = selectedCategories[i].description;
if(description == null){
description ="";
}
var product_level_img = selectedCategories[i].image_url;
var product_level_id = selectedCategories[i].product_level_id.toString();
var select_img = product_level_id.substring(product_level_id.length - 1);
if(product_level_img == "" || product_level_img == baseAdminUrl){
product_level_img = baseAdminUrl+"Images/App/catalogue-group-placeholder.jpg";
}
product_level_view += '
';
product_level_view += '';
product_level_view +='';
} //End of FOR LOOP
$('#dvCategories').html(product_level_view);
$(".owl-carousel").owlCarousel({
nav: false,
dots:false,
dotsData: false,
items:4,
loop:true,
margin:10,
autoplay:true,
autoplayTimeout:1000,
autoplayHoverPause:true
});
}
}