From 33ac36f226f66a0620de17aadb5ff436d9e9c326 Mon Sep 17 00:00:00 2001 From: fred Date: Wed, 1 Mar 2023 03:19:05 +0100 Subject: [PATCH] 1234 JS API --- README.md | 25 +++++++++++++++++++++++++ www/index_ONE.html | 46 +++++++++++++++++++++------------------------- 2 files changed, 46 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 5d1bd9cc..b6374aa7 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,7 @@ Une fois votre Station Astroport démarrée (```~/.start.sh```): ⚠ TELETUBE TELEPORT SYSTEM ⚠ ## RECUPERATION DU PORT DE REPONSE API : (◕‿‿◕) +### CLI ``` # PLAYER COPIER "_URL_" FAVORITE curl -so ~/.zen/tmp/${MOATS}/astro.port "http://astroport.localhost:1234/?salt=0&pepper=0&g1pub=_URL_&email=${EMAIL}" @@ -96,6 +97,30 @@ Une fois votre Station Astroport démarrée (```~/.start.sh```): # RECUPERER SON JETON PLAYER curl -so ~/.zen/tmp/${MOATS}/astro.rep "http://$TELETUBE:$TELEPORT" ``` +### JS +``` +var myURL = 'http://astroport.localhost:1234/?' + query; +async function fetchAstroport(myURL) { + try { + + let one = await fetch(myURL); // Gets a promise + var doc = await one.text(); + var regex = /url='([^']+)/i; // Get response PORT + var redirectURL = doc.match(regex)[1] + + console.log(redirectURL) + + setTimeout(function() { + // let two = await fetch(redirectURL); + // document.mydiv.innerHTML = await two.text(); // Replaces body with response + window.open( redirectURL, "AstroTab"); + }, 5000); + + } catch (err) { + console.log('Fetch error:' + err); // Error handling + } + } +``` ## ➤ PRIVATE ZONE (fonctionne sur toutes les Stations.) ### ```/?salt=${SALT}&pepper=${PEPPER}&${APPNAME}=${WHAT}&${OBJ}=${VAL}...``` diff --git a/www/index_ONE.html b/www/index_ONE.html index de3698e1..38d204e6 100644 --- a/www/index_ONE.html +++ b/www/index_ONE.html @@ -26,37 +26,33 @@