Skip to content

Instantly share code, notes, and snippets.

@DrI-T
Last active June 20, 2021 02:16
Show Gist options
  • Save DrI-T/0c91a02b46db6c1b8b7c2b7030a4b5fb to your computer and use it in GitHub Desktop.
Save DrI-T/0c91a02b46db6c1b8b7c2b7030a4b5fb to your computer and use it in GitHub Desktop.
a page to check if your internet connection is on
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<!DOCTYPE html><meta charset=utf8>
<link rel=icon href=checking.webp>
<title> Is my internet on ? </title>
<div id=container>
<img alt=bot src="https://robohash.org/:ip">
<h2> Is my internet on ? </h2>
<div id=resp><i>checking connection ...</i></div>
<br>
<div><img alt=status src="on.webp" data-src="https://ipfs.blockringtm.ml/ipfs/:qm/on.webp"></div>
</div>
<br>
<div>
<p>If you have <a href=https://bl.ocks.org/DrI-T/882ae8a852ab2bc58a333e3c6f279d03>IPFS</a> running,
this page can be found at local urls :
<ul>
<li><a id=qm href=http://127.0.0.1:8080/ipfs/:qm><i>/ipfs/:qm/</i></a>
or
<li><a href=http://127.0.0.1:8080/ipns/QmRn4v4xXt8Qn5dHdDCQrkGCczsU45HYjL2wsQhFjtZ1JN><i>/ipns/QmRn4v4xXt8Qn5dHdDCQrkGCczsU45HYjL2wsQhFjtZ1JN/</i></a>
</ul>
<p>Alternatively you can get the page at the <a href=https://gist.github.com/DrI-T>gist</a> url: <a href=https://bl.ocks.org/DrI-T/raw/0c91a02b46db6c1b8b7c2b7030a4b5fb>gist:0c91a02b46db6c1b8b7c2b7030a4b5fb</a>
<p>The Git repository for this code is <a id=git href="https://holoGIT-ml.ipns.dweb.link/odetrolio/isup.git" title="https://holoGIT-ml.ipns.dweb.link/odetrolio/isup.git"><i>holo</i>git:odetrolio/isup.git</a>
</div>
<style>
body {
height: 100vh;
/* ipfs add -w *.png *.jpg *.svg *.webp --cid-base base36
background-image: URL(http://localhost:8080/ipfs/QmdYeoosSbQdugaf3eB3fJvGfZLEodoM1w6oRyGoscvcPj/universe.webp);
background-image: URL(https://k2jmtxwzudn3qvqz4m7khkdj7haenqwslpo5fjhk7htuqt18zi64lzgq.ipfs.dweb.link/universe.webp);
*/
background-image: URL(https://kmuj9h5jlkkovu5bh66iwypj42xtbpk5niujq8d9sysm2b90woibu.ipfs.cf-ipfs.com/universe.webp);
background-size: 100vw 100%;
}
body > div:nth-child(1) {
margin-top: 10vw;
}
body > div {
background-color: white;
max-width: 142vh;
border: 1px solid grey;
margin: auto;
padding: 0.8rem;
overflow: auto;
box-shadow: 5px 5px 15px 2px rgba(4,3,5,0.9);
}
img[alt=status] {
display: block;
text-align: center;
/* background-image: URL(checking.webp); */
background-position: center;
background-repeat: no-repeat;
border: 1px;
width: 120px;
height: 120px;
margin: auto;
}
img[alt=bot] {
display: block;
float: right;
width: 10vw;
height: 10vw;
}
</style>
<script>
// ipfs key list -l --ipns-base=b58mh | grep -w isup
const keyid='QmRn4v4xXt8Qn5dHdDCQrkGCczsU45HYjL2wsQhFjtZ1JN'
// ipfs name publish --key=isup --ipns-base=b58mh /ipfs/$(ipfs add -w index.html *.webp *.svg -Q)
var qm= 'QmZczkmTAfAHuQurbzdekKqNotaKoS6732Va8VgrzUgXwF'; // ipfs add -w index.html *.webp *.svg
// qm='QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn';
let i = document.querySelector('img[alt=status]');
i.src = i.dataset.src.replace(':qm',qm)
let a = document.getElementById('qm');
a.href = a.href.replace(':qm',qm)
a.innerText = a.innerText.replace(':qm',qm)
let b = document.querySelector('img[alt=bot]');
console.log('b:',b)
var el = document.getElementById('resp');
var title = document.getElementsByTagName('title')[0];
var fav = document.getElementsByTagName('link')[0];
check_connection();
function check_connection() {
url='https://icanhazip.com'
url='https://ipfs.blockringtm.ml/cgi-bin/remote_addr.txt'
i.src = ''
fav.href = 'checking.webp'
title.innerText = 'Is my internet on?'
el.innerHTML = '<i>checking connection ...</i>'
i.src = `https://gateway.ipfs.io/ipfs/${qm}/checking.svg`
return fetch(url,{mode:'cors'}).then(resp => resp.text()).
then(ip => {
b.src = b.src.replace(':ip',ip)
i.src = `https://gateway.ipfs.io/ipfs/${qm}/on.svg`
fav.href = 'on.webp'
title.innerText = `internet is on: ${ip} 🟢`
el.innerHTML = `🟢 Yes and your ip-address is ${ip}.`
setTimeout(check_connection, 30011);
return ip;
}).
catch(err => {
console.log(err)
fav.href = 'off.webp'
title.innerText = `internet Down`
el.innerHTML = `🔴 No your internet connection seems to be down.`
i.src = 'off.svg'
setTimeout(check_connection, 60013);
return '0.0.0.0';
});
}
</script>
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
version="1.1"
id="svg2"
width="982.39532"
height="983.0343"
viewBox="0 0 982.39532 983.0343">
<metadata
id="metadata8">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs6" />
<path
id="path837"
style="opacity:0.98;fill:#00a900;fill-opacity:1;fill-rule:evenodd;stroke:#779c7b;stroke-width:4.97582;stroke-linecap:square;stroke-linejoin:round;stroke-opacity:1"
d="M 488.7501,2.5438418 C 272.68955,-1.9139263 69.32551,158.6377 17.46687,367.37333 -24.955624,528.1826 19.914445,709.3135 136.74012,828.70034 266.88126,969.91638 483.43665,1018.5608 662.20533,950.32203 852.52431,881.10626 989.24013,684.44661 979.87907,480.87408 981.03805,258.78921 807.73858,53.351157 590.40315,11.870293 557.00216,4.9796888 522.85,1.7672181 488.7501,2.5438418 Z m 3.40144,200.1241282 c 47.40221,-0.98924 50.14483,50.49656 46.59003,85.73626 0,71.21443 0,142.42885 0,213.64328 -12.55685,53.69905 -100.55281,39.59619 -92.2265,-16.39025 -0.19948,-82.59585 -2.62607,-165.34747 1.31837,-247.87494 4.26512,-20.03431 23.85935,-35.50141 44.3181,-35.11435 z m 191.05825,52.37385 c 48.88192,9.70344 72.52262,64.30168 95.2079,103.98401 62.37954,129.0486 21.76288,296.6116 -92.91253,382.72411 C 570.3038,834.93119 388.68898,829.87078 280.42508,727.6922 166.72618,630.93599 141.70356,451.12777 221.79383,325.96567 c 22.57491,-36.63347 65.70654,-98.00223 112.41745,-56.9841 42.81337,55.8636 -44.82851,93.35316 -52.392,146.62821 -46.75374,116.67296 28.07733,261.5204 149.99783,291.39634 106.88761,31.48622 230.71128,-29.93966 267.72633,-135.63072 33.50687,-81.87293 8.82734,-179.22071 -53.09415,-240.76605 -25.59167,-28.62505 -1.48212,-77.98081 36.7605,-75.56753 z" />
</svg>
#
tic=$(date +%s)
find . -name '*~1' -delete
qm=$(ipfs add -w index.html *.webp *.svg qm.log $0 -Q)
key=$(ipfs key list -l --ipns-base b58mh| grep -w isup | cut -d' ' -f1)
gwport=$(ipfs config Addresses.Gateway | cut -d'/' -f 5)
echo $tic: $qm >> qm.log
echo url: https://ipfs.blockring™.ml/ipfs/$qm
echo url: http://localhost:$gwport/ipns/$key
ipfs name publish --key=isup /ipfs/$qm
--- # qmlog blockring
1622539624: QmNkHoCjKh6z6bH5JpnM4XRXkqnRtqnZb5uJcU72hQng5G
1622539700: QmXETknAWfE5mQVAaiUFvQig9UFAA13hfUsjKYGwbemSax
1624155265: QmcebBwojDKJd3AbFPXZoP1JXGSJR7ZiNqTcgdTJVZHZb5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment