Posts

Showing posts from January, 2007

Who's running to get Vista ?

Yesterday HTML.it posted a nice question about Vista: "If You have Vista or You'll install them quickly put your hand in the air". This is just a mini report about users opinions (totally: 47) and I think these informations should be interesting: I'll install Vista as soon as I can or I just have Vista 12.8 % I don't believe in Vista and I'll be on XP for many other months/years 38.3 % I'm thinking to spend money for a Mac (with OSX ) instead of Vista license 8.5 % I'm thinking to install Ubuntu or I'll never instal Vista (I'm just on Ubuntu or other Linux distributions) 40.4 % So what are You waiting for to change your OS ? Get Linux !

bored with something to array convertion ? map them !

I'm rewriting my JSL to include by default inside my next project. This project will include automatically a lot of standard JS 1.5 methods or functions, and Array.map is one of those. While I'm testing some proto performances, I've thought about a really simple way to switch from an array or from a node list (getElementsByTagName) with a simple, fast and single line of function. // old example version // function _A(a){return [].map.call(a,function(a){return a})}; // new version, Daniel suggest, faster and doesn't require any prototype ! function _A(a){return [].slice.call(a)}; and that's all, do You like it ? As first point, You need FireFox 1 or greater (or Mozilla if You prefere) or this short piece of code: if(!Array.prototype.map) Array.prototype.map = function(callback){ for(var i = 0, j = this.length, result = new Array(j), self = arguments[1], u; i if(this[i] !== u) result[i] = callback.call(self, this[i], i, this); }; return result; }; Then You hav...

JavaScript Unobtrusive Security Form

In some cases JavaScript should be used to add more security during a client/servr interaction. Paul Johnston knows this and tha's why He created md5 and sha1 hashing JavaScript implemntations. You can choose to send just hashed form variables, to be sure, for example, that recieved stirngs are valid hash and they are present on db (removing sql injections problems). You could even create special hashed strings too, to forget "man in the middle" problems, using a salt that will be generated and verified from server side code. This hashed value could make your password more secure, requiring a kind of brute force that will be quite hard to do. // man in the middle found the salt and the logging string $try = 12345; if(hash($salt.hash($try))) echo 'Passwrod or collision found: '.$try; else { $try = 12346; if(hash($salt.hash($try))) // ... and again, again .. // every time with a double hashed string ( slower than a single :D ) } At the same time, this salt creates ...

a little error choosing byte family plugin namespace :D

Well ... not much things to tell You .. just sorry for my last plugin namespace choice. Now that I know What does it mean ( thanks to Dean and Mario ) I've changed namespace, Welcome overbyte plugin library :D (probably the uniq plugin I need is one for my English, not for my libraries ... :E)

prototype, singleton, what else ?

A lot or JS developers use prototype style to write (extends) classes (functions) or singleton to have a private scope. I often use different ways to create my classes (function) and I use prototype only to extend and not to create. These are some examples: /** prototype style */ // class Blog function Blog(){}; // prototype to extend Blog Blog.prototype = { getName:function(){ return this.name; }, setName:function(name){ this.name = name; }, name:"" }; // how to use Blog class var myblog = new Blog; // new Blog() with parenthesis is not useful. // full prototype style "doesn't accept" // parameters on constructor // (or better, it accepts but doesn't use them) myblog.setName("WebReflection"); // setName is absolutely necessary to set public // name parameter /** prototype style */ /** singleton style */ function Blog(name){ return { getName:function(){ return name; // name has a global scope // in this object, private // fo...

Dojo source ? 39,09 Kb generated in 0.0006 seconds

Image
It's true, less than 40Kb for dojo.js packed file without any packer, just using my overbyte Editor How ? Just open dojo.js file (146Kb) with one text editor (sure, Notepad too), select all, copy and past them inside overbyte Editor working area. Now click on download, and choose the first option as showed on image: Save the file as dojo.php and test on your host ... so view page informations, it's less than 40Kb with all gz compatible browsers ;-) What a news ? The beautyful thing is that my auto-generated php file (about 300Kb) decodes this js source in less than 1 millisecond, exactly 0.0006 seconds on my "old" centrino 1.6 Ghz with Apache 2.2 and PHP 5.2 running on PAMPA ! If You consider that generated file doesn't require zlib or gzencode function, as bootstrap js or php solution , and is compatible with every php hosting solution, You can think that JS size is not a big problem because You should decrease about 5X the final size. I don't know how many ...

overbyte Editor, from Alpha to Beta

Update !!! overbyte Editor now has a Suggest Panel inside textarea ! It doesn't contain every function or method but it has a kind of intelligent code interaction, do You like it ? :D --------------------------------------- Just a little update about my last experiment, overbyte Editor. I've fixed a lot of bugs and now it should work correctly on IE5.5, IE6, IE7, FireFox 2 (probably 1.5 too) and Opera 9 (probably 8 too). I don't know why Safari has some problem with menu and I'm working to solve Safari incompatibility, however, now this Editor is version beta, so You could test them or use without problems ( I mean without every Alpha release problems :D ). Please report me bugs or features You think should be cool and good JavaScripting ! :-) [edit] I forget a detail ... using my GzOutput.class.php with bootstrap.php solution, this component size is less than 14Kb without jsmin :-) jhp is about 12 Kb without jsmin too ... but I'm working on, this project will not b...

JavaScript get_class and is_a functions

Update a new version of get_class, works with prototype classes too. We often need to know the type of a variable with JavaScript but every dedicated function, such typeof or instanceof, are not always perfect. For example, the typeof a string, that should be declared as both primitive and object value, should be "string" or should be "object". var $1 = "test", $2 = new String($1); alert([ typeof($2), // object typeof($1), // string $2 == $1, // true $2 === $1, // false $2 instanceof String, // true $1 instanceof String, // false $2.constructor === $1.constructor // true !!! ].join("\n")); It's quite caotic ... but perfect, but every time We need to know if a variable is exactly that kind of variable We should verify the typeof or the constructor and the instanceof ... little boring ? With PHP We have two nice functions (... more than two, that's why I'm developing jhp ) that are perfectly to know the class name of a ...

Simple JavaScript bootstrap solution

As WebSiteOptimization suggests external JavaScript files should be included "one time for all". There are a lot of procedures to do that, using a server-side script to include and compress required files. This simple anonymous function should do something like dynamic JavaScript inclusion, based on unobrtusive cross-browser function and really simple to use. The concept is this one: when You add a script on Your page this will be exactly the last script present on document so You could do some operation using its source. bootstrap.js does it, and works as "includer" from first file name to last. <script type="text/javascript" src="jsfolder/bootstrap.js?jsfile"></script> In this example bootstrap will include jsfile.js that's inside jsfolder so You just need to include bootstrap.js file inside your dedicated JavaScript files folder. You could load multiple JS too, using char "|" as separator <script type="text/...

overbyte Editor and jhp

Happy New Year :-) I would like to present my last idea, jhp , that's absolutely alpha and that requires "a special" component to be tested quickly ... and that's the reason of this post, a work in progress plugin for my byte family library, called overbyte Editor. It's alpha version too and for some strange reason it doesn't work on Safari browser (but it doesn't show any error too ... ) but it's a simple online runtime JavaScript editor / debugger with some funny features that I've never seen on the net. It's not a FireBug alternative, it's just a "quick and dirty" enviroment to test rapidly your scripts, functions, html pages and probably other. overbyte Editor has some Extra special function, based on syncronous php interatcions or using jsmin to parse and test your code in one step. It could open your files, save them or inject into a dedicated php file that should solve definitely bandwidth problems using both jsmin and gz ...