Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit 50a9c86d authored by echicken's avatar echicken 🐔

Removed 000-mail.ssjs, added new 000-mail.xjs private mail page. Added...

Removed 000-mail.ssjs, added new 000-mail.xjs private mail page.  Added delete-mail API call and backend function for deletion of multiple messages.  Select-all and delete-selected-messages now available on the mail page.
parent 8a7c0d4e
//HIDDEN:Mail
if (typeof argv[0] !== 'boolean' || !argv[0]) exit();
if (user.number === 0 || user.alias === settings.guest) exit();
load('sbbsdefs.js');
load(system.exec_dir + '../web/lib/init.js');
load(settings.web_lib + 'forum.js');
writeln('<script type="text/javascript" src="./js/forum.js"></script>');
if (typeof http_request.query.notice !== 'undefined') {
writeln(
'<div id="noticebox" class="alert alert-warning">' +
http_request.query.notice[0] + '</div>' +
'<script type="text/javascript">' +
'$("#noticebox").fadeOut(3000,function(){$("#noticebox").remove();});' +
'</script>'
);
}
if (user.alias != settings.guest &&
!(user.security.restrictions&UFLAG_E) &&
!(user.security.restrictions&UFLAG_M)
) {
writeln(
'<button class="btn btn-default icon" ' +
'aria-label="Post a new message" title="Post a new message" ' +
'onclick="addNew(\'mail\')">' +
'<span class="glyphicon glyphicon-pencil"></span>' +
'</button>'
);
}
writeln(
format(
'<ul class="nav nav-tabs">' +
'<li role="presentation" class="%s">' +
'<a href="./?page=%s&amp;sent=0">Inbox</a>' +
'</li>' +
'<li role="presentation" class="%s">' +
'<a href="./?page=%s&amp;sent=1">Sent</a>' +
'</li>' +
'</ul><br>',
( typeof http_request.query.sent === 'undefined' ||
http_request.query.sent[0] == '0'
? 'active'
: ''
),
http_request.query.page[0],
( typeof http_request.query.sent !== 'undefined' &&
http_request.query.sent[0] == '1'
? 'active'
: ''
),
http_request.query.page[0]
)
);
writeln('<ul id="forum-list-container" class="list-group">');
function writeMessage(header) {
writeln(
format(
'<li id="li-%s" class="list-group-item mail striped %s">',
header.number,
(header.attr&MSG_READ ? 'read' : 'unread')
)
);
writeln(
format(
'<div style="cursor:pointer;" onclick="getMailBody(%s)">' +
'%s: <strong>%s</strong> on %s' +
'<p>Subject: <strong>%s</strong></p></div>' +
'<div class="message" id="message-%s" hidden></div>',
header.number,
( typeof http_request.query.sent === 'undefined' ||
http_request.query.sent[0] == '0'
? 'From'
: 'To'
),
( typeof http_request.query.sent === 'undefined' ||
http_request.query.sent[0] == '0'
? header.from
: header.to
),
(new Date(header.when_written_time * 1000)).toLocaleString(),
header.subject,
header.number
)
);
writeln('</li>');
}
getMailHeaders(
( typeof http_request.query.sent === 'undefined' ||
http_request.query.sent[0] == '0'
? false
: true
)
).forEach(writeMessage);
writeln('</ul>');
\ No newline at end of file
<!--HIDDEN:Mail-->
<?xjs
if (typeof argv[0] !== 'boolean' || !argv[0]) exit();
if (user.number == 0 || user.alias == settings.guest) exit();
load('sbbsdefs.js');
load(system.exec_dir + '../web/lib/init.js');
load(settings.web_lib + 'forum.js');
function sent() {
if (typeof http_request.query.sent === 'undefined') return false;
if (http_request.query.sent[0] == '0') return false;
return true;
}
?>
<?xjs function writeMessage(header) { ?>
<li id="li-<?xjs write(header.number); ?>" class="list-group-item mail striped <?xjs write(header.attr&MSG_READ ? 'read' : 'unread'); ?>">
<div class="row">
<div class="col-sm-1">
<div class="checkbox">
<label class="checkbox-inline">
<input id="check-<?xjs write(header.number); ?>" type="checkbox" class="mail-select">
</label>
</div>
</div>
<div class="col-sm-11" style="cursor:pointer;" onclick="getMailBody(<?xjs write(header.number); ?>)">
<?xjs write(!sent() ? 'From' : 'To'); ?>:
<strong><?xjs write(!sent() ? header.from : header.to); ?></strong>
on <?xjs write((new Date(header.when_written_time * 1000)).toLocaleString()); ?>
<p>Subject: <strong><?xjs write(header.subject); ?></strong></p>
</div>
</div>
<div class="message" id="message-<?xjs write(header.number); ?>" hidden></div>
</li>
<?xjs } ?>
<script type="text/javascript" src="./js/forum.js"></script>
<script type="text/javascript">
function selectAllMail() {
$('input.mail-select').each(
function () {
$(this).prop('checked', $(this).prop('checked') ? false : true);
}
);
}
function deleteSelectedMail() {
var numbers = [];
$('input.mail-select:checked').each(
function () { numbers.push($(this).attr('id').split('-')[1]); }
);
$.getJSON(
'./api/forum.ssjs?call=delete-mail&number=' + numbers.join('&number='),
function (data) {
if (!data.success) return;
numbers.forEach(function (e) { $('#li-' + e).remove(); });
}
);
}
</script>
<?xjs if (typeof http_request.query.notice != "undefined") { ?>
<div id="noticebox" class="alert alert-warning">
<?xjs write(http_request.query.notice[0]); ?>
</div>
<script type="text/javascript">
$("#noticebox").fadeOut(3000, function () { $("#noticebox").remove(); });
</script>
<?xjs } ?>
<?xjs if (!(user.security.restrictions&UFLAG_E) && !(user.security.restrictions&UFLAG_M)) { ?>
<button class="btn btn-default icon" aria-label="Post a new message" title="Post a new message" onclick="addNew('mail')">
<span class="glyphicon glyphicon-pencil"></span>
</button>
<button class="btn btn-default icon" aria-label="Select all messages" title="Select all messages" onclick="selectAllMail()">
<span class="glyphicon glyphicon-check"></span>
</button>
<button class="btn btn-default icon" aria-label="Delete selected messages" title="Delete selected messages" onclick="deleteSelectedMail()">
<span class="glyphicon glyphicon-trash"></span>
</button>
<?xjs } ?>
<ul class="nav nav-tabs">
<li role="presentation" class="<?xjs write(!sent() ? ' active' : ''); ?>">
<a href="./?page=<?xjs write(page); ?>&amp;sent=0">Inbox</a>
</li>
<li role="presentation" class="<?xjs write(sent() ? ' active' : ''); ?>">
<a href="./?page=<?xjs write(page); ?>&amp;sent=1">Sent</a>
</li>
</ul>
<br>
<ul id="forum-list-container" class="list-group">
<?xjs getMailHeaders(sent()).forEach(writeMessage); ?>
</ul>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment