001 : /*
002 :  * CSVの正しい読み方におけるプログラム変遷のためのスクリプト
003 :  *  Created : 2012.11.26
004 :  *  Modified : 2012.11.28
005 :  */
006 : 
007 : /**
008 :  * クラスCodeTransition
009 :  */
010 : function CodeTransitionViewer(idString, codeArray)
011 : {
012 :     /**
013 :      * 処理対象のエリア
014 :      */
015 :     this.id = idString;
016 :     
017 :     /**
018 :      * ソースコードの配列
019 :      */
020 :     this.codeArray = codeArray;
021 :     
022 :     /**
023 :      * 現在の表示インデックス(1 origin)
024 :      */
025 :     this.currentIndex = 1;
026 :     
027 :     /**
028 :      * プログラムの初期状態を表示する
029 :      */
030 :     this.transitionToFirst = function()
031 :     {
032 :         this.transitionTo(1);
033 :         return;
034 :     }
035 :     
036 :     /**
037 :      * プログラムの最終状態を表示する
038 :      */
039 :     this.transitionToLast = function()
040 :     {
041 :         this.transitionTo(this.codeArray.length);
042 :         return;
043 :     }
044 :     
045 :     /**
046 :      * 次のプログラムを表示する(エイリアス)
047 :      */
048 :     this.transitionNext = function()
049 :     {
050 :         this.transitionFollowing();
051 :         return;
052 :     }
053 :     
054 :     /**
055 :      * 次のプログラムを表示する
056 :      */
057 :     this.transitionFollowing = function()
058 :     {
059 :         this.transitionTo(this.currentIndex + 1);
060 :         return;
061 :     }
062 :     
063 :     /**
064 :      * 前のプログラムを表示する
065 :      */
066 :     this.transitionPrevious = function()
067 :     {
068 :         this.transitionTo(this.currentIndex - 1);
069 :         return;
070 :     }
071 :     
072 :     /**
073 :      * 指定インデックスのプログラムを表示する
074 :      */
075 :     this.transitionTo = function(anIndex)
076 :     {
077 :         anIndex = Math.min(Math.max(1, anIndex), this.getLength());
078 :         this.currentIndex = anIndex;
079 :         document.getElementById(this.id).innerHTML = this.codeArray[anIndex - 1];
080 :         return;
081 :     }
082 :     
083 :     /**
084 :      * プログラムの状態遷移数を応答する
085 :      */
086 :     this.getLength = function()
087 :     {
088 :         return this.codeArray.length;
089 :     }
090 :     
091 :     /**
092 :      * 現在のインデックスを応答する(1 origin)
093 :      */
094 :     this.getCurrentIndex = function()
095 :     {
096 :         return this.currentIndex;
097 :     }
098 :     
099 :     return;
100 : }
101 : 

This document was generated by NanigashiBiyori on 2012/11/28 at 19:08:52.