use direct if possible
This commit is contained in:
parent
98d89ca81c
commit
a3d2c9f866
1 changed files with 28 additions and 1 deletions
|
@ -102,7 +102,29 @@
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script src="https://unpkg.com/alpinejs" defer></script>
|
<script src="https://unpkg.com/alpinejs" defer></script>
|
||||||
<script src="/helper.js"></script>
|
<script>
|
||||||
|
function fetchback(url,cback){
|
||||||
|
fetch(url).then((request)=>request.json()).then((data)=>cback(data));
|
||||||
|
}
|
||||||
|
function interverse_data(url,cback){
|
||||||
|
url = interverse_proxy+"/initial?url="+url
|
||||||
|
fetch(url).then((response)=> {
|
||||||
|
if (!response.ok){
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
return response.json();
|
||||||
|
}).then((data)=>cback(data))
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://davidwalsh.name/query-string-javascript
|
||||||
|
function getUrlParameter(name) {
|
||||||
|
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
|
||||||
|
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
|
||||||
|
var results = regex.exec(location.search);
|
||||||
|
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
|
||||||
|
};
|
||||||
|
</script>
|
||||||
<div class="interverse" x-data x-if="Alpine.store('data')">
|
<div class="interverse" x-data x-if="Alpine.store('data')">
|
||||||
<section id="interverse-details">
|
<section id="interverse-details">
|
||||||
<img x-bind:src="Alpine.store('data')['image']">
|
<img x-bind:src="Alpine.store('data')['image']">
|
||||||
|
@ -232,6 +254,11 @@ Alpine.store('data',data['main'])
|
||||||
|
|
||||||
function initialize(url) {
|
function initialize(url) {
|
||||||
Alpine.store("data", {});
|
Alpine.store("data", {});
|
||||||
|
fetchback(url+'/.well-known/interverse',function(data){
|
||||||
|
if (data['name']){
|
||||||
|
Alpine.store('data',data);
|
||||||
|
}
|
||||||
|
});
|
||||||
interverse_data(url.replace("https://",'').replace('http://','').replace('/',''), function (data) {
|
interverse_data(url.replace("https://",'').replace('http://','').replace('/',''), function (data) {
|
||||||
console.log("Initializing interverse...")
|
console.log("Initializing interverse...")
|
||||||
Alpine.store('data',data);
|
Alpine.store('data',data);
|
||||||
|
|
Loading…
Reference in a new issue