config.html 1015 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <html>
  2. <script src="./jquery.min.js"></script>
  3. <body>
  4. <input type="text" id="port" value="8887" />
  5. <button id="start" onclick="start()">Start</button>
  6. <button id="stop" onclick="stop()">Stop</button>
  7. </body>
  8. <script>
  9. msg_center.on((event, msg) => {
  10. console.log(msg);
  11. switch (msg.code) {
  12. case 100:
  13. $('#port')[0].value = msg.cfg.port;
  14. break;
  15. case 200:
  16. $('#start').hide();
  17. $('#stop').show();
  18. break;
  19. case 201:
  20. $('#start').show();
  21. $('#stop').hide();
  22. break;
  23. default:
  24. break;
  25. }
  26. });
  27. function start() {
  28. const port = $('#port')[0].value;
  29. msg_center.send({ code: 200, cfg: { port: port } });
  30. }
  31. function stop() {
  32. msg_center.send({ code: 201 });
  33. }
  34. $('#start').show();
  35. $('#stop').hide();
  36. msg_center.send({ code: 100 });
  37. </script>
  38. </html>