Posts Tagged JavaScript
October 1, 2009 at 2:04 pm
· Filed under Technology ·Tagged Douglas Crockford, JavaScript, jslint
Today, my coworker asked why he can’t use ++ operators. I responded that jslint’s plusplus configuration ban it. He certainly was annoyed by such change in the configuration. A quick look into the reasoning behind the ban reveals the following statement from Douglas Crockford’s JSLint – JavaScript: The Good Parts:
The ++ (increment) and — (decrement) operators have been known to contribute to bad code by encouraging excessive trickiness. They are second only to faulty architecture in enabling viruses and other security menaces. The JSLint option plusplus prohibits the use of these operators.
Perhaps this ban is necessary for folks who have shown tendencies to develop obscure code in an attempt to deceive or trick others. At the same time, it also bans simple usages such as the one shown below:
var a = 0;
for (var i = 0; i < 5; i++) {
a = a + i;
}
In order to pass jslint, the for loop may have to look like the following:
var a = 0,
i;
for (i = 0; i < 5; i = i + 1) {
a = a + i;
}
Without ++ operators, code will no longer looks the same or as elegant as it used to be. Now that I have my 30 sec on this topic, life goes on with working code!
Permalink
September 10, 2009 at 2:17 pm
· Filed under Life in general ·Tagged Ext JS, ie, JavaScript, workaround
For the last couple days I ran into JavaScript errors with toolbars for Ext JS. One of the issues is clearly documented here. I just added hideMode:'offsets' to the toolbar definition and the error went away. The other one, I had to add enableOverflow: false option to the toolbar to avoid hitting Object required error in IE.
Permalink
August 24, 2009 at 2:46 pm
· Filed under Life in general ·Tagged Facebook, JavaScript
I came across this script and it worked for me. This is a good time saver!
Permalink
August 17, 2009 at 5:52 pm
· Filed under Technology, howto ·Tagged JavaScript, jslint
I worked with JSLint today to clean up my local code. While cleaning, I encountered a parameter name that had underscore in its name. JSLint didn’t like this and complained. Since this parameter name was used to communicate with the server and could not be changed, I needed to set an exception in the JavaScript file. This led me to the options section of this page. All I had to do was adding the following line at the beginning of the JavaScript file and JSLint stopped complained about the issue:
/*jslint sub: true */
Permalink
August 6, 2009 at 3:23 pm
· Filed under Technology ·Tagged Ext JS, image, JavaScript
This might be useful trick to upload and display an image.
Permalink
July 15, 2009 at 4:26 pm
· Filed under Life in general ·Tagged Ext JS, JavaScript, modal window
mmusson’s code post in this thread works well for me.
Permalink
June 19, 2009 at 9:53 am
· Filed under Life in general ·Tagged bug, firebug, JavaScript
I have a page with Javascript loaded from different directories. For one reason, the Javascripts source loaded from one of the directories did not display. This means I could not use the debugger to insert break points directly. The Firbug version was 1.3.3. Initially, I was able to get the source code to show after randomly clicked around, i.e. click on Yslow and switch back to script tab. Unfortunately, it was not a reliable workaround. Eventually, an idea came to me to work around the issue: insert a runtime error. A runtime error can be as simple as referencing a non-existing function. Make sure you don’t introduce syntax error, which will stop the browser from reading the source code. With the new runtime error, Firebug will show an error in the console and provide a link to the source code. Once I could see the source code, I added break points at the lines that I was actually interested and removed the artificial runtime error from the source code before reloaded the page.
Permalink
May 26, 2009 at 6:11 pm
· Filed under Technology ·Tagged Ext JS, JavaScript
createDelegate is an interesting way to pass a function object with a scope object. This is very useful for using callback functions. For more information, see this screencast.
Permalink
April 23, 2009 at 3:08 pm
· Filed under Life in general, Technology, howto ·Tagged Ext JS, JavaScript, XTemplate
This thread helped me to use Ext JS XTemplate with optional fields. The only thing I had to figure out was defining my own check exists function, this.exists().
Permalink
March 18, 2009 at 2:47 pm
· Filed under Technology ·Tagged cross-domain, HistoryManager, iframe, JavaScript
This post is very helpful for me to send small bits of information across iframes. However, this creates a new challenge with history manager that uses the same mechanism to store page state. Whenever an iframe uses fragment identifiers to send a message across iframes, the page state for the target iframe is wiped out. If the message leads to a new page state, this actually matches the intended use of history manager. However, for scenarios where the message does not lead to a new page state, it may lead to an inconsistent sate between the representation in the URL and what’s displayed on the target iframe. One work around is to reset or synchronize the page state for such use cases, which can generate unnecessary reload/AJAX calls. If you have a cleaner approach, let me know.
Permalink
Older Posts »