File: s7webserver_repl.html

package info (click to toggle)
snd 26.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 44,044 kB
  • sloc: ansic: 291,996; lisp: 260,569; ruby: 71,134; sh: 3,293; fortran: 2,342; csh: 1,067; cpp: 294; makefile: 294; python: 87; xml: 27; javascript: 1
file content (122 lines) | stat: -rw-r--r-- 3,723 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<!DOCTYPE html>

<!-- This file is based on the "echo.html" example in jq-console: http://replit.github.io/jq-console/ -->

<html>
  <head>
    <style>
    html, body {
      background-color: #333;
      color: white;
      font-family: monospace;
      margin: 0;
      padding: 0;
    }
    /* The console container element */
    #console {
      height: 400px;
      width: 750px;
      position:relative;
      background-color: black;
      border: 2px solid #CCC;
      margin: 0 auto;
      margin-top: 50px;
    }
    /* The inner console element. */
    .jqconsole {
        padding: 10px;
    }
    /* The cursor. */
    .jqconsole-cursor {
        background-color: gray;
    }
    /* The cursor color when the console looses focus. */
    .jqconsole-blurred .jqconsole-cursor {
        background-color: #666;
    }
    /* The current prompt text color */
    .jqconsole-prompt {
        color: #0d0;
    }
    /* The command history */
    .jqconsole-old-prompt {
        color: #0b0;
        font-weight: normal;
    }
    /* The text color when in input mode. */
    .jqconsole-input {
        color: #dd0;
    }
    /* Previously entered input. */
    .jqconsole-old-input {
        color: #bb0;
        font-weight: normal;
    }
    /* The text color of the output. */
    .jqconsole-output {
        color: white;
    }
    </style>
  </head>
  <body>

    <div id="console"></div>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="jqconsole.min.js" type="text/javascript" charset="utf-8"></script>
    <script>

     $(function () {
         function formatErrorMessage(jqXHR, exception) { // function copied from http://stackoverflow.com/questions/377644/jquery-ajax-error-handling-show-custom-exception-messages
             if (jqXHR.status === 0) {
                 return ('Not connected.\nPlease verify your network connection.');
             } else if (jqXHR.status == 404) {
                 return ('The requested page not found. [404]');
             } else if (jqXHR.status == 500) {
                 return ('Internal Server Error [500].');
             } else if (exception === 'parsererror') {
                 return ('Requested JSON parse failed.');
             } else if (exception === 'timeout') {
                 return ('Time out error.');
             } else if (exception === 'abort') {
                 return ('Ajax request aborted.');
             } else {
                 return ('Uncaught Error.\n' + jqXHR.responseText);
             }
         }

        var jqconsole = $('#console').jqconsole('S7 scheme\n', '>>> ');
        var startPrompt = function () {
          // Start the prompt with history enabled.
          jqconsole.Prompt(true, function (input) {
            // Output input with the class jqconsole-output.
              $.ajax({
                  type: "POST",
                  contentType: "text/plain",
                  data: input,
                  dataType: "text",
                  url: url.value,
                  success: function (data, status, xhr) {
                      jqconsole.Write(data+"\n");
                  },
                  error: function (xhr, status, thrown) {
                      jqconsole.Write(formatErrorMessage(xhr, status)+"\n")
                  }
              });

            startPrompt();
          });
        };
        startPrompt();
      });
    </script>

    <center>
      URL: <input type="text" id="TEXTBOX_ID" value="http://localhost:6080">
      <script type="text/javascript">
        var url = document.getElementById('TEXTBOX_ID');
      </script>
      <br>
    </center>

</body>
</html>