|
7 | 7 | <link rel="stylesheet" href="{{ $root }}static/spectre.min.css"> |
8 | 8 | <meta name="viewport" content="width=device-width, initial-scale=1" /> |
9 | 9 | <style type="text/css"> |
10 | | - @font-face { font-family: 'Inconsolata'; src: URL('{{ .root }}static/inconsolata.ttf') format('truetype'); } |
11 | | - .spacing-top { margin: 3px 0px 0px 0px !important; } |
12 | | - .spacing-left { margin: 0px 3px 0px 0px !important; } |
13 | | - .align-center { text-align: center; } |
14 | | - .navbar-fixed-height { height: 32px; } |
15 | | - .icon-height { height: 20px; } |
16 | | - .title-margin { margin-top: auto; margin-bottom: auto; margin-right: 10px; } |
17 | | - .md-heigh { height: 64px; } |
18 | | - .pipe { color: #e85600; border-color: #e85600; } |
19 | | - .pipe:hover { background: #e85600; border-color: #e85600; } |
20 | | - iframe { border: 0px; width: 100%; height: 100% } |
21 | | - .resizer { display: flex; margin: 0; padding: 0; resize: vertical; overflow: hidden } |
22 | | - .resizer > .resized { flex-grow: 1; margin: 0; padding: 0; border: 0 } |
23 | | - .syntax-menu { right: 35px; } |
24 | | - .align-right { text-align: right; } |
25 | | - textarea { |
26 | | - margin: 5px; |
27 | | - font-family: Inconsolata; |
28 | | - background-color: inherit; |
29 | | - color: inherit; |
30 | | - line-height: 8px; |
31 | | - resize: none; |
32 | | - } |
| 10 | + @font-face { font-family: 'Inconsolata'; src: URL('{{ .root }}static/inconsolata.ttf') format('truetype'); } |
| 11 | + .spacing-top { margin: 3px 0px 0px 0px !important; } |
| 12 | + .spacing-left { margin: 0px 3px 0px 0px !important; } |
| 13 | + .align-center { text-align: center; } |
| 14 | + .navbar-fixed-height { height: 32px; } |
| 15 | + .icon-height { height: 20px; } |
| 16 | + .title-margin { margin-top: auto; margin-bottom: auto; margin-right: 10px; } |
| 17 | + .md-heigh { height: 64px; } |
| 18 | + .pipe { color: #e85600; border-color: #e85600; } |
| 19 | + .pipe:hover { background: #e85600; border-color: #e85600; } |
| 20 | + iframe { border: 0px; width: 100%; height: 100% } |
| 21 | + .resizer { display: flex; margin: 0; padding: 0; resize: vertical; overflow: hidden } |
| 22 | + .resizer > .resized { flex-grow: 1; margin: 0; padding: 0; border: 0 } |
| 23 | + .syntax-menu { right: 35px; } |
| 24 | + .align-right { text-align: right; } |
| 25 | + textarea { |
| 26 | + margin: 5px; |
| 27 | + font-family: Inconsolata; |
| 28 | + background-color: inherit; |
| 29 | + color: inherit; |
| 30 | + line-height: 8px; |
| 31 | + resize: none; |
| 32 | + } |
| 33 | + .button-help { width: 32px; float: left; } |
| 34 | + .command-input { margin: 0px 0px 0px 36px; display: flex; width: calc(100% - 36px); min-width: 0; } |
| 35 | + .modal-box { width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.8); } |
| 36 | + .modal-search { width: 80%; height: 80%; margin: 10px; } |
| 37 | + .modal-results { width: 100%; max-height: 500px; position: initial; overflow-y: scroll; overflow-x: hidden; } |
| 38 | + .modal-results li { -webkit-user-select: text !important; -ms-user-select: text !important; user-select: text !important; } |
| 39 | + .modal-name-big { font-size: 20px; } |
| 40 | + .modal-name { color: #1447e6; font-weight: bold; font-family: Inconsolata; } |
| 41 | + .modal-args { color: #178236; font-style: italic; font-family: Inconsolata; } |
| 42 | + .modal-detail { width: 100%; margin: 10px 0px 0px 0px; } |
| 43 | + .modal-entry { width: 100%; margin: 0px 0px 0px 20px; list-style: none; } |
| 44 | + .modal-entry-text { min-width: 200px; display: inline-block; } |
| 45 | + .modal-searchbar { width: calc(100% - 36px); } |
| 46 | + .modal-close { float: right; width: 32px; } |
33 | 47 | </style> |
34 | 48 | <script> |
35 | 49 | function handle(obj) { |
|
108 | 122 | event.preventDefault(); |
109 | 123 | } |
110 | 124 | } |
| 125 | +{{ if $pipe }} |
| 126 | + var rizinCmds = JSON.parse({{ .cmds | stringify }}); |
| 127 | + var rizinCmdsList = Object.keys(rizinCmds); |
| 128 | + function openCmdHelp() { |
| 129 | + var modal = document.getElementById("command-help"); |
| 130 | + modal.className += " active"; |
| 131 | + var search = document.getElementById("search-focus"); |
| 132 | + search.focus(); |
| 133 | + } |
| 134 | + function closeCmdHelp() { |
| 135 | + var modal = document.getElementById("command-help"); |
| 136 | + modal.className = modal.className.replace(" active", ""); |
| 137 | + } |
| 138 | + function cmdAsText(parent, command) { |
| 139 | + var details = (command.details || []); |
| 140 | + var element = document.createElement('span'); |
| 141 | + element.className = "modal-name modal-name-big"; |
| 142 | + element.textContent = command.cmd; |
| 143 | + parent.appendChild(element); |
| 144 | + |
| 145 | + element = document.createElement('span'); |
| 146 | + element.className = "modal-args modal-name-big"; |
| 147 | + element.textContent = " " + command.args_str; |
| 148 | + parent.appendChild(element); |
| 149 | + |
| 150 | + if ((command.summary || "") != "") { |
| 151 | + element = document.createElement('div'); |
| 152 | + element.textContent = command.summary.replace(".", ".\n"); |
| 153 | + parent.appendChild(element); |
| 154 | + } |
| 155 | + if ((command.description || "") != "") { |
| 156 | + element = document.createElement('div'); |
| 157 | + element.textContent = command.description.replace(".", ".\n"); |
| 158 | + parent.appendChild(element); |
| 159 | + } |
| 160 | + for (var i = 0; i < details.length; i++) { |
| 161 | + var entries = (details[i].entries || []); |
| 162 | + var detail = document.createElement('ul'); |
| 163 | + detail.className = "modal-detail"; |
| 164 | + detail.textContent = details[i].name; |
| 165 | + parent.appendChild(detail); |
| 166 | + for (var i = 0; i < entries.length; i++) { |
| 167 | + var entry = document.createElement('li'); |
| 168 | + entry.className = "modal-entry"; |
| 169 | + detail.appendChild(entry); |
| 170 | + |
| 171 | + var text = document.createElement('span'); |
| 172 | + text.className = "modal-entry-text"; |
| 173 | + entry.appendChild(text); |
| 174 | + |
| 175 | + if ((entries[i].text || "").length > 0) { |
| 176 | + element = document.createElement('span'); |
| 177 | + element.className = "modal-name"; |
| 178 | + element.textContent = entries[i].text; |
| 179 | + text.appendChild(element); |
| 180 | + } |
| 181 | + |
| 182 | + if ((entries[i].arg_str || "").length > 0) { |
| 183 | + element = document.createElement('span'); |
| 184 | + element.className = "modal-args"; |
| 185 | + element.textContent = entries[i].arg_str; |
| 186 | + text.appendChild(element); |
| 187 | + } |
| 188 | + |
| 189 | + if ((entries[i].comment || "").length > 0) { |
| 190 | + element = document.createElement('span'); |
| 191 | + element.style.display = "inline-block"; |
| 192 | + element.textContent = " # " + entries[i].comment; |
| 193 | + entry.appendChild(element); |
| 194 | + } |
| 195 | + } |
| 196 | + } |
| 197 | + } |
| 198 | + function findCmd(element) { |
| 199 | + var dropdown = document.getElementById("dropdown-results"); |
| 200 | + var results = document.getElementById("search-results"); |
| 201 | + results.innerHTML = ""; |
| 202 | + var tokens = element.value.split(/\s+/); |
| 203 | + for (var i = 0, count = 0; i < rizinCmdsList.length; i++) { |
| 204 | + var key = rizinCmdsList[i]; |
| 205 | + var descr = rizinCmds[key].description || ""; |
| 206 | + var summr = rizinCmds[key].summary || ""; |
| 207 | + var found = true; |
| 208 | + for (var j = 0; j < tokens.length; j++) { |
| 209 | + if (key.indexOf(tokens[j]) < 0 && descr.indexOf(tokens[j]) < 0 && summr.indexOf(tokens[j]) < 0) { |
| 210 | + found = false; |
| 211 | + break; |
| 212 | + } |
| 213 | + } |
| 214 | + if (!found) { |
| 215 | + continue; |
| 216 | + } |
| 217 | + var li = document.createElement('li'); |
| 218 | + if (count > 0) { |
| 219 | + li.className = "divider"; |
| 220 | + results.appendChild(li); |
| 221 | + li = document.createElement('li'); |
| 222 | + } |
| 223 | + li.className = "menu-item"; |
| 224 | + cmdAsText(li, rizinCmds[key]); |
| 225 | + results.appendChild(li); |
| 226 | + count++; |
| 227 | + } |
| 228 | + if (dropdown.className.indexOf(" active") < 0) { |
| 229 | + dropdown.className += " active"; |
| 230 | + } |
| 231 | + } |
| 232 | +{{ end }} |
111 | 233 | </script> |
112 | 234 | </head> |
113 | 235 | <body> |
|
169 | 291 | {{ if $pipe }} |
170 | 292 | |
171 | 293 | <a class="btn" href="#" onclick="newcm()"><i class="icon icon-resize-horiz">Command Line</i> Command Line</a> |
| 294 | + |
| 295 | + <a class="btn" href="#" onclick="openCmdHelp()"><i class="icon icon-search">Help</i> Help</a> |
172 | 296 | {{ end }} |
173 | 297 | </div> |
174 | 298 | </div> |
175 | 299 | </div> |
| 300 | +{{ if $pipe }} |
| 301 | + <div id="command-help" class="modal modal-box"> |
| 302 | + <div class="modal-content modal-search" onclick="" style="z-index: 999999;"> |
| 303 | + <div class="modal-body"> |
| 304 | + <div class="content"> |
| 305 | + <div class="dropdown" id="dropdown-results" style="width: 100%; height: 100%; max-height: 500px;"> |
| 306 | + <button class="btn btn-primary modal-close" onclick="closeCmdHelp()">×</button> |
| 307 | + <input class="form-input modal-searchbar" id="search-focus" onchange="findCmd(this);" onkeypress="findCmd(this);" onpaste="findCmd(this);" oninput="findCmd(this);" value="" placeholder="Search for a command or keyword in a description"/> |
| 308 | + <ul class="modal-results menu active" id="search-results"></ul> |
| 309 | + </div> |
| 310 | + </div> |
| 311 | + </div> |
| 312 | + </div> |
| 313 | + </div> |
| 314 | +{{ end }} |
176 | 315 | </section> |
177 | 316 | </section> |
178 | 317 | </body> |
|
0 commit comments