trunk/src/emu/webengine.c
| r32391 | r32392 | |
| 292 | 292 | return json_slider_handler(conn); |
| 293 | 293 | } |
| 294 | 294 | } |
| 295 | else if (!strncmp(conn->uri, "/keypost",8)) |
| 296 | { |
| 297 | // Is there any sane way to determine the length of the buffer before getting it? |
| 298 | // A request for a way was previously filed with the mongoose devs, |
| 299 | // but it looks like it was never implemented. |
| 300 | |
| 301 | // For now, we'll allow a paste buffer of 32k. |
| 302 | // To-do: Send an error if the paste is too big? |
| 303 | char cmd_val[32768]; |
| 304 | |
| 305 | int pastelength = mg_get_var(conn, "val", cmd_val, sizeof(cmd_val)); |
| 306 | if (pastelength > 0) { |
| 307 | machine().ioport().natkeyboard().post_utf8(cmd_val); |
| 308 | } |
| 309 | // Send HTTP reply to the client |
| 310 | mg_printf(conn, |
| 311 | "HTTP/1.1 200 OK\r\n" |
| 312 | "Content-Type: text/plain\r\n" |
| 313 | "Content-Length: 2\r\n" // Always set Content-Length |
| 314 | "\r\n" |
| 315 | "OK"); |
| 316 | |
| 317 | // Returning non-zero tells mongoose that our function has replied to |
| 318 | // the client, and mongoose should not send client any more data. |
| 319 | return MG_TRUE; |
| 320 | } |
| 321 | else if (!strncmp(conn->uri, "/keyupload",8)) |
| 322 | { |
| 323 | const char *upload_data; |
| 324 | int data_length, ofs = 0; |
| 325 | char var_name[100], file_name[255]; |
| 326 | while ((ofs = mg_parse_multipart(conn->content + ofs, conn->content_len - ofs, var_name, sizeof(var_name), file_name, sizeof(file_name), &upload_data, &data_length)) > 0) { |
| 327 | mg_printf_data(conn, "File: %s, size: %d bytes", file_name, data_length); |
| 328 | } |
| 329 | |
| 330 | // That upload_data contains more than we need. It also has the headers. |
| 331 | // We'll need to strip it down to just what we want. |
| 332 | |
| 333 | if ((&data_length > 0) && (sizeof(file_name) > 0)) |
| 334 | { |
| 335 | char paste_data[data_length]; |
| 336 | strncpy (paste_data, upload_data, data_length); |
| 337 | // Now paste the stripped down paste_data.. |
| 338 | machine().ioport().natkeyboard().post_utf8(paste_data); |
| 339 | } |
| 340 | return MG_TRUE; |
| 341 | } |
| 295 | 342 | else if (!strncmp(conn->uri, "/cmd",4)) |
| 296 | 343 | { |
| 297 | 344 | char cmd_name[64]; |
trunk/web/index.html
| r32391 | r32392 | |
| 79 | 79 | updateStatusBar('<b style="color: red;">Disconnected</b>','Exited','No Driver'); |
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | | |
| 82 | |
| 83 | 83 | function executeHardReset() |
| 84 | 84 | { |
| 85 | 85 | executeCommands("hardreset"); |
| r32391 | r32392 | |
| 202 | 202 | window.onload = function() { |
| 203 | 203 | startWebSocket(); |
| 204 | 204 | }; |
| 205 | |
| 206 | $(document).ready(function() { |
| 207 | $( '#pasteTextForm' ).submit(function( event ) |
| 208 | { |
| 209 | $.ajax({ |
| 210 | url: "/keypost", |
| 211 | type:'POST', |
| 212 | data: |
| 213 | { |
| 214 | val: pasteText.value |
| 215 | }, |
| 216 | success: function(msg) |
| 217 | { |
| 218 | } |
| 219 | }); |
| 220 | event.preventDefault(); |
| 221 | }); |
| 222 | }); |
| 223 | |
| 205 | 224 | </script> |
| 206 | 225 | |
| 207 | 226 | <!-- This begins the MAIN MENU page -------------------------------------------------------------------> |
| r32391 | r32392 | |
| 327 | 346 | <div class="ui-block-a"><a href="#savestatepanel" data-transition="fade" data-role="button">Save State</a></div> |
| 328 | 347 | <div class="ui-block-b"><a href="#loadstatepanel" data-transition="fade" data-role="button">Load State</a></div> |
| 329 | 348 | </div> |
| 349 | <h2>Paste/Upload Text</h2> |
| 350 | <div class="ui-grid-a"> |
| 351 | <div class="ui-block-a"><a href="#pastepanel" data-transition="fade" data-role="button">Paste Text</a></div> |
| 352 | <div class="ui-block-b"><a href="#uploadpastepanel" data-transition="fade" data-role="button">Upload Text</a></div> |
| 353 | </div> |
| 330 | 354 | <h2>Execution Control</h2> |
| 331 | 355 | <a href="javascript:executeCommands('togglepause');" data-role="button">Toggle Pause</a> |
| 332 | 356 | <a href="confirmexit.html" data-rel="dialog" data-role="button">Exit</a> |
| r32391 | r32392 | |
| 464 | 488 | <!-- This is here to prevent webkit from trying to put the last row of states under the bottom menu on small screens like phone--> |
| 465 | 489 | <br><br><br><br><br> |
| 466 | 490 | </div> |
| 467 | | |
| 491 | |
| 492 | <!-- This begins the Paste Text panel --------------------------------------------------------> |
| 493 | <div data-role="panel" id="pastepanel" data-position="left" data-display="overlay" data-theme="a"> |
| 494 | <h4>Paste Text to Keyboard</h4> |
| 495 | |
| 496 | <form id="pasteTextForm" action="#pastepanel" method="post"> |
| 497 | <div data-role="controlgroup" data-type="horizontal"> |
| 498 | <a href="" data-rel="close" data-role="button">Exit</a> |
| 499 | <input type="submit" value="Send"> |
| 500 | <input type="reset" value="Clear"> |
| 501 | </div> |
| 502 | <br> |
| 503 | <textarea id="pasteText" name="val"></textarea> |
| 504 | </form> |
| 505 | <!-- This is here to prevent webkit from trying to put the last row of states under the bottom menu on small screens like phone--> |
| 506 | <br><br><br><br><br> |
| 507 | </div> |
| 508 | |
| 509 | <!-- This begins the Upload Text panel --------------------------------------------------------> |
| 510 | <div data-role="panel" id="uploadpastepanel" data-position="left" data-display="overlay" data-theme="a"> |
| 511 | <h4>Upload Text to Keyboard</h4> |
| 512 | |
| 513 | <form method="post" action="/keyupload" enctype="multipart/form-data" target="uploadpastelog" data-ajax="false"> |
| 514 | <!-- note that we can't do file uploads via Ajax --> |
| 515 | <div data-role="controlgroup" data-type="horizontal"> |
| 516 | <a href="" data-rel="close" data-role="button">Exit</a> |
| 517 | <input type="submit" value="Upload" /> |
| 518 | </div> |
| 519 | <input type="file" name="file" /> <br/> |
| 520 | </form> |
| 521 | <!-- This is here to prevent webkit from trying to put the last row of states under the bottom menu on small screens like phone--> |
| 522 | <br><br><br><br><br> |
| 523 | </div> |
| 468 | 524 | </div> |
| 469 | 525 | <div data-theme="a" data-role="footer" data-position="fixed"> |
| 470 | 526 | <div data-role="navbar" data-iconpos="top"> |
| r32391 | r32392 | |
| 795 | 851 | </ul> |
| 796 | 852 | </div> |
| 797 | 853 | </div> |
| 798 | | <div data-role="content" id="logsmenucontent"> |
| 854 | <div data-role="content" id="logsmenucontent"> |
| 855 | <p>Paste Upload Log</p> <!-- Yeah, this'll need reworking later. --> |
| 856 | <iframe name="uploadpastelog" width="250" height="250"></iframe> |
| 799 | 857 | </div> |
| 800 | 858 | <div data-theme="a" data-role="footer" data-position="fixed"> |
| 801 | 859 | <div data-role="navbar" data-iconpos="top"> |