Bonjour,
J'ai testé ce bout de code, pour les trois reg exp (keysWord, comment, string) mais avec la librairie prototype dispobible
ici ( c'est bien plus élégant).
Je bosse sur les indentaions et j'ai une question:
Y a t'il autant de tiret que d'espaces? - exemple:
' ' donne ->
' ' donne -->
' ' donne -->
Cordialement, Pierrick.
<---------------------------------------------------------------------------------------------------------->
<html>
<head>
<title></title>
<style type="">
#source{
width: 43%;
height: 100%;
float: left;
}
#myButton{
width: 8%;
height: 100%;
float: left;
margin-left: 30px;
margin-right: 30px;
}
#destination{
width: 43%;
height: 100%;
float: left;
}
</style>
<script src='prototype.js'></script>
<script language="javascript" type="text/javascript">
<!--
var reReservedKeys = /Private|Sub|For|To|Step|MsgBox|Next|End/;
var tplReservedKeys = "%blue%#{0}%%";
var reComment = /(.*)('.*')(.*)/;
var tplComment = "#{1}%green%#{2}%%#{3}";
var reString = /(.*)(".*")(.*)/;
var tplString = "#{1}%darkred%#{2}%%#{3}";
function haveFun(){
var s = document.getElementById("source").value;
s = s.gsub( reReservedKeys, tplReservedKeys);
s = s.gsub( reComment, tplComment);
s = s.gsub( reString, tplString);
document.getElementById("destination").value = s;
}
-->
</script>
</head>
<body>
<textArea id='source'></textArea>
<input id='myButton' type="button" value="Have fun !" onclick="haveFun();">
<textArea id='destination'></textArea>
</body>
</html>