Posts

Showing posts with the label multiple

Wait A Moment, JavaScript Does Support Multiple Inheritance!

... we are just doing it wrong! Classical Inheritance? We Have Something Better! The main limit about multiple inheritance in JavaScript is the presence of " instanceof " operator. In a prototypal based inheritance objects simply inherits from objects, and class keyword is almost meaningless. // generic constructor function B(){}; // remember the prototype var B1proto = B.prototype; // B instance var b1 = new B; // prototype reassignment B.prototype = { constructor:B }; // remember new prototype var B2proto = B.prototype; // B instance var b2 = new B; alert(b2 instanceof B); // true alert(b1 instanceof B); // false Above snippet demonstrates how inheritance and instanceof are related to the current prototype, rather than the function/constructor itself. In few words, the function is the implicit init method for the current prototype object. The relation, as we could spot with FireFox, is with the prototype and not the used constructor. // FireFox exposes __proto__ // wil...

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

Multiple Upload With Progress: Every Browser No Flash !!!

Image
Update: released official version in Google Code, cross browser, and easy to use. blog enry Ok guys, this is a quick and dirty entry in my blog. I need to write documentation, create the project in Google Code, explain better what I have done and how it works. I do not want to give you the zip right now because I have to change name (silly me do not check before) and to do last tests ... but basically, what I have created this week end, is a graceful enhanced multiple file upload manager compatible with Chrome, FireFox, Internet Explorer (5.5 or greater), Opera, Safari. The manager wrap an input type file and manages it allowing multiple files selection, where supported, or one after one insert with possibility to remove one or more file from the list. Everything is absolutely customizable, since the wrapper is entirely in CSS, the library has a language namespace for errors or messages, and events are created by developers. In those browsers were Ajax upload is not supported, the pro...

Safari 4 Multiple Upload With Progress Bar

Update - I slightly modified the demo page adding another bar, the one for the current file. I'll update the zip asap but all you need is a copy and paste of the JS in the index. Apparently multiple should be set as multiple, rather than true ... in any ... it works as long as it is an attribute. This one from Ajaxian has been one of the best news I could read about HTML5 specs and browsers evolution. I could not wait to download Safari 4 and test instantly this feature. I have always been interested in this possibility, both progress bar, plus multiple uploads and that's why I would like to add this post to this list: PHP upload progress , 22 September 2005 FileReference for JavaScript , 08 November 2005 Upload progress bar with PHP5, APC and jQuery , 09 October 2007 First Step: The Input Type File We can create a multiple input files in different ways: directly in the layout <input type="file" multiple="multiple" /> or via JavaScript:...

JavaScript bits and bops :-)

This post is about a couple of probably useful JavaScript functions, that on daily basis could make our code smarter ;) String.prototype.Replace Ok, ok, a prototype into a native constructor is not a good start point, but this one, strings dedicated, is probably one of those "must have" protos, a Replace with multiple inputs, as is for PHP. String.prototype.Replace = function(replace){return function(RegExp, String){ if(!(RegExp instanceof Array)) RegExp = [RegExp]; if(!(String instanceof Array)) String = [String]; for(var result = this, i = 0, l = 0, index = RegExp.length, length = String.length; i result = replace.call(result, RegExp[i], String[l return result; }}(String.prototype.replace); With above prototype it is possible to search and replace with multiple RegExps and multiple replacements. The proto works as native replace one, but it is possible to perform a replace like this as well: "abc".Replace([/a/, /b/, /c/], ...