WordPress – 2 plugins pour mettre en valeur du code

Dean’s Code Highlighter

Site officiel

Utilisation

<pre lang="php"> ... </pre>
<pre lang="html"> ... </pre>
<pre lang="css"> ... </pre>

Exemples

<pre lang="php"> ... </pre>

Google Code Prettify

Site Officiel (faq)

Utilisation

<pre class="prettyprint"> ... </pre> ou <code class="prettyprint"> ... </code>

Exemples

<pre class="prettyprint lang-html"> ... </pre>

  The lang-* class specifies the language file extensions.
  File extensions supported by default include
    "bsh", "c", "cc", "cpp", "cs", "csh", "cyc", "cv", "htm", "html",
    "java", "js", "m", "mxml", "perl", "pl", "pm", "py", "rb", "sh",
    "xhtml", "xml", "xsl".

App

Javascript – Debug application en Ajax

Une utilisation originale d’AJAX pour tracker un dysfonctionnement entre le client et votre applicatif.

  • Le javascript code :

  • <script Language="JavaScript">
    var from_time = new Date();
    from_time = from_time.getTime();
    function benchmark_loading_time() {
    var to_time = new Date();
    to_time = to_time.getTime();
    var msecs = (to_time - from_time);
    //submit the result
    var req = null;
    try { req = new XMLHttpRequest(); } catch(e) {}
    if (!req) try { req = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {}
    if (!req) try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {}
    req.open("GET", '/benchmark_loading_time.php?msecs=' + msecs + '&url=' + location.href, false);
    req.send(null);
    }
    </script>

  • L’appel dans l’HTML page:


<body onLoad="benchmark_loading_time()>

  • Cote serveur, le script PHP benchmark_loading_time.php se chargera de jouer avec les paramètres msecs et url

Source : lien

Web

Recent Tweets

Catégories