From a9a1b4bfa5b557a2fe7b25ed53295e715d626ea5 Mon Sep 17 00:00:00 2001 From: Stephan Schmitz Date: Fri, 15 Mar 2019 14:10:22 +0100 Subject: [PATCH 1/2] Raise timeout for xhr --- static/app.js | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/static/app.js b/static/app.js index 5729bd9..f804677 100644 --- a/static/app.js +++ b/static/app.js @@ -2,7 +2,7 @@ var GithubApi = { xhr: null, apiBaseUrl: 'https://api.github.com', - githubStatusApiUrl: 'https://kctbh9vrtdwd.statuspage.io/api/v2/summary.json', + githubStatusApiUrl: 'https://kctbh9vrtdwd.statuspage.io/api/v2/summary.json', // https://www.githubstatus.com/api getXMLHttpRequest: function() { if (!!window.XMLHttpRequest) { this.xhr = new window.XMLHttpRequest; @@ -17,11 +17,20 @@ get: function(requestUrl, success, failure) { this.getXMLHttpRequest(); + if (!this.xhr) { + window.console.log("AJAX (XMLHTTP) not supported by your client."); + failure({ + status: 'error', + msg: 'AJAX (XMLHTTP) not supported by your client but required for Nicegist to work, sorry.' + }); + return; + } + var self = this.xhr; this.xhr.open('GET', requestUrl, true); this.xhr.setRequestHeader('Accept', 'application/json'); - this.xhr.timeout = 1000; // time in milliseconds + this.xhr.timeout = 1500; // time in milliseconds self.onload = function() { if (self.status >= 200 && self.status < 400) { @@ -65,6 +74,15 @@ }); } } + failure({ + status: 'error', + msg: 'API timeout error when fetching Gist.' + }); + } else { + failure({ + status: 'error', + msg: 'API timeout error when fetching Gist.' + }); } }, error => { failure({ @@ -83,12 +101,10 @@ this.xhr.send(); }, getGist: function(gistId, success, failure) { - var endpoint = '/gists/' + gistId; - this.get(this.apiBaseUrl + endpoint, success, failure); + this.get(`${this.apiBaseUrl}/gists/${gistId}`, success, failure); }, getGistComments: function(gistId, success, failure) { - var endpoint = '/gists/' + gistId + '/comments'; - this.get(this.apiBaseUrl + endpoint, success, failure); + this.get(`${this.apiBaseUrl}/gists/${gistId}/comments`, success, failure); }, getGithubApiStatus: function(success, failure) { this.get(this.githubStatusApiUrl, success, failure); From 0a4feb930ae29bfdbec2aaa3c445d32374b6720c Mon Sep 17 00:00:00 2001 From: Stephan Schmitz Date: Fri, 15 Mar 2019 14:11:28 +0100 Subject: [PATCH 2/2] HTML markup --- 404.html | 44 +++++++++++++-------------- index.html | 88 +++++++++++++++++++++++++++--------------------------- 2 files changed, 66 insertions(+), 66 deletions(-) diff --git a/404.html b/404.html index 0c663af..9d02590 100644 --- a/404.html +++ b/404.html @@ -1,38 +1,38 @@ - + Nicegist - + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + +