Posts

Showing posts from June, 2007

A simple JvaScript way to change element color

function gradient(id, start, end, speed, prop, callback){ var style = id.style || document.getElementById(id).style, i = setInterval(function(){ for(var j = 0; j < 3; j++) start[j] = gradient.run(start[j], end[j], speed); style[prop] = gradient.color(start); if(String(start) === String(end)) { clearInterval(i); if(typeof callback === "function") callback(id); } }, 20); start = gradient.rgb(start); end = gradient.rgb(end); speed = speed || 10; prop = prop || "color"; return i; }; gradient.color = function(c){return "#".concat(gradient.hex(c[0]), gradient.hex(c[1]), gradient.hex(c[2]))}; gradient.hex = function(rgb, c){return (c = rgb.toString(16)).length === 1 ? "0".concat(c) : c}; gradient.norm = function(c){return (c = c.substring(1)).length < 6 ? "".concat(c, c) : c}; gradient.rgb = function(c){return [parseInt((c = gradient.norm(c)).substr(0,2), 16), parseInt(c.substr(2,2), 16), parseInt(c

JSOMON, a JSON Evolution !

Image
Have You never thought to send object methods too? Have You never thought to drive completely your client side application from server? Did You never try to save functions, callbacks or methods using JSON? This is a new client/server interaction way for your Web 2.0 applications, this is JSOMON ! Another joke? Another experiment? Well, probably, but JSOMON is just ready to be tested, used and why not, to be better if You have some interesting features to add or modify and I'm waiting for your feedbacks. Have fun with JSOMON!

FireFox 3 Password Manager? Well, check You password security :-)

This simple function returns a short number from 0 to 9, for a total of 10 points, to verify security level of your choosed password. Score is evaluated in two different parts: one for the password length and one for character used for that password (different and alpha numeric, upper/lower case is better!). This version is quite better than older one showed in this post: Unobtrusive Password Security Level Form So have fun with password and take care your security :-) function PasswordSecurityLevel(pass){ var level = 0, length = pass.length, re = PasswordSecurityLevel, check = [re.all.test(pass), re.alu.test(pass), re.num.test(pass)], i, chars, key; switch(true){ case length > 15: level++; case length > 11: level++; case length > 7: level++; case length > 5: level++; break; }; if(re.oth.test(pass)) level++; if(check[0] && check[1] && check[2]) level++; if((check[0] && check[1]) || (check[0] && check[2]) || (

Simple setTimeout / setInterval extra arguments IE fix

One of the coolest thing of Internet Explorer is that even version 7 doesn't respect timeouts or intervals creation functions as every other browser does! I'm talking about extra parameters, that we need to pass inside a "temporary" (not for GC) extra function to use closures and to have same result. Here is an example: // i need an interval that check a variable ... // ... and this is the way we usually do that ... var i = setInterval((function(start){ return function(){ if(new Date - start > 990) { alert("about 1 second: ".concat(new Date - start)); clearInterval(i); } } })(new Date), 20); Well done, two functions for our browser and boring unelegant way to code. With FireFox, Opera, Safari and other more standard browsers, we should send directly extra arguments after delay interval. setInterval(callback, delay, param1, param2, ..., paramN); This means at least two things: 1 - we don't need to create a function wrapper to send a

Simplest JavaScript Deadlock

It's just another basic test to understand better JavaScript asyncronous queues and it could crash your browser or freeze them. var loop = true, block = setTimeout(function(){loop = false}, 1); while(loop); It's a deadlock, because while loop is waiting that condition is setted to false while timeout, the one who'll set that condition to false, is waiting while loop end to be executed. THe same behaviour is expected with Ajax or every other async interaction. This is JavaScript, have fun :-)

Did He really need 2 posts and all that test time?

for(var nullable = null, i = 0, loop = 500000, timeOut = setTimeout(function(){alert(nullable)}, 1); i < loop; i++ ) { if(i + 1 === loop) nullable = "Hello World"; }; Sometime I really don't understand Ajaxian choice ... they totally ignored my JSTONE experiment but they spent time to post about a normal JS behaviour :-(

Why Safarisoft ?

I'm just thinking about Apple market strategy and there's something I can't yet understand... In the Web 2.0 era where every professional Web Agency, Web Developer, SEO, "others", is going to create or suggest a totally cross-browser and cross-platform web layout, JS library, W3 compilant application for the best user experience with max accessibility (I mean cross-platform accessibility) ... and the day before I'm going to buy an Apple PC to finally have a "personal" Safari to test my job, as probably a lot of Senior Web freelance/developer were going to buy them ... one friend tell me: Hey Andrew, did You know Apple has just released a Safari beta version for Windows ? Well ... at this point I think there are only two possibilities: Apple is "our friend" and would be happy if we'll develop next web pages compatible with Safari too Apple didn't think about its beautiful operating system that people "love" every day more a

JSTONE - JavaScript Temporary Object Notation Engine

No Cookies ? No Ajax ? No Server ? No Gears ? It's simple, JSTONE ! What's that? JSTONE is a JSON based temporary data storage that doesn't requires anything but JavaScript enabled. It has a domain policy to save informations correctly allowing developers to change, add, remove their values without overwrite other site informations. JSTONE uses basically unsecure (atleast in my humil opinion) window.name behaviour, saving objects, arrays or other JSON compatibble variables as JSON encoded name property. What should be JSTONE useful for? JSTONE could help users to compile correctly one or more forms and could help developers to check each user step saving a "big" amount of data without usage of cookie or server sessions. JSTONE is not secure as https cookie should be and it's not absolutely a server-side session substitute, it's just to bring informations from one page to another, present on same domain or in another site, if You choose to enable free doma

He can init Gears too

(function (D,W,A,R,F) {if(!W[A]||!W[A][R]){ if(W.GearsFactory)F=newGearsFactory; else{try{F =new ActiveXObject ("Gears.Factory")}catch(e){if(navigator. mimeTypes["application/x-"+A+R]){F=D. createElement( "object");F.style .display="none" ;F.width=F.height =0;F.type="application/x-"+A+R; D.documentElement.appendChild(F) }}};if(F&& (W[A]||(W[A ]={})))W[A][R]={factory:F};} })(document,window ,"google", "gears" ); He's ready to fight (function( D,W,A,R,F ){if(!W[ A]||!W [A] [R]){if(W.GearsFactory) F=new GearsFactory;else{try{F =new ActiveXObject("Gears.Factory") }catch(e){if(navigator.mimeTypes[ "application/x-"+A+R]){ F=D.createElement("obje