function addMod(userEmail,listEmail){ $.post('/api/list/add_mod',{list:listEmail,email:userEmail},reload,'json'); } function addPermission(userEmail,permission){ if (confirm("Really give permission to "+userEmail+"?")){ $.post('/api/user/addpermission',{email:userEmail,permissions:permission},reload,'json'); } } function disableList(listEmail){ $.post('/api/list/disable',{list:listEmail},showListResult,'json'); } function dropList(listEmail){ $.post('/api/list/drop',{list:listEmail},showListResult,'json'); } function dropMember(userEmail,listEmail){ $.post('/api/list/drop_member',{list:listEmail,email:userEmail},reload,'json'); } function dropMod(userEmail,listEmail){ $.post('/api/list/drop_mod',{list:listEmail,email:userEmail},reload,'json'); } function dropPermission(userEmail,permission){ if (confirm("Really withdraw permission from "+userEmail+"?")){ $.post('/api/user/droppermission',{email:userEmail,permissions:permission},reload,'json'); } } function enableList(listEmail){ $.post('/api/list/enable',{list:listEmail},showListResult,'json'); } function hideList(listEmail){ $.post('/api/list/hide',{list:listEmail},showListResult,'json'); } function loadArchive(listEmail,month){ $.get('/api/list/archive?month='+month+'&list='+listEmail,showListArchive,'json'); } function loadArchiveSummary(listEmail){ $.get('/api/list/archive?list='+listEmail,showListArchiveSummary,'json'); } function loadListDetail(listEmail){ $.post('/api/list/detail',{list:listEmail},showListDetail,'json'); } function loadListOfModeratedLists(){ $.getJSON('/api/list/moderated', showListOfModeratedLists); } function loadListOfSubscribableLists(){ $.getJSON('/api/list/subscribable', showListList); } function loadMembers(listEmail){ $.post('/api/list/members',{list:listEmail},showMembers,'json'); } function loadUserList(){ $.getJSON('/api/user/list', showUserList); } function reload(){ window.location.reload(true); } function showList(listEmail){ $.post('/api/list/show',{list:listEmail},showListResult,'json'); } function showListArchive(data){ console.log(data); let posts = data.archive.posts; for (let time in posts){ let post = posts[time]; let row = $(''); var url = 'post?id='+post.id; $('').html(''+post.date+'').appendTo(row); $('').html(''+post.from_name+'').appendTo(row); $('').html(''+post.subject+'').appendTo(row); row.appendTo($('#archive table')); } } function showListArchiveSummary(data){ console.log(data); let summary = data.archive.summary; for (let month in summary){ let url = 'archive?month='+month+'&list='+data.archive.list; let row = $(''); $('').html(''+month+'').appendTo(row); $('').html(''+summary[month]+'').appendTo(row); row.appendTo($('#archive table')); } } function showListDetail(data){ var options = ['forward_from','forward_attached','hide_receivers','reply_to_list','open_for_guests','open_for_subscribers','archive','edit_mods','delete_messages']; options.forEach(function(option,index,array){ console.log(option,'→',data[option]); if (data[option]) $('input[name="'+option+'"]').prop('checked',true); }); if (data['delete_messages']) $('input[name="hold_time"]').val(data['delete_messages']); } function showListOfModeratedLists(data){ for (let i in data.lists){ let list = data.lists[i]; let row = $(''); let addr = list.email.prefix+'@'+list.email.domain; let inspect = 'inspect?list='+addr; let td = $(''); $('',{href:inspect}).text(list.name).appendTo(td); td.appendTo(row); td = $(''); $('',{href:inspect}).text(addr).appendTo(td) td.appendTo(row); let states = []; for (let state in list.state){ if (list.state[state] > 0) states.push(state); } $('').text(states.toString()).appendTo(row); if (list.last_error){ $('').html(''+list.last_error+'').appendTo(row); } else $('').text('-').appendTo(row); let select = $('