Search
⌘K
DirectoryEntrepreneur
Back
Entrepreneur Main Site
HelpDesk
Coaching
Launchpad
University
Customize
Community
Professionals
Suite Main Page
email-marketing
Back
Log in
Theme
Auto
Light
Dark
d
DirectoryEntrepreneur
Entrepreneur Main Site
HelpDesk
Coaching
Launchpad
University
Customize
Community
Professionals
Suite Main Page
e
email-marketing
"']/g, function(c){ return ({"&":"&","<":"<",">":">","\"":""","'":"'"}[c]); }); } function byId(id){ return document.getElementById(id); } function pushAnalytics(name, detail){ try{ window.dispatchEvent(new CustomEvent(name,{detail:detail})); }catch(e){} if (window.dataLayer && Array.isArray(window.dataLayer)) window.dataLayer.push({event:name, detail:detail}); } var CATS={}; function rebuildCats(){ CATS={}; FILTER_DATA.forEach(function(line){ var p=line.split('|'); (CATS[p[0]]||(CATS[p[0]]=[])).push({label:p[1], code:p[2]}); }); } rebuildCats(); var filters={}; function encodeState(){ var parts=[]; Object.keys(filters).forEach(function(k){ var v=filters[k]; if(v==='must') parts.push('m:'+encodeURIComponent(k)); else if(v==='nice') parts.push('n:'+encodeURIComponent(k)); }); return parts.join(','); } function decodeState(s){ var out={}; if(!s) return out; s.split(',').forEach(function(t){ var m=t.split(':'); if(m.length===2){ out[decodeURIComponent(m[1])] = m[0]==='m'?'must': m[0]==='n'?'nice': 'off'; }}); return out; } function updateShareHref(){ var f=encodeState(); var base=location.href.split('#')[0].split('?')[0]; var url=base+(f?('?f='+encodeURIComponent(f)):'' ); navigator.clipboard&&navigator.clipboard.writeText(url).then(function(){ byId('btnShare').textContent='Copied!'; setTimeout(function(){ byId('btnShare').textContent='Copy Share Link'; },1000); }); } function readInitialState(){ var params=new URLSearchParams(location.search); var f=params.get('f'); if(f){ filters=decodeState(decodeURIComponent(f)); } } function triRowHTML(label,key,isCat){ var value=filters[key]||'off'; var groupId='rg-'+key.replace(/[^a-z0-9]/gi,'-'); return '\n
\n
'+esc(label)+' '+(isCat?'
(Category)
':'')+(isCat?'':'
('+esc(key)+')
')+'
\n
\n
Off
\n
Nice
\n
Must
\n
\n
'; } function renderFilters(){ var host=byId('filterHost'); host.innerHTML=''; Object.keys(CATS).forEach(function(cat){ var catDiv=h('
\n
'+esc(cat)+'
+
\n
\n
'); var body=catDiv.querySelector('.cat-body'); body.appendChild(h(triRowHTML('Any '+cat,cat,true))); (CATS[cat]||[]).forEach(function(it){ body.appendChild(h(triRowHTML(it.label,it.code,false))); }); catDiv.querySelector('.cat-head').addEventListener('click', function(){ var t=catDiv.querySelector('.cat-tgl'); body.classList.toggle('active'); t.textContent=body.classList.contains('active')?'−':'+'; }); host.appendChild(catDiv); }); } function setFilter(key,val){ if (CATS[key] && val==='nice'){ var anyChildMust=(CATS[key]||[]).some(function(it){ return filters[it.code]==='must'; }); if(anyChildMust){ alert('Cannot set category to "Nice" while a sub-item is "Must".'); return; } } if (!CATS[key] && val==='must'){ for (var cat in CATS){ if ((CATS[cat]||[]).some(function(it){ return it.code===key; }) && filters[cat]==='nice'){ filters[cat]='must'; } } } if (val==='off') delete filters[key]; else filters[key]=val; updateRadios(); renderSummary(); process(); var params=new URLSearchParams(location.search); var f=encodeState(); if(f) params.set('f',f); else params.delete('f'); history.replaceState(null,'',location.pathname+(params.toString()?('?'+params.toString()):'')); pushAnalytics('dk.filters.changed',{filters:filters}); } function updateRadios(){ document.querySelectorAll('.radio').forEach(function(r){ var k=r.getAttribute('data-k'); var v=r.getAttribute('data-v'); var sel=filters[k]||'off'; r.setAttribute('aria-checked', String(sel===v)); r.setAttribute('tabindex', sel===v?'0':'-1'); }); } function radioHandlers(){ document.addEventListener('click', function(e){ var r=e.target.closest('.radio'); if(!r) return; setFilter(r.getAttribute('data-k'), r.getAttribute('data-v')); }); document.addEventListener('keydown', function(e){ var r=e.target.closest('.radio'); if(!r) return; var group=r.parentElement; var radios=[].slice.call(group.querySelectorAll('.radio')); var idx=radios.indexOf(r); if (e.key==='ArrowRight' || e.key==='ArrowDown'){ e.preventDefault(); var ni=Math.min(radios.length-1, idx+1); radios[ni].click(); radios[ni].focus(); } if (e.key==='ArrowLeft' || e.key==='ArrowUp'){ e.preventDefault(); var pi=Math.max(0, idx-1); radios[pi].click(); radios[pi].focus(); } if (e.key===' ' || e.key==='Enter'){ e.preventDefault(); r.click(); } }); } var products=[]; function parseProducts(){ products = PRODUCTS.map(function(line){ var p=line.split('|'); return { name:p[0], description:p[1], image:p[2], infoLink:p[3], purchaseLink:p[4], badges:(p[5]||'').split(',').filter(Boolean), codes:(p[6]||'').split(',').filter(Boolean), affiliateLink:p[7]||'', score:0, meetsRequired:true }; }); } parseProducts(); var CATEGORY_CODE_MAP={}; function rebuildCatCodeMap(){ CATEGORY_CODE_MAP={}; for (var c in CATS){ CATEGORY_CODE_MAP[c]=CATS[c].map(function(x){return x.code}); } } rebuildCatCodeMap(); function matchesKey(prod,key){ if (CATEGORY_CODE_MAP[key]){ var list=CATEGORY_CODE_MAP[key]; return prod.codes.some(function(code){ return list.indexOf(code)>-1; }); } return prod.codes.indexOf(key)>-1; } function process(){ products.forEach(function(p){ p.score=0; p.meetsRequired=true; }); var req=[], nice=[]; for (var k in filters){ if(filters[k]==='must') req.push(k); else if(filters[k]==='nice') nice.push(k); } req.forEach(function(k){ products.forEach(function(p){ if(!matchesKey(p,k)) p.meetsRequired=false; }); }); nice.forEach(function(k){ products.forEach(function(p){ if(matchesKey(p,k)) p.score++; }); }); if (CONFIG.affiliate.softBoost>0){ products.forEach(function(p){ if(p.affiliateLink) p.score += CONFIG.affiliate.softBoost; }); } products.sort(function(a,b){ if (a.meetsRequired && !b.meetsRequired) return -1; if (!a.meetsRequired && b.meetsRequired) return 1; if (b.score!==a.score) return b.score - a.score; if (CONFIG.affiliate.tieBreakFirst){ if (!!a.affiliateLink !== !!b.affiliateLink) return a.affiliateLink? -1 : 1; } return Math.random()<.5 ? -1 : 1; }); renderProducts(); } function renderLegend(){ var used=new Set(); products.forEach(function(p){ (p.badges||[]).forEach(function(b){ used.add(b); }); }); var host=byId('legend'); host.innerHTML=''; ['Affiliate','Featured','Coupon','Popular','E-commerce','All-in-one','Monetization','Agency Focus','Course Creation','Coaching'].forEach(function(tag){ if(used.has(tag) || tag==='Affiliate'){ var s=h('
'+esc(tag)+'
'); host.appendChild(s); }}); } function renderSummary(){ var host=byId('summary'); host.innerHTML=''; Object.keys(filters).forEach(function(k){ var v=filters[k]; var label = CATS[k]? ('Any '+k) : (function(){ for (var c in CATS){ var f=CATS[c].find(function(it){return it.code===k}); if(f) return f.label+' ('+k+')'; } return k; })(); var chip=h('
'+esc(label)+'
'); host.appendChild(chip); }); if(!Object.keys(filters).length){ host.appendChild(h('
No filters selected
')); } } function renderProducts(){ var grid=byId('grid'); var ct=byId('count'); grid.innerHTML=''; var qualified=products.filter(function(p){return p.meetsRequired}); var byScore={}; qualified.forEach(function(p){ (byScore[p.score]||(byScore[p.score]=[])).push(p); }); var scores=Object.keys(byScore).map(Number).sort(function(a,b){return b-a}); var tier={}; scores.forEach(function(sc,idx){ var arr=byScore[sc]; if(idx===0) arr.forEach(function(p){tier[p.name]='tier-best'}); else if(idx===1) arr.forEach(function(p){tier[p.name]='tier-better'}); else if(idx===2) arr.forEach(function(p){tier[p.name]='tier-good'}); }); var prevTop3=(renderProducts._top3||[]).map(function(x){return x}); var newTop3=products.filter(function(p){return p.meetsRequired}).slice(0,3).map(function(p){return p.name}); renderProducts._top3=newTop3; if(JSON.stringify(prevTop3)!==JSON.stringify(newTop3)){ pushAnalytics('dk.top3.changed',{top3:newTop3}); } products.forEach(function(p){ var t=tier[p.name]||''; var badgeHTML=t?('
'+(t==='tier-best'?'Best Fit': t==='tier-better'?'Better Fit':'Good Fit')+'
'):''; var link=p.affiliateLink||p.purchaseLink||'#'; var bset=(p.badges||[]).slice(); if(p.affiliateLink) bset.unshift('Affiliate'); var card=h('
'+badgeHTML+'
'+esc(p.name)+'
'+esc(p.description)+'
'+ bset.map(function(b){return '
'+esc(b)+'
'}).join('') + (p.meetsRequired? ('
Score: '+(Math.round(p.score*100)/100)+'
'):'') + '
Learn more
Get started
'); card.querySelectorAll('.actions a').forEach(function(a){ a.addEventListener('click', function(){ pushAnalytics('dk.product.click',{name:p.name, action:(a.textContent||'').trim()}); }); }); grid.appendChild(card); }); ct.textContent=products.length; renderLegend(); } function init(){ readInitialState(); renderFilters(); radioHandlers(); updateRadios(); renderSummary(); process(); byId('btnReset').onclick=function(){ filters={}; updateRadios(); renderSummary(); process(); history.replaceState(null,'',location.pathname); }; byId('btnToggle').onclick=function(){ var bodies=document.querySelectorAll('.cat-body'); var anyClosed=[].some.call(bodies,function(b){return !b.classList.contains('active')}); [].forEach.call(bodies,function(b){ b.classList.toggle('active',anyClosed); b.previousElementSibling.querySelector('.cat-tgl').textContent=b.classList.contains('active')?'−':'+'; }); this.textContent= anyClosed? 'Collapse all' : 'Expand all'; }; byId('btnShare').onclick=updateShareHref; } init(); })();