hi allz.
I wrote a little page that converts normal letters into ...
yes, morse code. Don't ask me why I just thought I should do so.
I solved that problem by using two arrays (one is latin letters the
second is morse code. they have the same length and e in lain would be . in morse)
and checked the charAt(a position of the string) with all characters in the
latin-array to find its position and added the the code which has the same position
but in the morse array. At the end, the morsed sentence is put out.
It was easy to do so but, hmm, I could imagine that by finding the
ASCII value of the characters it would be even easier.
So, can you tell me how to find the ASCII value of characters??? puh-lea-zah!
here is that page I was talking about if you want to have a look at it:
--- page starts ---
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>morse.psychotenesis</TITLE>
<!--
<link rel="stylesheet" type="text/css" href="zcsszero.css">
-->
<style type="text/css">
body{background-color: black; color:white; font-family:Verdana; margin-top:0px; margin-left:0px;}
a{color:white;}
a:hover{color:white;}
.end{font-size:10px; color:#111111}
td{font-size:12px;}
a{font-weight:bold; text-decoration:none; color:white;}
a:hover{text-decoration:underline;}
#listing{position:absolute; top:30; left:30; visibility:visible;}
</style>
<script language="JavaScript" type="text/JavaScript"><!--
//arrays coutning values in latin letters ans morse.
var latin=new Array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z",0,1,2,3,4,5,6,7,8,9," ","ch","ä","ö","ü","å","é","ñ","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z");
var morse=new Array(".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--..","-----",".---- ","..---","...--","....-",".....","-....","--...","---..","----.","<br>","----",".-.-","---.","..--",".--.-","..-..","--.--",".-","-...","-.-.","-..",".","..-.","--.","....", "..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--..")
//other variables
var thisChar;
var thisMorse;
var tAfter="";
function init()
{
oAfter=new makeObj("after");
list()
}
//Makes browser object.
var b=new fBrowser();
function fBrowser()
{
this.dom=document.getElementById?1:0;
this.ie=document.all?1:0;
this.ns=document.layers?1:0;
this.bd=(this.gecko| |this.ie| |this.ns);
if(!this.bd){alert("Unidentified browser");}
return this
}
//Makes crossbrowser object.
function makeObj(obj)
{
this.css=b.gecko?document.getElementById(obj).style:b.ie?document.all[obj].style:b.ns?document.layers[obj]:0;
this.wref=b.gecko?document.getElementById(obj):b.ie?document.all[obj]:b.ns?document.layers[obj].document:0;
this.writeIt=fWriteObj;
this.visi=fVisibility;
return this;
}
function fWriteObj(text)
{
if(b.ns){this.wref.write(text);this.wref.close();}
else this.wref.innerHTML=text;
}
function fVisibility(oObj)
{
if(oObj.css.visibility=="visible"){oObj.css.visibility="hidden";}
else{oObj.css.visibility="visible";}
}
function fTranslate(text)
{
tAfter="";
for(var i=0;i<text.length;i++)
{
thisChar=text.charAt(i);
//check for ch
if(thisChar+text.charAt(i+1)=="ch"){tAfter+=" ----";i++;}
else
{
for(var j=0;j<latin.length;j++)
{
if(thisChar==latin[j]){thisMorse=morse[j];}
}
tAfter+=" "+thisMorse;
}
}
oAfter.writeIt(tAfter);
}
var undefined;
function list()
{
oList=new makeObj("listing");
var tList="";
tList+="<center><table bgcolor='#000000' cellpadding=2 border=1 border-color='#ffffff' cellspacing=0>";
tList+="<tr><td>";
tList+="<p align='left'>Listing. Latin Alphabet versus Morse</p></td><td style=background-color:'#333333'>";
tList+="<p align='center'><a href='javascript:fVisibility(oList)';>xXx</a></p>";
tList+="</td></tr><tr><td width='100%' colspan='2'><table wodth='100%' cellpadding=2 border=1 border-color='#ffffff' cellspacing=0>"
for(i=0;i<latin.length;i=i+4)
{
if(i<latin.length) {tList+="<tr><td>"+latin[i]+" = "+morse[i]+"</td>";}; else{break;}
if(i+1<latin.length){tList+="<td>"+latin[i+1]+" = "+morse[i+1]+"</td>";}; else{break;}
if(i+2<latin.length){tList+="<td>"+latin[i+2]+" = "+morse[i+2]+"</td>";}; else{break;}
if(i+3<latin.length){tList+="<td>"+latin[i+2]+" = "+morse[i+2]+"</td></tr>";}; else{break;}
}
tList+="</table></td></tr><tr><td width='100%' style=background-color:'#333333' colspan='2'>";
tList+="<p align='center'><a href='javascript:fVisibility(oList);'><b>‘kay, got it!</a></p></table></center>";
oList.writeIt(tList);
oList.visi(oList);oList.visi(oList);
}
onload=init;
//--></script>
</HEAD>
<BODY>
<p align="center">k.one.o TestL@b$</p>
<p align="center">MORSING<br>Convert words to morse</p>
<p align="center"><a href="javascript:fVisibility(oList);">view the list</a></p>
<FORM ID="morsein">
<INPUT ID="before" TYPE="text" NAME="before" VALUE="insert the sentence you want to be translated in morse" SIZE="60">
<INPUT ID="trans" TYPE="button" NAME="trans" VALUE="translate to morse" onClick="fTranslate(before.value)">
<div id="after"><!-- the translation will be inserted here --></div>
</FORM>
<div id="listing" style="width=100%;"><!-- the list will be shown in here --><div>
</BODY>
</HTML>
---page ends ---
can somebody tell me if it works alright in NN+?
kars10
every1 with psycho10esis raise my hand