File indexing completed on 2024-04-28 15:23:05

0001 <html>
0002 <!--
0003 Javascript Konsole (c) 2001 Till Krech <till@snafu.de>
0004 Dieser Code unterliegt den Bedingungen der Gnu Public License Version 2.
0005 -->
0006 <head>
0007 <title>Javascript Konsole</title>
0008 <style type="text/css">
0009 code {
0010         color:#444488;
0011 }
0012 em {
0013         font-weight: bold;
0014 }
0015 </style>
0016 <script language="JavaScript">
0017 
0018 function do_eval() {
0019         var fo = document.forms.fo;
0020     fo.restyp.value = "";
0021     fo.field.value = "";
0022     var fo = document.fo;
0023     var expr = fo.zeile.value;
0024     var result = eval(expr);
0025     fo.restyp.value = typeof(result);
0026         var tuedel = "";
0027         if (typeof(result) == "string") {
0028                 tuedel = '"';
0029         }
0030     fo.field.value = tuedel + result + tuedel;
0031 }
0032 
0033 function do_properties() {
0034         var fo = document.forms.fo;
0035     fo.restyp.value = "";
0036     fo.field.value = "";
0037     var fo = document.fo;
0038     var expr = fo.zeile.value;
0039     var result = eval(expr);
0040         var i;
0041     fo.restyp.value = typeof(result);
0042     var fieldvalue = "";
0043         if (typeof(result) != "undefined") {
0044            for (i in result) {
0045                 var tuedel = "";
0046                 var propval = result[i];
0047                 if (typeof(propval) == "string") {
0048                         tuedel = '"';
0049                 }
0050                 fieldvalue +=
0051                         i
0052                         + " [" + typeof(propval) + "] = "
0053                         + tuedel + propval + tuedel + "\n";
0054            }
0055            fo.field.value = fieldvalue;
0056         }
0057 }
0058 
0059 
0060 </script>
0061 </head>
0062 <body bgcolor="#dddddd">
0063 <h1>JavaScript Konsole</h1>
0064 <form name="fo">
0065 <table bgcolor="#cccccc" cellspacing="1" cellpadding="8">
0066  <tr bgcolor="#ffeeee"><th  height="40" align="right">Expression</th><td><input name="zeile" type="text" size="60"></td></tr>
0067  <tr bgcolor="#eeeeee"><th align="right">Result Type</th><td><input name="restyp" readonly type="text" size="60"></td></tr>
0068  <tr bgcolor="#eeeeee"><th align="right">Result(s)</th><td><textarea readonly name="field" rows="10" cols="60"></textarea></td></tr>
0069 <tr bgcolor="#ffeeee"><td>&nbsp;</td><td>
0070  <input type="button" value="list properties" onclick="do_properties()">
0071  <input type="button" value="evaluate" onclick="do_eval()">
0072  <input type="reset" value="clear fields"
0073 </td></tr>
0074 </table>
0075 </form>
0076 <h2>Explanation</h2>
0077 <h3>Operation</h3>
0078 <blockquote>
0079 When <em>evaluate</em> is pressed, the given expression is evaluated and the result is displayed in the result(s) field.
0080 In case of <em>list properties</em> being pressed, the result of the expression is taken as an object
0081 and the objects properties are displayed with their type and value in the result(s) field.
0082 </blockquote>
0083 <h3>Expression</h3>
0084 <blockquote>
0085 Expression must be a valid javascript expression, e.g.<br><code>window</code>
0086 <br>or<br><code>document.body.innerHTML</code><br>or<br>
0087 <code>"Today: " + (new Date()).toString()</code><br>
0088 or<br>
0089 <code>"Cablecar".match(/ab.*c/)</code>
0090 <br>It is also possible to assign a value,
0091 e.g.<br><code>document.getElementsByTagName('H1').item(0).innerText="Hello World"</code><br>
0092 You may execute these examples by pasting them into the expression field.
0093 </blockquote>
0094 <h3>Result Type</h3>
0095 <blockquote>
0096 The type of the result of the given expression.
0097 </blockquote>
0098 <h3>Result(s)</h3>
0099 <blockquote>
0100 The result of the expression is implicitly converted to a primitive type by the javascript interpreter,
0101 if <em>evaluate</em> was pressed. When <em>list properties</em> was pressed, a <code>for (var i in obj)</code> loop
0102 is executed to list the properties. These object properties are in turn evaluated and their types and values
0103 are displayed.
0104 </blockquote>
0105 <p>
0106 <a href="mailto:till@snafu.de?subject=JavaScript%20Konsole">Till Krech</a>
0107 </p>
0108 <p>
0109 <br>
0110 </p>
0111 
0112 </body>
0113 </html>