use direct if possible

This commit is contained in:
Gabriel 2022-10-12 04:52:31 -04:00
parent 98d89ca81c
commit a3d2c9f866

View file

@ -102,7 +102,29 @@
}
</style>
<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')">
<section id="interverse-details">
<img x-bind:src="Alpine.store('data')['image']">
@ -232,6 +254,11 @@ Alpine.store('data',data['main'])
function initialize(url) {
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) {
console.log("Initializing interverse...")
Alpine.store('data',data);