jquery font resizer
via: http://devolux.org/2009/03/jquery-font-resizer/
I just programmed a simple but nicely working jQuery font resizer. I intend to create a jQuery and a Wordpress plug-in from it.
![]()
Required are the jQeruy core and the jQuery plug-in "COOKIE". Here you see the font resizer jQuery code:
$(document).ready(function(){ $("#small").click(function(event){ event.preventDefault(); $("#page").css("font-size","8px"); $.cookie("fontSize","8px"); }); $("#default").click(function(event){ event.preventDefault(); $("#page").css("font-size","10px"); $.cookie("fontSize","10px"); }); $("#large").click(function(event){ event.preventDefault(); $("#page").css("font-size","12px"); $.cookie("fontSize","12px"); }); // Cookie var fontSize = $.cookie("fontSize"); // Calling Cookie if(fontSize == "8px") { $("#page").css("font-size","8px"); }; if(fontSize == "10px") { $("#page").css("font-size","10px"); }; if(fontSize == "12px") { $("#page").css("font-size","12px"); }; });In addition, the font resizer affects two other files of your website. You must insert three links into your html document, just as it is done here:
<html> <head> <title>font resizer</title> <link rel="stylesheet" href="fontResizer.css" type="text/css" /> <script type="text/javascript" src="jquery-1-3-2.js"></script> <script type="text/javascript" src="cookies.js"></script> <script type="text/javascript" src="fontResizer.js"></script> </head> <body> <div id="page"> <p> <a id="small" href="http://jquery.com/">small</a> <a id="default" href="http://jquery.com/">default</a> <a id="large" href="http://jquery.com/">large</a> </p> <div id="content"> Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. <p id="test">Duis autem vel eum iriure dolor in hendrerit</p> in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, At accusam aliquyam diam diam dolore dolores duo eirmod eos erat, et nonumy sed tempor et et invidunt justo labore Stet clita ea et gubergren, kasd magna no rebum. sanctus sea sed takimata ut vero voluptua. est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat. Consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. </div> </div> </body> </html>Finally it is essential that only the outward element of your document owns an absolute CSS font size. All elements inside it must obtain relative font sizes. These will be in relation to the value set in the outward container. Have a look at the following CSS:
div#page {font: normal 10px Verdana;} a {font-size: 110%;} div#content {font-size: 120%;}This will result in an 11px font size for all a-element and a12px font size for divs. That's it. I hope you will enjoy it.
Note: If you should use this code on your homepage I'd be very graceful for creating also a link to my website.
e adesso si ragiona per integrarlo bene a PHP-Fusion..
come risolvere: “_gat is not defined”
via: http://vpxcc.wordpress.com/
Just a small JavaScript addition can solve a minor bug in Google's Analytics Script. If anybody has a common AdBlocker installed and visits your Google Analytics enhanced page, she will notice 2 errors, including the famous: "_gat is not defined". Looks like the google script does not validate if the actual tracking script is already loaded before it is executed.
As a quick work around add the following BOLD lines around your script:
<script type="text/javascript"> if (typeof(_gat) == 'object') { var pageTracker (YOUR TRACKING CODE) ... } </script>ét voilá.
slug_me
a better (?) version of toAscii function by Matteo Spinelli
function slug_me($str, $replace=array(), $delimiter='-', $charset='ISO-8859-1') {
$str = iconv($charset, 'UTF-8', $str);
if (!empty($replace)) { $str = str_replace((array)$replace, ' ', $str); }
$clean = iconv('UTF-8', 'ASCII//TRANSLIT', $str);
$clean = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $clean);
$clean = strtolower(trim($clean, '-'));
$clean = preg_replace("/[\/_|+ -]+/", $delimiter, $clean);
return $clean;
}
The perfect PHP clean url generator
via: http://cubiq.org/the-perfect-php-clean-url-generator/12
In my hunt for the perfect clean url (smart url, slug, permalink, whatever) generator I've always slipped in some exception or bug that made the function a piece of junk. But I recently found an easy solution I hope I could call "definitive".
Clean url generators are crucial for search engine optimization or just to tidy up the site navigation. They are even more important if you work with international characters, accented vowels
/à, è, ì, .../, cedilla/ç/, dieresis/ë/, tilde/ñ/and so on.First of all we need to strip all special characters and punctuation away. This is easily accomplished with something like:
function toAscii($str) { $clean = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $str); $clean = strtolower(trim($clean, '-')); $clean = preg_replace("/[\/_|+ -]+/", '-', $clean); return $clean; }With our
toAsciifunction we can convert a string like “Hi! I’m the title of your page!” tohi-im-the-title-of-your-page. This is nice, but what happens with a title like “A piñata is a paper container filled with candy”?
The result will bea-piata-is-a-paper-container-filled-with-candy, which is not cool. We need to convert all special characters to the closest ascii character equivalent.There are many ways to do this, maybe the easiest is by using iconv.
setlocale(LC_ALL, 'en_US.UTF8'); function toAscii($str) { $clean = iconv('UTF-8', 'ASCII//TRANSLIT', $str); $clean = preg_replace("/[^a-zA-Z0-9\/_| -]/", '', $clean); $clean = strtolower(trim($clean, '-')); $clean = preg_replace("/[\/_| -]+/", '-', $clean); return $clean; }I always work with UTF-8 but you can obviously use any character encoding recognized by your system. The piñata text is now transliterated into
a-pinata-is-a-paper-container-filled-with-candy. Lovable.
If they are not Spanish, users will hardly search your site for the word piñata, they will most likely search for pinata. So you may want to store both versions in your database. You may have a title field with the actual displayed text and a slug field containing its ascii version counterpart.We can add a delimiter parameter to our function so we can use it to generate both clean urls and slugs (in newspaper editing, a slug is a short name given to an article that is in production, source).
setlocale(LC_ALL, 'en_US.UTF8'); function toAscii($str, $delimiter='-') { $clean = iconv('UTF-8', 'ASCII//TRANSLIT', $str); $clean = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $clean); $clean = strtolower(trim($clean, '-')); $clean = preg_replace("/[\/_|+ -]+/", $delimiter, $clean); return $clean; } // echo toAscii("A piñata is a paper container filled with candy.", ' '); // returns: a pinata is a paper container filled with candyThere’s one more thing. The string “I’ll be back!” is converted to
ill-be-back. This may or may not be an issue depending on your application. If you use the function to generate a searchable slug for example, looking for “ill” would return the famous Terminator quote that probably isn’t what you wanted.setlocale(LC_ALL, 'en_US.UTF8'); function toAscii($str, $replace=array(), $delimiter='-') { if( !empty($replace) ) { $str = str_replace((array)$replace, ' ', $str); } $clean = iconv('UTF-8', 'ASCII//TRANSLIT', $str); $clean = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $clean); $clean = strtolower(trim($clean, '-')); $clean = preg_replace("/[\/_|+ -]+/", $delimiter, $clean); return $clean; }You can now pass custom delimiters to the function. Calling
toAscii("I'll be back!", "'")you’ll geti-ll-be-back. Also note that the apostrophe is replaced before the string is converted to ascii as character encoding conversion may lead to weird results, for exampleéis converted to'e, so the apostrophe needs to be parsed before the string is mangled by iconv.The function seems now complete. Lets stress test it.
echo toAscii("Mess'd up --text-- just (to) stress /test/ ?our! `little` \\clean\\ url fun.ction!?-->"); returns: messd-up-text-just-to-stress-test-our-little-clean-url-function echo toAscii("Perché l'erba è verde?", "'"); // Italian returns: perche-l-erba-e-verde echo toAscii("Peux-tu m'aider s'il te plaît?", "'"); // French returns: peux-tu-m-aider-s-il-te-plait echo toAscii("Tänk efter nu – förr'n vi föser dig bort"); // Swedish returns: tank-efter-nu-forrn-vi-foser-dig-bort echo toAscii("ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöùúûüýÿ"); returns: aaaaaaaeceeeeiiiidnooooouuuuyssaaaaaaaeceeeeiiiidnooooouuuuyy echo toAscii("Custom`delimiter*example", array('*', '`')); returns: custom-delimiter-example echo toAscii("My+Last_Crazy|delimiter/example", '', ' '); returns: my last crazy delimiter exampleI’m sure we are far from perfection and probably some php/regex guru will soon bury me under my ignorance suggesting an über-simple alternative to my function. What do you thing?
w3c validators
Leggendo l'ormai famoso articolo di Robin Good (e anche per esperienza diretta) ho scoperto che rendere un sito accessibile sul web può essere davvero una sfida estenuante, ma grazie agli strumenti che tra un attimo t' illustrerò, il tuo sito avrà sicuramente quella marcia in più che può fare la differenza!
Devi sapere che le tecnologie utilizzate per creare i siti web, cosi come i protocolli internetsono definiti da alcuni standard ai quali bisogna attenersi per assicurarsi di avere un sito (dal punto di vista del codice) in regola.Sono certo che ti starai chiedendo chi crea questi standard e come fare per attenersi ad essi... bene devi sapere che questi standard sono creati dal W3C (Word Wide Web Consortium) il W3C è un consorzio internazionale senza fini di lucro, che ha il compito di definire gli standard condivisi per il funzionamento e la gestione del web.
Vediamo quindi come sfruttare gli strumenti offerti da W3C per assicurarti di avere un codice conforme agli standard!
Per le tue pagine che contengono marcatori HTML, XHTML, SMIL, MathML, etc puoi utilizzare il validatore di marcatori
Come puoi vedere è semplicissimo da usare! Basta inserire l'indirizzo del tuo sito e cliccare sul pulsante Check oppure puoi scegliere di inviare un file da analizzare nel caso il tuo sito non sia online cliccando sulla tab Validate by File Upload, o ancora puoi inserire direttamente il codice da analizzare cliccando sulla tab Validate by Direct Input.Un altro strumento utilissimo che W3C ti mette a disposizione è il Link Checker che verifica la validità di tutti i link presenti all'indirizzo immesso!
Per i tuoi RSS feed invece w3c ti mette a disposizione il Feed Validator; anche in questo caso ti basterà inserire il link dei tuoi feed e cliccare sul pulsante Check.
Per i tuoi fogli di stile CSS invece puoi utilizzare il CSS Validator sempre con la stessa facilità d'utilizzo degli altri strumentiNon poteva mancare poi uno strumento per la convalida dei tuoi file XML ecco quindi che w3c mette a tua disposizione l'XML Schema Validator questo validator ti mette a disposizione due modalità di utilizzo: link o file.
Ognuno degli strumenti che ti ho illustrato ti fornirà un dettagliato report sui problemi rilevati e alcune indicazioni per risolverli, e tutto questo a costo 0!
.png)

