Please I Need Help - Evaluating A Javascript Code Line By Line - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Please I Need Help - Evaluating A Javascript Code Line By Line (775 Views)
1 Reply
| Please I Need Help - Evaluating A Javascript Code Line By Line by Cybergenius(op): 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(op): 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. |
Adding Validation To Javascript Code • What Could Be Wrong With This Javascript Code • Javascript Code Autocomplete In Webpage • 2 • 3 • 4
Revolutionary Social Media Experience, Orbi; Twitter For Voice Notes Launches • Software Architecture - Don't Ignore The Big Picture • Please I Need An Original Eassy Browsing Cyber Cafe Timer
.text().replace(/[\n]/ig,"};"