From f19bd3933b2a38c0b0e4f79822e25f19eb51b5ef Mon Sep 17 00:00:00 2001 From: smshine Date: Sat, 7 Feb 2026 11:00:48 +0800 Subject: [PATCH] ffff --- module.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/module.js b/module.js index 8c68adb..562b059 100644 --- a/module.js +++ b/module.js @@ -45,18 +45,23 @@ M.mod_programming.init_history = function(Y) { var r = Y.all('.diff1'); if (r.size() > 0) { var firstDiff = r.item(0); - if (firstDiff) { + if (firstDiff && firstDiff.hide) { firstDiff.hide(); } } r = Y.all('.diff2'); if (r.size() > 0) { var lastDiff = r.item(r.size() - 1); - if (lastDiff) { + if (lastDiff && lastDiff.hide) { lastDiff.hide(); } } + var historyForm = Y.one('#history-diff-form'); + if (!historyForm) { + return; + } + var is_history_diff_form_submitable = function() { var f1 = false, f2 = false; Y.all('.diff1').each(function(node) { @@ -71,11 +76,14 @@ M.mod_programming.init_history = function(Y) { return f1 && f2 && f1.get('value') != f2.get('value'); }; - Y.one('#history-diff-form').on('submit', is_history_diff_form_submitable); + historyForm.on('submit', is_history_diff_form_submitable); - Y.all('#history-diff-form input[type=radio]').each(function(node) { + historyForm.all('input[type=radio]').each(function(node) { node.on('change', function() { - var btn = Y.one('#history-diff-form input[type=submit]'); + var btn = historyForm.one('input[type=submit]'); + if (!btn) { + return; + } if (is_history_diff_form_submitable()) { btn.removeAttribute('disabled'); } else { @@ -84,7 +92,10 @@ M.mod_programming.init_history = function(Y) { }); }); - Y.one('#history-diff-form input[type=submit]').setAttribute('disabled', true); + var submitBtn = historyForm.one('input[type=submit]'); + if (submitBtn) { + submitBtn.setAttribute('disabled', true); + } }; M.mod_programming.init_reports_detail = function(Y) {