Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

lost in my own script need master advice

Status
Not open for further replies.

NEVERSLEEP

Programmer
Apr 14, 2002
667
0
0
CA
when i run my page my script
misconduct it self and i can't seem to spot the bug
run the page wait for the end (u will know when)
and then hit the debug word to view what i wanted
it not the same....
could someone help me ! thanks alot
here the code
<!-- author : aDjOu (c) adjtml 1.0 tester page -->
<html>
<head>
<style type=&quot;text/css&quot;>
<!--
BODY{
scrollbar-face-color:000000;
scrollbar-arrow-color:000000;
scrollbar-track-color:000000;
scrollbar-highlight-color:000000;
}
div.one{
color:0066cc;
font:28px bold;
font-family:helvetica;
position:absolute;
left:160;
top:30;
width:600;
text-align:left;
}
div.two{
color:FFFFFF;
font:24px bold;
font-family:helvetica;
position:absolute;
left:160;
top:130;
width:600;
text-align:left;
}
-->
</style>
<!-- in the js code here we are asuming your browser suport my methods mine are ie6 & ns6.2 -->
<script language=&quot;javascript1.2&quot; type=&quot;text/javascript&quot;>
<!--
var delay = 80;
var operator = 0;
var lastoprt = 0;
var deepoprt = 0;
var counter_one = 0;
var counter_two = 0;
var operator_history = 0;
var lock;
var tag;
var thatag;
var letter_one;
var letter_two;
var link_value = &quot;&quot;;
var mail_value = &quot;&quot;;
var image_value = &quot;&quot;;
var content_one = &quot;100% preserved code <br> [br] for title&quot;;
var content_two = &quot;adjtml example ~:~ (linebreak test each line)[br]pre ? : <br> ~again ? ~ <br> see[br][image ][br]now text fun :[br]test test test[br]some test again [br]more[br]end&quot;;

function startup() {
runner = setInterval(&quot;dothajob()&quot;, delay);
}

function dothajob() {
if (content_two.charAt(counter_two) == &quot;[&quot;) {
if (content_two.charAt(counter_two + 1) == &quot;/&quot;) {
if ((content_two.charAt(counter_two + 2) == &quot;b&quot;) && (content_two.charAt(counter_two + 3) == &quot;]&quot;)) {
setoperator();
counter_two += 3;
}
if ((content_two.charAt(counter_two + 2) == &quot;i&quot;) && (content_two.charAt(counter_two + 3) == &quot;]&quot;)) {
setoperator();
counter_two += 3;
}
if ((content_two.charAt(counter_two + 2) == &quot;u&quot;) && (content_two.charAt(counter_two + 3) == &quot;]&quot;)) {
setoperator();
counter_two += 3;
}
if ((content_two.charAt(counter_two + 2) == &quot;l&quot;) && (content_two.charAt(counter_two + 3) == &quot;i&quot;) && (content_two.charAt(counter_two + 4) == &quot;n&quot;) && (content_two.charAt(counter_two + 5) == &quot;k&quot;) && (content_two.charAt(counter_two + 6) == &quot;]&quot;)) {
setoperator();
counter_two += 6;
}
if ((content_two.charAt(counter_two + 2) == &quot;m&quot;) && (content_two.charAt(counter_two + 3) == &quot;a&quot;) && (content_two.charAt(counter_two + 4) == &quot;i&quot;) && (content_two.charAt(counter_two + 5) == &quot;l&quot;) && (content_two.charAt(counter_two + 6) == &quot;]&quot;)) {
setoperator();
counter_two += 6;
}
} else {
if (content_two.charAt(counter_two + 1) == &quot;b&quot;) {
if ((content_two.charAt(counter_two + 2) == &quot;r&quot;) && (content_two.charAt(counter_two + 3) == &quot;]&quot;)) {
writetag('<br>');
counter_two += 3;
} else {
if (content_two.charAt(counter_two + 2) == &quot;]&quot;) {
writetag('<b></b>');
lastoprt = operator;
operator = 1;
counter_two += 2;
}
}
} else {
if ((content_two.charAt(counter_two + 1) == &quot;u&quot;) && (content_two.charAt(counter_two + 2) == &quot;]&quot;)) {
writetag('<u></u>');
deepoprt = lastoprt;
lastoprt = operator;
operator_history++;
operator = 2;
counter_two += 2;
} else {
if ((content_two.charAt(counter_two + 1) == &quot;i&quot;) && (content_two.charAt(counter_two + 2) == &quot;]&quot;)) {
writetag('<i></i>');
deepoprt = lastoprt;
lastoprt = operator;
operator_history++;
operator = 3;
counter_two += 2;
} else {
if ((content_two.charAt(counter_two + 1) == &quot;i&quot;) && (content_two.charAt(counter_two + 2) == &quot;m&quot;) && (content_two.charAt(counter_two + 3) == &quot;a&quot;) && (content_two.charAt(counter_two + 4) == &quot;g&quot;) && (content_two.charAt(counter_two + 5) == &quot;e&quot;) && (content_two.charAt(counter_two + 6) == &quot; &quot;)) {
lock = 7;
while (lock > 0) {
if (content_two.charAt(counter_two + lock) == &quot;]&quot;) {
counter_two += lock;
lock = 0;
} else {
image_value += content_two.charAt(counter_two + lock);
lock++;
}
}
writetag('<img src=&quot;' + image_value + '&quot; border=&quot;0&quot;>');
} else {
// underc
if ((content_two.charAt(counter_two + 1) == &quot;l&quot;) && (content_two.charAt(counter_two + 2) == &quot;i&quot;) && (content_two.charAt(counter_two + 3) == &quot;n&quot;) && (content_two.charAt(counter_two + 4) == &quot;k&quot;) && (content_two.charAt(counter_two + 5) == &quot; &quot;)) {
deepoprt = lastoprt;
lastoprt = operator;
operator_history++;
operator = 4;
} else {
if ((content_two.charAt(counter_two + 1) == &quot;m&quot;) && (content_two.charAt(counter_two + 2) == &quot;a&quot;) && (content_two.charAt(counter_two + 3) == &quot;i&quot;) && (content_two.charAt(counter_two + 4) == &quot;l&quot;) && (content_two.charAt(counter_two + 5) == &quot; &quot;)) {
deepoprt = lastoprt;
lastoprt = operator;
operator_history++;
operator = 4;
}
}
// end underc
}
}
}
}
}
} else {
document.getElementById('one').appendChild(document.createTextNode(content_one.charAt(counter_one)));
if (operator == 0) {
document.getElementById('two').appendChild(document.createTextNode(content_two.charAt(counter_two)));
} else {
if (operator == 1) {
tag = document.getElementById('two').getElementsByTagName('b');
tag[tag.length - 1].appendChild(document.createTextNode(content_two.charAt(counter_two)));
} else {
if (operator == 2) {
tag = document.getElementById('two').getElementsByTagName('u');
tag[tag.length - 1].appendChild(document.createTextNode(content_two.charAt(counter_two)));
} else {
if (operator == 3) {
tag = document.getElementById('two').getElementsByTagName('i');
tag[tag.length - 1].appendChild(document.createTextNode(content_two.charAt(counter_two)));
} else {
tag = document.getElementById('two').getElementsByTagName('a');
tag[tag.length - 1].appendChild(document.createTextNode(content_two.charAt(counter_two)));
}
}
}
}
}
if ((content_one.charAt(counter_one) == &quot;&quot;) && (content_two.charAt(counter_two) == &quot;&quot;)) {
window.clearInterval(runner);
} else {
counter_one++;
counter_two++;
}
}

function setoperator() {
if (operator_history == 0) {
operator = 0;
} else {
if (operator_history == 1) {
operator = lastoprt;
} else {
if (operator_history == 2) {
operator = deepoprt;
}
}
operator_history--;
}
}

function writetag(whatag) {
if (operator == 0) {
document.getElementById('two').appendChild(document.createElement(whatag));
} else {
if (operator == 1) {
tag = document.getElementById('two').getElementsByTagName('b');
} else {
if (operator == 2) {
tag = document.getElementById('two').getElementsByTagName('u');
} else {
if (operator == 3) {
tag = document.getElementById('two').getElementsByTagName('i');
} else {
if (operator == 4) {
tag = document.getElementById('two').getElementsByTagName('a');
}
}
}
}
tag[tag.length - 1].appendChild(document.createElement(whatag));
}
}

function debug() {
alert(content_two + &quot;\n\n\n&quot; + &quot;counter_two = &quot; + counter_two + &quot; : operator value = &quot; + operator + &quot; : operator_history value = &quot; + operator_history + &quot;\n\n\n&quot; + &quot;suppose to be :\nadjtml example ~:~ (linebreak test each line)\npre ? : <br> ~again ? ~ <br> see\n[image ...]\nnow text fun :\ntest test test\nsome test again \nmore\nend&quot;);
}
-->
</script>
</head>
<body onload=&quot;startup()&quot; bgcolor=&quot;000000&quot;>
<br><a href=&quot;javascript:debug()&quot;>debug</a>
<div id=&quot;one&quot; class=&quot;one&quot;></div>
<div id=&quot;two&quot; class=&quot;two&quot;></div>
</body>
</html> someone knowledge ends where
someone else knowledge starts
 
underc.gif
someone knowledge ends where
someone else knowledge starts
 
help me please... someone knowledge ends where
someone else knowledge starts
 
so that does means that u r clueless like me ?

underc.gif


please help me here someone knowledge ends where
someone else knowledge starts
 
It looks like it does exactly what you said you want it to do. What is it doing wrong??

S
 
the third last line in the second div
display wrong (see below)
<i>some <u>te<b>s</b>in t</u> aga</i>
should be (see below)
<i>some <u>te<b>s</b>t aga</u>in </i>

????
thanks for your reply !
someone knowledge ends where
someone else knowledge starts
 
the situation is :
some user submit to a form a text with &quot;adjtml&quot;
a cgi store it in a file
when u ask for this page another cgi
read a database and generate this
all &quot;input&quot; will be stored in content_two
that whay i have to keep in mind
that content_two is not always the same

and upon using mutilple <tag> my script get &quot;lost&quot;
we &quot;write&quot; in a wrong child... someone knowledge ends where
someone else knowledge starts
 
any help please??? someone knowledge ends where
someone else knowledge starts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top