My Subscriptions
User:
<%= userid %>
<%= userid %>
<%
const subKeys = (userSubs && Object.keys(userSubs)) || [];
const subCount = subKeys.length;
const groups = {};
subKeys.forEach(function(channelID){
const c = userSubs[channelID] || {};
const nm = (c.channelName || '').trim();
const first = (nm[0] || '#').toUpperCase();
const key = /^[A-Z]$/.test(first) ? first : '#';
if(!groups[key]) groups[key] = [];
groups[key].push({ id: channelID, c: c });
});
const letters = Object.keys(groups).sort();
letters.forEach(function(L){
groups[L].sort(function(a,b){
const an = (a.c.channelName||'').toLowerCase();
const bn = (b.c.channelName||'').toLowerCase();
return an.localeCompare(bn,'en',{sensitivity:'base'});
});
});
%>
<%= subCount %> <%= subCount === 1 ? 'subscription' : 'subscriptions' %>
<% letters.forEach(function(L){ %>
<%= L %>
<% groups[L].forEach(function(entry){ const c = entry.c; const channelID = entry.id; %>
<%= c.channelName %>
<% }) %>
<% }) %>