You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
2.6 KiB
94 lines
2.6 KiB
4 weeks ago
|
|
||
|
document.addEventListener('DOMContentLoaded', function() {
|
||
|
const links = document.querySelectorAll('.nav-pills .nav-link');
|
||
|
// Get the current page path
|
||
|
const currentPath = window.location.pathname;
|
||
|
links.forEach(link => {
|
||
|
// Compare the link's href with the current path
|
||
|
if (link.href.endsWith(currentPath)) {
|
||
|
link.classList.add('active');
|
||
|
} else {
|
||
|
link.classList.remove('active');
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
|
||
|
function showModal(message) {
|
||
|
// 设置 Modal 中的消息
|
||
|
document.getElementById('modalMessage').innerText = message;
|
||
|
|
||
|
// 显示 Modal
|
||
|
const responseModal = new bootstrap.Modal(document.getElementById('responseModal'));
|
||
|
responseModal.show();
|
||
|
}
|
||
|
|
||
|
//动态填充select控件
|
||
|
function set_select_data(select_ele_id,datas){
|
||
|
const select_Ele = document.getElementById(select_ele_id);
|
||
|
//清空老数据
|
||
|
select_Ele.innerHTML = '';
|
||
|
//添加列表
|
||
|
datas.forEach(option => {
|
||
|
const optionElement = document.createElement('option');
|
||
|
optionElement.textContent = option;
|
||
|
select_Ele.appendChild(optionElement);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
//设定选项选中状态
|
||
|
function set_select_selct(select_ele_id,option_str){
|
||
|
let bfind = false;
|
||
|
const select_Ele = document.getElementById(select_ele_id);
|
||
|
for(let i=0;i< select_Ele.options.length;i++){
|
||
|
if(select_Ele.options[i].value === option_str){
|
||
|
select_Ele.options[i].selected = true;
|
||
|
bfind = true;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
return bfind;
|
||
|
}
|
||
|
|
||
|
//将输入框内容转换为单精度型,若转换失败则返回0 -- 若需要整型,parseInt
|
||
|
function getInputValueAsFloat(id) {
|
||
|
var value = document.getElementById(id).value;
|
||
|
return value ? parseFloat(value) : 0;
|
||
|
}
|
||
|
|
||
|
//正则匹配IP是否合法 return true,false
|
||
|
function isValidIP(ip) {
|
||
|
const ipRegex = /^(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)$/;
|
||
|
return ipRegex.test(ip);
|
||
|
}
|
||
|
|
||
|
//post提交JSON数据
|
||
|
function postJson(url,data){
|
||
|
|
||
|
}
|
||
|
|
||
|
//post提交From数据 -- 返回数据是JSON
|
||
|
function postFrom(url,data){
|
||
|
fetch(url, {
|
||
|
method: 'POST',
|
||
|
body: data,
|
||
|
})
|
||
|
.then(response => response.json())
|
||
|
.then(data => {
|
||
|
const istatus = data.status;
|
||
|
alert(data.msg);
|
||
|
if(istatus == 1 ){
|
||
|
fetchModelData();
|
||
|
$('#updateMM').modal('hide');
|
||
|
}
|
||
|
})
|
||
|
.catch(error => {
|
||
|
console.error('Error:', error);
|
||
|
alert('升级失败,请重试。');
|
||
|
btn.disabled = false;
|
||
|
});
|
||
|
}
|
||
|
|
||
|
//get请求数据
|
||
|
function getDATA(url){
|
||
|
}
|