$html>
$head>
$title>Struktur Data Linked List$/title>
$/head>
$body>
$script language = "JavaScript">
$!--
function DoublyLinkedList()
{
this._Kepala = null;
this._Ekor = null;
this._Panjang = 0;
}
DoublyLinkedList.prototype =
{
constructor: DoublyLinkedList,
Tambah: function (data)
{
var node = {data: data, next: null, prev: null};
if (this._Panjang == 0)
{
this._Kepala = node;
this._Ekor = node;
}
else
{
this._Ekor.next = node;
node.prev = this._Ekor;
this._Ekor = node;
}
this._Panjang++;
},
ItemList: function(index)
{
if (index > -1 && index $ this._Panjang)
{
var NodeTanda = this._Kepala,
i = 0;
while(i++ $ index)
{
NodeTanda = NodeTanda.next;
}
return NodeTanda.data;
}
else
{
return null;
}
},
Buang: function(index){
if (index > -1 && index $ this._Panjang)
{
var NodeTanda = this._Kepala, i = 0;
if (index === 0)
{
this._Kepala = NodeTanda.next;
if (!this._Kepala)
{
this._Ekor = null;
}
else
{
this._Kepala.prev = null;
}
}
else
if (index === this._Panjang -1)
{
NodeTanda = this._Ekor;
this._Ekor = NodeTanda.prev;
this._Ekor.next = null;
}
else
{
while(i++ $ index)
{
NodeTanda = NodeTanda.next;
}
NodeTanda.prev.next = NodeTanda.next;
}
this._Panjang--;
return NodeTanda.data;
}
else
{
return null;
}
},
Ukuran: function(){
return this._Panjang;
},
toArray: function(){
var result = [],
NodeTanda = this._Kepala;
while(NodeTanda){
result.push(NodeTanda.data);
NodeTanda = NodeTanda.next;
}
return result;
},
toString: function(){
return this.toArray().toString();
}
}
var List = new DoublyLinkedList();
List.Tambah("Teknik Informatika");
List.Tambah("Teknik Komputer");
List.Tambah("Komputerisasi Akuntansi");
List.Tambah("Computer Networking");
document.write("Isi LinkedList $br>");
document.write("--------------- $br>");
for (i=0; i$4; i++)
{
document.write(List.ItemList(i) + "$br>") ;
}
document.write("--------------- $br>");
alert("Isi LinkedList Awal =" + List.ItemList(0));
alert("ItemList 1 pada Linked List diBuang, yaitu = " +List.ItemList(1));
List.Buang(1);
document.write("$br>Isi LinkedList Terakhir $br>");
document.write("--------------- $br>");
for (i=0; i$4; i++)
{
document.write(List.ItemList(i) + "$br>") ;
}
document.write("--------------- $br>");
//-->
$/script>
$/body>
$/html>
jason..mraz..i'm..yours
Sabtu, 13 Juni 2009
Buka Link Google pake Dinamit
$HTML>
$HEAD>$TITLE>High Explosive Link: charge your links with dynamite$/TITLE>
$SCRIPT>
$!-- Beginning of JavaScript -
// The width of your image (pixels)
var imgwidth=120
// The height of your image (pixels)
var imgheight=60
// The URL of the sliced image
var imgurl="linkexploder.gif"
// The URL of the redirection link
var redirurl="http://www.google.com"
// Final horizontal position of the image: distance to the left margin of the window
var x_finalpos=240
// Final vertical position of the image: distance to the top margin of the window
var y_finalpos=80
// Number of sliced cells (the higher this number the slower the script)
var x_slices=8
// Number of sliced rows (the higher this number the slower the script)
var y_slices=4
// Speed of explosion
var pause=10
// Do not change the variables below
var marginright
var width_slice=Math.floor(imgwidth/x_slices)
var height_slice=Math.floor(imgheight/y_slices)
var cliptop=0
var clipbottom=height_slice
var clipleft=0
var clipright=width_slice
var spancounter=0
var x_random=new Array()
var y_random=new Array()
var max_explsteps=15
var i_explsteps=0
function initiate() {
spancounter=0
for (i=0;i$=y_slices-1;i++) {
for (ii=0;ii$=x_slices-1;ii++) {
x_random[spancounter]=Math.ceil(240*Math.random())-120
y_random[spancounter]=Math.ceil(240*Math.random())-120
spancounter++
}
}
}
function explode_IE() {
spancounter=0
if (i_explsteps$=max_explsteps) {
for (i=0;i$=y_slices-1;i++) {
for (ii=0;ii$=x_slices-1;ii++) {
var thisspan=eval("document.all.span"+spancounter+".style")
thisspan.posLeft+=x_random[spancounter]
thisspan.posTop+=y_random[spancounter]
spancounter++
}
}
i_explsteps++
var timer=setTimeout("explode_IE()",pause)
}
else {
spancounter=0
for (i=0;i$=y_slices-1;i++) {
for (ii=0;ii$=x_slices-1;ii++) {
var thisspan=eval("document.all.span"+spancounter+".style")
thisspan.posLeft=-5000
spancounter++
}
}
clearTimeout(timer)
var newwin=window.open(redirurl, "newindow",
"status=yes,toolbar=yes,menubar=yes,resizable=yes,scrollbars=yes,width=800,height=500,top=30,left=20")
}
}
// - End of JavaScript - -->
$/SCRIPT>
$META content="MSHTML 5.50.4522.1800" name=GENERATOR>$/HEAD>
$BODY text=#ffffff vLink=#ffffff aLink=#ffffff link=#ffffff bgColor=#000000
onload=initiate()>
$SCRIPT>
$!-- Beginning of JavaScript -
for (i=0;i$=y_slices-1;i++) {
for (ii=0;ii$=x_slices-1;ii++) {
marginright=screen.width+50
document.write("$span id='span"+spancounter+"' style='position:absolute;visibility:visible;
left:"+x_finalpos+"px;top:"+y_finalpos+"px;clip:rect("+cliptop+"px "+clipright+"px "+clipbottom+"px "+clipleft+"px)'>")
document.write("$a href='javascript:explode_IE()'>")
document.write("$img src='"+imgurl+"' border='0'>")
document.write("$/a>")
document.write("$/span>")
clipleft+=width_slice
clipright+=width_slice
spancounter++
}
clipleft=0
clipright=width_slice
cliptop+=height_slice
clipbottom+=height_slice
}
// - End of JavaScript - -->
$/SCRIPT>
$/BODY>
$/HTML>
$HEAD>$TITLE>High Explosive Link: charge your links with dynamite$/TITLE>
$SCRIPT>
$!-- Beginning of JavaScript -
// The width of your image (pixels)
var imgwidth=120
// The height of your image (pixels)
var imgheight=60
// The URL of the sliced image
var imgurl="linkexploder.gif"
// The URL of the redirection link
var redirurl="http://www.google.com"
// Final horizontal position of the image: distance to the left margin of the window
var x_finalpos=240
// Final vertical position of the image: distance to the top margin of the window
var y_finalpos=80
// Number of sliced cells (the higher this number the slower the script)
var x_slices=8
// Number of sliced rows (the higher this number the slower the script)
var y_slices=4
// Speed of explosion
var pause=10
// Do not change the variables below
var marginright
var width_slice=Math.floor(imgwidth/x_slices)
var height_slice=Math.floor(imgheight/y_slices)
var cliptop=0
var clipbottom=height_slice
var clipleft=0
var clipright=width_slice
var spancounter=0
var x_random=new Array()
var y_random=new Array()
var max_explsteps=15
var i_explsteps=0
function initiate() {
spancounter=0
for (i=0;i$=y_slices-1;i++) {
for (ii=0;ii$=x_slices-1;ii++) {
x_random[spancounter]=Math.ceil(240*Math.random())-120
y_random[spancounter]=Math.ceil(240*Math.random())-120
spancounter++
}
}
}
function explode_IE() {
spancounter=0
if (i_explsteps$=max_explsteps) {
for (i=0;i$=y_slices-1;i++) {
for (ii=0;ii$=x_slices-1;ii++) {
var thisspan=eval("document.all.span"+spancounter+".style")
thisspan.posLeft+=x_random[spancounter]
thisspan.posTop+=y_random[spancounter]
spancounter++
}
}
i_explsteps++
var timer=setTimeout("explode_IE()",pause)
}
else {
spancounter=0
for (i=0;i$=y_slices-1;i++) {
for (ii=0;ii$=x_slices-1;ii++) {
var thisspan=eval("document.all.span"+spancounter+".style")
thisspan.posLeft=-5000
spancounter++
}
}
clearTimeout(timer)
var newwin=window.open(redirurl, "newindow",
"status=yes,toolbar=yes,menubar=yes,resizable=yes,scrollbars=yes,width=800,height=500,top=30,left=20")
}
}
// - End of JavaScript - -->
$/SCRIPT>
$META content="MSHTML 5.50.4522.1800" name=GENERATOR>$/HEAD>
$BODY text=#ffffff vLink=#ffffff aLink=#ffffff link=#ffffff bgColor=#000000
onload=initiate()>
$SCRIPT>
$!-- Beginning of JavaScript -
for (i=0;i$=y_slices-1;i++) {
for (ii=0;ii$=x_slices-1;ii++) {
marginright=screen.width+50
document.write("$span id='span"+spancounter+"' style='position:absolute;visibility:visible;
left:"+x_finalpos+"px;top:"+y_finalpos+"px;clip:rect("+cliptop+"px "+clipright+"px "+clipbottom+"px "+clipleft+"px)'>")
document.write("$a href='javascript:explode_IE()'>")
document.write("$img src='"+imgurl+"' border='0'>")
document.write("$/a>")
document.write("$/span>")
clipleft+=width_slice
clipright+=width_slice
spancounter++
}
clipleft=0
clipright=width_slice
cliptop+=height_slice
clipbottom+=height_slice
}
// - End of JavaScript - -->
$/SCRIPT>
$/BODY>
$/HTML>
Single LinkedList
$html>
$head>
$title>Struktur Data Linked List $/title>$/head>
$body>
$script language = "JavaScript">
$!--
function LinkedList()
{
this._panjang = 0;
this._kepala = null;
}
LinkedList.prototype =
{
construktor : LinkedList,
//Membuat Metode Untuk Menambah Data kedalam List
Tambah : function (data)
{
//Membuat Node List
var node = {data:data,next: null },NodeTanda;
//Periksa Isi List
if (this._kepala===null)
{
this._kepala = node;
}
else
{
NodeTanda = this._kepala;
while (NodeTanda.next)
{
NodeTanda = NodeTanda.next;
}
NodeTanda.next = node;
}
this._panjang++;
},
//Membuat Metode Untuk Menunjuk Item Data
Item : function (index)
{
if (index > -1 && index $this._panjang)
{
var NodeTanda = this._kepala,
i = 0;
while (i ++ $ index)
{
NodeTanda = NodeTanda.next;
}
return NodeTanda.data;
}
else
{
return null;
}
},
//Membuat Metode Untuk Membuang Elemen List
Buang : function (index)
{
if (index > -1 && index $ this._panjang)
{
var NodeTanda = this._kepala,previous,i = 0;
if (index === 0 )
{
this._kepala = NodeTanda.next;
}
else
{
while (i++ $ index)
{
previous = NodeTanda;
NodeTanda = NodeTanda.next;
}
previous.next = NodeTanda.next;
}
this._panjang--;
return NodeTanda.data;
}
else
{
return null;
}
},
//Membuat Metode Untuk Mengetahui Jumlah Elemen List
Ukuran :function()
{
return this._panjang;
},
//Membuat Metode Untuk Membentuk Array
toArray : function()
{
var result = [],
NodeTanda = this._kepala;
while(NodeTanda){
result.push (NodeTanda.data);
NodeTanda = NodeTanda.next;
}
return result;
},
//Membuat Metode Untuk Konversi ke String
toString : function()
{
return this.toArray().toString();
}
};
//Lanjutan
var list = new LinkedList();
list.Tambah("Teknik Informatika");
list.Tambah("Teknik Komputer");
list.Tambah("Komputerisasi Akuntansi");
list.Tambah("Computer Networking");
document.write ("Isi LinkedList $br>") ;
document.write("----------------$br>");
for(i=0; i$4; i++)
{
document.write(list.Item(i) + "$br>");
}
document.write("----------------$br>");
alert("Isi LinkedList Awal="+ list.Item(0));
alert("Item 1 pada Linked list dibuang,yaitu =" +list.Item(1));
list.Buang(1);
document.write("Isi LinkedList Terakhir $br>");
document.write("------------------------$br>");
for(i=0;i$4;i++)
{
document.write(list.Item(i) + "$br>");
}
document.write("--------------------$br>");
//-->
$/script>
$/body>
$/html>
$head>
$title>Struktur Data Linked List $/title>$/head>
$body>
$script language = "JavaScript">
$!--
function LinkedList()
{
this._panjang = 0;
this._kepala = null;
}
LinkedList.prototype =
{
construktor : LinkedList,
//Membuat Metode Untuk Menambah Data kedalam List
Tambah : function (data)
{
//Membuat Node List
var node = {data:data,next: null },NodeTanda;
//Periksa Isi List
if (this._kepala===null)
{
this._kepala = node;
}
else
{
NodeTanda = this._kepala;
while (NodeTanda.next)
{
NodeTanda = NodeTanda.next;
}
NodeTanda.next = node;
}
this._panjang++;
},
//Membuat Metode Untuk Menunjuk Item Data
Item : function (index)
{
if (index > -1 && index $this._panjang)
{
var NodeTanda = this._kepala,
i = 0;
while (i ++ $ index)
{
NodeTanda = NodeTanda.next;
}
return NodeTanda.data;
}
else
{
return null;
}
},
//Membuat Metode Untuk Membuang Elemen List
Buang : function (index)
{
if (index > -1 && index $ this._panjang)
{
var NodeTanda = this._kepala,previous,i = 0;
if (index === 0 )
{
this._kepala = NodeTanda.next;
}
else
{
while (i++ $ index)
{
previous = NodeTanda;
NodeTanda = NodeTanda.next;
}
previous.next = NodeTanda.next;
}
this._panjang--;
return NodeTanda.data;
}
else
{
return null;
}
},
//Membuat Metode Untuk Mengetahui Jumlah Elemen List
Ukuran :function()
{
return this._panjang;
},
//Membuat Metode Untuk Membentuk Array
toArray : function()
{
var result = [],
NodeTanda = this._kepala;
while(NodeTanda){
result.push (NodeTanda.data);
NodeTanda = NodeTanda.next;
}
return result;
},
//Membuat Metode Untuk Konversi ke String
toString : function()
{
return this.toArray().toString();
}
};
//Lanjutan
var list = new LinkedList();
list.Tambah("Teknik Informatika");
list.Tambah("Teknik Komputer");
list.Tambah("Komputerisasi Akuntansi");
list.Tambah("Computer Networking");
document.write ("Isi LinkedList $br>") ;
document.write("----------------$br>");
for(i=0; i$4; i++)
{
document.write(list.Item(i) + "$br>");
}
document.write("----------------$br>");
alert("Isi LinkedList Awal="+ list.Item(0));
alert("Item 1 pada Linked list dibuang,yaitu =" +list.Item(1));
list.Buang(1);
document.write("Isi LinkedList Terakhir $br>");
document.write("------------------------$br>");
for(i=0;i$4;i++)
{
document.write(list.Item(i) + "$br>");
}
document.write("--------------------$br>");
//-->
$/script>
$/body>
$/html>
Langganan:
Postingan (Atom)