Recipe Finder is a tool to help you serve the perfect drink every time in Coffee Talk.
Whether a customer walks up and asks for a Gala Had by name or just mumbles something about wanting “chocolate and mint,” this tool has your back. Search by drink name to get the exact Base, Primary and Secondary combo, or plug in the ingredients a customer mentions to find matching recipes.
'
:'
'+t.unnamed+'
')+
'
'+t.ingBase+'
'+tr(r.ingredients.base)+'
'+
'
'+t.ingPrimary+'
'+tr(r.ingredients.primary)+'
'+
'
'+t.ingSecondary+'
'+tr(r.ingredients.secondary)+'
';
grid.appendChild(card);
});
}
function updateMoreBtn(){
var rem=matches.length-shown;
var next=Math.min(rem,PAGE);
document.getElementById('ct-show-more').textContent=t.showMore(next,rem);
}
function showResults(list){
matches=list;shown=0;
document.getElementById('ct-grid').innerHTML='';
document.getElementById('ct-no-results').classList.add('ct-hidden');
document.getElementById('ct-show-more').classList.add('ct-hidden');
document.getElementById('ct-results').classList.remove('ct-hidden');
var countEl=document.getElementById('ct-count');
if(!list.length){
document.getElementById('ct-no-results').classList.remove('ct-hidden');
countEl.textContent='';return;
}
countEl.textContent=list.length===1?t.match1:list.length+' '+t.matchMany;
renderCards(list,0,PAGE);
shown=Math.min(PAGE,list.length);
if(list.length>PAGE){updateMoreBtn();document.getElementById('ct-show-more').classList.remove('ct-hidden');}
}
// ── Public API ────────────────────────────────────────────────
window.ctShowMore=function(){
renderCards(matches,shown,PAGE);
shown+=Math.min(PAGE,matches.length-shown);
if(shown>=matches.length){document.getElementById('ct-show-more').classList.add('ct-hidden');}
else{updateMoreBtn();}
};
window.ctReset=function(){
['ct-warm','ct-cool','ct-sweet','ct-bitter'].forEach(function(id){
document.getElementById(id).value='';
});
document.getElementById('ct-results').classList.add('ct-hidden');
};
window.ctFetchByChar=function(){
var w=document.getElementById('ct-warm').value;
var c=document.getElementById('ct-cool').value;
var s=document.getElementById('ct-sweet').value;
var b=document.getElementById('ct-bitter').value;
if(!w&&!c&&!s&&!b){showResults([]);return;}
showResults(recipes.filter(function(r){
// characteristics are now objects — compare against .en key
if(w&&(typeof r.characteristics.warm==='object'?r.characteristics.warm.en:r.characteristics.warm)!==w)return false;
if(c&&(typeof r.characteristics.cool==='object'?r.characteristics.cool.en:r.characteristics.cool)!==c)return false;
if(s&&(typeof r.characteristics.sweet==='object'?r.characteristics.sweet.en:r.characteristics.sweet)!==s)return false;
if(b&&(typeof r.characteristics.bitter==='object'?r.characteristics.bitter.en:r.characteristics.bitter)!==b)return false;
return true;
}));
};
window.ctFetchByName=function(){
var n=document.getElementById('ct-name').value;
if(!n){showResults([]);return;}
// name is now an object — compare against .en key
showResults(recipes.filter(function(r){
if(!r.name)return false;
return(typeof r.name==='object'?r.name.en:r.name)===n;
}));
};
})();