Skip to content

Instantly share code, notes, and snippets.

@kerbyfc
Created October 28, 2016 15:56
Show Gist options
  • Save kerbyfc/982ad28636ec900ab6851aad93c27fec to your computer and use it in GitHub Desktop.
Save kerbyfc/982ad28636ec900ab6851aad93c27fec to your computer and use it in GitHub Desktop.
branch feature/ABR-68976. Apply it from root
diff --git a/assets/errors/50x.html b/assets/errors/50x.html
index 4468f58..c931df6 100644
--- a/assets/errors/50x.html
+++ b/assets/errors/50x.html
@@ -40,16 +40,26 @@
<script type="text/javascript">
var offline;
+
+ /**
+ * Remember the timestamp of page closing (or reloading).
+ */
var seenKey = 'seen';
+ window.onbeforeunload = function(event) {
+ localStorage.setItem(seenKey, new Date().getTime());
+ };
+
+ /**
+ * Check if user has reload the page and redirect him to "/"
+ * @example
+ * 1) service error -> error page -> f5 -> redirect to /
+ * 2) service error -> error page -> CLOSE ERROR PAGE -> service error -> error page -> f5 -> redirect to /
+ */
var seen = +localStorage.getItem(seenKey);
if (seen && (new Date().getTime() - new Date(seen).getTime() < 2000)) {
location.href = '/';
}
- window.onbeforeunload = function(event) {
- localStorage.setItem(seenKey, new Date().getTime());
- };
-
loadTranslations("<%- VERSION %>", "<%- LANGS %>", offline = true)
.then(function(translations) {
Array.prototype.slice.call(document.getElementsByClassName("translate"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment