Browse Source

Changement dans les données des CHATONS : https://forum.chatons.org/t/afficher-les-services-similaire-chatons/2173/6

David 3 years ago
parent
commit
2cf64dd23e
1 changed files with 7 additions and 8 deletions
  1. 7 8
      lib/alternative-chatons.js

+ 7 - 8
lib/alternative-chatons.js

@@ -1,9 +1,8 @@
-
-const jsonFile = "https://chatons.org/fr/entraide/json";
+const jsonFile = "https://www.chatons.org/entraide/json";
 const typeFiltre = "Partage temporaire de fichiers (alternative à WeTransfer, DropSend)"
 const typeFiltre = "Partage temporaire de fichiers (alternative à WeTransfer, DropSend)"
 const openFiltre = "Ouvert à tou⋅te⋅s sans inscription"
 const openFiltre = "Ouvert à tou⋅te⋅s sans inscription"
 const separateur = ' - '
 const separateur = ' - '
-//console.log('alternative chatons');
+//~ console.log('alternative chatons');
 // onready : Inspiré : http://jsfiddle.net/electricvisions/Jacck/
 // onready : Inspiré : http://jsfiddle.net/electricvisions/Jacck/
 document.onreadystatechange = function () {
 document.onreadystatechange = function () {
     var state = document.readyState
     var state = document.readyState
@@ -12,21 +11,21 @@ document.onreadystatechange = function () {
 	entraide = {};
 	entraide = {};
 	// start JSON retrieval here
 	// start JSON retrieval here
 	$.getJSON(jsonFile, function(data) {
 	$.getJSON(jsonFile, function(data) {
-	    entraide = data.nodes; 
+	    entraide = data; 
 	    var x=0;
 	    var x=0;
 	    for (var i = 0; i < entraide.length; i++) {
 	    for (var i = 0; i < entraide.length; i++) {
-		if (entraide[i].node.type == typeFiltre
-		&& entraide[i].node.open == openFiltre) {
+		if (entraide[i].type == "Partage temporaire de fichiers" 
+		&& entraide[i].access_type == "Ouvert à tou⋅te⋅s") {
 		    if (x != 0) {
 		    if (x != 0) {
 			$("#entraide-chatons-alternative").append(separateur);	    
 			$("#entraide-chatons-alternative").append(separateur);	    
 		    }
 		    }
-		    link=entraide[i].node.endpoint;
+		    link=entraide[i].endpoint;
 		    link=link.replace('https://', '');
 		    link=link.replace('https://', '');
 		    link=link.replace('http://', '');
 		    link=link.replace('http://', '');
 		    //console.log(link);	
 		    //console.log(link);	
 		    const regex = /\/$/i;
 		    const regex = /\/$/i;
 		    link = link.replace(regex, '')
 		    link = link.replace(regex, '')
-		    $("#entraide-chatons-alternative").append('<a href="'+entraide[i].node.endpoint+'">'+link+'</a>');
+		    $("#entraide-chatons-alternative").append('<a href="'+entraide[i].endpoint+'">'+link+'</a>');
 		    x=x+1;
 		    x=x+1;
 		}
 		}
 	    }
 	    }