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 ⚠
|
⚠ TELETUBE TELEPORT SYSTEM ⚠
|
||||||
|
|
||||||
## RECUPERATION DU PORT DE REPONSE API : (◕‿‿◕)
|
## RECUPERATION DU PORT DE REPONSE API : (◕‿‿◕)
|
||||||
|
### CLI
|
||||||
```
|
```
|
||||||
# PLAYER COPIER "_URL_" FAVORITE
|
# PLAYER COPIER "_URL_" FAVORITE
|
||||||
curl -so ~/.zen/tmp/${MOATS}/astro.port "http://astroport.localhost:1234/?salt=0&pepper=0&g1pub=_URL_&email=${EMAIL}"
|
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
|
# RECUPERER SON JETON PLAYER
|
||||||
curl -so ~/.zen/tmp/${MOATS}/astro.rep "http://$TELETUBE:$TELEPORT"
|
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.)
|
## ➤ PRIVATE ZONE (fonctionne sur toutes les Stations.)
|
||||||
### ```/?salt=${SALT}&pepper=${PEPPER}&${APPNAME}=${WHAT}&${OBJ}=${VAL}...```
|
### ```/?salt=${SALT}&pepper=${PEPPER}&${APPNAME}=${WHAT}&${OBJ}=${VAL}...```
|
||||||
|
|
|
@ -26,37 +26,33 @@
|
||||||
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
// BORIS STUFF COMES HERE
|
|
||||||
async function fetchMyDocument(myURL) {
|
|
||||||
try {
|
|
||||||
|
|
||||||
let response = await fetch(myURL); // Gets a promise
|
|
||||||
var doc = await response.text();
|
|
||||||
var regex = /url='([^']+)/i;
|
|
||||||
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
|
|
||||||
window.open( redirectURL, "AstroTab");
|
|
||||||
}, 5000);
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
console.log('Fetch error:' + err); // Error handling
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function sendtostation (mycontent) {
|
function sendtostation (mycontent) {
|
||||||
|
|
||||||
var query = 'qrcode='+ mycontent;
|
var query = 'qrcode='+ mycontent;
|
||||||
var fullURL = 'http://astroport.localhost:1234/?' + query;
|
var myURL = 'http://astroport.localhost:1234/?' + query;
|
||||||
console.log(fullURL)
|
console.log(fullURL)
|
||||||
fetchMyDocument(fullURL)
|
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// BORIS STUFF COMES HERE
|
|
||||||
|
|
||||||
let scanner = new Instascan.Scanner({ video: document.getElementById('preview') });
|
let scanner = new Instascan.Scanner({ video: document.getElementById('preview') });
|
||||||
scanner.addListener('scan', function (content) {
|
scanner.addListener('scan', function (content) {
|
||||||
|
|
Loading…
Reference in New Issue