' +
'
' +
'' +
'' +
'
' +
'' + cat.label + '
' +
'' +
'' +
'' +
'Revenue model: ' + escapeHtml(idea.model) + '' +
'
' +
'' +
'' +
'' +
'
' +
'';
els.result.querySelector('.tbi-idea-title').textContent = title;
els.result.querySelector('.tbi-idea-desc').textContent = desc;
els.result.querySelector('.tbi-idea-tip span').textContent = tip;
return { title: title, cat: idea.cat };
}
function escapeHtml(str){
return String(str).replace(/&/g, '&').replace(//g, '>');
}
function renderHistory(){
if(state.history.length === 0){
els.historyCard.style.display = 'none';
return;
}
els.historyCard.style.display = 'block';
els.historyList.innerHTML = '';
state.history.slice().reverse().forEach(function(item){
var cat = CATEGORIES[item.cat] || CATEGORIES.service;
var row = document.createElement('div');
row.className = 'tbi-history-item';
row.innerHTML =
'' +
'';
row.querySelector('.tbi-history-name').textContent = item.title;
els.historyList.appendChild(row);
});
}
function generate(){
var interest = els.interest.value.trim() || 'your skills';
var idea = pickIdea();
var shown = renderResult(idea, interest);
state.history.push({ title: shown.title, cat: shown.cat });
if(state.history.length > 8){ state.history.shift(); }
save();
renderHistory();
els.regenerate.style.display = 'flex';
}
els.themeBtn.addEventListener('click', function(){
var current = els.app.getAttribute('data-theme');
setTheme(current === 'dark' ? 'light' : 'dark');
});
els.generate.addEventListener('click', generate);
els.regenerate.addEventListener('click', generate);
els.clearHistory.addEventListener('click', function(){
state.history = [];
save();
renderHistory();
});
els.interest.addEventListener('keydown', function(e){
if(e.key === 'Enter'){ generate(); }
});
load();
renderHistory();
if(state.history.length > 0){
els.regenerate.style.display = 'flex';
}
})();