switched to manual reload to allow new features

This commit is contained in:
Synox 2018-06-14 19:15:03 +02:00
parent 1257f83e57
commit aa28cec701
2 changed files with 38 additions and 1 deletions

View File

@ -15,6 +15,11 @@ $purifier_config->set('HTML.Nofollow', true);
$purifier_config->set('HTML.ForbiddenElements', array("img"));
$purifier = new HTMLPurifier($purifier_config);
$mailIds = array_map(function ($mail) {
return $mail->id;
}, $emails);
$mailIdsJoinedString = filter_var(join('|', $mailIds), FILTER_SANITIZE_SPECIAL_CHARS);
?>
<html lang="en">
<head>
@ -41,11 +46,30 @@ $purifier = new HTMLPurifier($purifier_config);
document.execCommand('copy', false);
inp.remove();
}
setInterval(function () {
var r = new XMLHttpRequest();
r.open("GET", "./json-api.php?action=has_new_messages&address=$<?php echo $user->address?>&email_ids=<?php echo $mailIdsJoinedString?>", true);
r.onreadystatechange = function () {
if (r.readyState != 4 || r.status != 200) return;
if (r.responseText > 0) {
console.log("There are", r.responseText, "new mails.");
document.getElementById("new-content-avalable").style.display = 'block';
}
};
r.send();
}, 15000);
</script>
</head>
<body data-turbolinks="false">
<body>
<div id="new-content-avalable" class="alert alert-info alert-fixed" role="alert">
<strong>New mails</strong> have arrived - <a href="javascript:location.reload();" class="alert-link">reload!</a>
</div>
<header>
<div class="container">

View File

@ -30,6 +30,19 @@ div.min-height {
min-height: 400px;
}
.alert-fixed {
position: fixed;
top: 0px;
left: 0px;
width: 100%;
z-index: 9999;
border-radius: 0px;
text-align: center;
}
#new-content-avalable {
display: none;
}
header {
background-color: #D9E2E9;
padding-top: 5px;