Adapt to new markup format

This commit is contained in:
ZenithalHourlyRate 2023-02-26 21:32:11 +08:00 committed by Zenithal
parent a4fa1ceb21
commit 838cf7c830

View File

@ -8,29 +8,30 @@ $(document).ready(() => {
.find('table')
.addClass("table table-bordered table-striped");
var update_apt_file = (ev) => {
var sel = $(ev.target),
os_name=sel.find("option:selected").data('os'),
release_name=sel.find("option:selected").data('release'),
release_security=sel.find("option:selected").data('security'),
opt=sel.find('option:selected').data('opt'),
tmpl_selector=sel.data("template"),
target_selector=sel.data("target"),
apt_template=$.trim($(tmpl_selector).text()),
tmpl_data=$.extend({}, {
os_name: os_name,
release_name: release_name,
release_security: release_security,
}, opt),
apt_content=Mark.up(
apt_template,
tmpl_data
const update_target = (ev) => {
const sel = $(ev.target);
const target_selectors = sel.data("target").split(",");
for (const target_selector of target_selectors) {
const template_selector = $(target_selector).data("template");
const select_selectors = $(target_selector).data("select").split(",");
const template_data = {
"mirror": "{{ site.hostname }}/" + window.mirrorId,
};
for (const select_selector of select_selectors) {
const opt = $(select_selector).find('option:selected').data();
$.extend(template_data, opt);
}
const template = $.trim($(template_selector).text());
const content = Mark.up(
template,
template_data
);
$(target_selector).html(apt_content);
$(target_selector).html(content);
}
};
$("select.release-select").on('change', update_apt_file);
$("select.release-select").each((i, e) => {
$("select.content-select").on('change', update_target);
$("select.content-select").each((i, e) => {
$(e).trigger('change');
});