"Fossies" - the Fresh Open Source Software Archive

Member "snd-20.9/s7webserver/s7webserver_repl.html" (13 Oct 2018, 3723 Bytes) of package /linux/misc/snd-20.9.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) HTML source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 <!DOCTYPE html>
    2 
    3 <!-- This file is based on the "echo.html" example in jq-console: http://replit.github.io/jq-console/ -->
    4 
    5 <html>
    6   <head>
    7     <style>
    8     html, body {
    9       background-color: #333;
   10       color: white;
   11       font-family: monospace;
   12       margin: 0;
   13       padding: 0;
   14     }
   15     /* The console container element */
   16     #console {
   17       height: 400px;
   18       width: 750px;
   19       position:relative;
   20       background-color: black;
   21       border: 2px solid #CCC;
   22       margin: 0 auto;
   23       margin-top: 50px;
   24     }
   25     /* The inner console element. */
   26     .jqconsole {
   27         padding: 10px;
   28     }
   29     /* The cursor. */
   30     .jqconsole-cursor {
   31         background-color: gray;
   32     }
   33     /* The cursor color when the console looses focus. */
   34     .jqconsole-blurred .jqconsole-cursor {
   35         background-color: #666;
   36     }
   37     /* The current prompt text color */
   38     .jqconsole-prompt {
   39         color: #0d0;
   40     }
   41     /* The command history */
   42     .jqconsole-old-prompt {
   43         color: #0b0;
   44         font-weight: normal;
   45     }
   46     /* The text color when in input mode. */
   47     .jqconsole-input {
   48         color: #dd0;
   49     }
   50     /* Previously entered input. */
   51     .jqconsole-old-input {
   52         color: #bb0;
   53         font-weight: normal;
   54     }
   55     /* The text color of the output. */
   56     .jqconsole-output {
   57         color: white;
   58     }
   59     </style>
   60   </head>
   61   <body>
   62 
   63     <div id="console"></div>
   64     <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js" type="text/javascript" charset="utf-8"></script>
   65     <script src="jqconsole.min.js" type="text/javascript" charset="utf-8"></script>
   66     <script>
   67 
   68      $(function () {
   69          function formatErrorMessage(jqXHR, exception) { // function copied from http://stackoverflow.com/questions/377644/jquery-ajax-error-handling-show-custom-exception-messages
   70              if (jqXHR.status === 0) {
   71                  return ('Not connected.\nPlease verify your network connection.');
   72              } else if (jqXHR.status == 404) {
   73                  return ('The requested page not found. [404]');
   74              } else if (jqXHR.status == 500) {
   75                  return ('Internal Server Error [500].');
   76              } else if (exception === 'parsererror') {
   77                  return ('Requested JSON parse failed.');
   78              } else if (exception === 'timeout') {
   79                  return ('Time out error.');
   80              } else if (exception === 'abort') {
   81                  return ('Ajax request aborted.');
   82              } else {
   83                  return ('Uncaught Error.\n' + jqXHR.responseText);
   84              }
   85          }
   86 
   87         var jqconsole = $('#console').jqconsole('S7 scheme\n', '>>> ');
   88         var startPrompt = function () {
   89           // Start the prompt with history enabled.
   90           jqconsole.Prompt(true, function (input) {
   91             // Output input with the class jqconsole-output.
   92               $.ajax({
   93                   type: "POST",
   94                   contentType: "text/plain",
   95                   data: input,
   96                   dataType: "text",
   97                   url: url.value,
   98                   success: function (data, status, xhr) {
   99                       jqconsole.Write(data+"\n");
  100                   },
  101                   error: function (xhr, status, thrown) {
  102                       jqconsole.Write(formatErrorMessage(xhr, status)+"\n")
  103                   }
  104               });
  105 
  106             startPrompt();
  107           });
  108         };
  109         startPrompt();
  110       });
  111     </script>
  112 
  113     <center>
  114       URL: <input type="text" id="TEXTBOX_ID" value="http://localhost:6080">
  115       <script type="text/javascript">
  116         var url = document.getElementById('TEXTBOX_ID');
  117       </script>
  118       <br>
  119     </center>
  120 
  121 </body>
  122 </html>