Skip to content

Instantly share code, notes, and snippets.

View ideesimple's full-sized avatar

Laurent Toulemonde ideesimple

View GitHub Profile
@ideesimple
ideesimple / gist:752836
Created December 23, 2010 11:06
doTimeout
ex : $(this).html('<p id="BlocSuccess">message envoyé :-)</p>').doTimeout(1000,function (){
$("#contactform").html(contenuForm);});
(function($){var a={},c="doTimeout",d=Array.prototype.slice;$[c]=function(){return b.apply(window,[0].concat(d.call(arguments)))};$.fn[c]=function(){var f=d.call(arguments),e=b.apply(this,[c+f[0]].concat(f));return typeof f[0]==="number"||typeof f[1]==="number"?this:e};function b(l){var m=this,h,k={},g=l?$.fn:$,n=arguments,i=4,f=n[1],j=n[2],p=n[3];if(typeof f!=="string"){i--;f=l=0;j=n[1];p=n[2]}if(l){h=m.eq(0);h.data(l,k=h.data(l)||{})}else{if(f){k=a[f]||(a[f]={})}}k.id&&clearTimeout(k.id);delete k.id;function e(){if(l){h.removeData(l)}else{if(f){delete a[f]}}}function o(){k.id=setTimeout(function(){k.fn()},j)}if(p){k.fn=function(q){if(typeof p==="string"){p=g[p]}p.apply(m,d.call(n,i))===true&&!q?o():e()};o()}else{if(k.fn){j===undefined?e():k.fn(j===false);return true}else{e()}}}})(jQuery);
$modx->log(modX::LOG_LEVEL_ERROR, "{ } log");
@ideesimple
ideesimple / gist:751361
Created December 22, 2010 10:36
différent chunk ou bout de code selon l'id
[[*id:is=`1`:then=`[[$chunk1]]`:else=`[[$chunk2]]`]]
[[*id:is=`1`:then=`ton code`:else=`ton autre code`]]
@ideesimple
ideesimple / var_dump
Created December 16, 2010 16:20
afficher valeur dans un tableau via javascript
function var_dump(obj) {
if(typeof obj == "object") {
return "Type: "+typeof(obj)+((obj.constructor) ? "\nConstructor: "+obj.constructor : "")+"\nValue: " + obj;
} else {
return "Type: "+typeof(obj)+"\nValue: "+obj;
}
}
@ideesimple
ideesimple / gist:740570
Created December 14, 2010 15:26
return single value results via xPDO
<?php
$stmt = $modx->query("SELECT MAX(id) FROM {$modx->getTableName('modResource')}");
$maxId = (integer) $stmt->fetch(PDO::FETCH_COLUMN);
$stmt->closeCursor();
?>
@ideesimple
ideesimple / gist:740511
Created December 14, 2010 14:46
récupère la position d'une ressource ainsi que le nombre de ressource de son parent
<?php
$count = 0;
$IdAvant='';
$IdApres='';
$position='';
$criteria = array(
'parent' => $parent,
'deleted' => false,
'published' => true,
);
@ideesimple
ideesimple / gist:725010
Created December 2, 2010 08:58
show chunk if parent is:
$current_docid = $modx->resource->get('parent');
$output ='';
if($current_docid ==8){
$output = $modx->getChunk('this_chunk');
}
elseif($current_docid ==9){
$output = $modx->getChunk('this_chunk');
}
@ideesimple
ideesimple / gist:725008
Created December 2, 2010 08:55
stylesheets for only 1 resource (in snippet)
<?php
$modx->regClientCSS('path/to/css/file');
$modx->regClientStartupScript('path/to/js/file');
@ideesimple
ideesimple / gist:725006
Created December 2, 2010 08:53
Revolution Performance
<br /><!--MySQL: [^qt^], [^q^] request(s), PHP: [^p^], total: [^t^], document retrieved from [^s^]. -->
@ideesimple
ideesimple / gist:725005
Created December 2, 2010 08:52
Multiplier prix par un nombre via snippet
<?php
//[[*Price:mpyfs=`1.196`]]
$output = '';
if (!empty($input) && is_numeric($input) && !empty($options) && is_numeric($options)) {
/* Multiply & Round the Float to 2 Digits */
$output = round($input * $options, 2);
}
else