Posts

Showing posts with the label cross-browser

Node sourceIndex for every browser

I was doing a couple of tests in my bloody Android and I don't even know how I ended up with such snippet ... anyway, accordingly with @ ppk table sourceIndex is a node property compatible with every version of Internet Explorer and latest Opera browser but not with Chrome, Firefox, or Safari (WebKit Android and iPhone as well). Being these unsupported browsers compatible with both native Array.prototype.indexOf and __defineGetter__ and being 5 to 100 times faster than IE, I thought: why don't put this as well into vice-versa ? /** sourceIndex by vice-versa - Mit Style License * @target FireFox, Safari, Chrome */ if(typeof document.documentElement.sourceIndex == "undefined") HTMLElement.prototype.__defineGetter__("sourceIndex", (function(indexOf){ return function sourceIndex(){ return indexOf.call(this.ownerDocument.getElementsByTagName("*"), this); }; })(Array.prototype.indexOf)); ; I so much would have cac...

Formaldehyde JS - The Circle Is Close

As announced in Ajaxian , I have created Formaldehyde JS with exactly the same Zero Config logic. We put this file before everything else and that's it, Formaldehyde will automatically decide how to show errors in a wide range of browsers: Chrome Firefox Internet Explorer 5, 5.5, 6, 7, 8 with or whout console Opera Safari Logs will naturally degrade until the most primitive alert but hey, Formaldehyde is for debug and development environments, not for production. Enjoy ;)

The Fastest Date toJSON and fromJSON?

I know yesterday post supposed to be the last 'till the the end of the month but I could not resits. Dustin Diaz twitted anyone trying to parse our wonky rails dates in JS. do this: var date = Date.parse(str.replace(/( \+)/, ' UTC$1')); seems to fix it. Again, I could not resist to create a toUTCString based function to create JSON strings and to parse them back. This is the result and apparently is both the fastest implementation I know and cross browser (Chrome, Firefox, Inernet Explorer, Safari). This is a quick post so if you find some problem please let me know, thanks. (function(){ // WebReflection Fast Date.prototype.toJSON and Date.fromJSON Suggestion var rd = /^.{5}(\d{1,2}).(.{3}).(.{4}).(.{2}).(.{2}).(.{2}).+$/, rs = /^(.{4}).(.{2}).(.{2}).(.{2}).(.{2}).(.{2}).+$/, d = new Date, f = /(GMT|UTC)$/.exec(d.toUTCString())[1], // cheers gazheyes m = {}, i = 0, s = "" ; d.setUTCDate(1); while(i < 12){ d.setUTCMonth(i)...

noSWFUpload - Zero Plug-In Multiple Upload

Image
As announced a couple of days ago, I am finally proud to introduce my last library free Multiple Upload Component , now compatible with every browser and always without usage of 3rd parts plug-ins. This little project has been hosted in Google Code and I promise I'll write there a complete documentation asap. Righ now, you can read the project source code via zip to understand what he little API is doing. Update I added a couple of sections in the Wiki page ;) Compatibility? Internet Explorer 5.5 (probably 5 too), 6, 7, and 8 FireFox? 3 or greater Google Chrome 1.0 Opera 8, 9, and 10 Safari 4 (current beta) other browsers via unobtrusive iframe Try the demo if you do not believe it :P