Pages

Showing posts with label Javascript. Show all posts
Showing posts with label Javascript. Show all posts

Monday, March 28, 2011

Javascript - Like Google

index.php


<html>
<head>
<title>
Javascript Update
</title>

</head>
<body>
<select id="name">
    <option value="aura">Aura</option>
    <option value="luna">Luna</option>
    <option value="lady">Lady</option>
</select>
<input type="button" value="Get" onclick="getData()"/>
<br/>
<input type="button" value="Last Name" onclick="lastName()"/>
<input type="button" value="City" onclick="city()"/>
<input type="button" value="Age" onclick="age()"/>
<script>
function getData(){
    var script = document.createElement('script');
    var name = document.getElementById('name');
    var head = document.getElementsByTagName('head')[0];
    head.appendChild(script);
    script.setAttribute('src','hello.php?fname='+name.value);
    alert('');
}
function lastName(){
    alert(data.lname);
}
function city(){
    alert(data.city);
}
function age(){
    alert(data.age);
}


</script>


</body>
</html>


hello.php

<?php

    $data = array(
        'luna' => array('maya','denpasar',24),
        'lady' => array('gaga','new york',24),
         'aura' => array('kasih','jakarta',25),
    );
   
    $fname = $_GET['fname'];
   
    $output = 'var data = {};';
    $out = array();
   
    foreach($data as $key => $value){
        if(strcmp($fname, $key) == 0){
            foreach($value as $v){
                $out[] = $v;
               
            }
        }
    }
    $output .= 'data.lname = "'.$out[0].'";';
                $output .= 'data.city = "'.$out[1].'";';
                $output .= 'data.age = "'.$out[2].'";';
   
    header('Content-type: text/javascript');
    echo $output;
?>
   

Friday, March 25, 2011

HTML5 - Lucia


var ctx = document.getElementById('canvas').getContext('2d');

grad = ctx.createLinearGradient(0,30,280,30);
grad.addColorStop(0.1, '#af8');
grad.addColorStop(0.5, '#fc0');
grad.addColorStop(1.0, '#faf');
ctx.fillStyle = grad;

ctx.fillRect(0,0,280,60)

ctx.fillStyle = '#a5f';
ctx.font = '30px arial';
ctx.fillText('Lucia Corporation',20, 40);

The above code will finish in like below:


Friday, March 18, 2011

PHP - Using SQLite3

/**
 * index.php
 */

<html>
<head>
<script src="jquery.js"></script>
<script>
function save(){
    var ajax = new XMLHttpRequest();
    var name = document.getElementById('name');
    var city = document.getElementById('city');
    var age = document.getElementById('age');
    var mode = 'write';
    

Wednesday, February 16, 2011

Front End Design

<div id="satu">
<h2>Technical Specification</h2>
<div id="list">

<div class="item">
<h3>The Current Priorities</h3>
<ul><li>Skripsi</li>
<li>Web Portfolio</li>
</ul>
</div>

<div class="item">
<h3>The Next Priorities</h3>
<ul><li>Jobs in hacker centric place</li>
<li>Get to the next stage of hacking skills</li>
<li>Get the certificates of Hacking</li>
</ul>
</div>

<div class="item">
<h3>In Americas</h3>
<ul><li>Jobs in NVidia</li>
<li>Building part-time technology business</li>
</ul>
</div>

<div class="item">
<h3>The Next Ahead</h3>
<ul><li>Big Business</li>
<li>Nta Fund</li>
</ul>
</div>


<style>
html, body, div, h1, h2, h3 { margin: 0px; }
ol, ul { list-style: square; padding: 0 0 0 15px; }
html { background: #eee; color: #333;}
#satu { margin: 20px; padding: 20px; -moz-box-shadow: 0 0 1px #aaa; background: white; -moz-border-radius: 4px; font: 12px sans-serif; }

#satu h2 { border-bottom: 1px solid #aaa; padding: 0 0 10 0px; margin: 0 0 20px; }
.item { float: left; width: 50%; margin: 0 0 15px; }
.item li { margin: 0 0 5px; }

</style>

<div style="clear: both; "></div>
</div>
</div>

Wednesday, January 19, 2011

Breadcum

<p>
    <a href="javascript:getCountry()">Home</a>
    <span id="country"></span> 
    <span id="state"></span>
    <span id="city"></span>
    <span id="company"></span>
</p>
<div id="list"></div>
<script>

var countries = ["usa","indonesia","japan"];
var states = [
  ["california", "new york", "texas"],
  ["east java", "south sumatra", "west java"],
  ["honsu", "kyusu"]
];
var cities = [
  [
    ["mountain view", "palo alto", "san jose"],
    ["nyc", "columbia", "rokefeller"],
    ["dallas", "austin"]
  ],
  [
    ["surabaya", "malang", "jember"],
    ["medan", "natal", "batak"],
    ["bandung", "cirebon", "bogor"]
  ],
  [
    ["kyoto","osaka"],
    ["tokyo"]
  ]
];
var companies = [
  [
    [
      ["<h1>HeadQuarter of Google</h1>"], 
      ["<h1>Yahoo Headquarter</h1>"],
      ["<h1>Adobe Base Camp</h1>"]
    ],
    [
      ["un is here","bloomberg is here"],
      ["univ of columbia"],
      ["rockefeller center"]
    ],
    [
      ["dell may be hee","large airport is here"],
      ["like name of you"]
    ]
  ],
  [
    [
      ["unair is here","its also"],
      ["unibraw is here","umm also"],
      ["just for unej"]
    ],
    [
      ["usu"],
      ["none"],
      ["none also"]
    ],
    [
      ["itb","unpad"],
      ["none"],
      ["ipb"]
    ]
  ],
  [
    [
      ["none"],
      ["none also"]
    ],
    [
      ["tokyo univ"]
    ]
  ]
];

function getCountry(){
    var list = document.getElementById('list');
    list.innerHTML = "";
    for(i=0;i<countries.length;i++){
        list.innerHTML = list.innerHTML +
          "<a href='javascript:getStates("+i+")'>"+ 
          countries[i] + "</a><br/>";
    }
    var country = document.getElementById('country');
    country.innerHTML = "";

    var state = document.getElementById('state');
    state.innerHTML = "";

    var city = document.getElementById('city');
    city.innerHTML = "";
}

function getStates(k){
    var list = document.getElementById('list');
    list.innerHTML = "";
    for(i=0;i<states[k].length;i++){
        list.innerHTML = list.innerHTML + 
          "<a href='javascript:getCities(" +k+ "," +i+ ")'>" +
          states[k][i] + "<br/>";
    }
    var country = document.getElementById('country');
    country.innerHTML = ">> <a  href='javascript:getCountry()'>"+
       "Country</a>";

    var state = document.getElementById('state');
    state.innerHTML = "";

    var city = document.getElementById('city');
    city.innerHTML = "";
}

function getCities(k,l){
    var list = document.getElementById('list');
    list.innerHTML = "";
    for(i=0;i<cities[k][l].length;i++){
    list.innerHTML = list.innerHTML + 
      "<a href='javascript:getCompanies(" +k+ "," +l+ ","
      +i+ ")'>"+ cities[k][l][i] + "<br/>";
}
    var state = document.getElementById('state');
    state.innerHTML = ">> <a href='javascript:getStates(" +k+ 
      ")'>States</a>";

    var city = document.getElementById('city');
    city.innerHTML = "";
}

function getCompanies(k,l,m){
    var list = document.getElementById('list');
    list.innerHTML = "";
    for(i=0;i<companies[k][l][m].length;i++){
        list.innerHTML = list.innerHTML + "<h1>" + 
        companies[k][l][m][i] + "</h1><br/>";
    }
    var state = document.getElementById('city');
    city.innerHTML = ">> <a href='javascript:getCities(" +k+ 
        "," +l+ ")'>Cities</a>";
}

getCountry()
</script>    

<style>
    a { text-decoration: none; text-transform: capitalize;}
    h1 { text-transform: capitalize; }
</style>   

Thursday, January 6, 2011

Pagination Using Javascript

function Pagination(d){
 this.data = d;
 this.item = 10;
 this.numPage = Math.ceil(this.data.length/this.item);
}

Pagination.prototype.setFirstPage = function(){
 var arr = new Array();
 for(i=0;i<this.item;i++){
  arr[i] = this.data[i];
 }
 return arr;
}

Pagination.prototype.setLastPage = function(){
 var arr = new Array();
 var startLastIndex = (this.numPage-1) * this.item;
 for(i=0;i<(this.data.length-startLastIndex);i++){
  arr[i] = this.data[startLastIndex];
  startLastIndex++;
 }
 return arr;
}

Pagination.prototype.next = function(){
 
}

Pagination.prototype.previous = function(){

}

Pagination.prototype.displayAtPage = function(n){
var arr = new Array();
 n = n-1;
 var startIndex = n * this.item;
 for(i=0;i<(this.item);i++){
  arr[i] = this.data[startIndex];
  startIndex++;
 }
 return arr;
}

Wednesday, January 5, 2011

Ajax Presentation

<div id="container">
    <div id="one">
        <a href="javascript:lol(0)">Home</a> |
        <a href="javascript:lol(1)">Page</a> |
        <a href="javascript:lol(2)">Setting</a>
        <div id="logout" style="display:inline; float: right; ">
            <a href="javascript:">Log Out</a>
        </div>
    </div>
    <div id="two">

    </div>
    <div id="three" style="width: 100%; height: 50px;">

    </div>

</div>

<style>
    div { margin: 0px; }
    body { font-family: arial; font-size: 12px; }
    a { text-decoration: none; }
    a:hover { text-decoration: underline; }
    #one { border-bottom: 1px solid #af5; padding: 0 0 3 0px;
    margin: 0 0 5 0px; }

</style>

<script>

var home = [
    "<a href=\"javascript:enter('fuchsia')\">Indonesia</a> | "
    +"<a href=\"javascript:enter('red')\">Malaysia</a> | "
    +"<a href=\"javascript:enter('cornsilk')\">Filipine</a>",

    "<a href=\"javascript:enter('pink')\">New Page</a> | "
    +"<a href=\"javascript:enter('yellow')\">Edit Page</a>",

    "<a href=\"javascript:enter('brown')\">Template</a> | "
    +"<a href=\"javascript:enter('lime')\">Layout</a>"
    ];

function lol(p){
    for(i=0;i<home.length;i++){
        if(i==p)
            document.getElementById('two').innerHTML = home[i];
    }



function enter(dd){
    document.body.style.backgroundColor = dd;
}

</script>

Sunday, January 2, 2011

Traffic Animation Using JS

/**
 * This framework provide simple traffic animation using
 * javascript style programming.
 * 
 * @author  : irfanudin ridho
 * @email   : irfan.ub@gmail.com
 * @date    : January 2, 2011
 * @version : 1.0
 */

<h1>Traffic Animation</h1>
<div id='satu'></div>


<script>

function TA(w,h){
    this.ta = document.createElement('div');
    this.ta.setAttribute('style','width:'+w+'; height:'+h+'; 
     padding: 2px; border:1px solid #aaa; position:relative;
     margin:0 auto;overflow: hidden;');
}

TA.prototype.create = function(){
    return this.ta;
};

TA.prototype.setMobil = function(lol){
    this.ta.appendChild(lol);
};


function Mobil(c,w,h){
    this.ta = document.createElement('div');
    this.ta.setAttribute('style','width:'+w+'; height: '+h+';
      background: '+c+'; position: relative; margin: 2px; ');
    this.i = 0;
}

Mobil.prototype.create = function(){
    return this.ta;
};

Mobil.prototype.run = function(s){
    this.ta.style.left = this.i;
    this.i = this.i + 1;
    var lol =  this;
    setTimeout(function(){lol.run(s);},1000/s);
};

var satu = document.getElementById('satu');
var lol = new TA('80%');
var a = new Mobil('red',30,10);
var b = new Mobil('blue',20,10);
var c = new Mobil('green',25,10);
var d = new Mobil('brown',25,10);
a.run(50);
b.run(70);
c.run(260);
d.run(40);                                                                        
lol.setMobil(a.create());
lol.setMobil(b.create());
lol.setMobil(c.create());
lol.setMobil(d.create());
satu.appendChild(lol.create());

</script>

Thursday, December 30, 2010

Grouping Algorithm Using Javascript

/**
 * @author  : irfanudin ridho
 * @email   : irfan.ub@gmail.com
 * @date    : December 29,2010
 * @version : 1.0
 *
 * This function will provide distinct selection algorithm.
 */

/**
 * Constructor service
 * @param data array of data
 */
function GroupingAlgorithm(data){
    this.data = data;
}

/**
 * a mehtod that provide base service to slice the data.
 * var data = [1,2,2,3,1,2]
 *          = [2,2,3,2]
 *          = [3]
 *          = []
 * @param varData array of data
 * @return sliced array
 */
GroupingAlgorithm.prototype.first = function(varData){
    var value = varData[0];
    var newData = new Array();
    var k = 0;
    for(i=1;i<varData.length;i++){
        if(varData[i]!=value){
            newData[k]=varData[i];
            k++;
        }
    }
    return newData;
};


/**
 * This function will do like what happend at SELECT DISTINCT 
 * in MySQL.
 * @return array unsorted distinct value;
 */
GroupingAlgorithm.prototype.getDistinctValue = function(){
    var rest = true;
    var distinctValue = new Array();
    var d = 0;
    var copyData = this.data;
    while(rest){
        distinctValue[d]=copyData[0];
        copyData = this.first(copyData);
        d++;
        if(copyData.length==0){
            rest = false;
        }

    }
    return distinctValue;
};

/**
 * A method to know how many occurence for specified value
 *
 * @return array of data
 */
GroupingAlgorithm.prototype.getTotalNumber = function(){
    var distinctData = this.getDistinctValue();
    var nTimes = new Array();
  
    for(i=0;i<distinctData.length;i++){
        var n = 0;
        for(j=0;j<this.data.length;j++){
            if(distinctData[i]==this.data[j]){
                n++;
            }
        }
        nTimes[i]=n;
    }
    return nTimes;
};
        

Selection Algorithm Using Java

/**
 * Selection Algorithm
 * This function provide service for selection algorithm.
 *
 * @author  : irfanudin ridho
 * @email   : irfan.ub@gmail.com
 * @date    : December 29, 2010
 * @version : 1.0
 */

/**
 * Constructor service
 * @param data array of data
 */
function DataAlgorithm(data){
    this.data = data;
}

/**
 * function to get min value from the data
 * @return min value of the data
 */
DataAlgorithm.prototype.getMinValue = function(){
    return this.data[this.getMinValueIndex()];
};

/**
 * function to get max value from the data
 * @return max value of the data
 */
DataAlgorithm.prototype.getMaxValue = function(){
    return this.data[this.getMaxValueIndex()];
};

/**
 * function to get index of the min value
 * @return number index of the min value
 */
DataAlgorithm.prototype.getMinValueIndex = function(){
    var minIndex = this.data[0];
    for(i=0;i<this.data.length;i++){
        if(this.data[i+1]<this.data[minIndex]){
            minIndex = i+1;
        }
    }
    return minIndex;
};

/**
 * method to get index of the max value
 * @return number index of the max value
 */
DataAlgorithm.prototype.getMaxValueIndex = function(){
    var maxIndex = this.data[0];
    for(i=0;i<this.data.length;i++){
        if(this.data[i+1]>this.data[maxIndex]){
            maxIndex = i+1;
        }
    }
    return maxIndex;
};
      

List In Javascript

/**
 * A List of ADT. This ADT works well like list in other library.
 *
 * @author  : irfanudin ridho
 * @email   : irfan.ub@gmail.com
 * @date    : December 31, 2010
 * @version : 1.0
 */

/**
 * Constructor service
 */
function List(){
    this.data = new Array();
}

/**
 * method to add an element to list
 *
 * @param item string,number,boolean value. element to be added
 */
List.prototype.add = function(item){
    var len = this.data.length;
    this.data[len] = item;
};

/**
 * method to remove an element from the list
 *
 * @param item string, number or boolean as what the list contains.
 */
List.prototype.remove = function(item){
    var newData = new Array();
    var len = this.data.length;
    var k = 0;
    for(i=0;i<len;i++){
        if(this.data[i]!=item){
            newData[k] = this.data[i];
            k++;
        }
    }
    this.data = newData;
};


/**
 * method to know how many elements in the list
 *
 * @return number number of elements
 */
List.prototype.size = function(){
    return this.data.length;
};

/**
 * method to give this list as an array
 *
 * @return an array
 */
List.prototype.toArray = function(){
    return this.data;
};
      

Queue In Javascript

/**
 * A Queue ADT. This ADT provide functionality for FIFO 
 * data structure.
 *
 * @author  : irfanudin ridho
 * @email   : irfan.ub@gmail.com
 * @date    : December 31, 2010
 * @version : 1.0
 */

/**
 * A constructor service.
 */
function Queue(){
    this.data = new Array();
}

/**
 * method to insert an element to the Queue
 *
 * @param item string, number, boolean element to be inserted.
 */
Queue.prototype.push = function(item){
    var len = this.data.length;
    var newData = new Array();
    newData[0] = item;
    for(i=0;i<len;i++){
        newData[i+1]=this.data[i];
    }
    this.data = newData;
};

/**
 * A method to remove the first item inserted.
 *
 * @return first element of the Queue.
 */
Queue.prototype.pop = function(){
    var len = this.data.length;
    var first = this.data[len-1];
    var newData = new Array();
    for(i=1;i<len;i++){
        newData[i-1]=this.data[i];
    }
    this.data = newData;
    return first;
};

/**
 * A method to get how many elements in the Queue
 *
 * @return number number of elements.
 */
Queue.prototype.size = function(){
    return this.data.length;
};

/**
 * A method to represent this queue as an array data structure.
 *
 * @return array of data
 */
Queue.prototype.toArray = function(){
    return this.data;
}

Stack In Javascript

/**
 * An ADT of Stack. This is an implementation of LIFO 
 * data structure.
 *
 * @author  : irfanudin ridho
 * @email   : irfan.ub@gmail.com
 * @date    : December 31, 2010
 * @version : 1.0
 */

/**
 * A constructor service.
 */
function Stack(){
    this.data = new Array();
}

/**
 * A method to insert an element to the top position.
 *
 * @param item string, number or boolean value to be inserted
 */
Stack.prototype.push = function(item){
    var len = this.data.length;
    this.data[len]=item;
};

/**
 * A method to get the top position from the stack. As well as
 * to remove it.
 *
 * @return the value of the top position.
 */
Stack.prototype.pop = function(){
    var len = this.data.length;
    var last = this.data[len-1];
    var newStack = new Array();
    for(i=0;i<len-1;i++){
        newStack[i]=this.data[i];
    }
    this.data = newStack;
    return last;
};

/**
 * A method to get the size of elements in the Stack.
 *
 * @return number number of elements in Stack
 */
Stack.prototype.size = function(){
     return this.data.length;
};

/**
 * A method to convert the stack to be an array representation.
 *
 * @return an array of data.
 */
Stack.prototype.toArray = function(){
     return this.data;
}
         

Map In Javascript

/**
 * An ADT of Map. This ADT will do functionality as 
 * the key value ADT.
 *
 * @author  : irfanudin ridho
 * @email   : irfan.ub@gmail.com
 * @date    : December 31, 2010
 * @version : 1.0
 */

/**
 * A constructor service.
 */
function Map(){
    this.key = new Array();
    this.value = new Array();
}

/**
 * A method to add an elements to the Map
 *
 * @param k string, number key element
 * @param v string, number, boolean value element
 */
Map.prototype.add = function(k,v){
    var len = this.key.length;
    this.key[len] = k;
    this.value[len] = v;
};

/**
 * A method to get an element as suitable for the key
 *
 * @param k key of the element
 * @return value as suitable for the key.
 */
Map.prototype.get = function(k){
    var index = 0;
    for(i=0;i<k.length;i++){
        if(this.key[i]==k)
        index = i;
    }
    return this.value[index];
};
     

Manipulating Array

/**
 * This class provide functionality to manipulate array of 2
 * dimension
 *
 * @author  : irfanudin ridho
 * @email   : irfan.ub@gmail.com
 * @date    : December 31, 2010
 * @version : 1.0
 */

/**
 * A constructor service.
 */
function Arr(){

}

/**
 * A method to create a two dimensional array based on two array.
 * The format of the array is [n][2]. The first element is placed in
 * [n][0], while the second element is placed in [n][1]
 *
 * @param f array the first array
 * @param s array the second array
 * @return two dimensional of array
 */
Arr.prototype.twoDim = function(f,s){
    if(f.length!=s.length)
        return 'must same in length';
    var twoDimm = new Array();
    for(i=0;i<f.length;i++){
        twoDimm[i] = new Array();
        twoDimm[i][0] = f[i];
        twoDimm[i][1] = s[i];
    }
    return twoDimm;
};

/**
 * A method to get the first value of the second index
 * operator [n][0]
 *
 * @param data two dimensional of array in format [n][2]
 * @return first one dimensional of array in format[n]
 */
Arr.prototype.getFirst = function(data){
    var first = new Array();
    for(i=0;i<data.length;i++){
        first[i] = data[i][0];
    }
    return first;
};

/**
 * A method to get the second value of the second index 
 * operator [n][1]
 *
 * @param data two dimensional of array in format [n][2]
 * @return second one dimensional of array in format[n]
 */
Arr.prototype.getSecond = function(data){
    var second = new Array();
    for(i=0;i<data.length;i++){
        second[i] = data[i][1];
    }
    return second;
};

Grouping Algorithm

/**
 * Grouping Algorithm
 * This algorithm will do select just a distinct value of the data.
 *
 * @author  : irfanudin ridho
 * @email   : irfan.ub@gmail.com
 * @date    : December 31, 2010
 * @version : 2.0
 */

/**
 * A constructor service.
 *
 * @param data array of data.
 */
function Grouping(data){
    this.data = data;
}

/**
 * A private method that provide slice functionality of the 
 * array of data
 *
 * @param data data to be sliced.
 * @return sliced of array
 */
Grouping.prototype.slice = function(data){
    var value = data[0];
    var newData = new Array();
    var k = 0;
    for(i=1;i<data.length;i++){
        if(data[i]!=value){
            newData[k]=data[i];
            k++;
        }
    }
    return newData;
};

/**
 * A method that gives what this class intended. 
 * This gives a distinct
 * value of array in the form of array.
 *
 * @return distinct value of array
 */
Grouping.prototype.create = function(){
    var dataValue = new Array();
    var k = 0;
    var loop = true;
    var data = this.data;
    while(loop){
        dataValue[k] = data[0];
        data = this.slice(data);
        k++;
        if(data.length==0)
            loop = false;
        }
        return dataValue;
};


/**
 * This method provide serive on how many a value counting in the data.
 *
 * @return array counting value.
 */
Grouping.prototype.valueCounting = function(){
    var groupedData = this.create();
    var countValue = new Array();
    var data = this.data;
    for(i=0;i<groupedData.length;i++){
        var k = 1;
        for(j=0;j<data.length;j++){
            if(groupedData[i]==data[j]){
                countValue[i]=k;
                k++;
            }
        }
    }
    return countValue;
};


/**
 * A method to map distinct value and how many occurence of 
 * the value
 * in the data
 *
 * @return two dimensional array in the form [n][2]
 */
Grouping.prototype.mapping = function(){
    var data = this.data;
    var dimData = new Array();
    var value = this.create();
    var countValue = this.valueCounting();
    var len = value.length;
    for(i=0;i<len;i++){
        dimData[i] = new Array();
        dimData[i][0] = value[i];
        dimData[i][1] = countValue[i];
    }
    return dimData;
};

Tuesday, December 28, 2010

Rotating Algorithm Using JS

/**
 * This function will do rotate element of the data.
 * If the step of rotate, n, is equal length of data-1, the data
 * will be reversed.
 * 
 * @author  : irfanudin ridho
 * @email   : irfan.ub@gmail.com
 * @date    : December 29, 2010
 * @version : 1.0
 */

/**
 * @param data array of data
 * @param n number step to rotate
 * @return datas new rotated data in n step
 */
function Rotate(data,n){
    var datas = new Array();
    for(i=n;i<data.length;i++){
       datas[i] = data[i-n];
    }
    for(i=0;i<n;i++){
        datas[i]= data[data.length-1-i];
    }
    return datas;
}

Monday, December 27, 2010

Simple Substitution Cipher

/**
 * Function that provide substitution encryption and decryption
 * algorithm.
 * 
 * @author  : irfanudin ridho
 * @email   : irfan.ub@gmail.com
 * @date    : December 28, 2010
 * @version : 1.0
 */


/**
 * @param string text either plaintext or encrypted text
 * /
function SubstitutionCipher(text){
    this.text = text;
}


/**
 * @return encrypted string
 */
SubstitutionCipher.prototype.encrypt = function(){

    var encrypted = this.text.replace(/a/g,'1');
    encrypted = encrypted.replace(/e/g,'2');
    encrypted = encrypted.replace(/i/g,'3');
    encrypted = encrypted.replace(/o/g,'4');
    encrypted = encrypted.replace(/u/g,'5');
    encrypted = encrypted.replace(/ /g,'6');

    return encrypted;
};


/**
 * @return plaintext 
 */
SubstitutionCipher.prototype.decrypt = function(){

    var decrypted = this.text.replace(/1/g,'a');
    decrypted = decrypted.replace(/2/g,'e');
    decrypted = decrypted.replace(/3/g,'i');
    decrypted = decrypted.replace(/4/g,'o');
    decrypted = decrypted.replace(/5/g,'u');
    decrypted = decrypted.replace(/6/g,' ');

    return decrypted;
};
      

Polinomial Differentiation Using JS

/**
 * This function will do polinomial differentioation.
 * 
 * @author  : irfanudin ridho
 * @email   : irfan.ub@gmail.com
 * @date    : December 28, 2010
 * @version : 1.0
 */




function Polinomial(){
    var x = new Array();
    x[0] = 1;
    var dx = 0.1;
    var y = new Array();
    var fx = 2*x[0];
    y[0] = 1;
    for(i=1;i<12;i++){
        x[i] = x[i-1]+dx;                   //1.1 - 1.2 - 1.3
        y[i]=y[i-1]+dx-fx;
       fx = 2*x[i];
    }
}
                           

Linear Eq Using Numerical Method

/**
 * Function for solving linear equation using numerical method. 
 * 
 * @author  : irfanudin ridho
 * @email   : irfan.ub@gmail.com
 * @date    : December 28, 2010
 * @version : 1.0
 */


/**
 * @return x number value expected
 */
function getByNumericalMethod(){
    var x=100;
    for(i=0;i<110;i++){
        var y = x-10;
        if(y>0)
            x--;
        else if(y<0)
            x++;
   }
   return x;
}