Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions Themes/default/scripts/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ function reqOverlayDiv(desktopURL, sHeader, sIcon)

// Create the div that we are going to load
const oContainer = new smc_Popup(containerOptions);
const oPopup_body = oContainer.cover.querySelector('.popup_content');

// Load the help page content (we just want the text to show)
fetch(desktopURL + (desktopURL.includes('?') ? ';' : '?') + 'ajax', {
Expand All @@ -276,11 +275,14 @@ function reqOverlayDiv(desktopURL, sHeader, sIcon)
})
.then((res, rej) => res.ok ? res.text() : rej(res))
.then(data => {
oPopup_body.innerHTML = data;
const parser = new DOMParser();
const doc = parser.parseFromString(data, "text/html");
const body = doc?.querySelector('body div')?.innerHTML ?? data;
oContainer.setBody(body);
})
.catch(error => {
const errorMsg = error.headers.get('x-smf-errormsg');
oPopup_body.innerHTML = errorMsg || error.message || banned_text;
const errorMsg = error?.headers?.get('x-smf-errormsg') ?? error;
oContainer.setBody(errorMsg || error.message || banned_text);
});

return false;
Expand Down Expand Up @@ -419,6 +421,11 @@ smc_Popup.prototype.hide = function ()
return false;
}

smc_Popup.prototype.setBody = function(data)
{
document.getElementById(this.popup_id).querySelector('.popup_content').innerHTML = data;
}

// Remember the current position.
function storeCaret(oTextHandle)
{
Expand Down