JavaScript - Jslint - What's Important, What's Not
Here is sampling from a JSLinting of one "core" js file, with some requests for help ... (Btw it runs OK on my machine and is IE only to work with Sketchup web dialogs)
Code: Problem at line 15 character 5: 'window' is not defined. window.location = "skp:" + callback + "@" + params.join(';'); This seems very odd to me; surely it cannot be bad! Code: Problem at line 29 character 9: 'nameDown' is not defined. nameDown(params); nameDown is a function in another file; any problem with that? There will be other similar calls. Code: Problem at line 103 character 65: Be careful when making functions within a loop. Consider putting the function in a closure. o.onmousedown = function() { coreDown(this , c , dv ); }; This one is more difficult. Here is the relevant part of the function: Code: // o is a div o.className = p + cn; o.onmousedown = function() { coreDown(this , c , dv ); }; s = o.style; s.width = "100%"; s.height = ch; Is the recommendation relevant, possible? Code: Problem at line 141 character 5: Bad line breaking ... ,interval); in this code (Actually my last thread here) Code: function coreAnimate(obj, elm, begin, end, duration, fps) { var change,interval,steps,i; change = end-begin; interval = Math.ceil(1000/fps); steps = Math.ceil(duration/interval); if(obj.coreStop){ window.clearInterval(obj.coreStop); } i = 0; obj.coreStop = window.setInterval( function() { obj.last = linearTween(i, begin, change, steps); obj.style[elm] = obj.last + 'px'; i+=1; if (i > steps){ window.clearInterval(obj.coreStop); } } ,interval); } It certainly does not look good but is it bad? Code: Problem at line 148 character 14: 'ActiveXObject' is not defined. fs = new ActiveXObject("Scripting.FileSystemObject"); I guess this is the same as window as noted in the last bit of the report: Code: Implied global: window 7,15,130,133,139, nameDown 29, Refresh 63, ActiveXObject 148,162,171 Any help and suggestions gratefully received. Chris Similar TutorialsJSLint doesn't like this script. Code: document.getElementById('mypic').src=pics[this.number]; if(disc[this.number]!='') { imge=document.createElement('img'); imge.setAttribute('src',disc[this.number]); suggest for line two to use == or === [JavaScript] lint warning: comparisons against null, 0, true, false, or an empty string allowing implicit type conversion (use === or !==) Can anyone help me with this. I am out of my depth. Thanks in advance. Frank I am working on a site and in the process borrowed some js from some one to get dropdown menus to work, but after a while got reports from people who tested my site of some problems and decided to verify all my code, and i have fixed most bugs but the one listed in the title. Code: sfHover = function() { var sfEls = document.getElementById("nav").getElementsByTagName("LI"); for (var i=0; i<sfEls.length; i++) { sfEls[i].onmouseover=function() { this.className+=" sfhover"; }; sfEls[i].onmouseout=function() { this.className=this.className.replace(new RegExp(" sfhover\\b"), ""); }; } }; if (window.attachEvent) {window.attachEvent("onload", sfHover);} and i am verifying it on jslint the error i get is: Quote: Error: Problem at line 6 character 10: Don't make functions within a loop. }; Problem at line 9 character 10: Don't make functions within a loop. }; Implied global: sfHover 1,12, document 2, window 12 any help will be appreciated, and I'm sure this isn't complex but i don't know much js and want to keep it the same. Validator (My CSE HTML Validator v9.0 ) reports javascript errors but program runs. There seems to be a problem with commands used twice and a missing semi-colon. Also there are problems with Firefox. Unable to reselect another image. OK with IE8. I would appreciate it if someone with better eyesight than me could give the jscript a once over for me. Thanks oin advance. Frank Culprit is here. EDITED. hi everyone.. please i want to know how to create a cron job from a file in php i made this command but it does not get any response. it get the error die message i made it in php and i serched online in google and many websites and i did not solve my problem my php command is: PHP Code: exec("crontab -e * * * * * /usr/local/bin/php -f /home/survey/public_html/john/cron/snd2.php") or die ("<br><br>Error in executing Cron file"); so i want to create or use my cron job using javascript.. any help |