Move some DOM generation into the HTML settings file directly

This commit is contained in:
Guillaume Gomez 2022-05-18 11:39:46 +02:00
parent 77972d2d01
commit 72496d88d3
2 changed files with 15 additions and 19 deletions

View File

@ -596,9 +596,19 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
|buf: &mut Buffer| {
write!(
buf,
"<link rel=\"stylesheet\" type=\"text/css\" \
href=\"{root_path}settings{suffix}.css\">\
<script defer src=\"{root_path}settings{suffix}.js\"></script>",
"<div class=\"main-heading\">\
<h1 class=\"fqn\">\
<span class=\"in-band\">Rustdoc settings</span>\
</h1>\
<span class=\"out-of-band\">\
<a id=\"back\" href=\"javascript:void(0)\" onclick=\"history.back();\">\
Back\
</a>\
</span>\
</div>\
<link rel=\"stylesheet\" type=\"text/css\" \
href=\"{root_path}settings{suffix}.css\">\
<script defer src=\"{root_path}settings{suffix}.js\"></script>",
root_path = page.static_root_path.unwrap_or(""),
suffix = page.resource_suffix,
)

View File

@ -206,22 +206,8 @@
];
// Then we build the DOM.
let innerHTML = "";
let elementKind = "div";
if (isSettingsPage) {
elementKind = "section";
innerHTML = `<div class="main-heading">
<h1 class="fqn">
<span class="in-band">Rustdoc settings</span>
</h1>
<span class="out-of-band">
<a id="back" href="javascript:void(0)" onclick="history.back();">Back</a>
</span>
</div>`;
}
innerHTML += `<div class="settings">${buildSettingsPageSections(settings)}</div>`;
const elementKind = isSettingsPage ? "section" : "div";
const innerHTML = `<div class="settings">${buildSettingsPageSections(settings)}</div>`;
const el = document.createElement(elementKind);
el.id = "settings";
el.innerHTML = innerHTML;