Archive for the ‘ Javascript ’ Category

jsPDF An javascript utility library for generate PDF’s

jsPDF is a javascript utility library for generate PDF’s
With only 5.8kb it let us to generate PDF’S dynamically.
Is compatible with Safari, Firefox 3.5 y iPhone Safari.

1
2
3
4
5
6
7
8
9
10
11
jsPDF.init();
jsPDF.addPage();
jsPDF.text(20, 20, 'Hello world!');
jsPDF.text(20, 30, 'This is client-side Javascript, pumping out a PDF.');
jsPDF.addPage();
jsPDF.text(20, 20, 'Do you like that?');

// Making Data URI
var out = jsPDF.output();
var url = 'data:application/pdf;base64,' + Base64.encode(out);
document.location.href = url;

iPhone & iPod Detection

For detecting iPhone / iPod / iPad users and redirecting them to their iPhone-compatible website you can use this simple code snippets:

PHP

1
2
3
4
5
6
7
8
9
if(
    strstr($_SERVER['HTTP_USER_AGENT'],'iPhone') ||
    strstr($_SERVER['HTTP_USER_AGENT'],'iPod') ||
    strstr($_SERVER['HTTP_USER_AGENT'],'iPad')
)
{
    header('Location: http://yoursite.com/iphone');
    exit();
}

Javascript

1
2
3
4
5
6
7
8
if(
    (navigator.userAgent.match(/iPhone/i)) ||
    (navigator.userAgent.match(/iPod/i)) ||
    (navigator.userAgent.match(/iPad/i))
)
{
    //Your redirection code here
}

.htaccess

1
2
3
4
5
6
7
8
RewriteCond %{HTTP_USER_AGENT} ^.*iPad.*$
RewriteRule ^(.*)$ http://ipad.yourdomain.com [R=301]
RewriteCond %{HTTP_USER_AGENT} ^.*iPhone.*$
RewriteRule ^(.*)$ http://mobile.yourdomain.com [R=301]
RewriteCond %{HTTP_USER_AGENT} ^.*BlackBerry.*$
RewriteRule ^(.*)$ http://mobile.yourdomain.com [R=301]
RewriteCond %{HTTP_USER_AGENT} ^.*Palm.*$
RewriteRule ^(.*)$ http://mobile.yourdomain.com [R=301]

Ultra-light jQuery calendar

New concept for date selection jquery calendar.

Autor Blog: http://roberto.open-lab.com/2010/04/06/ultra-light-jquery-calendar/
Download page: http://bugsvoice.com/applications/bugsVoice/site/test/calendarPickerDemo.jsp
Download: Ultra-light jQuery calendar