November 5th, 2008
@biophonc
There are some selector hacks out there, but I don’t like them - ie: (@media screen and (-webkit-min-device-pixel-ratio:0) {}). My personal favourite is done with Prototype because I use it a lot and it is pretty simple:
<link rel="stylesheet" type="text/css" media="none" href="/css/safari.css" id="safari" />
<script type="text/javascript">
// matches all safari/chrome versions
if(Prototype.Browser.WebKit) {
$('safari').media="all";
}
</script>
If you set the media attribute to none - no media device will display it. By adding the little if statement, you can check if the Browser is WebKit, which is the engine name of safari or chrome and alter the media value to all.
If you do not use prototype, you can do it like this:
<script type="text/javascript">
// targets safari 3 - not 2!
if(window.devicePixelRatio) {
document.getElementById('safari')media="all";
}
// targets all safari or better said webKit engines
if(navigator.userAgent.indexOf('AppleWebKit/') > -1) {
document.getElementById('safari')media="all";
}
// prototype way + targeting old and new webKit with two stylesheets
if(Prototype.Browser.WebKit) {
var mySafari = (window.devicePixelRatio) ? 'safari3' : 'safari2';
document.getElementById(mySafari)media="all";
}
</script>
Note, this method shouldn’t be used for “accessible” Websites, because it relies on javascript. You can do it then serverside as well by “sniffing” the UserAgent from the HTTP Request and add your little switch there - whereas this isn’t a 100% safe method though, because some people alter their UserAgent strings and there are tons of vendors/versions thus your detection may fail from time to time.
An alternative to this way is to load the needed script on the fly, so you can reduce a HTTP Request, by writing the link tag dynamically to your document. However - the describe method above is shorter 
Tags: code, css, javascript, prototype
Posted in code, css | 1 Comment »
October 24th, 2008
@biophonc
just in time. One of our clients requested it (minified + packed) last week and today I found an updated version and it seems t work fine: http://code.google.com/p/protosafe/
Tags: javascript, prototype
Posted in code | No Comments »
July 4th, 2008
@biophonc
My neighbours just had sex - uhh, ahhh, uuhhhh - well for about 4 minutes - not much longer - then they were done. So I’d call it a quickly. I was quite tempted to have a look but I thought that would be indecent and naughty, even though it sounded like a doggy-style
However, I’m no voyeur and it’s a hot night and every cool cat wanna have a kitten - or so…
The only reason I’ve noticed them is, our balcony doors are next to each other and both are wide open. But for my excuse, I’m still fixing a database - or better said, I do a modification. for writershops.com I use the world DB from MySQL plus an extra column for the CIA facts book country code. However, I’m still thinking about to extend it with postal codes and make it public to everyone. Maybe. Time-management is not one of my primary attributes so far.
Tomorrow we have “beer and sausage” at our company, which is quite cool - I mean the fact that we do such things on company time and money. Each first Friday on every new month one department is organizing this little event. Last time we had Becks, this time we’ll have Berliner and sausages.
However (I love this word), I’m currently working on a new JavaScript lib, with a carousel, an interactive navigation and some tab switcher, a lightbox, some fx wrapper and other stuff, based on prototype and scriptaculous. That it nothing phenomenal, but I try to keep it slick as possible and of course flexible. ATM you still can apply any function to the callback functions »beforeStart« and »afterFinish«, via one method call. I’ll post the code when I’ve got something like a milestone release, which seems to be end of July.
Tags: balcony, beer and sausage, javascript, MySQL, neighbours, Thursday, work
Posted in code, motd, personal | No Comments »
February 23rd, 2008
@biophonc
if you need a very easy regex, to validate emails - here’s some I wrote:
^(([\da-z���\.\_\-\~]+)\@([\da-z���\.\_\-\~]+)+(\.\b[a-z]{2,}))$
Tags: code, email, javascript, validate
Posted in code | No Comments »