c4se記:さっちゃんですよ☆

.。oO(さっちゃんですよヾ(〃l _ l)ノ゙☆)

.。oO(此のblogは、主に音樂考察Programming に分類されますよ。ヾ(〃l _ l)ノ゙♬♪♡)

音樂は SoundCloud に公開中です。

考察は現在は主に Scrapbox で公表中です。

Programming は GitHub で開發中です。

JavaScript手打ち電卓履歴つき #js

そういえば。ちょっとした確認には、以下のようなコードを使ってる。
手打ち電卓のようなものだけど。

<?xml version="1.0" encoding="UTF-8"?>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Contene-Type" content="text/html; charset=UTF-8"/>
    <meta http-equiv="Content-Script-Type" content="application/javascript"/>
    <meta http-equiv="Content-Style-Type" content="text/css"/>
    <script>
    var testc4sejs = {};
    window.onload = function(){
      testc4sejs.history = "";
      testc4sejs.result = "";
      testc4sejs.evaluate = function(){
        try{
          this.result = eval(document.console.code.value);
        }catch(e){
          document.console.history.value = document.console.history.value + e.toString();
          return e;
        }
        document.console.result.value = this.result.toString();
        this.history = this.result.toString()+"\n"+this.history;
        document.console.history.value = this.history;
      };
      testc4sejs.evaluateSimple = function(){
        try{
          this.result = eval(document.console.simplecode.value);
        }catch(e){
          document.console.history.value = document.console.history.value + e.toString();
          return e;
        }
        document.console.resultS.value = this.result.toString();
        this.history = this.result.toString()+"\n"+this.history;
        document.console.history.value = this.history;
      };
      testc4sejs.clearSimple = function(){
        document.console.simplecode.value = "";
        document.console.resultS.value = "";
      };
      testc4sejs.resetHistory = function(){
        this.history = "";
        document.console.history.value = "";
      };
      testc4sejs.history = document.console.history.value;
    }//onload
    </script>
    <style>
    body{
      font-size:9pt;
      line-height:1.2em;
    }
    input, textarea{font-size:8pt;}
    div{overflow:hidden;}
    div#title{
      position:absolute;
      z-index:4;
      margin:0;
      padding:0;
      height:2em;
      width:100%;
      top:0;
      right:0;
      bottom:auto;
      left:0;
      text-align:center;
    }
    div#console{
      position:absolute;
      z-index:3;
      margin:0 0 0 1px;
      padding:0;
      height:auto;
      width:auto;
      top:2em;
      right:auto;
      bottom:auto;
      left:0;
    }
    div#history{
      position:absolute;
      z-index:2;
      margin:0;
      padding:0;
      height:auto;
      width:20em;
      top:2em;
      right:0;
      bottom:auto;
      left:auto;
    }
    </style>
    <title>c4seMath console</title>
  </head>
  <body>
    <div id="title">
      <span style="color:#33f;">c</span><span style="color:#f00;">4</span><span style="color:#3f3;">s</span><span style="color:#fc0;">e</span>Math console
    </div>
    <form name="console">
      <div id="console">
        * Console *<br/>
        simple <input type="text" name="simplecode" size="90" value=""
                      onblur="javascript:testc4sejs.evaluateSimple()"/><br/>
        elpmis <input type="text" name="resultS" size="70"/>
               <input type="button" name="clearSimple" value="←clear↑"
                      onclick="javascript:testc4sejs.clearSimple()"/><br/>
        <br/>
        Code
        <input type="button" neme="evaluate" value="Evaluate↓"
               onclick="javascript:testc4sejs.evaluate()"/><br/>
        <textarea name="code" rows="30" cols="100"></textarea><br/>
        Result <input type="text" name="result" size="90"/><br/>
      </div>
      <div id="history">
        Result Histry
        <input type="button" name="resetHistory" value="clear history"
               onclick="javascript:testc4sejs.resetHistory()"/><br/>
        <textarea name="history" rows="40" cols="35"></textarea>
      </div>
    </form>
  </body>
</html>

もう一年来使ってるコード。

追記 20110122

コード改変自体は遥か以前だけど、ずっと使ってたエラー処理可コードへ改変。