Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//https://framagit.org/kepon/file2link/-/blob/master/lib/alternative-chatons.js
const jsonFile = "https://chatons.org/fr/entraide/json";
const typeFiltre = "Chat IRC ou Jabber (alternative à MSN)"
const openFiltre = "Ouvert à tou⋅te⋅s sans inscription"
const separateur = ' - '
//console.log('alternative chatons');
// onready : Inspiré : http://jsfiddle.net/electricvisions/Jacck/
document.onreadystatechange = function () {
var state = document.readyState
// A la fin du chargement du document
if (state == 'complete') {
entraide = {};
// start JSON retrieval here
$.getJSON(jsonFile, function(data) {
entraide = data.nodes;
var x=0;
for (var i = 0; i < entraide.length; i++) {
if (entraide[i].node.type == typeFiltre
&& entraide[i].node.open == openFiltre) {
if (x != 0) {
$("#entraide-chatons-alternative").append(separateur);
}
link=entraide[i].node.endpoint;
link=link.replace('https://', '');
link=link.replace('http://', '');
//console.log(link);
const regex = /\/$/i;
link = link.replace(regex, '')
$("#entraide-chatons-alternative").append('<a href="'+entraide[i].node.endpoint+'">'+link+'</a>');
x=x+1;
}
}
});
}
}