Preview image inline before uploading.
I hope HTML5 and Google Gear could do this thing better
http://hedgerwow.appspot.com/image-upload-preview/demo.html
Keep It Simple, Stupid
{ Category Archives }
I hope HTML5 and Google Gear could do this thing better
http://hedgerwow.appspot.com/image-upload-preview/demo.html
http://code.google.com/p/jot-project/wiki/SyntaxAndHowTos , still beta.
Hope you’d like it.
One day, I was trying to detect whether an element is an element that has no close tag.
So I did this:
var tagName = el.tagName.toLowerCase();
if( tagName == ‘img’ || tagName == ‘br’ || tagName == ‘input’ || tagName == ‘embed ‘ ){
// This is just a example, not all single tags are tested. These tags are :
// area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed.
// Do something here.
}
Well, this is not that efficient to write your program.
So I switch to use a string map, which is rather simple and John Resig uses the same trick in his HTML Parser.
var map = makeMap(’area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed’);
if( map[tagName]){
// Do something here.
}
Of course we can use RegExp to test it, just like many others did.
var reg = /^(area|base|basefont|br|col|frame|hr|img|input|isindex|link|meta|param|embed)$/i;
var tagName = ‘BR’;
if( reg.test(tagName)){
// Do something…
}
and maybe you can find more tricks that solve the same problem with low cost, but below is the most interesting one that caught my attention.
if ( tagName != “BUTTON” | “B” | “A” ){
// Do something…
}
Wait, this seems really strange to me and seems not to perform as what I was expecting.
However, since I found this code snippets from MSDN, there must be something magic which makes this working.
Unfortunately, this is simply not working though I almost thought I found a new JS pattern from MSDN and was very excited about it for just about 10 seconds.
It’s fun to learn JS from microsoft.
Hopefully, we’re safe from this kind of problems..
http://www.hedgerwow.com/360/bugs/js-spider-monkey-bug.html
I’d think that stable sorting does matter for most sortable UI, and it’s better to let JS to do it natively since we use JS a lot to make UI sortable.
http://www.hedgerwow.com/360/dhtml/js_array_stable_sort.html
for really long words in HTML, there’s a way to break it.
http://www.hedgerwow.com/360/dhtml/css-word-break.html
My answer which explain why people like to use JavaScript label for inline script unconsciously.
http://www.hedgerwow.com/360/dhtml/js_label/
My two cents for this little JavaScript trick.
http://www.hedgerwow.com/360/dhtml/js-simple-instantiation.html