Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,149,819 members, 7,806,305 topics. Date: Tuesday, 23 April 2024 at 02:27 PM |
Nairaland Forum / Science/Technology / Programming / Please I Need Help - Evaluating A Javascript Code Line By Line (702 Views)
Adding Validation To Javascript Code / What Could Be Wrong With This Javascript Code / Javascript Code Autocomplete In Webpage (2) (3) (4)
(1) (Reply)
Please I Need Help - Evaluating A Javascript Code Line By Line by Cybergenius(m): 5:30pm On Oct 26, 2014 |
I have this html/javascript +jquery code, which is meant to compile my code, but i dont know how to read the javascript as a code. //the code <!DOCTYPE html> <html> <head> <script src="jquery.js"></script> <script async> window["logerrors"] = function(){ var script = $("script#val".text().replace(/[\n]/ig,"};" var reps = script.replace(/};/ig,"~" var eachLine = reps.split("~" var errors =""; var err = []; for($i=0;$i<eachLine.length;$i++){ try{ new Function(eachLine[$i])(); err.push("no" continue; } catch(e){ errors += "Scope Number: "+ Number($i+1) +"<br>"+e + "<br><span style='color:red;white-space: pre'>"+eachLine [$i]+"</span><hr>"; err.push("yes" continue; } } if(err.indexOf("yes" > -1){ $("body".html(errors); } else{ return true; } } </script> </head> <body onLoad="logerrors()"> <script id="val"> var i = jQuery; while(!i){ var i = jQuery; } phrompt(i.fn.jquery); ro(q); //the while loop is an example, the code reads it as "while(!i){" </script> </body> </html> |
Re: Please I Need Help - Evaluating A Javascript Code Line By Line by Cybergenius(m): 5:33pm On Oct 26, 2014 |
The above code is meant to compile my code in a script tag with an id of "#val", if i read the code by line, it wont work out, cause it would also read "while(!i){" as a code on its own, my question is - How do i read that particular block of code while(!i){ var i = jQuery; } read this as whole and not by line |
Re: Please I Need Help - Evaluating A Javascript Code Line By Line by bot101(m): 12:41am On Oct 27, 2014 |
from what i can see here, i believe you have commited some syntax errors. look for a missing " and ; and close/delete appropriately. your replace() is also missing a second parameter. |
(1) (Reply)
See It: If You Want To Get Job In Google / Global Game Jam 2015 Jan 23rd - Jan 25th / 50 Things To Know About Bill Gate
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 10 |