JavaScript - Get Lines
Hello every body
i have a problem with javascript i wrote a script which process the entry of a text area 1 and i made the script process only the first line of the entry i want a method to make the script to process all of the lines which the user enter it OR make a varibals to every line entered from the user i am so sorry about the weak language thank you in advance Similar Tutorialsi have a program which gets values from different arrays and displays them on screen. how do i insert a break every 5 lines so its easier to read?
I am new to javascript but am proficient in .net languages. If I have a text file that is structured as follows; -35.889,150.984 -35.578,151.022 -35.449,150.993 I have two questions; 1. How can I read the text in that file into an array? I've tried Code: var file = "X:\ASP.Net\GoogleMaps\GMAP\MarkerCoordinates.txt"; //file:\\X:\ASP.Net\GoogleMaps\GMAP\MarkerCoordinates.txt $.get(file,function(txt) P.S. I tried the commented way above also and that didnt work I also tried using XMLHttprequest like so Code: var txtFile = new XMLHttpRequest(); txtFile.open("GET", "file:\\C:Gmap\test.txt", true); 2. How do you iterate through each line in the array? I'm not sure how to do a for-each in javascript, would be simple in .net Thank you, in advance, for any assistance Here I have a code to redirect a page to one of these three pages. But is there a limit to the amount of websites I can add? Code: <script type="text/javascript"> var urls = new Array(); urls[0] = "http://www.google.com"; urls[1] = "http://www.youtube.com"; urls[2] = "http://www.codingforums.com"; var random = Math.floor(Math.random()*urls.length); window.location = urls[random]; </script> Would I be allowed to have, say, hundreds of thousands of different sites? Or would the script stop working? Thanks. I'm making a graph in Canvas. I plot the grid with ctx.strokeStyle = '#ccc'; I then plot the data lines with ctx.strokeStyle = '#000';, and the GRID color then turns back to '#000' too! The same happens with any color. The same happens with lineWidth. The fillStyle of the labels is not affected. It happens even if I surround the code with save/restore. It happens in both Firefox and Chrome. Has anyone else had this problem? Is there any way around it? Say I have a <textarea> input and I want to strip all the blank lines (lines with only whitespace). I have this regular expression, why doesn't it do anything? I've tried different variations with the flags (m and g). Code: ... var output = input.replace(/^\s*$/gm, "notworking!"); ... The very same regex works fine in my text editor (Notepad2), and I can match all empty lines. Code: LINE1 LINE4 ^(line 3 has some spaces) should become Code: LINE1 LINE4 And when I finally do get this to work, how would I remove the empty line? This is my first posting to this forum. I have list of about a thousand applications for which various outsourcing companies are supporting at different levels. I want to use the attached code to filter. For example, if I type "SOX", every row with "SOX" appears. The filter works well but when I type "S" and the information appears on row, the height of the row changes. When I type "O" it changes more. What must I change to keep the height of the rows consistent. Thank you <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Filter applications</title> </head> <body> <table style="width: 646px; height: 926px;" id="content"> <tbody> <tr> <td id="main"> <div class="node"> <div class="content"><img style="width: 636px; height: 183px;" alt="" src="../Common%20Graphics/header.png" /><br /> <big><span style="font-family: Arial;">Governing outsourcing companies servicing applications</span></big><br /> <br /> <script type="text/javascript"> function filter (phrase, _id){ var words = phrase.value.toLowerCase().split(" "); var table = document.getElementById(_id); var ele; for (var r = 1; r < table.rows.length; r++){ ele = table.rows[r].innerHTML.replace(/<[^>]+>/g,""); var displayStyle = 'none'; for (var i = 0; i < words.length; i++) { if (ele.toLowerCase().indexOf(words[i])>=0) displayStyle = ''; else { displayStyle = 'none'; break; } } table.rows[r].style.display = displayStyle; } } </script> <form><b style="font-family: Arial;">Filter:</b> <input name="filt" onkeyup="filter(this, 'sf')" type="text" /></form> <br /> <hr style="width: 100%; height: 2px;" /> <table id="sf" style="width: 636px; height: 994px;" border="0" cellpadding="2" cellspacing="1"> <tbody> <tr> <td style="font-family: Arial; background-color: rgb(255, 255, 153);"><font color="">Application</font></td> <td style="font-family: Arial; background-color: rgb(255, 255, 153);"><font color="">Outsourcing company</font></td> <td style="font-family: Arial; background-color: rgb(255, 255, 153);"><font color="">Support</font></td> </tr> <tr> <td style="font-family: Arial;"><a href="HTML/index.html" target="_blank">432 Reports Prod</a></td> <td style="font-family: Arial;">InfoSys </td> <td style="font-family: Arial;">Gold</td> </tr> <tr bgcolor="#eaecef"> <td style="color: black; width: 256px; font-family: Arial;">Accomodation Reservation System</td> <td style="width: 223px; font-family: Arial;">InfoSys </td> <td style="width: 133px; font-family: Arial;">Silver</td> </tr> <tr bgcolor="#ffffff"> <td style="color: black; width: 256px; font-family: Arial; height: 30px;">ACL - Audit Command Language</td> <td style="width: 223px; font-family: Arial;">Accenture </td> <td style="width: 133px; font-family: Arial;">Gold SOX</td> </tr> <tr bgcolor="#eaecef"> <td style="color: black; width: 256px; font-family: Arial;">Actions Tracker</td> <td style="width: 223px; font-family: Arial;">Tata </td> <td style="width: 133px; font-family: Arial;">Gold SOX Critical</td> </tr> <tr bgcolor="#ffffff"> <td style="color: black; width: 256px; font-family: Arial;">Air Quality Public Website and Dispersion Forecast</td> <td style="width: 223px; font-family: Arial;">InfoSys </td> <td style="width: 133px; font-family: Arial;">Silver SOX</td> </tr> <tr bgcolor="#eaecef"> <td style="color: black; width: 256px; font-family: Arial;">Airport Management System</td> <td style="width: 223px; font-family: Arial;">InfoSys</td> <td style="width: 133px; font-family: Arial;">Bronze</td> </tr> <tr bgcolor="#ffffff"> <td style="color: black; width: 256px; font-family: Arial;">All Mines Grade Control</td> <td style="width: 223px; font-family: Arial;">InfoSys</td> <td style="width: 133px; font-family: Arial;">Gold</td> </tr> <tr bgcolor="#eaecef"> <td style="color: black; width: 256px; font-family: Arial;">ALLDATA</td> <td style="width: 223px; font-family: Arial;">Tata</td> <td style="width: 133px; font-family: Arial;">Gold Critical</td> </tr> <tr bgcolor="#ffffff"> <td style="color: black; width: 256px; font-family: Arial;">AppAdmin</td> <td style="width: 223px; font-family: Arial;">Accenture</td> <td style="width: 133px; font-family: Arial;">Gold SOX</td> </tr> <tr bgcolor="#eaecef"> <td style="color: black; width: 256px; font-family: Arial;">APPSRS</td> <td style="width: 223px; font-family: Arial;">InfoSys</td> <td style="width: 133px; font-family: Arial;">Silver SOX</td> </tr> <tr bgcolor="#ffffff"> <td style="color: black; width: 256px; font-family: Arial;">ArcGIS</td> <td style="width: 223px; font-family: Arial;">InfoSys</td> <td style="width: 133px; font-family: Arial;">Silver</td> </tr> <tr bgcolor="#eaecef"> <td style="color: black; width: 256px; font-family: Arial;">ASGLIB</td> <td style="width: 223px; font-family: Arial;">InfoSys</td> <td style="width: 133px; font-family: Arial;">Gold Critical</td> </tr> <tr bgcolor="#ffffff"> <td style="color: black; width: 256px; font-family: Arial;">Asset Integrity</td> <td style="width: 223px; font-family: Arial;">InfoSys </td> <td style="width: 133px; font-family: Arial;">Bronze</td> </tr> <tr bgcolor="#eaecef"> <td style="color: black; width: 256px; font-family: Arial;">Asset Integrity - FLPS QA Survey</td> <td style="width: 223px; font-family: Arial;">InfoSys</td> <td style="width: 133px; font-family: Arial;">Silver</td> </tr> <tr bgcolor="#ffffff"> <td style="color: black; width: 256px; font-family: Arial;">Asset Management Framework (FLPS)</td> <td style="width: 223px; font-family: Arial;">InfoSys </td> <td style="width: 133px; font-family: Arial;">Gold</td> </tr> <tr bgcolor="#eaecef"> <td style="color: black; width: 256px; font-family: Arial;">Auto Cad (MB)</td> <td style="width: 223px; font-family: Arial;">InfoSys</td> <td style="width: 133px; font-family: Arial;">Gold SOX</td> </tr> <tr bgcolor="#ffffff"> <td style="color: black; width: 256px; font-family: Arial;">Autocad</td> <td style="width: 223px; font-family: Arial;">InfoSys </td> <td style="width: 133px; font-family: Arial;">Gold SOX Critical</td> </tr> <tr bgcolor="#eaecef"> <td style="color: black; width: 256px; font-family: Arial;">AutoMod</td> <td style="width: 223px; font-family: Arial;">InfoSys </td> <td style="width: 133px; font-family: Arial;">Silver</td> </tr> <tr bgcolor="#ffffff"> <td style="color: black; width: 256px; font-family: Arial;">AutoSkills</td> <td style="width: 223px; font-family: Arial;">InfoSys </td> <td style="width: 133px; font-family: Arial;">Bronze</td> </tr> <tr bgcolor="#eaecef"> <td style="color: black; width: 256px; font-family: Arial;">B Cleaner Circuit Control Summary (BCLDIS)</td> <td style="width: 223px; font-family: Arial;">InfoSys </td> <td style="width: 133px; font-family: Arial;">Silver SOX</td> </tr> <tr bgcolor="#ffffff"> <td style="color: black; width: 256px; font-family: Arial;">BACCESS (Acton)</td> <td style="width: 223px; font-family: Arial;">Tata </td> <td style="width: 133px; font-family: Arial;">Bronze</td> </tr> <tr bgcolor="#eaecef"> <td style="color: black; width: 256px; font-family: Arial;">BACSESS-IP</td> <td style="width: 223px; font-family: Arial;">Tata</td> <td style="width: 133px; font-family: Arial;">Gold</td> </tr> <tr bgcolor="#ffffff"> <td style="color: black; width: 256px; font-family: Arial;">Bank deposit</td> <td style="width: 223px; font-family: Arial;">Accenture </td> <td style="width: 133px; font-family: Arial;">Gold SOX Critical</td> </tr> <tr bgcolor="#eaecef"> <td style="color: black; width: 256px; font-family: Arial;">Barometer Display</td> <td style="width: 223px; font-family: Arial;">Accenture </td> <td style="width: 133px; font-family: Arial;">Gold Critical</td> </tr> <tr bgcolor="#ffffff"> <td style="color: black; width: 256px; font-family: Arial;">Batch & Print Pro</td> <td style="width: 223px; font-family: Arial;">Tata </td> <td style="width: 133px; font-family: Arial;">Silver</td> </tr> </tbody> </table> </div> <br /> </div> </td> </tr> </tbody> </table> </body> </html> Hi. I have the following line in my HTML file <table class="bz_buglist" cellspacing="0" cellpadding="4" width="100%"> And I need to use javascript to change this line to <table id="main_table" class="bz_buglist" cellspacing="0" cellpadding="4" width="100%"> . I just need to add the ID part. How can I do this? Is there a method of replacing the line, or a way to "add attribute"? thanks! kev. Has anyone ever tried to break up a text area into 2 lines, but at the same time each line has a limited number of characters allowed in it ? i.e. line 1 = maxcharacters = 124 , line 2 = machcharacters = 1024 (Line 2 will therefore wrap until 1024 chracters are reached) ... including spaces as characters. Something along the lines of: Code: var maxLines = txtArea.rows; var maxChars = txtArea.rows * txtArea.cols; countChars.value = txtArea.value.length; countLines.value = getLines(txtArea); document.myForm.maxLines.value = maxLines; document.myForm.maxChars.value = maxChars; if((txtArea.value.length >= maxChars || getLines(txtArea) >= maxLines) && (window.event.keyCode == 10 || window.event.keyCode == 13)) { while(getLines(txtArea) > maxLines) txtArea.value = txtArea.value.substr(0,txtArea.value.length-2); while(txtArea.value.length > maxChars) txtArea.value = txtArea.value.substr(0,txtArea.value.length-2); alert("chars and / or lines limit reached"); } else if(txtArea.value.length > maxChars ) { while(txtArea.value.length > maxChars) { txtArea.value = txtArea.value.substr(0,txtArea.value.length-1); } alert("chars limit reached"); } else if (f (countLines.value > maxLines) { while(countLines.value > maxLines) { txtArea.value = txtArea.value.substr(0,txtArea.value.length-1); } alert("lines limit reached"); } countChars.value = txtArea.value.length; countLines.value = getLines(txtArea); } Thanks Hi - I have the following requirement for a textarea: Limit the number of lines to 8 Limit the number of characters to 20 per line Force a line beak when the user reaches he end of a line but break the line at the start of the last word (not half way through the word). Allow pasting into the field and auto-format the line/character count Keep he cursor where it should be (don't move it to the end of the field after any formatting) This is more complicated than it sounds - anyone worked on something similar? Hi guys. I'm using a jquery plugin called innerfade, which I got from he http://medienfreunde.com/lab/innerfade/ . I've used it to fade few lines of text into each other: Code: <div class="fade"> <p>Line 1 asdfghjkl</p> <p>Line 2 sdasdsafasdgedgr</p> <p>Line 3 ddddddddddddddddddddd</p> </div> So only first line appears on page load, then after few seconds fades into Line 2 etc. Everything works perfect, but there is only one problem - the text is not centered even if it says so in CSS. Since the lines have different lenghts, the shorter the line the more it's aligned to the left. I've added properties for both div and p's - tried all combinations of text-align: center and margin left & right: auto. No joy. But when I remove the script all 3 lines appear centered perfectly. So my question is how do I make them centered? I presume it has to be added in the JS part since it seems to be overriding the CSS. Here is the script's full code: Code: (function($) { $.fn.innerfade = function(options) { return this.each(function() { $.innerfade(this, options); }); }; $.innerfade = function(container, options) { var settings = { 'animationtype': 'fade', 'speed': 'normal', 'type': 'sequence', 'timeout': 2000, 'containerheight': 'auto', 'runningclass': 'innerfade', 'children': null }; if (options) $.extend(settings, options); if (settings.children === null) var elements = $(container).children(); else var elements = $(container).children(settings.children); if (elements.length > 1) { $(container).css('position', 'relative').css('height', settings.containerheight).addClass(settings.runningclass); for (var i = 0; i < elements.length; i++) { $(elements[i]).css('z-index', String(elements.length-i)).css('position', 'absolute').hide(); }; if (settings.type == "sequence") { setTimeout(function() { $.innerfade.next(elements, settings, 1, 0); }, settings.timeout); $(elements[0]).show(); } else if (settings.type == "random") { var last = Math.floor ( Math.random () * ( elements.length ) ); setTimeout(function() { do { current = Math.floor ( Math.random ( ) * ( elements.length ) ); } while (last == current ); $.innerfade.next(elements, settings, current, last); }, settings.timeout); $(elements[last]).show(); } else if ( settings.type == 'random_start' ) { settings.type = 'sequence'; var current = Math.floor ( Math.random () * ( elements.length ) ); setTimeout(function(){ $.innerfade.next(elements, settings, (current + 1) % elements.length, current); }, settings.timeout); $(elements[current]).show(); } else { alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\''); } } }; $.innerfade.next = function(elements, settings, current, last) { if (settings.animationtype == 'slide') { $(elements[last]).slideUp(settings.speed); $(elements[current]).slideDown(settings.speed); } else if (settings.animationtype == 'fade') { $(elements[last]).fadeOut(settings.speed); $(elements[current]).fadeIn(settings.speed, function() { removeFilter($(this)[0]); }); } else alert('Innerfade-animationtype must either be \'slide\' or \'fade\''); if (settings.type == "sequence") { if ((current + 1) < elements.length) { current = current + 1; last = current - 1; } else { current = 0; last = elements.length - 1; } } else if (settings.type == "random") { last = current; while (current == last) current = Math.floor(Math.random() * elements.length); } else alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\''); setTimeout((function() { $.innerfade.next(elements, settings, current, last); }), settings.timeout); }; })(jQuery); // **** remove Opacity-Filter in ie **** function removeFilter(element) { if(element.style.removeAttribute){ element.style.removeAttribute('filter'); } } And call: Code: $(document).ready( function(){ $('.fade').innerfade({ animationtype: 'fade', speed: 750, timeout: 5000, type: 'random', containerheight: '1em' }); }); wait... why am i here???
I need to pass two lines of code through an onClick event.... player1.sendEvent('STOP'); player2.sendEvent('STOP'); I tried Code: <a href="javascript:void(0)" onClick="player1.sendEvent('STOP'); player2.SendEvent('STOP');" title="<?php echo $list[$i]->title ?>"> only the event of player1.sendEvent('STOP'); is working... but not the second one. How do I manage this right here on the link rather than calling a fuction. Thanks Is there a script that automatically applies two different styles to the first two lines of text in a container, without using CSS? Example: ====== This Would be Line One as a Title with its Own Style This would be line two as a byline with a separate style This is the main text of the paragraph... etc etc. ====== Thanks for any help. Steph Hi all, I hoping somebody can help me. I'm trying to acheive a line of text (with multiple links on each line) that change at set intervals. The code below seems to be working but I can only get working links on the first line that appears. Please can somebody help a gal out? xo [CODE] <html> <head> <title>Rotating Text</title> <script type="text/javascript"> var rotatingTextElement; var rotatingText = new Array(); var ctr = 0; function initRotateText() { rotatingTextElement = document.getElementById("textToChange"); rotatingText[0] = rotatingTextElement.innerHTML; rotatingText[1] = "why won't you work!?!?!?"; rotatingText[2] = "purdy please"; setInterval(rotateText, 5000); } function rotateText() { ctr++; if(ctr >= rotatingText.length) { ctr = 0; } rotatingTextElement.innerHTML = rotatingText[ctr]; } window.onload = initRotateText; </script> </head> <body> <span id="textToChange">log into your <a href="http://www.hotmail.com/">please</a> policy.</a> | can you <a href="http://www.google.com"> me?</a> </span> </body> </html> Hey all. I'm looking for a way to have a single, random line fetched from multiple text files, and then have that combination output somewhere, whether just to some field or another text file. For example: Text file A - I like I hate I love I despise I cherish Text file B - apples bananas oranges grapes grapefruit pineapple cherries Text file C - some of the time. most of the time. a lot of the time. pretty much never. So it would go in, get a line from each, and display something like: I love - grapefruit - most of the time. I cherish - pineapple - some of the time. etc. etc. I know it's a weird-sounding example, but you get the point. The line choices don't have to be separated by hyphens, but they preferably would be separated by something, like a comma, semi-colon, slash, whatever. I know this is pretty much a web coding forum, so that would be fine if I had to host it on my server or open it with a browser. But it would be optimal if this could be made into a standalone executable. I'm basically looking for something like Random Line Picker, just with the added functionality I mentioned. I'd be willing to make a little donation to someone if coding this would be a little difficult. Thanks! Hi, I'm one of the main developers from Trackmill.com (which is a gaming website), One of our main games is Free rider 2, Which we have converted to run via a database so people don't have to manually send around track codes so other people can evaluate their tracks. I am trying to build a track previewer in html5/javascript which will eventually replace our current one written in flash (which lags terribly on large tracks) I am stuck on 1 thing though, With the larger tracks there are up to thousands of lines that are drawn using lineTo() moveTo() etc. And when i move using the arrow keys, It requires the javascript to reload the track, and parse every single line again, Causing the screen to turn white whilst it does so. Is there a way i can use a similar method to the way it has been done in the flash version, where it is in a movieclip, which then instead of moving each line, it moves the movieclip instead. Script: Code: <html> <head> <script type="application/javascript"> var offsetx = -133; var offsety = 135; scale = 1; var canvas; var ctx; var test; function init() { canvas = document.getElementById("game"); ctx = canvas.getContext("2d"); loadtrack(); } function loadtrack() { canvas.width = canvas.width; ctx.fillText("Loading track... Please wait.",10,16); var request=new XMLHttpRequest; request.open("GET","test.txt",false); request.send(); var trackcode = request.responseText; var type = trackcode.split("#"); var line = type[0].split(","); var sline = type[1].split(","); for(var i=0; i<line.length; i++) { var section = line[i].split(" "); ctx.beginPath(); ctx.strokeStyle='black'; ctx.moveTo(parseInt(section[0],32)+offsetx+0.5, parseInt(section[1],32)+offsety+0.5); ctx.stroke(); for(var j=0; j<section.length; j+=2) { ctx.lineTo(parseInt(section[j],32)+offsetx+0.5, parseInt(section[j+1],32)+offsety+0.5); ctx.stroke(); } } for(var i=0; i<sline.length; i++) { var section = sline[i].split(" "); ctx.beginPath(); ctx.strokeStyle='grey'; ctx.moveTo(parseInt(section[0],32)+offsetx+0.5, parseInt(section[1],32)+offsety+0.5); ctx.stroke(); for(var j=0; j<section.length; j+=2) { ctx.lineTo(parseInt(section[j],32)+offsetx+0.5, parseInt(section[j+1],32)+offsety+0.5); ctx.stroke(); } } } function mousescroll(evt){ if (evt.detail <= 0){ scale += .05; loadtrack(); } else { scale -= .05; loadtrack(); } } function doKeyDown(evt){ switch (evt.keyCode) { case 37: offsetx -= 5; break; case 39: offsetx += 5; break; case 38: offsety -= 5; break; case 40: offsety += 5; break; } loadtrack(); } window.addEventListener('DOMMouseScroll', mousescroll, false); window.addEventListener('keydown',doKeyDown,true); </script> </head> <body onload="init()"> <canvas id="game" height="500" width="1200"></canvas> </body> </html> Smaller tracks load fine, example: Code: 42 1i 5u a,8e a 8e -a 8e -u 8e -1i 92 -18 92 0 9m a aa 0 au -a au a,8e -1i 9m -26 au -1i aa -18 9m -1i 92 -18,6i a 84 a,b8 -a b8 a cg u d4 k do u do a do -a do -u cg -1i bs -18,do -u d4 -k bs -18,b8 -a bs -k bs 0 cg a d4 0 d4 -k,e2 k e2 -1i em -18,e2 -u em -k em u,fa -u fu -k gi -u fa -1i em -18,fu -k fu k fu u,gi k gi -u,fa -u em -k,6i a 5u a,gs -u gs 0 gs a i4 u jc a jc -u,gs -18 gs -u,gs -18 hg -1i hg 0 gs a,hg 0 i4 a io 0 jc a,io 0 io -1i jc -18 jc -u,jm a ku u li k m6 u m6 a,jm a jm -a ka -k ka 0 ku a li 0 li -k m6 -u m6 a,li -k ka -18 ku -1i m6 -u,mg a no u p0 a p0 -a oc -k no -u,oc -k p0 -u no -1i no -18 no -a,mg a n4 0 no a oc 0 no -a,qi a qi k r6 u r6 0 t2 u t2 a se 0 t2 -a,qi a qi -a,qi -1i qi 0,qi -1i rq -26 t2 -1i t2 -u t2 -a,r6 -18 rq -1i se -18 t2 -1i,se -18 se -k rq -a r6 -k r6 -18,qi -1i r6 -18,tc k u0 u,tc k tc 0 tc -18 u0 -1i u0 u,ua a vi u 10q a 10q -k 10q -1s 106 -26 106 -1i,ua a ua -a ua -u uu -k uu 0 vi a 106 0 106 -k 10q -u,ua -u vi -1i 106 -18 106 -1i,106 -k vi -u uu -k,114 a 12c u 130 k 11o 0 11o -a,114 a 114 -a 114 -u 12c -1i 13k -u 130 -k 130 -a 130 0 13k -a 13k -u,130 -k 12c -u 11o -k 114 -u,11o -k 11o -a,13u k 13u -u 13u -18 14i -1i 14i 0,13u k 14i u 14i 0,17m a 19i 1i 1es 1i 3d2 1i,pa a q8 a,8e a 9m u au a,e2 k em u,gi k fu u,42 1i -1mm 1i,17m a 14s a#9m -1i 9m -a aa 0,9m -a 92 0,bs 0 cg -a cg -u,cg -a d4 0,bs -k cg -u,em -k fa -a fa a fu 0,fa -a fu -k,em 0 fa a,hg 0 i4 -a io 0,hg -k i4 -u i4 -a,i4 -u io -k,ka 0 ku -a li 0,ku -a ku -u,ka -k ku -u,no -1i mg -u mg -a n4 0,mg -u no -a,no -u n4 -k,r6 -18 rq -u rq -a,rq -u se -18,tc -18 tc -1s u0 -1i,uu 0 vi -a vi -u,vi -a 106 0,11o -k 12c -a 12c a,12c -a 130 -k,130 0 12c a,14i -1i 156 -18 156 -k 14i -u##BMX# (you need to put that in test.txt in the same directory as the html file) But as soon as you load a large track, it lags. Would be quite useful if i could get a quick response as to how i could fix this. hi, Does any one knows the javascript that read step by step single line from form and then store in array , and that array use 4 further references Please help i need this Please Please Please Thanx Regards Fawad Hi, Does anyone know how to make a javascript regex ignore new lines? I have this Code: html = html.replace(/<!--(.*?)-->/gi, ''); // HTML comments which matches single line comments like - Code: <!-- this is a comment --> but not this - Code: <!-- This is a comment on multiple lines --> I think the answer lies with [\s\S] but I can't get it to work e.g. - Code: html = html.replace(/<!--(.*[\s\S]?)-->/gi, ''); // HTML comments Any help will be greatly appreciated Cheers Al I'm having major pains trying to figure this out. I'm kind of new to Javascript, I need to open a text file from an external server, store each line in an array, then search that array for a certain word (HIGH), and if it exists then write something to the webpage, and if not, write something else. Here is what I have so far: Code: <html> <head> <title>Test</title> <script> <!-- function test(x) { if (wxd1txt.readyState === 4 && wxd1txt.status === 200) { // Makes sure the document is ready to parse and Makes sure it's found the file. var wxd1text = wxd1txt.responseText; var wxd1array = wxd1txt.responseText.split("\n"); // Will separate each line into an array var wxd1high = wxd1array.toString(); //Converting the String content to String //var highsearchreg = new RegExp("HIGH"); //var wxd1high = wxd1array[x].search(highsearchreg); document.write(wxd1high); if (wxd1high.search("HIGH") >= 0){ document.write("HIGH RISK");} else { document.write("NO RISK");} } } //--> </script> </head> <body> Hi! <script> <!-- var Today = new Date(); var ThisDay = Today.getDate(); var ThisMonth = Today.getMonth()+1; var ThisYear = Today.getYear(); var Hour = Today.getHours(); var Day2 = Today.getDate()+1; var Day3 = Today.getDate()+2; if (navigator.appName != "Microsoft Internet Explorer") { ThisYear = ThisYear + 1900;} if (ThisMonth < 10) { ThisMonth = "0" + ThisMonth;} if (ThisDay < 10) { ThisDay = "0" + ThisDay;} if (Hour == 2 || Hour == 22 || Hour == 23 || Hour == 0 || Hour == 1) { var wxHourd1 = 0600} else if (Hour >= 3 && Hour <= 10) { var wxHourd1 = 1300;} else if (Hour >= 11 && Hour <= 13) { var wxHourd1 = 1630;} else if (Hour >= 14 && Hour <= 16) { var wxHourd1 = 2000;} else if (Hour >= 17 && Hour <= 21) { var wxHourd1 = 0100;} //var wxurld1 = "http://www.spc.noaa.gov/products/outlook/archive/"+ThisYear+"/KWNSPTSDY1_"+ThisYear+""+ThisMonth+""+ThisDay+""+wxHourd1+".txt"; var wxurld1 = "http://www.spc.noaa.gov/products/outlook/archive/2010/KWNSPTSDY1_201005101300.txt" //(High risk day for testing) //document.write(wxurld1); //Use this to verify this section is working if (window.XMLHttpRequest) { wxd1txt=new XMLHttpRequest(); } else // IE 5/6 { wxd1txt=new ActiveXObject("Microsoft.XMLHTTP"); } wxd1txt.open("GET", wxurld1, true); wxd1txt.onreadystatechange = test(); // --> </script> </body> </html> When added to a webpage, nothing shows up except the "Hi!" and there are no errors in the Javascript Console in Google Chrome. Is this possible with Javascript, and if so, what am I doing wrong or not doing? Also, I have 2 URLs, one is a text file that has the HIGH text I want for an example, the other is the current file, which shouldn't have HIGH in it (unless the weather in the US turns really bad) |