kodeoversætter2
dette er videre på denne tråd http://www.eksperten.dk/spm/876595jeg kan ikke svare i den anden tråd, den ser helt mærkelig ud, derfor laver jeg denne, håber det er ok.
jeg har fået lavet denne kode selv:
<html>
<script language="JavaScript">
<!--
function toAk(text)
{
var ak = ""
var i=0
for (i=0; i<text.length; i++) {
switch (text.substring(i, i+1)) {
case "a": ak += "k"; break;
case "b": ak += "l"; break;
case "c": ak += "m"; break;
case "d": ak += "n"; break;
case "e": ak += "o"; break;
case "f": ak += "p"; break;
case "g": ak += "q"; break;
case "h": ak += "r"; break;
case "i": ak += "s"; break;
case "j": ak += "t"; break;
case "k": ak += "u"; break;
case "l": ak += "v"; break;
case "m": ak += "w"; break;
case "n": ak += "x"; break;
case "o": ak += "y"; break;
case "p": ak += "z"; break;
case "q": ak += "æ"; break;
case "r": ak += "ø"; break;
case "s": ak += "å"; break;
case "t": ak += "a"; break;
case "u": ak += "b"; break;
case "v": ak += "c"; break;
case "w": ak += "d"; break;
case "x": ak += "e"; break;
case "y": ak += "f"; break;
case "z": ak += "g"; break;
case "æ": ak += "h"; break;
case "ø": ak += "i"; break;
case "å": ak += "j"; break;
case "A": ak += "K"; break;
case "B": ak += "L"; break;
case "C": ak += "M"; break;
case "D": ak += "N"; break;
case "E": ak += "O"; break;
case "F": ak += "P"; break;
case "G": ak += "Q"; break;
case "H": ak += "R"; break;
case "I": ak += "S"; break;
case "J": ak += "T"; break;
case "K": ak += "U"; break;
case "L": ak += "V"; break;
case "M": ak += "W"; break;
case "N": ak += "X"; break;
case "O": ak += "Y"; break;
case "P": ak += "Z"; break;
case "Q": ak += "Æ"; break;
case "R": ak += "Ø"; break;
case "S": ak += "Å"; break;
case "T": ak += "A"; break;
case "U": ak += "B"; break;
case "V": ak += "C"; break;
case "W": ak += "D"; break;
case "X": ak += "E"; break;
case "Y": ak += "F"; break;
case "Z": ak += "G"; break;
case "Æ": ak += "H"; break;
case "Ø": ak += "I"; break;
case "Å": ak += "J"; break;
case "1": ak += "1"; break;
case "2": ak += "2"; break;
case "3": ak += "3"; break;
case "4": ak += "4"; break;
case "5": ak += "5"; break;
case "6": ak += "6"; break;
case "7": ak += "7"; break;
case "8": ak += "8"; break;
case "9": ak += "9"; break;
case "0": ak += "0"; break;
case ".": ak += "."; break;
case "?": ak += "?"; break;
case "!": ak += "!"; break;
case ",": ak += ","; break;
case "-": ak += "-"; break;
case " ": ak += " "; break;
default: ak += "fejl"; break;
}
}
document.outData2.outText2.value = ak
}
// -->
</script>
<script language="JavaScript">
<!--
function toAk2(text)
{
var ak2 = ""
var i=0
for (i=0; i<text.length; i++) {
switch (text.substring(i, i+1)) {
case "a": ak2 += "s"; break;
case "b": ak2 += "u"; break;
case "c": ak2 += "v"; break;
case "d": ak2 += "w"; break;
case "e": ak2 += "x"; break;
case "f": ak2 += "y"; break;
case "g": ak2 += "z"; break;
case "h": ak2 += "æ"; break;
case "i": ak2 += "ø"; break;
case "j": ak2 += "å"; break;
case "k": ak2 += "a"; break;
case "l": ak2 += "b"; break;
case "m": ak2 += "c"; break;
case "n": ak2 += "d"; break;
case "o": ak2 += "e"; break;
case "p": ak2 += "f"; break;
case "q": ak2 += "g"; break;
case "r": ak2 += "h"; break;
case "s": ak2 += "i"; break;
case "t": ak2 += "j"; break;
case "u": ak2 += "k"; break;
case "v": ak2 += "l"; break;
case "w": ak2 += "m"; break;
case "x": ak2 += "n"; break;
case "y": ak2 += "o"; break;
case "z": ak2 += "p"; break;
case "æ": ak2 += "q"; break;
case "ø": ak2 += "r"; break;
case "å": ak2 += "s"; break;
case "A": ak2 += "T"; break;
case "B": ak2 += "U"; break;
case "C": ak2 += "V"; break;
case "D": ak2 += "W"; break;
case "E": ak2 += "X"; break;
case "F": ak2 += "Y"; break;
case "G": ak2 += "Z"; break;
case "H": ak2 += "Æ"; break;
case "I": ak2 += "Ø"; break;
case "J": ak2 += "Å"; break;
case "K": ak2 += "A"; break;
case "L": ak2 += "B"; break;
case "M": ak2 += "C"; break;
case "N": ak2 += "D"; break;
case "O": ak2 += "E"; break;
case "P": ak2 += "F"; break;
case "Q": ak2 += "G"; break;
case "R": ak2 += "H"; break;
case "S": ak2 += "I"; break;
case "T": ak2 += "J"; break;
case "U": ak2 += "K"; break;
case "V": ak2 += "L"; break;
case "W": ak2 += "M"; break;
case "X": ak2 += "N"; break;
case "Y": ak2 += "O"; break;
case "Z": ak2 += "P"; break;
case "Æ": ak2 += "Q"; break;
case "Ø": ak2 += "R"; break;
case "Å": ak2 += "S"; break;
case "1": ak2 += "1"; break;
case "2": ak2 += "2"; break;
case "3": ak2 += "3"; break;
case "4": ak2 += "4"; break;
case "5": ak2 += "5"; break;
case "6": ak2 += "6"; break;
case "7": ak2 += "7"; break;
case "8": ak2 += "8"; break;
case "9": ak2 += "9"; break;
case "0": ak2 += "0"; break;
case ".": ak2 += "."; break;
case "?": ak2 += "?"; break;
case "!": ak2 += "!"; break;
case ",": ak2 += ","; break;
case "-": ak2 += "-"; break;
case " ": ak2 += " "; break;
default: ak2 += "fejl"; break;
}
}
document.outData3.outText3.value = ak2
}
// -->
</script>
<body>
<center>
<table border="1" width="383" bgcolor="#0000FF">
<tr>
<td width="384" bgcolor="#000080" align="left"><font color="#FFFFFF" size="4"
face="Arial, Helvetica, sans-serif"><b>Morse oversætter </b></font></td>
</tr>
<tr>
<td width="384"><form name="inData">
<p align="left"><font color="#FFFFFF" size="3" face="Arial, Helvetica, sans-serif"><strong>Kildetekst:</strong></font><br>
<textarea name="inText" rows="4" cols="40" wrap="PHYSICAL"></textarea></p>
<p align="left"><input type="button" name="Translate" value="Oversæt" onclick="toAk(document.inData.inText.value);toAk2(document.inData.inText.value)"> <input type="reset" name="Reset"
value=" Ryd "> </p>
</form>
<form name="outData2">
<p align="left"><strong><font color="#FFFFFF" size="3" face="Arial, Helvetica, sans-serif">A-K
med W (omvendt)</font><font
color="#FFFFFF">:</font></strong><br>
<textarea name="outText2" rows="4" cols="40" wrap="VIRTUAL"></textarea> </p>
</form>
<form name="outData3">
<p align="left"><strong><font color="#FFFFFF" size="3" face="Arial, Helvetica, sans-serif">A-K med W (korrekt</font><font
color="#FFFFFF">):</font></strong><br>
<textarea name="outText3" rows="4" cols="40" wrap="VIRTUAL"></textarea> </p>
</form>
</td>
</tr>
</table>
</center>
<p align="left"> </p>
</body>
</html>
så skal jeg bare have skrevet 30 koder mere ind, men det er ikke problemet og det virker også som det skal.
Det jeg gerne ville have lavet er, som jeg nævnte i mit tidligere indlæg, en søgefunktion som søger efter nogle alm. ord. Kik evt på min tegning her så kan i måske forstå hvad jeg mener http://www.strandboerne.dk/kodeoversatteren.bmp