| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- let activePageIntervalId = null;
- function showPage(pageId) {
- const pages = document.querySelectorAll('.page');
- number = 0
- pages.forEach(page => {
- page.classList.remove('active');
- button_id = pageId
- if (pageId == "page2") {
- setActivePage(function1, 1000)
- }
- if (pageId == "page3" || pageId == "page5") {
- setActivePage(function2, 1000)
- }
- if (pageId == "page4" || pageId == "page1") {
- setActivePage(function3, 1000)
- }
- });
- const selectedPage = document.getElementById(pageId);
- selectedPage.classList.add('active');
- }
- function function1() {
- ws.send(mk_hdr_bin(0, PKT_TYPE.PKT_TYPE_POWER_TOTAL, 0, 0, 0));
- }
- function function2() {
- ws.send(mk_hdr_bin(0, PKT_TYPE.PKT_TYPE_POWER_CH, 0, 0, 0));
- }
- function function3() {
- console.log(1)
- }
- function setActivePage(pageFunction, intervalTime) {
- // 停止之前活动的页面定时函数
- if (activePageIntervalId != null) {
- clearInterval(activePageIntervalId);
- }
- activePageIntervalId = setInterval(pageFunction, intervalTime);
- }
- document.addEventListener('DOMContentLoaded', () => {
- showPage('page1');
- });
|