1234 JS API
This commit is contained in:
parent
01da5a332f
commit
33ac36f226
25
README.md
25
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}...```
|
||||
|
|
|
@ -26,20 +26,25 @@
|
|||
|
||||
|
||||
<script type="text/javascript">
|
||||
// BORIS STUFF COMES HERE
|
||||
async function fetchMyDocument(myURL) {
|
||||
function sendtostation (mycontent) {
|
||||
|
||||
var query = 'qrcode='+ mycontent;
|
||||
var myURL = 'http://astroport.localhost:1234/?' + query;
|
||||
console.log(fullURL)
|
||||
|
||||
async function fetchAstroport(myURL) {
|
||||
try {
|
||||
|
||||
let response = await fetch(myURL); // Gets a promise
|
||||
var doc = await response.text();
|
||||
var regex = /url='([^']+)/i;
|
||||
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 resp = await fetch(redirectURL);
|
||||
//document.body.innerHTML = await response.text(); // Replaces body with response
|
||||
// let two = await fetch(redirectURL);
|
||||
// document.mydiv.innerHTML = await two.text(); // Replaces body with response
|
||||
window.open( redirectURL, "AstroTab");
|
||||
}, 5000);
|
||||
|
||||
|
@ -47,16 +52,7 @@
|
|||
console.log('Fetch error:' + err); // Error handling
|
||||
}
|
||||
}
|
||||
|
||||
function sendtostation (mycontent) {
|
||||
|
||||
var query = 'qrcode='+ mycontent;
|
||||
var fullURL = 'http://astroport.localhost:1234/?' + query;
|
||||
console.log(fullURL)
|
||||
fetchMyDocument(fullURL)
|
||||
|
||||
}
|
||||
// BORIS STUFF COMES HERE
|
||||
|
||||
let scanner = new Instascan.Scanner({ video: document.getElementById('preview') });
|
||||
scanner.addListener('scan', function (content) {
|
||||
|
|
Loading…
Reference in New Issue