Alternative CHATONS récupérer sur https://chatons.org/fr/entraide/json
This commit is contained in:
parent
efff92154d
commit
6913442891
2 changed files with 47 additions and 7 deletions
18
index.php
18
index.php
|
@ -271,14 +271,18 @@ if ($passwordForm == false) {
|
|||
@include_once('./header-page.php');
|
||||
$similarServicesLink='';
|
||||
if ($config['similarServicesView']) {
|
||||
//~ $similarServicesLink='<div class="similarServices">
|
||||
//~ <div class="similarHref"><a href="#similarServices" id="similarServices">'._('Similar services').'</a></div>
|
||||
//~ <div class="similarLink">';
|
||||
//~ $similarServicesLink.= '<script type="text/javascript" src="'.$config['baseUrl'].'/lib/alternative-chatons.js"></script>';
|
||||
//~ $similarServicesLink.= '<p id="entraide-chatons-alternative"></p>';
|
||||
//~ $similarServicesLink.='</div></div>';
|
||||
$similarServicesLink='<div class="similarServices">
|
||||
<div class="similarHref"><a href="#similarServices" id="similarServices">'._('Similar services').'</a></div>
|
||||
<div class="similarLink">';
|
||||
foreach ($config['similarServicesLink'] as $link) {
|
||||
$similarServicesLink.=$link.' ';
|
||||
}
|
||||
$similarServicesLink.='</div>
|
||||
</div>';
|
||||
<div class="similarHref">'._('Similar services').' :</div>
|
||||
<div>';
|
||||
$similarServicesLink.= '<script type="text/javascript" src="'.$config['baseUrl'].'/lib/alternative-chatons.js"></script>';
|
||||
$similarServicesLink.= '<p id="entraide-chatons-alternative"></p>';
|
||||
$similarServicesLink.='</div></div>';
|
||||
}
|
||||
$uploadDirId=$config['uploadDir'].'/'.$id;
|
||||
$action = null;
|
||||
|
|
36
lib/alternative-chatons.js
Normal file
36
lib/alternative-chatons.js
Normal file
|
@ -0,0 +1,36 @@
|
|||
|
||||
const jsonFile = "https://chatons.org/fr/entraide/json";
|
||||
const typeFiltre = "Partage temporaire de fichiers (alternative à WeTransfer, DropSend)"
|
||||
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;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Reference in a new issue