Help in java script code, THX :P

F

fAnSKyer

I want to use a program in C# or whatever language to controll the
following JS html.
What the following code did is

document.write ('<input type="button"
value="'+langString(strSEND)+
'" onClick="SendClosedCaptionText
(document.myForm.message1)">')
document.write ('</input>')

send caption via a function which uses the JAR
I am a newbie for JS, and really have no idea what should i do.

Can somebody give me idea or give me some examples? Thanks a lot


<html>
<head>
<!--#include file="a_common.ssi" -->
<script>ClearLastSubmitedData();</script>
<script language="JavaScript" src="apicmd.js"></script>
</head>
<script>
var nextPage = null;
var backPage = null;
var form = "myForm";
var group = null;
var action = "";
var g_lastIndexSent = 0;
var historyIndex = 0;
var kHistorySize = 10;
var history = new Array ()
function ShowHistory (newValue)
{
var index
var historyString = ""
history [historyIndex] = newValue

// For each array element that exists append it to the string
for (index = historyIndex; history[index]; index--)
{
historyString = history[index] + "<br>" + historyString
}
document.getElementById ("history").innerHTML = historyString
// Remove the last element if there are more than kHistorySize
historyIndex++
if (historyIndex >= kHistorySize)
{
history [historyIndex - kHistorySize] = null
}
}

function SendClosedCaptionText (object)
{
if (object.value != "")
{
if (ExtendedAsciiOnly (object))
{
APICMD ("screen near")

eval(document.ClosedCaptionApplet.writeClosedCaption(object.value))
ShowHistory (object.value)
object.value = ""
}
}
object.focus ()
}

var kReturnEvent = 13
function OnKeyCode (evt, object)
{
var keyCode = evt.which ? evt.which : evt.keyCode;

// If the user hits the enter key send the text
switch (keyCode)
{
case kReturnEvent:
SendClosedCaptionText (object)
break
}
//return !(window.event && window.event.keyCode == 13);
return !(window.event && keyCode == kReturnEvent);
}
AddBodyStart (langString(strCLOSEDCAP), form, group, action)
</script>
<tr>
<td align="center">
<table cellpadding="0" cellspacing="0">
<tr><td class="ccHistory" id="history"></td></tr>
<tr>
<td align="center">
<input type="text" name="message1" maxlength="127"
size="100"
onKeyDown="return OnKeyCode(event, this)">
</input>
<applet codebase="." archive="closedcaption.jar"
name="ClosedCaptionApplet"
code="polycom.closedcaption.ClosedCaptionApplet.class"
height=0 width=0 mayscript>
</applet>
</td>
</tr>
<tr>
<td align="center">
<script>
document.write ('<input type="button"
value="'+langString(strSEND)+
'" onClick="SendClosedCaptionText
(document.myForm.message1)">')
document.write ('</input>')
</script>
</td>
</tr>
</table>
</td>
</tr>
<iframe src="testframe.htm" name="hideme" height="0px"
width="0px" marginwidth="0px" scrolling="no" frameborder="no"></
iframe>
<script>
AddDataTableScreenAndBodyEnd (backPage, nextPage, false, false);
</script>
</html>
 
D

David Mark

I want to use a program in C# or whatever language to controll the
following JS html.

What does that mean?
What the following code did is

document.write ('<input type="button"
value="'+langString(strSEND)+
'" onClick="SendClosedCaptionText
(document.myForm.message1)">')
document.write ('</input>')

send caption via a function which uses the JAR
I am a newbie for JS, and really have no idea what should i do.

You should explain your design goals more clearly.
Can somebody give me idea or give me some examples? Thanks a lot

Examples of what?
<html>
<head>
<!--#include file="a_common.ssi" -->
<script>ClearLastSubmitedData();</script>

What type of script is this?
<script language="JavaScript" src="apicmd.js"></script>

I assume this is JS, but you shouldn't use the language attribute.
</head>
<script>
var nextPage = null;
var backPage = null;
var form = "myForm";
var group = null;
var action = "";
var g_lastIndexSent = 0;
var historyIndex = 0;
var kHistorySize = 10;
var history = new Array ()
function ShowHistory (newValue)
{
var index
var historyString = ""
history [historyIndex] = newValue

// For each array element that exists append it to the string
for (index = historyIndex; history[index]; index--)
{
historyString = history[index] + "<br>" + historyString
}
document.getElementById ("history").innerHTML = historyString
// Remove the last element if there are more than kHistorySize
historyIndex++
if (historyIndex >= kHistorySize)
{
history [historyIndex - kHistorySize] = null
}
}

function SendClosedCaptionText (object)
{
if (object.value != "")
{
if (ExtendedAsciiOnly (object))
{
APICMD ("screen near")

eval(document.ClosedCaptionApplet.writeClosedCaption(object.value))

You don't need to eval this.
ShowHistory (object.value)
object.value = ""
}
}
object.focus ()
}

var kReturnEvent = 13
function OnKeyCode (evt, object)
{
var keyCode = evt.which ? evt.which : evt.keyCode;

// If the user hits the enter key send the text
switch (keyCode)
{
case kReturnEvent:
SendClosedCaptionText (object)
break
}
//return !(window.event && window.event.keyCode == 13);
return !(window.event && keyCode == kReturnEvent);

This makes no sense.
}
AddBodyStart (langString(strCLOSEDCAP), form, group, action)

This is silly. Without scripting you get no body or tables.
</script>
<tr>
<td align="center">
<table cellpadding="0" cellspacing="0">
<tr><td class="ccHistory" id="history"></td></tr>
<tr>
<td align="center">
<input type="text" name="message1" maxlength="127"
size="100"
onKeyDown="return OnKeyCode(event, this)">

Don't use camel-case with attributes.
</input>
<applet codebase="." archive="closedcaption.jar"
name="ClosedCaptionApplet"
code="polycom.closedcaption.ClosedCaptionApplet.class"
height=0 width=0 mayscript>
</applet>
</td>
</tr>
<tr>
<td align="center">
<script>
document.write ('<input type="button"
value="'+langString(strSEND)+
'" onClick="SendClosedCaptionText
(document.myForm.message1)">')
document.write ('</input>')

You don't need a closing tag for input elements.
</script>
</td>
</tr>
</table>
</td>
</tr>

You don't need all of these tables.
<iframe src="testframe.htm" name="hideme" height="0px"
width="0px" marginwidth="0px" scrolling="no"

You don't use units with height and width attributes. And why would a
dimension of 0 need to be qualified anyway?

frameborder="no"></
iframe>
<script>
AddDataTableScreenAndBodyEnd (backPage, nextPage, false, false);
</script>

This is some really lousy "js html." You don't want to control it
with anything. Throw it away. If the referenced JAR is from the same
source, throw that away too.
 
F

fAnSKyer

Thanks a lot for help me analyze this code. But I don't have a choice
to use this code.

What I need is, for example, some software can auto post a comment on
a blog, auto post on a forum.

I want to use a program to auto post a caption through this JS code

Thanks a lot

Cheers


I want to use a program in C# or whatever language to controll the
following JS html.

What does that mean?
What the following code did is
document.write ('<input type="button"
value="'+langString(strSEND)+
'" onClick="SendClosedCaptionText
(document.myForm.message1)">')
document.write ('</input>')
send caption via a function which uses the JAR
I am a newbie for JS, and really have no idea what should i do.

You should explain your design goals more clearly.


Can somebody give me idea or give me some examples? Thanks a lot

Examples of what?


<html>
<head>
<!--#include file="a_common.ssi" -->
<script>ClearLastSubmitedData();</script>

What type of script is this?
<script language="JavaScript" src="apicmd.js"></script>

I assume this is JS, but you shouldn't use the language attribute.




</head>
<script>
var nextPage = null;
var backPage = null;
var form = "myForm";
var group = null;
var action = "";
var g_lastIndexSent = 0;
var historyIndex = 0;
var kHistorySize = 10;
var history = new Array ()
function ShowHistory (newValue)
{
var index
var historyString = ""
history [historyIndex] = newValue
// For each array element that exists append it to the string
for (index = historyIndex; history[index]; index--)
{
historyString = history[index] + "<br>" + historyString
}
document.getElementById ("history").innerHTML = historyString
// Remove the last element if there are more than kHistorySize
historyIndex++
if (historyIndex >= kHistorySize)
{
history [historyIndex - kHistorySize] = null
}
}
function SendClosedCaptionText (object)
{
if (object.value != "")
{
if (ExtendedAsciiOnly (object))
{
APICMD ("screen near")
eval(document.ClosedCaptionApplet.writeClosedCaption(object.value))

You don't need to eval this.




ShowHistory (object.value)
object.value = ""
}
}
object.focus ()
}
var kReturnEvent = 13
function OnKeyCode (evt, object)
{
var keyCode = evt.which ? evt.which : evt.keyCode;
// If the user hits the enter key send the text
switch (keyCode)
{
case kReturnEvent:
SendClosedCaptionText (object)
break
}
//return !(window.event && window.event.keyCode == 13);
return !(window.event && keyCode == kReturnEvent);

This makes no sense.
}
AddBodyStart (langString(strCLOSEDCAP), form, group, action)

This is silly. Without scripting you get no body or tables.
</script>
<tr>
<td align="center">
<table cellpadding="0" cellspacing="0">
<tr><td class="ccHistory" id="history"></td></tr>
<tr>
<td align="center">
<input type="text" name="message1" maxlength="127"
size="100"
onKeyDown="return OnKeyCode(event, this)">

Don't use camel-case with attributes.




</input>
<applet codebase="." archive="closedcaption.jar"
name="ClosedCaptionApplet"
code="polycom.closedcaption.ClosedCaptionApplet.class"
height=0 width=0 mayscript>
</applet>
</td>
</tr>
<tr>
<td align="center">
<script>
document.write ('<input type="button"
value="'+langString(strSEND)+
'" onClick="SendClosedCaptionText
(document.myForm.message1)">')
document.write ('</input>')

You don't need a closing tag for input elements.
</script>
</td>
</tr>
</table>
</td>
</tr>

You don't need all of these tables.
<iframe src="testframe.htm" name="hideme" height="0px"
width="0px" marginwidth="0px" scrolling="no"

You don't use units with height and width attributes. And why would a
dimension of 0 need to be qualified anyway?

frameborder="no"></
iframe>
<script>
AddDataTableScreenAndBodyEnd (backPage, nextPage, false, false);
</script>

This is some really lousy "js html." You don't want to control it
with anything. Throw it away. If the referenced JAR is from the same
source, throw that away too.


</html>- -

- -- -

- -- -

- -- -

- -
 
D

David Mark

Thanks a lot for help me analyze this code. But I don't have a choice
to use this code.

What I need is, for example, some software can auto post a comment on
a blog, auto post on a forum.

I want to use a program to auto post a caption through this JS code

[snip]

It sounds to me like you should write a Java app and leave JS and HTML
out of it. Do you understand that the posted example embeds a Java
applet and calls on it to do the captioning?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top