summaryrefslogtreecommitdiff
path: root/p/scripts/api.js
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2019-01-26 16:03:29 +0100
committerGravatar GitHub <noreply@github.com> 2019-01-26 16:03:29 +0100
commit8dcdde6251ae4dfc690b1a014488df125c5e5cdc (patch)
treef5762ac9c76acf708a50534f081e558489ccad86 /p/scripts/api.js
parentf0a359619fa2936d66a2b96dd086d4686e7405fa (diff)
parent38e8e265e0f2ead830aa12e7ef81de12599405b5 (diff)
Merge pull request #2220 from FreshRSS/dev1.13.1
FreshRSS 1.13.1
Diffstat (limited to 'p/scripts/api.js')
-rw-r--r--p/scripts/api.js62
1 files changed, 62 insertions, 0 deletions
diff --git a/p/scripts/api.js b/p/scripts/api.js
new file mode 100644
index 000000000..841b16a6a
--- /dev/null
+++ b/p/scripts/api.js
@@ -0,0 +1,62 @@
+"use strict";
+/* jshint esversion:6, strict:global */
+
+function check(url, next) {
+ if (!url || !next) {
+ return;
+ }
+ const req = new XMLHttpRequest();
+ req.open('GET', url, true);
+ req.setRequestHeader('Authorization', 'GoogleLogin auth=test/1');
+ req.onerror = function (e) {
+ next('FAIL: HTTP ' + e);
+ };
+ req.onload = function () {
+ if (this.status == 200) {
+ next(this.response);
+ } else {
+ next('FAIL: HTTP error ' + this.status + ' ' + this.statusText);
+ }
+ };
+ req.send();
+}
+
+const jsonVars = JSON.parse(document.getElementById('jsonVars').innerHTML);
+
+check(jsonVars.greader + '/check/compatibility', function next(result1) {
+ const greaderOutput = document.getElementById('greaderOutput');
+ if (result1 === 'PASS') {
+ greaderOutput.innerHTML = '✔️ ' + result1;
+ } else {
+ check(jsonVars.greader + '/check%2Fcompatibility', function next(result2) {
+ if (result2 === 'PASS') {
+ greaderOutput.innerHTML = '⚠️ WARN: no <code>%2F</code> support, so some clients will not work!';
+ } else {
+ check('./greader.php/check/compatibility', function next(result3) {
+ if (result3 === 'PASS') {
+ greaderOutput.innerHTML = '⚠️ WARN: Probable invalid base URL in ./data/config.php';
+ } else {
+ greaderOutput.innerHTML = '❌ ' + result1;
+ }
+ });
+ }
+ });
+ }
+ });
+
+check(jsonVars.fever + '?api', function next(result1) {
+ const feverOutput = document.getElementById('feverOutput');
+ try {
+ JSON.parse(result1);
+ feverOutput.innerHTML = '✔️ PASS';
+ } catch (ex) {
+ check('./fever.php?api', function next(result2) {
+ try {
+ JSON.parse(result2);
+ feverOutput.innerHTML = '⚠️ WARN: Probable invalid base URL in ./data/config.php';
+ } catch (ex) {
+ feverOutput.innerHTML = '❌ ' + result1;
+ }
+ });
+ }
+ });