Author: daniele

  • Defer javascript execution using data

    Due to page performance you should load javascript at the end of page (see http://developer.yahoo.com/performance/rules.html), at least all javascript you can defer to load. There are script that have to load at the very begin of page. But are you sure there is no option? Well, actually this is a critical consideration on my own…

  • jQuery context menu

    jQuery context menu

    Project on Github code and issues on github: https://github.com/danielecr/jquery-contextual-menu ! Prize June 2014 jsclasses.org innovation award Thanks to this prize I got a book from Addy Osmani, design pattern in javascript. The idea behind context menu Ok, I admit I do not search to much out there if this is available.. A simple jquery plugin…

  • Simplepie and CodeIgniter

    yes, found: http://www.haughin.com/code/simplepie/ and tried with php 5.3 installation … simply do not work I recalled there was a problem in simplepie for assign new by reference, just downloaded newer code from http://simplepie.org/ … still same problem. So {syntaxhighlighter brush:bash} sed ‘s/=&\ new/=\ new/’ simplepie.inc > Simplepie.php {/syntaxhighlighter} adding if ( ! defined(‘BASEPATH’)) exit(‘No direct…

  • Introduzione a JavaScript – Terza parte

    Una video introduzione al linguaggio javascript e le sue principali caratteristiche In questa terza parte: gli eventi. Nota: gli eventi si propagano dal document fino al target e dal target fino al document (non al body) La documentazione di call e apply da mozilla Oggetti e ereditarietà in javascript sono presentati in http://www.howtocreate.co.uk/tutorials/javascript/objects Un semplice…

  • Introduzione a JavaScript – Seconda parte

    Una video introduzione al linguaggio javascript e le sue principali caratteristiche In questa seconda parte: oggetti, il DOM, un esempio concreto, le closure La documentazione di call e apply da mozilla Oggetti e ereditarietà in javascript sono presentati in http://www.howtocreate.co.uk/tutorials/javascript/objects Un semplice esempio che usa prototype in http://snippets.dzone.com/posts/show/899 DOM Level 2 Event Model è documentato…

  • Introduzione a JavaScript – Prima parte

    Una breve introduzione al linguaggio e le principali caratteristiche dello scripting client side per il web Presentati sinteticamente: sintassi, JSON, Object, DOM, Eventi Oggetti e ereditarietà in javascript sono presentati in http://www.howtocreate.co.uk/tutorials/javascript/objects Un semplice esempio che usa prototype in http://snippets.dzone.com/posts/show/899 DOM Level 2 Event Model è documentato in http://www.w3.org/TR/DOM-Level-2-Events/events.html Un ottima e completa guida e…

  • jquery Form Hint plugin (mine)

    This is my view of form hint plugin: show a div over with the title content inside, instead of replace text in input elements and match it with placeholder simply run $(selector).formHint() on all form element and title is used as hint See also http://code.google.com/p/jquery-watermark/

  • shuffle db table order

    simple code to shuffle a table … with php shuffle: $result = $mysql->query(“SELECT id FROM $table ORDER BY id”); $rows = $result->num_rows; $order = shuffle(range(1,$rows)); while($row=$result->fetch_row()) { $num=array_shift($order); $mysql->query(“UPDATE $table SET rand_sort=$num WHERE id=”.$row[0]); } added: with MySQL RAND(): $result = $mysql->query(“SELECT id FROM $table ORDER BY RAND()”); for($i=1;$row=$result->fetch_row();$i++) { $mysql->query(“UPDATE $table SET rand_sort=$i WHERE…

  • Ajax frontend for my backoffice in jQuery and PHP

    This is my way to organize php for a simple jQuery frontend ajax based: 1.in a administration page include the php that generate html for each box 2.for each box setup behavior in Javascript 3.let each php manage POST request (for change/update) and GET request for show content So in admin.php we could have something…

  • Fix SEO problem in drupal (give 301 to node/xx request)

    this was a problem with www.tecnomagazine.it : http://www.tecnomagazine.it/recensioni/casio-exilim_ex-z60/442 could be accessed from /node/442 Solution is to redirect all /node/[0-9]* url to the aliased one … and is very simple in code: includes/path.inc : function drupal_init_path() { if (!empty($_GET[‘q’])) { // add this conditional if(preg_match(‘/node\/[0-9]*$/’,$_GET[‘q’])) { include “includes/common.inc”; $newq = trim(url($_GET[‘q’]),’/’); if($newq!=$_GET[‘q’]) { drupal_goto(trim($_GET[‘q’],’/’),NULL,NULL,301); } }…