Skip to content
This repository has been archived by the owner on May 23, 2019. It is now read-only.

Commit

Permalink
Update #169 display web user's drift time.
Browse files Browse the repository at this point in the history
  • Loading branch information
hdsdi3g committed Dec 27, 2015
1 parent 660b4dc commit 70bc2d0
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
26 changes: 26 additions & 0 deletions app/views/User/index.html
Expand Up @@ -29,6 +29,8 @@
</div>
#{/if}

<div id="display_drift_date"></div>

<div class="container">
<p class="lead">&{'userprofile.usereditor.pagename'}</p>

Expand All @@ -42,13 +44,37 @@
</div>
#{/form}
</div>

</div>

<script type="text/javascript" charset="UTF-8">
<!--
$(document).ready(function() {
try {
$("#btnSession").addClass("active");

var server_time = ${System.currentTimeMillis()};
var client_time = Date.now();
var drift = (client_time - server_time) / 1000;
if (window.performance) {
if (window.performance.timing) {
if (window.performance.timing.responseStart) {
drift = (window.performance.timing.responseStart - server_time) / 1000;
}
}
}

if (Math.abs(drift) > 10) {
$("#display_drift_date").html(
i18n("userprofile.drifttime.value", drift) + "<br />" +
i18n("userprofile.drifttime.server", new Date(server_time)) + "<br />" +
i18n("userprofile.drifttime.warn")
);
$("#display_drift_date").addClass("alert");
if (Math.abs(drift) > 30) {
$("#display_drift_date").addClass("alert-error");
}
}
} catch(err) {
console.log(err);
}
Expand Down
3 changes: 3 additions & 0 deletions conf/messages.en
Expand Up @@ -470,6 +470,9 @@ userprofile.baskets.admin.rawview.modal.cancel=Cancel
userprofile.baskets.admin.rawview.modal.save=Save
userprofile.baskets.admin.rawview.modal.warning=Warning!
userprofile.baskets.admin.rawview.modal.cantfoundsomeitems=Could not find this/these item(s) in storage:
userprofile.drifttime.value=Drift time with the server: %s sec
userprofile.drifttime.server=The server is now the %s
userprofile.drifttime.warn=Because of this shift, the information dates and time on the site may be incorrect.

userprofile.mailtemplate.mailtest=Send test mail
userprofile.mailtemplate.testmessage=This email was sent to check the proper functioning of the mail engine, as well as your ability to receive and read this email.
Expand Down
3 changes: 3 additions & 0 deletions conf/messages.fr
Expand Up @@ -470,6 +470,9 @@ userprofile.baskets.admin.rawview.modal.cancel=Annuler
userprofile.baskets.admin.rawview.modal.save=Enregister
userprofile.baskets.admin.rawview.modal.warning=Attention !
userprofile.baskets.admin.rawview.modal.cantfoundsomeitems=Impossible de trouver cet/ces element(s) dans les stockages :
userprofile.drifttime.value=Décallage de temps avec le serveur : %s sec
userprofile.drifttime.server=Le serveur est actuellement le %s
userprofile.drifttime.warn=A cause de ce décallage, les informations de dates et de temps sur le site peuvent être erronées.

userprofile.mailtemplate.mailtest=Test d'envoi de mail
userprofile.mailtemplate.testmessage=Ce mail a été envoyé pour vérifier le bon fonctionnement du moteur de mail, ainsi que votre capacité à pouvoir recevoir et lire ce mail.
Expand Down

0 comments on commit 70bc2d0

Please sign in to comment.