JavaScript - Port 900 Line Java Applet To Javascript Time
I have a Java Applet that I have been managing for some time. Approximately how long would it take to port a 900 line Java Applet to JavaScript? My intention is to reproduce as close as I can to the Java Applet. If you would like to see the Java Applet code, it is available here : http://www.chatapp.comuf.com/AppletClient(Public).java
This Java Applet is a chat client that connects to a Java server (I am NOT porting the server). It has a simple interface with panel tabs for various activities (chat room, login, text color chooser, etc). **Note : I have not programmed in JavaScript before. I went over some tutorials before I posted this. ***N00b note : I know Java and JavaScript have NOTHING to do with each other. Similar TutorialsFirst of all, I must say that I am recently introduced to JavaScript and I am not fully aware of its complete functionality. So I have an HTML document which has defined within a its body a JavaScript function and I have also a JApplet class which is also loaded in the HTML and can call the JavaScript function. But I have also another Java class which is not an applet and I would like to find a way for this class to be able to call the JavaScript function (but it is essential for this class not to be an applet). I am aware that this would raise some security concerns but it is for local usage and I am interested to hear some ways if possible for this to be done. Thank You beforehand to all of you! Hi, I'm a newbie to javascript programming and I'm seeking on a solution on how to connect to a tcp port using javascript. Basically, we have phone server that is constantly streaming XML data on port 1024 (serverIP:1024). I've ran a packet sniffer and was able to gather the elements and attributes for the XML data that the server is streaming. Now, I have a test XML parser which works with the XML document using the elements and attributes i've gathered from the packet sniffer. Is there a way for me to connect to the TCP port i've mentioned using javascript and incorporate it with the XML parser that I have. Here is the code for my XML Parser. Quote: <html> <body> <script type="text/javascript"> var xmlDoc; if (window.XMLHttpRequest) { xmlDoc=new window.XMLHttpRequest(); xmlDoc.open("GET","acddataentry.xml",false); xmlDoc.send(""); xmlDoc=xmlDoc.responseXML; } // IE 5 and IE 6 else if (ActiveXObject("Microsoft.XMLDOM")) { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async=false; xmlDoc.load("acddataentry.xml"); } document.write("<table border='1'>"); var x=xmlDoc.getElementsByTagName("ACD"); for (i=0;i<x.length;i++) { document.write("<tr><td>"); document.write(x[i].getElementsByTagName("Calls_Waiting")[0].childNodes[0].nodeValue); document.write("</td><td>"); document.write(x[i].getElementsByTagName("Crt_Wait_Time")[0].childNodes[0].nodeValue); document.write("</td></tr>"); } document.write("</table>"); </script> </body> </html> Any help on this is highly appreciated. Thank in advance. Internet Explorer requires the user to click on an applet to activate it, which means two clicks if there is a start button, for example. I previously learned a workaround, which is to activate the applet from an external Javascript, something like this: Code: document.write('<applet code="' + appletname + '" width="' + w + '" height="' + h + '"></applet>'); This doesn't work in IE8. Is there a workaround for IE8? Thanks. I am trying to pass a screen resolution parameter to a java applet so that it will appear in full screen mode when it launches. This is working fine in Firefox and Chrome but not in IE8. Here is the code: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script type="text/javascript"> function getresolution() { var yourres = screen.width + 'x' + screen.height; document.write('<param name="geometry" value="' + yourres + '">'); } </script> </head> <body> <applet name='rdp' code='com.elusiva.rdp.applet.RdpApplet' archive='JavaRDP16-1.1.jar' codebase='.' width='1' height='1'> <param name='server' value='XXXXXXXXXX'> <param name='port' value='3389'> <param name='shell' value='C:\seamlessrdp\seamlessrdpshell.exe -s C:\Program%20Files%20(x86)\TRAMS\CBplus\CBplus.exe'> <script type="text/javascript">getresolution();</script> </applet> </body> </html> Any help on this would be much appreciated! I am developing a web page which contains a java script file. Java script file is created using excel tool. My problem is that the execution time of a java script function is very high,mainly in chrome browser. what will be solution to overcome this?
Hi Script Experts I am facing issue in below code for Brisilia time zone.(GMT-3). Issue comes in October month only. It is going tobig loop. I am not getting how Date object is behaving here. Thanks in advance Pranav Sharma *********************************** <script type="text/javascript"> var nDate; var nCurrentYear = 2011; var nCurrentMonth = 10; nYear=2011; nMonth=10; var date = new Date(nYear, nMonth-1, 1); document.write('Month:'+date.getMonth() +':CurrentMonth:'+nCurrentMonth); while (date.getMonth() == nCurrentMonth-1) { nDate = date.getDate(); document.write(date.toDateString()); date = new Date(nCurrentYear, date.getMonth(), date.getDate()+1); } </script> ********************************** 1 down vote favorite I do have the countdown script (see link below) to display the time between current time and the date given in real-time. However, I want to achieve to display the time difference between a given start and end time. Right now, it calculates from the current server time to the end time. I want to be able to set up my own start time and end time. Here is what I have: http://jsfiddle.net/BgEtE/ thank you for help Hello, I'm making a Javascript implementation for my Java program. But I'm having a proplem. I want to call my own Java code from the Javascript script. Is that possible? Thanks, enderp Not much programming experience, but some C++ and Python. I would like to make a web page that 1. flashes and image for 1 second 2. flashes a a pair of images for 1 second 3. displays an image and waits 4. Wait for a certain correct keystroke to be entered. 5. Repeat 1-4 a few hundred times. ^The above would iterate through a loop, say of 300 counts, and sub-iterate through an array of images, say 30, going through all 30 images 10 times for example. Oh, and the array elements would be displayed in random order. Also, I would like to keep track of errors (wrong keystroke) and time it took to enter correct keystroke. I would prefer that this webpage work on the iphone, even older ones. Java is limited on iphone? I tried playing a Java chess game and had no luck on iphone. So, would I be able to do this using Javascript? If not, Java would be best? As I said, I would prefer iphone compatibility, but it is not required. I just want to know which one I should use before I bury my nose in a book about programming Java or Javascript. Hi everybody! I've a problem and I'm not able to solve it alone. I want to invoke java methods of a self written java programm with javascript. I found something like a tutorial (http://stanislavvitvitskiy.blogspot....lications.html), but it has not worked. I put my class file in a jar file and when I want to load it in javascript i get an error. I tried it this way: var url = new java.net.URL('C:/java_js' + '/xultest.jar'); var cl = new java.net.URLClassLoader(url); var aClass = java.lang.Class.forName("com.stan.XULDemo", true, cl); var inst = aClass.newInstance(); // Calling 'sum' function from java var a = inst.sum(2, 3); alert(a); // Will alert '5' Can anyone please help, and say to me what's wrong about it? Or does anyone have another aproach to call java methods with javascript? cheers, Martin I have 2 drag-able containers, they are created in PHP objects which are linked to a file. The working example can be found he 888x7.com The problem that I'm facing is that I can't click test1, and only test2. Now I originally though that it was something to do with them having the same java-script variables, so I renamed all the variables using a unique ID to each object too no success. Here's the code: PHP file: Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <?php include 'design/compatability.php'; include 'design/meta.php'; ?> <link rel="stylesheet" type="text/css" href="css.css" /> <title></title> </head> <body> <div id="background"> <img src="images/bg1.jpg" class="stretch" alt="" /> </div> <div id="wrapper"> <?php include 'design/dragdiv.php'; $container = new dragable_box(200, 300, 10, 60, "../designimages/bggrey.png", "test", 1); $container2 = new dragable_box(590, 400, 10, 10, "../designimages/bggrey.png", "test", 2); ?> <?php include 'design/toplinks.php'; ?> </div> <?php include 'design/footer.php'; ?> </body> </html> Code: <?php class dragable_box { public function __construct($width, $height, $x, $y, $bg, $text, $id) { ?> <style type="text/css"> #mydiv<?php echo $id; ?> { z-index:10; background-image:url(<?php echo $bg; ?>); color:#ffffff; width: <?php echo $width; ?>px; height: <?php echo $height; ?>px; position: absolute; top: <?php echo $x; ?>%; left: <?php echo $y; ?>%; cursor:move; padding:10px; } </style> <script language="javascript"> var positionx = <?php echo $x; ?>; var positiony = <?php echo $y; ?>; var setpositionx = window.innerWidth * positionx / 100; var setpositiony = window.innerHeight * positiony / 100; var drag=0; var xdif=0; var ydif=0; var initx=setpositionx; var inity=setpositiony; function begindrag<?php echo $id; ?>(event) { if(drag==0) { floatingd = document.getElementById("mydiv<?php echo $id; ?>"); if(floatingd.style.left=="") { floatingd.style.left=initx; } if(floatingd.style.top=="") { floatingd.style.top=inity; } prex=floatingd.style.left.replace(/px/,""); prey=floatingd.style.top.replace(/px/,""); drag=1; xdif = event.clientX-prex; ydif = event.clientY-prey; } else { drag=0; } } function mousepos<?php echo $id; ?>(event) { floatingd = document.getElementById("mydiv<?php echo $id; ?>"); if(drag==1) { floatingd.style.left = event.clientX-setpositionx+"px"; floatingd.style.top = event.clientY-setpositiony+"px"; } } </script> </HEAD> <BODY onMouseMove="mousepos<?php echo $id; ?>(event)" > <div id='mydiv<?php echo $id; ?>' onClick="begindrag<?php echo $id; ?>(event)" > <?php echo $text; echo $id; ?> </div> <?php } } ?> I need help being able to select both DIV's, can anyone point me in the right direction? Thanks Can you place java code in an external javascript file (.js). For example can I do the following in my xx.js file. $(document).ready(function(){ <% execute some java code here %> ...execute some javascript code here... }) Can I do the above? Another question ... I know <% %> is to execute java code inside html. But what does <%-- - -%> mean? Thanks for any help. Hi All.....I am new to javascript coding ...I am unable to forward from my jsp to servlet file via javascript below is my code.... [JSP CODE] <html> <body> <form action="Bean" method="get" name="form1"> <ul> <li><a onclick="javascript:view('vprod')" name="vprod">View</a></li> </ul> [Script Code] function view(value) { alert(value); document.form1.action="/Bean"; document.form1.submit(); } Please can one help me in this regard.....Thanks in Advance when i run applet nothing shows jsut text field [highlight=Java] import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Assign6 extends JApplet implements ActionListener { JLabel answerLabel; JTextField answerField; public void init() { Container c = getContentPane(); c.setLayout (new FlowLayout()); answerLabel = new JLabel(""); answerField = new JTextField(10); answerField.setEditable(true); answerField.addActionListener(this); c.add(answerLabel); c.add(answerField); } public int generateNumbers() { int x=0; x = 1 + (int)(Math.random() * 10); return x; } public void actionPerformed(ActionEvent e) { String correct = new String("Correct "); int x = generateNumbers(); int y = generateNumbers(); showStatus("How much is " + x + " times " + y); int answer; answer = Integer.parseInt(answerField.getText()); int product = x*y; if (product == answer){ showStatus("Very good!"); } else showStatus("No. Please try again."); } @Override public void paint(Graphics g) { super.paint(g); } } { } [/highlight] How do I get new line to work in javascript. Everytime I try to use it, it never works. There should be a new line with 5 * instead of having 17 * on one line. Code: <html> <body> <script type ="text/javascript"> var x=0; for (x=0;x<=12;x++) { document.writeln("*"); } document.writeln("\n"); for (x=0;x<=5;x++){ document.writeln("*"); } </script> </body> <html> Hello experts, My first question folks. I have recently joined a web based video conference which allow people to join as a guest (no need to create account). This conference's interface and function is written in javascript as an applet. To cut the long story short, is it possible to capture this applet and see the conference (without having to join the conference)? What happen at the moment is people wont be able to see the conference without join in and therefore take one slot out of 7 seats if you like. When all slots are taken people can not see the event. I was wondering if there is a way to capture this event using other javascript. I have all the scripts required to make this conference running, i know the logic of how javascript works but i dont know what is what in detail. Can anyone suggest anything? Thanks. I have now go an applet from http://castleamber.com/amberticker.html, I have contacted the publisher and asked whether ther is a way to add line/streaming text from a textarea into he applet at runtime, however they are not responding as yet. If possible could someone tell me how I would use a repaint() case statement in this applet in order to get the value of the textarea to reflect in the ticker. Any code I do use will have all compliments to the creators and those who have helped along the way. Thank you Sorry if this post is very noobish, its because I am a noob. Ok, so I have a forum with Proboards and want to add a chat using the "headers/footers" but as Ive been having some trouble on my forum, I need the chat to have an admin panel (ban, warn, even see IP's if possible etc). I also need it to be streaming, not a refresh chat room. I cant seem to find a chat with this function anywhere, can anyone help? P.S I know you can have AddonChat with Proboards but that does not have the admin tools that I need and I cant afford to pay for these priveleges. If this is not possible, does anyone know any codes I could use with my AddonChat to at least give me some kind of admin control? Cheers xx I have a slideshow that goes through pictures once you click on the Play button and doesn't stop until you press on the Stop button. How can I make it so that it automatically plays once the website loads without having to click on the Play button? Heres the code: Code: <div class="tabs png"><span class="tabs-inner"><a href=""></a> <a href=""></a> <a href=""></a> <a href=""></a> <a href=""></a> <a href=""></a> <a href=""></a></span></div> <div class="slider-indent-button"> <a href="#" onClick='$("div.tabs").tabs().play();'>Play</a> <a href="#" onClick='$("div.tabs").tabs().stop();'>Stop</a> </div> All help is much appreciated!!! I have this Javascript and I am wanting to create a line break between the tweet and the time it was posted, here is the javascript, I am guessing I need to insert the <BR> tag somewhere but just not sure where? Thanks function twitterCallback2(twitters) { var statusHTML = []; for (var i=0; i<twitters.length; i++){ var username = twitters[i].user.screen_name; var status = twitters[i].text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g, function(url) { return '<a href="'+url+'">'+url+'</a>'; }).replace(/\B@([_a-z0-9]+)/ig, function(reply) { return reply.charAt(0)+'<a href="http://twitter.com/'+reply.substring(1)+'">'+reply.substring(1)+'</a>'; }); statusHTML.push('<li><span>'+status+'</span> <a style="font-size:85%" href="http://twitter.com/'+username+'/statuses/'+twitters[i].id_str+'">'+relative_time(twitters[i].created_at)+'</a></li>'); } document.getElementById('twitter_update_list').innerHTML = statusHTML.join(''); } function relative_time(time_value) { var values = time_value.split(" "); time_value = values[1] + " " + values[2] + ", " + values[5] + " " + values[3]; var parsed_date = Date.parse(time_value); var relative_to = (arguments.length > 1) ? arguments[1] : new Date(); var delta = parseInt((relative_to.getTime() - parsed_date) / 1000); delta = delta + (relative_to.getTimezoneOffset() * 60); if (delta < 60) { return 'less than a minute ago'; } else if(delta < 120) { return '<br>about a minute ago'; } else if(delta < (60*60)) { return (parseInt(delta / 60)).toString() + ' minutes ago'; } else if(delta < (120*60)) { return 'about an hour ago'; } else if(delta < (24*60*60)) { return 'about ' + (parseInt(delta / 3600)).toString() + ' hours ago'; } else if(delta < (48*60*60)) { return '1 day ago'; } else { return (parseInt(delta / 86400)).toString() + ' days ago'; } } |