2
0

newcontainer_resolve.htm 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <style>
  2. #dialog_reslov {
  3. position: absolute;
  4. top: 0;
  5. left: 0;
  6. bottom: 0;
  7. right: 0;
  8. background: rgba(0, 0, 0, 0.7);
  9. display: none;
  10. z-index: 20000;
  11. }
  12. #dialog_reslov .dialog_box {
  13. position: relative;
  14. background: rgba(255, 255, 255);
  15. top: 10%;
  16. width: 50%;
  17. margin: auto;
  18. display: flex;
  19. flex-wrap: wrap;
  20. height:auto;
  21. align-items: center;
  22. }
  23. #dialog_reslov .dialog_line {
  24. margin-top: .5em;
  25. margin-bottom: .5em;
  26. margin-left: 2em;
  27. margin-right: 2em;
  28. }
  29. #dialog_reslov .dialog_box>h4,
  30. #dialog_reslov .dialog_box>p,
  31. #dialog_reslov .dialog_box>div {
  32. flex-basis: 100%;
  33. }
  34. #dialog_reslov .dialog_box>img {
  35. margin-right: 1em;
  36. flex-basis: 32px;
  37. }
  38. body.dialog-reslov-active {
  39. overflow: hidden;
  40. height: 100vh;
  41. }
  42. body.dialog-reslov-active #dialog_reslov {
  43. display: block;
  44. }
  45. </style>
  46. <script>
  47. function close_reslov_dialog() {
  48. document.body.classList.remove('dialog-reslov-active')
  49. document.documentElement.style.overflowY = 'scroll'
  50. }
  51. function reslov_container() {
  52. let s = document.getElementById('cmd-line-status')
  53. if (!s)
  54. return
  55. let cmd_line = document.getElementById("dialog_reslov_text").value;
  56. if (cmd_line == null || cmd_line == "") {
  57. return
  58. }
  59. cmd_line = cmd_line.replace(/(^\s*)/g,"")
  60. if (!cmd_line.match(/^docker\s+(run|create)/)) {
  61. s.innerHTML = "<font color='red'><%:Command line Error%></font>"
  62. return
  63. }
  64. let reg_space = /\s+/g
  65. let reg_muti_line= /\\\s*\n/g
  66. // reg_rem =/(?<!\\)`#.+(?<!\\)`/g // the command has `# `
  67. let reg_rem =/`#.+`/g// the command has `# `
  68. cmd_line = cmd_line.replace(/^docker\s+(run|create)/,"DOCKERCLI").replace(reg_rem, " ").replace(reg_muti_line, " ").replace(reg_space, " ")
  69. console.log(cmd_line)
  70. window.location.href = '<%=luci.dispatcher.build_url("admin/docker/newcontainer")%>/' + encodeURI(cmd_line)
  71. }
  72. function clear_text(){
  73. let s = document.getElementById('cmd-line-status')
  74. s.innerHTML = ""
  75. }
  76. function show_reslov_dialog() {
  77. document.getElementById('dialog_reslov') || document.body.insertAdjacentHTML("beforeend", '<div id="dialog_reslov"><div class="dialog_box"><div class="dialog_line"></div><div class="dialog_line"><span><%:Plese input <docker create/run> command line:%></span><br /><span id="cmd-line-status"></span></div><div class="dialog_line"><textarea class="cbi-input-textarea" id="dialog_reslov_text" style="width: 100%; height:100%;" rows="15" onkeyup="clear_text()"></textarea></div><div class="dialog_line" style="text-align: right;"><input type="button" class="btn cbi-button cbi-button-apply" type="submit" value="<%:Submit%>" onclick="reslov_container()" /> <input type="button" class="btn cbi-button cbi-button-reset" type="reset" value="<%:Cancel%>" onclick="close_reslov_dialog()" /></div><div class="dialog_line"></div></div></div>')
  78. document.body.classList.add('dialog-reslov-active')
  79. let s = document.getElementById('cmd-line-status')
  80. s.innerHTML = ""
  81. document.documentElement.style.overflowY = 'hidden'
  82. }
  83. </script>
  84. <%+cbi/valueheader%>
  85. <input type="button" class="btn cbi-button cbi-button-apply" value="<%:Command line%>" onclick="show_reslov_dialog()" />
  86. <%+cbi/valuefooter%>