Skip to content

Commit 3de8cb4

Browse files
authored
v1
Initial base v0.1
2 parents bae801e + 1c2ef40 commit 3de8cb4

File tree

3 files changed

+74
-4
lines changed

3 files changed

+74
-4
lines changed

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
# HTML Embed for cState
1+
<p align="center"><img src="images/logosvg?sanitize=true" alt="cState alt logo"></p>
22

3-
✔ The basic code for checking if a cState-powered status page (using its read-only API) has a status other than "fully operational."
3+
✔ The basic JavaScript code for checking if a cState-powered status page (using its read-only API).
44

5-
**This is a work in progres. Playkit for developers.**
5+
**There is no UI for this project, so you are you free to write that yourself or [contribute so others can use it](https://github.com/cstate/html-embed/issues/2).**
6+
7+
The `index.js` file has the JavaScript you can add to your page and use for making other things happen.
68

79
## Prerequisites
810

@@ -23,4 +25,6 @@ The demo page uses this for its `netlify.toml`:
2325

2426
The idea for this project was [originally inspired](https://github.com/cstate/cstate/issues/131) by the GitHub / cState user @ririko5834.
2527

26-
MIT
28+
Contributing rules same as on main [cState repository](https://github.com/cstate/cstate)
29+
30+
Licensed MIT, made by Mantas Vilčinskas since 2020. Thank you to all contributors.

images/logo.svg

Lines changed: 28 additions & 0 deletions
Loading

index.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// HTML Embed for cState
2+
// Version 1.0
3+
// github.com/cstate/html-embed
4+
5+
// Variables
6+
// Site + '/index.json'
7+
var cStateAPIRoot = 'https://flamboyant-shirley-6bc75e.netlify.app/index.json'
8+
var cStateEmbedPrefix = '[cState HTML Embed v1.0] ';
9+
var cStateEmbedDebugging = false;
10+
var cStateAPIStatus = 'tryingToGetStatus';
11+
12+
// Code itself
13+
fetch(cStateAPIRoot)
14+
.then(
15+
function(response) {
16+
if (response.status !== 200) {
17+
console.log(cStateEmbedPrefix + 'API not OK, it sent HTTP status code ' +
18+
response.status);
19+
return;
20+
}
21+
22+
// Examine the text in the response
23+
response.json().then(function(data) {
24+
25+
// When debugging, this code should be run to see API response
26+
if (cStateEmbedDebugging) {
27+
console.log(cStateEmbedPrefix + 'API response: ', data);
28+
cStateAPIStatus = data.summaryStatus;
29+
console.log(cStateEmbedPrefix + 'API says status page is: ' + cStateAPIStatus);
30+
}
31+
32+
});
33+
}
34+
)
35+
.catch(function(err) {
36+
console.log('Fetch error :-S', err);
37+
});
38+

0 commit comments

Comments
 (0)