Skip to content

Commit 0da2b11

Browse files
authored
Merge pull request #9002 from jdarwood007/3.0/fixes8989
[3.0] Popup setBody function
2 parents af86a96 + 715b810 commit 0da2b11

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

Themes/default/scripts/script.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ function reqOverlayDiv(desktopURL, sHeader, sIcon)
261261

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

266265
// Load the help page content (we just want the text to show)
267266
fetch(desktopURL + (desktopURL.includes('?') ? ';' : '?') + 'ajax', {
@@ -276,11 +275,14 @@ function reqOverlayDiv(desktopURL, sHeader, sIcon)
276275
})
277276
.then((res, rej) => res.ok ? res.text() : rej(res))
278277
.then(data => {
279-
oPopup_body.innerHTML = data;
278+
const parser = new DOMParser();
279+
const doc = parser.parseFromString(data, "text/html");
280+
const body = doc?.querySelector('body div')?.innerHTML ?? data;
281+
oContainer.setBody(body);
280282
})
281283
.catch(error => {
282-
const errorMsg = error.headers.get('x-smf-errormsg');
283-
oPopup_body.innerHTML = errorMsg || error.message || banned_text;
284+
const errorMsg = error?.headers?.get('x-smf-errormsg') ?? error;
285+
oContainer.setBody(errorMsg || error.message || banned_text);
284286
});
285287

286288
return false;
@@ -419,6 +421,11 @@ smc_Popup.prototype.hide = function ()
419421
return false;
420422
}
421423

424+
smc_Popup.prototype.setBody = function(data)
425+
{
426+
document.getElementById(this.popup_id).querySelector('.popup_content').innerHTML = data;
427+
}
428+
422429
// Remember the current position.
423430
function storeCaret(oTextHandle)
424431
{

0 commit comments

Comments
 (0)