JavaScript - Des Implementation In C++ Or Java
Hello everyone,
I needed some help on finding a complete code which implements DES in either c++ or Java. Thanks Similar TutorialsHello all and thank you in advance. I am very unfamiliar with Java and hope someone can help. I have a site using a wordpress theme and want to add the +, -, and reset buttons to control the text size. I am using this site http://go.internet.com/?id=474X1058&...php%23examples as my tutorial and am finding out that this is not a step by step buy requires prior knowledge for java coding. For step one I copied the 3 lines of code and placed them in the header. Then for step 2 I placed them in the single post editor (not sure if the link "#" needs to be changed. And for step 3 I am lost completely. I downloaded the file linked on that page which includes 4 .js files, which I am not even sure if I will need. Is this something anyone here can help me with? I am familiar with html and css, and very little php coding, but this is confusing. Thanks. Hi guys, I need your expertise regarding my dilema. I was able to create a simple google map html page at our web server, this web server has access to the internet. the problem is, when this page is accessed from a different PC that has no internet access, the google map won't work. I know that javascripts are run at the client side, so i'm asking is it possible to run everything at the server, including the javascripts and still output the google map? i used this tutorial to make my google map page : http://googlemaps.mayzes.org/ Hey guys, We have implemented dfp on our network using js and xml but are having issues with companion ads. We are looking for someone to tweak our js since we are running out of ideas, we would of course compensate you for your time. Basically what we are doing is scanning our page for specific <DIV> after the page has loaded, match that div and url with an XML file then insert the proper doubleclick tag to display our ads. example: <div class="_DblClick" id="300x250top" size="300x250" pos="top"></div> It has been working like a charm until we started to do sponsorships whith companion ads: Here is an example of a page working perfectly (hard coded tags): http://emmisdigitalvault.com/test/tag-hardcoded.html Here is the same campaign using JS, you will notice that on some refresh sometime wrongs ads will show up: http://emmisdigitalvault.com/test/tag.html Here is the feedback we received from google: My investigation indicates that the ads sometimes appear in the wrong order because the ad calls from the three ad tags on this page are not always made in the order intended. The ad tags appear to be dynamically generated by scripts that aren't accessible externally, with the responses from the DFP ad server then automatically inserted into the page. In order for Roadblocking (master/companion pairs) to function properly, the ad calls must be made sequentially, with the ad tag that calls the master first and the ad tag that calls the companion immediately after. In the case of this website, it appears that the order of the ad calls can vary with each page load, making which ads serve to the two 300x250 ad slots unpredictable. If you have already encountered this road block or can think of a solution please contact me What is JAVA? From where I can learn. Please guide me the best institution that is teaching JAVA in the world. Any online tutorial or site where I can get online material. I am not familiar with this program nor i have any idea. I am waiting for your response because i want to start it immediately. I'm new to coding, And would like to know if java is capable of: Playing a sound file when a name or word is seen on the screen. Or, In this case on a windows sidebar gadget. Thanks I have been trying to learn java coding from a book and have run into a coding question that I'm confused about. Can someone help? I have a one dimensional array of positive integers. I'm trying to create another array with the same length and scan the original array for finding the maximum integer. I am then needing to copy that maximum integer in first position of the created array and set the maximum integer in the original array to zero. For second round, I need to write code to find the maximum integer in the original array and copy that in second position of created array and set the maximum integer in the original array to zero. I need to repeat this until all numbers in original array is zero. My created array should be sorted in positive integer numbers. I need to write this sort method that accepts a one dimensional array of integers that return the sorted array testing this method using the main method. ok, so, I honestly have no clue why it wont work.. I'm workin in html and I put some javascript code(im learnin) so here it is, please help! <script> code = 0 function mf() { code += 1 if (code >= 1) { code = 0 {document.getElementById("test").innerHTML = "I have changed";} } else { code = 1 {document.getElementById("test").innerHTML = "Click below to change me!";} } } </script> <p id = "test">Click below to change me!</p> <button type = "button" onclick = "mf()">click here!</button> please hekp to sort this out.. .. The price of a ticket to a passenger on AOU-Airways is computed based on the following table: [9] Class Price First Class KD 300 Economy Class (with meal) KD 150 Economy Class (without meal) KD 130 Using nested if statements, write a JavaScript code which will work according to the following specifications: a. Read the class that the passenger wants to travel on. b. If the class is the first class, print the price of ticket. c. If the class is the economy class, ask the user if he/she wants a meal on the flight. Then print the price of the ticket according to the response of the passenger. The program should simply accept one possible strings the user enters; it is not required to work for all possible inputs such as First, first, FIRST or Yes , yes, YES. this is what i have so far but im having trouble adding an accessor method for answer which i have called getAnswer public class Question { private String text; private String answer; private String getAnswer; /** * Constructs a question with empty question and answer. */ public Question() { text = ""; answer = ""; } /** * Sets the question text. * @param questionText the text of this question */ public void setText(String questionText) { text = questionText; } /** * Sets the answer for this question. * @param correctResponse the answer */ public void setAnswer(String correctResponse) { answer = correctResponse; } public String getAnswer(){ return answer; } /** * Checks a given response for correctness. * @param response the response to check * @return true if the response was correct, false otherwise */ public boolean checkAnswer(String response) { return response.equals(answer); } /** * Displays this question. */ public void display() { System.out.println(text); } } Hi Chaps, I'm looking for a 'preloader' progress bar to appear whilst a file is uploaded/downloaded from my php app. Not sure whether this is a Java/Flash question, but any help would be appreciated. Cheers how to get first 4 digits of mobile number using substing method and then how to check that number in if condition using java script.that is i entered the mobile number 9688786064.i want to check first four digits 9688 .in that same check all the entered number only 9688 started nymber can allow to store data base..how can i develop the program..plz help me var ph1=document.getElementById('ph'); ph1=ph.substring(0,4) is it correct or not .if it is correct then tell further steps.if it wrong tell me the correct code hi i want to implement this java script . This is the Original Java script page . Where you see if i click on the yahoo or | google buttons the new window is loading and the same page is displaying with a tab bar menu and close button. I want to implement the same on one of my documents where i created css and java script based drop down menus. But when i tried to implement the same java script on my own page its not working properly.Please help me fix it . I have changed the code only on Button -4 Link-1 only Hers the Live Demo of the page : Live Demo Of the page Heres the Java Script: Java Script Here's the CSS : Code: html,body { padding:0; margin: 0px; background: #306f80; } #wrapper{ width: 1024px; margin-right: auto; margin-left: auto; background: #FFFFFF; height: 1000px; } #header{ height: 100px; width: 1024px; background: url(../images/header.png) repeat-x; } .icons_hold{ float: right; height: 55px; width: 200px; position: relative; top: 10px; right: 10px; } .navestyle{ width: 1024px; font-weight: bold; margin-right: auto; margin-left: auto; } .navestyle:after{ /*Add margin between menu and rest of content in Firefox*/ content: "."; display: block; height: 0; clear: both; visibility: hidden; } .navestyle ul{ border: 1px solid #BBB; width: 100%; background: url(../images/nav_bg.png) repeat-x center center; /*THEME CHANGE HERE*/ padding: 4px 0; margin: 0; text-align: center; font: 12px Verdana, Arial, Helvetica, sans-serif; } .navestyle ul li{ display: inline; margin-right: 2px; margin-left: 2px; } .navestyle ul li a{ color: #494949; padding: 4px 45px 4px 7px; margin: 0; text-decoration: none; border-right: 1px solid #DADADA; } .navestyle ul li a:hover, .navestyle ul li a.selected{ /*script dynamically adds a class of "selected" to the current active menu item*/ background: url(../images/hover.png) repeat-x center center; /*THEME CHANGE HERE*/ color: #FFFFFF; } /* ######### Style for Drop Down Menu ######### */ .dropmenudiv{ position:absolute; top: 0; border: 1px solid #BBB; /*THEME CHANGE HERE*/ border-bottom-width: 0; font:normal 12px/18px Verdana, Arial, Helvetica, sans-serif; z-index:100; background-color: white; visibility: hidden; width: 200px; } .dropmenudiv a{ width: auto; display: block; text-indent: 3px; border-bottom: 1px solid #BBB; /*THEME CHANGE HERE*/ padding: 2px 0; text-decoration: none; font-weight: bold; color: black; } * html .dropmenudiv a{ /*IE only hack*/ width: 100%; } .dropmenudiv a:hover{ /*THEME CHANGE HERE*/ background-color: #F0F0F0; } img { border: none; } .pagination{ padding: 0px 2px 2px; clear: both; } .pagination ul{ margin: 0; padding: 0; text-align: center; /*Set to "right" to right align pagination interface*/ font-size: 16px; } .pagination li{ list-style-type: none; display: inline; padding-bottom: 1px; } .pagination a, .pagination a:visited{ padding: 0 5px; border: 1px solid #9aafe5; text-decoration: none; color: #2e6ab1; } .pagination a:hover, .pagination a:active{ border: 1px solid #2b66a5; color: #000; background-color: #FFCC33; } .pagination a.currentpage{ background-color: #2e6ab1; color: #FFF !important; border-color: #2b66a5; font-weight: bold; cursor: default; } .pagination a.disablelink, .pagination a.disablelink:hover{ background-color: white; cursor: default; color: #929292; border-color: #929292; font-weight: normal !important; } .pagination a.prevnext{ font-weight: bold; } #demoArea { padding: 10px ; height: 580px ; background: #FFFFFF ; /*border: 1px solid black ;*/ /*display: table ;*/ } #demoLinks { width: 20% ; border-right: 1px dotted blue ; float: left ; } #demoBrowser { position: relative; width: 950px; margin-left: auto; margin-right: auto; } #tabBrowser { position: absolute ; width: 100% ; } /* --------------- TABS -------------------*/ #tabDemo { display: none } #tabContainer { display: block ; } #tabs { cursor: default ; list-style-type: none ; /*width: 560px ;*/ margin: 0 ; padding: 0 ; } #tabs li { background: #FFFBF0 ; border: 1px solid green ; border-bottom: 0 ; -moz-border-radius-topleft: 5px ; -moz-border-radius-topright: 5px ; float: left ; width: 100px ; min-width: 35px ; height: 20px ; margin: 0 2px 3px 0 ; padding-left: 3px ; } .tabTitle { float: left ; width: 80% ; height: 100% ; overflow: hidden ; } .closeTab { text-align: center ; text-transform: uppercase ; margin: 2px 3px 2px 80% ; border: outset 1px #D40000 ; } .closeTab:hover { background: #000000; } /* --------------- BROWSER -------------------*/ #tabContent { position: relative ; clear: both ; width: 100% ; } #tabContent div { position: absolute ; width: 100% ; } Here's the Mark Up : 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" lang="en" xml:lang="en"> <head> <title>Testing page</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" type="text/css" href="css/css.css" /> <script type="text/javascript" src="js/tabbed_browser.js"></script> <script type="text/javascript" src="js/chrome.js"> </script> </head> <body> <div id="wrapper"> <div id="header"> <div class="icons_hold"><a href="#"><img src="images/home.png" title="home" /></a> <a href="#"><img src="images/help.png" title="help" /></a> <a href="#"><img src="images/sign_out.png" title="signe out" /></a></div> </div> <div class="navestyle" id="navemenu"> <ul> <li><a href="#" title="chaitnyas testing page">Button-1</a></li> <li><a href="#" title="chaitnyas testing page">Button-2</a></li> <li><a href="#" title="chaitnyas testing page">Button-3</a></li> <li><a href="#" rel="dropmenu1" title="chaitnyas testing page">Button-4</a></li> <li><a href="#" rel="dropmenu2" title="chaitnyas testing page">Button-5</a></li> <li><a href="#" rel="dropmenu3" title="chaitnyas testing page">Button-6</a></li> <li><a href="#" title="chaitnyas testing page">Button-7</a></li> <li><a href="#" title="chaitnyas testing page">Button-8</a></li> </ul> </div> <!--1st drop down menu --> <div id="dropmenu1" class="dropmenudiv"> <a id="link1" onclick="openTab('link1')" href="http://yahoo.com." title="chaitnyas testing page" ><img src = "images/1.gif" /> Link-1</a> <a href="link-2.htm" title="chaitnyas testing page"><img src = "images/2.gif" /> Link-2</a> <a href="link-3.htm" title="chaitnyas testing page"><img src = "images/3.gif" /> Link-3</a> <a href="link-4.htm" title="chaitnyas testing page"><img src = "images/4.gif" /> Link-4</a> <a href="link-5.htm" title="chaitnyas testing page"><img src = "images/5.gif" /> Link-5</a></div> <!--2nd drop down menu --> <div id="dropmenu2" class="dropmenudiv" style="width: 150px;"> <a href="#" title="chaitnyas testing page"><img src = "images/6.gif" /> Link-1</a> <a href="#" title="chaitnyas testing page"><img src = "images/7.gif" /> Link-2</a> <a href="#" title="chaitnyas testing page"><img src = "images/8.gif" /> Link-3</a></div> <!--3rd drop down menu --> <div id="dropmenu3" class="dropmenudiv" style="width: 150px;"> <a href="#" title="chaitnyas testing page"><img src = "images/9.gif" /> Link-1</a> <a href="#" title="chaitnyas testing page"><img src = "images/10.gif" /> Link-2</a> <a href="#" title="chaitnyas testing page"><img src = "images/11.gif" /> Link-3</a></div> <script type="text/javascript"> cssdropdown.startchrome("navemenu") </script> <p><br /> <div id="demoBrowser"> <div id="tabBrowser"> <div id="tabContainer"> <ul id="tabs"><li id="tabDemo"><div class="tabTitle">Google</div><div class="closeTab">x</div></li> </ul> </div> <div id="tabContent"> </div> </div> </div> </div><br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> </p> <div class="pagination"> <ul> <li><a href="products.htm" class="currentpage" title="Products">1</a></li> <li><a href="products1.htm" title="Products">2</a></li> <li><a href="products2.htm" title="Products">3</a></li> </ul> </div><br /> </p> </div> </body> </html> Can someone help me with this javascript? It works fine with 10 images, but when I add the 11th it will not rotate the 11th image but still rotate the 1st 10. <br> <script type="text/javascript"> var imgs1 = new Array("/resource/resmgr/Ad_Banner/ad16.jpg","/resource/resmgr/Ad_Banner/ad13.jpg","/resource/resmgr/Ad_Banner/ad14.jpg","/resource/resmgr/Ad_Banner/ad8.jpg","/resource/resmgr/Ad_Banner/ad15.jpg","/resource/resmgr/Ad_Banner/ad18.jpg","/resource/resmgr/Ad_Banner/ad12.jpg","/resource/resmgr/Ad_Banner/ad19.jpg","/resource/resmgr/Ad_Banner/ad20.jpg","/resource/resmgr/Ad_Banner/ad21.jpg","/resource/resmgr/Ad_Banner/ad21.jpg","/resource/resmgr/ad_Banner/ad3.jpg"); var lnks1 = new Array("http://www.adamscollision.com","http://www.huntleyrealty.com","http://www.trinitycpraed.com","http://www.sccah.com/?page=SCFestival","http://www.blazekshomefurnishings.hdspd.com","http://www.sccah.com/?page=JB_Const","http://tgconsultantsinc.com/","http://blueskiespilotshop.com/index.html ","http://www.aaaglass.com/ ","http://www.carytravelexpress.com/","http://www.sccah.com/?page=Ad_Inquiry "); var alt1 = new Array("Adams Collision","Huntley Realty","Trinity","Sun City Arizona","Hunter Douglas Window Coverings and Custom Draperies","J&B Construction","TGI Consulting","Blue Skies","AAA Glass","Cary Travel Express","THIS COULD BE YOUR AD!!!"); var currentAd1 = 0; var imgCt1 = 11; function cycle1() { if (currentAd1 == imgCt1) { currentAd1 = 0; } var banner1 = document.getElementById('adBanner1'); var link1 = document.getElementById('adLink1'); banner1.src=imgs1[currentAd1] banner1.alt=alt1[currentAd1] document.getElementById('adLink1').href=lnks1[currentAd1] currentAd1++; } window.setInterval("cycle1()",4000); </script> <a href=""http://www.adamscollision.com"" id="adLink1" rel="nofollow" target="_blank"> <img src="/resource/resmgr/Ad_Banner/ad16.jpg" id="adBanner1" border="0" width="170" height="200"></a> I need good java coder to join to make website to new Gaming croup, we cannot pay you anything but job is not that big eighter, so if here is someone who could help to make this one website i would be very happy. Thanks! Kalmah Hello all, I am an admin, and I am building a radial button search option on a webpage. It works fine, except I cant seem to get it to open the results in a new window. I tried using the "window.open" but it didnt work. Any assitance would be appreciated! Also, I am not a great java programmer, and what you see below is the extent of my knowledge Thanks in Advance!! ===================CODE=============== <html> <body> <script language="JavaScript">eng = 'http://www.google.com/search?q=';</script> Search: <input type="text" id="searchterms"> <input type="button" value="Search" onload="" onclick="window.location = eng + escape(document.getElementById('searchterms').value); return false;"> <br /> <input type="radio" onclick="eng = this.value;" checked name="sengines" value="http://www.google.com/search?q=" />Google <input type="radio" onclick="eng = this.value;" name="sengines" value="http://support.citrix.com/search/basic/?searchQuery=" />CTX KB <input type="radio" onclick="eng = this.value;" name="sengines" value="http://support.microsoft.com/search/default.aspx?mode=r&query=" />MS KB </body> </html> hi i have this code i want to put a java script for this java scrip should be (amt1*amt2)+(amt3)*(amt4)=amt5 if (amt1*amt2)+(amt3)*(amt4) > amt5 should giver mesage on keyup of amount amt4 plzz help me how do i put javascript for this ...........plz help me Code: <table width="1113" height="99" border="0"> <tr bgcolor="#99FF66"> <td width="60"><div align="center"><strong>GROUP ID</strong></div></td> <td width="46"><div align="center"><strong>PART ID</strong></div></td> <td width="97"><div align="center"><strong>ITEM NAME</strong></div></td> <td width="144"><div align="center"><strong>UNIT</strong></div></td> <td width="144"><div align="center"><strong>a/b/c</strong></div></td> <td width="144"><div align="center"><strong>Qty/Crtn</strong></div></td> <td width="144"><div align="center"><strong>Nbr of Crtns</strong></div></td> <td width="144"><div align="center"><strong>Nett Wt/Crt</strong></div></td> <td width="152"><div align="center"><strong>Grs Wt/Crtn</strong></div></td> </tr> <?php $noofrow=0; $result10 = mysql_query("SELECT * FROM Ibws_Data WHERE Sc_No='$PcNo' AND Seq_No='$SeqNo' "); // $row1000 = mysql_fetch_array( $result1000 ); //$Sub_Total=""; while($row10 = mysql_fetch_array( $result10 )) { //$ttlamt=mysql_number_format(); $noofrow++; ?> <tr bgcolor="#99CC66"> <td><label> <?php echo '<input name="Group_ID'.$noofrow.'" value="'.$row10['Group_ID'].'" type="text" size="8" maxlength="12" readonly="readonly" style="text-align:center" />' ; ?> </label></td> <td><label> <?php echo '<input name="Part_ID'.$noofrow.'" value="'.$row10['Part_ID'].'" type="text" size="8" maxlength="12" readonly="readonly" style="text-align:center" />' ; ?> </label></td> <td><label> <?php echo '<input name="Name'.$noofrow.'" value="'.$row10['Name'].'" type="text" size="20" maxlength="25" readonly="readonly" style="text-align:center" />' ; ?> </label></td> <td><label> <?php echo '<input name="Unit'.$noofrow.'" value="'.$row10['Unit'].'" type="text" size="8" maxlength="25" readonly="readonly" style="text-align:center" />' ; ?> </label></td> <td><label> <?php echo '<input name="cat'.$noofrow.'" value="a" type="text" size="8" maxlength="25" readonly="readonly" style="text-align:center" />' ; ?> </label></td> <td><label> <?php echo '<input name="amt1'.$noofrow.'" value="a" type="text" size="8" maxlength="25" readonly="readonly" style="text-align:center" />' ; ?> </label></td> <td><label> <?php echo '<input name="amt2'.$noofrow.'" value="a" type="text" size="8" maxlength="25" readonly="readonly" style="text-align:center" />' ; ?> </label></td> <td><label> <?php echo '<input name="amt3'.$noofrow.'" value="a" type="text" size="8" maxlength="25" readonly="readonly" style="text-align:center" />' ; ?> </label></td> <td><label> <?php echo '<input name="amt4'.$noofrow.'" value="a" type="text" size="8" maxlength="25" readonly="readonly" style="text-align:center" />' ; ?> </label></td> <td><label> <?php echo '<input name="amt5'.$noofrow.'" value="a" type="text" size="8" maxlength="25" readonly="readonly" style="text-align:center" />' ; ?> </label></td> </tr> <tr> <td><label> <input type="submit" name="button" id="button" value="Submit" /> </label></td> <td><label></label></td> <td><label></label></td> <td> </td> <td><label></label></td> <td><label></label></td> </tr> </table> <p> </p> <p> </p> </form> plz help me with a sample java scrip code I was hoping someone could help me fix this javascript code. I have been working for hours and it does not work. <html> <head> <title>Moondoe's Coffee House</title> </head> <script type="text/javascript"> var drink, ounces; prompt( "Enter the drink type:espresso, latte, cappuccino, americano" ); prompt( "Enter the ounce size: 8, 12, 16" ); var shots = prompt ( "Enter the number of shots" ); if ( drink == "espresso") price = 1.40; if ( drink == "latte") || drink == "cappuccino" ) { if ( ounce == 8 ) price = 1.95; else if ( ounce == 12 ) price = 2.35; else if ( ounce == 16 ) price = 2.75; } if ( drink == "americano" ) price = 1.20 + ( ( (ounce/8) -1 ) * .30 ); price = price + ( (shots-1) * .50 ); price = price * 1.055; price = Math.round ( price*100 ) /100; alert ( "Your " + ounce + "oz. " + drink + "with " + shots + "\nshots of espresso costs: $ " + price ); alert( "drink = " + drink + "ounce = "ounce + "shots = "shots ); </script> </html> Hey guys! I have this website mmosaga.com and in need of some help to fix my BG. Im trying to get my BG to rescale to various of monitor sizes. My monitor width is 1440 and my BG images are Width: 1566 Height:768. I want that position to show up on all the other browsers including IE. Here the code I use PHP Code: <html> <head> <script language="javascript"> function randomBackground() { var myImages = Array(); myImages[0] = 'Florenga.jpg'; myImages[1] = 'pangar.jpg'; myImages[2] = 'GrandChaseBG.png'; myImages[3] = 'ADBG.png'; myImages[4] = 'AionBG.png'; myImages[5] = 'FiestaBG.jpg'; myImages[6] = 'GalaxyOnlineBG.jpg'; myImages[7] = 'GunzBG.png'; myImages[8] = 'IrisOnlineBG.png'; myImages[9] = 'MabinogiBG.png'; myImages[10] = 'APB.jpg'; myImages[11] = 'S4LeagueBG.jpg'; myImages[12] = 'APB.jpg'; myImages[13] = 'WorldOfTanksBG.jpg'; myImages[14] = 'Elsword.jpg'; myRandomNumber = Math.floor(Math.random()*myImages.length); document.body.style.backgroundImage = 'URL('+myImages[myRandomNumber]+')'; } </script> <style type="text/css"> body { background-attachment: fixed; background-repeat: no-repeat; } </style> </head> <body onload="randomBackground();"></body> Can someone help tell me where i've gone wrong! My finished script works in all browser except IE in IE it works on some machines not others, if i put the finesed page in a Iframe on another site it works but not in the original URL and on my machine it works if i go directly to the URL however if i hit refresh it doesn't work until i go directly to the URL again! In developer tools it comes up with the following error: SCRIPT5022: DOM Exception: TYPE_MISMATCH_ERR (17) cgl.js, line 147 character 3 here is the script it is referring too! Please help!!! PHP Code: var CGL = {}; CGL.canvas = { DEFAULT_CONTEXT : "2d", DEFAULT_CANVAS_ID : "cglcanvas", CANVAS_CONTAINER : "", CANVAS_WIDTH : 300, CANVAS_HEIGHT : 200, TARGET_FPS : 60, setDefault : function(option, value){ CGL.canvas[option] = value; }, getDefault : function(option){ return CGL.canvas[option]; }, /** * @method createCanvas(id, width, height) * @param id : sets the CANVAS_CONTAINER * @param width : sets the CANVAS_WIDTH * @param height : sets the CANVAS_HEIGHT * * Creates a <canvas> element that will be used as the main graphics container for the game! */ createCanvas : function(id, width, height){ var canvas = document.createElement("canvas"); CGL.canvas.CANVAS_WIDTH = width; CGL.canvas.CANVAS_HEIGHT = height; CGL.canvas.CANVAS_CONTAINER = id; canvas.setAttribute("width", width); canvas.setAttribute("height", height); canvas.style.borderColor = "black"; canvas.style.borderStyle = "solid"; canvas.style.borderWidth = "1px"; canvas.setAttribute("id", CGL.canvas.DEFAULT_CANVAS_ID); document.getElementById(id).appendChild(canvas); var elem = document.createElement("div"); elem.setAttribute("id", "status"); elem.style.width = width + "px"; elem.style.height = "120px"; elem.style.overflowY = "scroll"; elem.style.borderColor = "black"; elem.style.borderStyle = "solid"; elem.style.borderWidth = "1px"; elem.style.color = "black"; elem.style.backgroundColor = "white"; elem.style.display = "none"; document.getElementById(id).appendChild(elem); }, /** * @method getContext() * * Returns the graphic context as chosen by the DEFAULT_CONTEXT global. */ getContext : function(){ var canvas = document.getElementById(CGL.canvas.DEFAULT_CANVAS_ID); return canvas.getContext(CGL.canvas.DEFAULT_CONTEXT); } }; CGL.image = { IMAGE_ID : 0, DEFAULT_IMAGECONT_ID : "imgcont", createImageContainer : function() { var div = document.createElement("div"); div.setAttribute("id", CGL.image.DEFAULT_IMAGECONT_ID); div.style.display = "none"; document.body.appendChild(div); }, load : function(src, id){ var img = document.createElement("img"); img.setAttribute("src", src); img.setAttribute("id", id); img.setAttribute("onload", "notifyLoaded(" + id + ")"); document.getElementById(CGL.image.DEFAULT_IMAGECONT_ID).appendChild(img); }, Image : function(source, uid, srcx, srcy){ var img = { id : uid, x : srcx, y : srcy }; CGL.image.load(source, uid); return img; }, render : function(ctx, img){ ctx.drawImage(document.getElementById(img.id), img.x, img.y); }, renderAt : function(ctx, imgid, x, y){ ctx.drawImage(document.getElementById(imgid), x, y); }, renderPart : function(ctx, imgid, srcx, srcy, srcwidth, srcheight, destx, desty, destwidth, destheight){ ctx.drawImage(document.getElementById(imgid), srcx, srcy, srcwidth, srcheight, destx, desty, destwidth, destheight); } }; CGL.sprite = { Sprite : function(frames, time){ var sprite = { active : true, speed : time || 500, activeFrame : 0, maxFrames : frames.length - 1, images : frames, timeCount : 0, loop : true, nextFrame : function(){ sprite.activeFrame += 1; if(sprite.activeFrame > sprite.maxFrames) { if(sprite.loop) { sprite.activeFrame = 0; } else { sprite.activeFrame = 0; sprite.active = false; } } }, setSpeed : function(time){ sprite.speed = time; }, setLoop : function(looping){ sprite.loop = looping; }, setActiveFrame : function(actFrame){ sprite.activeFrame = actFrame; }, stop : function(){ sprite.active = false; }, start : function(){ sprite.active = true; }, replay : function(){ sprite.activeFrame = 0; sprite.active = true; }, update : function(time){ if(sprite.active) { sprite.timeCount += time; } if(sprite.timeCount > sprite.speed) { sprite.nextFrame(); sprite.timeCount = 0; } }, render : function(ctx, x, y){ ctx.drawImage(document.getElementById(sprite.images[sprite.activeFrame]), x, y); } }; return sprite; } }; CGL.resource = { RESOURCES : 0, loadImages : function(xml){ var image, elem, i; var img = new Array(); var imgsrc, imgid; xmlhttp = CGL.ajax._createXHR(); xmlhttp.onreadystatechange = function(){ if (xmlhttp.readyState==4 && xmlhttp.status==200){ image = xmlhttp.responseXML.documentElement.getElementsByTagName("image"); for(i = 0; i < image.length; i++){ elem = image[i].getElementsByTagName("src"); try{ imgsrc = elem[0].firstChild.nodeValue; } catch(er){ } elem = image[i].getElementsByTagName("id"); try{ imgid = elem[0].firstChild.nodeValue; } catch(er){ } CGL.image.load(imgsrc, imgid); img[i] = imgid; CGL.resource.RESOURCES++; CGL.util.printLn("Loaded Image: " + imgsrc + " With ID: " + imgid); } } }; xmlhttp.open("GET",xml,false); xmlhttp.send(); return img; } }; CGL.highscore = { highscore : function(url, posts) { var highScore = { name : new Array(posts), score : new Array(posts), level : new Array(posts), size : posts, getHighScore : function() { highScore.size = 10; xmlhttp = CGL.ajax._createXHR(); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { var string = xmlhttp.responseText; var list = eval( "(" + string + ")" ); for(i = 0; i < list.length; i++){ highScore.name[i] = list[i].name; highScore.score[i] = list[i].score; highScore.level[i] = list[i].level; } highScore.size = list.length; } } xmlhttp.open("GET",url + "?action=get&posts=" + highScore.size ,false); xmlhttp.send(); }, recordHighScore : function(name, level, score) { xmlhttp = CGL.ajax._createXHR(); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { CGL.util.printLn(xmlhttp.responseText); } } xmlhttp.open("GET",url + "?action=put&name=" + name + "&score=" + score + "&level=" + level ,false); xmlhttp.send(); }, reInit : function() { for(var i = 0; i < highScore.size; i++) { delete highScore.name[highScore.size-i]; delete highScore.score[highScore.size-i]; delete highScore.level[highScore.size-i]; } } }; return highScore; } }; CGL.ajax = { _createXHR : function() { try { return new XMLHttpRequest(); } catch(e) {} try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); } catch (e) {} try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); } catch (e) {} try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {} try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} return null; } }; CGL.util = { MESSAGE_ID : 0, LASTUPDATE : 0, UPDATE_RPS : 40, printLn : function(message) { var elem = document.createElement("p"); elem.setAttribute("id", CGL.util.MESSAGE_ID); document.getElementById("status").appendChild(elem); document.getElementById(CGL.util.MESSAGE_ID).innerHTML = CGL.util.MESSAGE_ID + " : " + message; CGL.util.MESSAGE_ID++; }, gameTimer : function() { delta = new Date(); if(delta.getTime() > CGL.util.LASTUPDATE + 1000/CGL.util.UPDATE_RPS) { CGL.util.LASTUPDATE = delta.getTime(); return true; } else return false; }, }; CGL.math = { Vector2 : function(vx, vy) { var Vector2 = { x : vx || 0.0, y : vy || 0.0, interpolate : function(a_vec, b_vec, a_f){ return a_vec.mul(a_f).add(b_vec.mul(1-a_f)); }, mul : function(other){ Vector2.x *= other.x; Vector2.y *= other.y; }, mulScale : function(scale) { Vector2.x *= scale; Vector2.y *= scale; }, sub : function(other) { Vector2.x -= other.x; Vector2.y -= other.y; }, add : function(other) { Vector2.x += other.x; Vector2.y += other.y; }, div : function(other) { Vector2.x /= other.x; Vector2.y /= other.x; }, divScale : function(scale) { Vector2.x /= scale; Vector2.y /= scale; }, scale : function(a_f, a_g){ return new CGL.math.Vector2d(a_f * Vector2d.m_x, a_g * Vector2d.m_y); }, dot : function(other) { return ((Vector2.x * other.x) + (Vector2.y * other.y)); }, neg : function() { return new CGL.math.Vector2(-Vector2.x, -Vector2.y); }, normalize : function() { var l = Vector2.length(); if(l == 0){ return; } Vector2.x /= l; Vector2.y /= l; }, lengthSquared : function() { return (Vector2.x * Vector2.x) + (Vector2.y * Vector2.y); }, length : function() { return Math.sqrt(Vector2.lengthSquared()); }, toString : function() { return "[Vector (" + Vector2.x + ", " + Vector2.y + ")]"; }, copy : function(other) { Vector2.x = other.x; Vector2.y = other.y; }, draw : function(ctx) { /* Convert to Local space */ var lx, ly; if(Vector2.x < 0.0) { lx = (-Vector2.x * -50) + 200; } else { lx = (Vector2.x * 50) + 200; } if(Vector2.y > 0.0) { ly = (Vector2.y * -50) + 200; } else { ly = (-Vector2.y * 50) + 200; } ctx.beginPath(); ctx.arc(lx, ly, 2, 0, Math.PI*2, true); // Outer circle ctx.fill(); } }; return Vector2; }, getNormal : function(vx, vy) { var n = new CGL.math.Vector2(vy.x, vy.y); n.sub(vx); n = new CGL.math.Vector2(n.y, -n.x); n.normalize(); return n; } }; CGL.ui = { Button : function(imgs, srcx, srcy, srcwidth, srcheight) { var button = { images : imgs, x : srcx, y : srcy, width : srcwidth, height : srcheight, active : false, clicked : false, update : function(mx, my, mb) { if(mx > button.x && mx < button.x + button.width && my > button.y && my < button.y + button.height) { button.active = true; } else { button.active = false; } if(button.active && mb) { button.clicked = true; } }, activated : function() { return button.clicked; }, deactivate : function() { button.clicked = false; }, render : function(ctx) { if(!button.active) { ctx.drawImage(document.getElementById(button.images[0]), button.x, button.y); } else { ctx.drawImage(document.getElementById(button.images[1]), button.x, button.y); } } }; return button; } }; CGL.event = { MOUSEX : 0, MOUSEY : 0, KLEFT : false, KRIGHT : false, KDOWN : false, KUP : false, KSPACE : false, KPAUSE : false, CLICKED : false, ACTIVEGAMEKEY : true, handleEventMovement : function(e) { CGL.event.getCursorPosition(e); }, handleEventClick : function(e) { CGL.event.CLICKED = true; }, clearEvents : function() { CGL.event.KLEFT = false; CGL.event.KRIGHT = false; CGL.event.KDOWN = false; CGL.event.KUP = false; CGL.event.KSPACE = false; CGL.event.KPAUSE = false; CGL.event.CLICKED = false; }, handleEventKey : function(e) { if(CGL.event.ACTIVEGAMEKEY) { e.stopPropagation(); e.preventDefault(); } switch(e.keyCode) { case 19: CGL.event.KPAUSE = true; break; case 32: CGL.event.SPACE = true; CGL.util.printLn("Space was triggered!"); break; case 37: CGL.event.KLEFT = true; break; case 38: CGL.event.KUP = true; break; case 39: CGL.event.KRIGHT = true; break; case 40: CGL.event.KDOWN = true; break; case 65: CGL.event.KLEFT = true; CGL.util.printLn("Left was triggered!"); break; case 87: CGL.event.KUP = true; CGL.util.printLn("Up was triggered!"); break; case 68: CGL.event.KRIGHT = true; CGL.util.printLn("Right was triggered!"); break; case 80: CGL.event.KPAUSE = true; break; case 83: CGL.event.KDOWN = true; CGL.util.printLn("Down was triggered!"); break; default: break; }; }, getCursorPosition : function(e) { if (e.pageX != undefined && e.pageY != undefined) { CGL.event.MOUSEX = e.pageX; CGL.event.MOUSEY = e.pageY; } else { CGL.event.MOUSEX = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; CGL.event.MOUSEY = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; } CGL.event.MOUSEX -= document.getElementById(CGL.canvas.DEFAULT_CANVAS_ID).offsetLeft; CGL.event.MOUSEY -= document.getElementById(CGL.canvas.DEFAULT_CANVAS_ID).offsetTop; } }; hi, i have a html form and i have three text boxes named Max Accessories: Accessory SKU: Accessory CPC ID: and i want a javascript functionality like, if the user enters in the max accessories text box value as 1, then the below two text boxes should update like automatically like below, AcceSsory 1 SKU ACCESSORY 1 CPC ID SIMILARLY if user enters Max accessories value as 2 in the text box, then the below two text boxes should update like automatically like below AcceSsory 1 SKU ACCESSORY 1 CPC ID AcceSsory 2 SKU ACCESSORY 2 CPC ID onchange of the key, for accessory it should call some function in the same page and dynamically update. can any one please provide, a solution for this , thanks. |