Skip to content

Commit

Permalink
.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Miala-python committed Mar 8, 2024
1 parent d1d24a7 commit d0e1c47
Showing 1 changed file with 52 additions and 21 deletions.
73 changes: 52 additions & 21 deletions lib/script/sub_domains.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
console.log('sub_domains.js >> V0.00.3');
console.log('sub_domains.js >> V0.00.4');

function subd_convertURL(an_url) {
let url = new URL(an_url);
Expand Down Expand Up @@ -28,7 +28,7 @@ function subd_replaceLinks() {
for (const link of links) {
let href = new URL(link.getAttribute('href'), subd_url_mtn);

if (href.hostname.endsWith(subd_host)){
if (href.hostname.endsWith(subd_host)) {
link.setAttribute("onclick", `subd_change_url(${herf.toString()});`);
}
}
Expand All @@ -37,23 +37,54 @@ function subd_replaceLinks() {

function subd_change_url(url) {
let reel_url = subd_convertURL(url).trimEnd("/");
fetch(reel_url)
.then(response => response.text())
.then(text => {
subd_url_mtn = url;
history.pushState({}, "Miala", url);


document.querySelector('html').innerHTML = newContent;

subd_replaceLinks();

subd_evalScripts(container);
})
.catch(error => {
console.log(error);
setTimeout(() => {
window.location.href = ulr + '?err&faut_vraiment_que_tu_me_donne_lurl_parceque_sinon_ca_marche_pas';
}, timeout);
});
// fetch(reel_url)
// .then(response => response.text())
// .then(text => {
// subd_url_mtn = url;
// history.pushState({}, "Miala", url);


// document.querySelector('html').innerHTML = newContent;

// subd_replaceLinks();

// subd_evalScripts(container);
// })
// .catch(error => {
// console.log(error);
// setTimeout(() => {
// // window.location.href = ulr + '?err&faut_vraiment_que_tu_me_donne_lurl_parceque_sinon_ca_marche_pas';
// }, 1000);
// });

const xhr = new XMLHttpRequest();

xhr.open('GET', reel_url);

xhr.onload = function () {
if (xhr.status === 200) {
let text = xhr.responseText;
subd_url_mtn = url;
history.pushState({}, "Miala", url);


document.querySelector('html').innerHTML = newContent;

subd_replaceLinks();

subd_evalScripts(container);
} else {
console.error('Error fetching data:', xhr.statusText);
// Implement error handling (redirect or display message)
}
};

xhr.onerror = function () {
console.error('Network error:', xhr.statusText);
// Implement error handling (redirect or display message)
};

xhr.send();


}

0 comments on commit d0e1c47

Please sign in to comment.