The popular open-source contract for web designers and developers by Stuff & Nonsense
- Originally published: 23/12/2008
- Revised date: 15/12/2013
- Original post
| <!-- Strip tags from post content and filter through truncate --> | |
| {{ function("strip_tags", post.content)|truncate(50) }} |
| /* | |
| Usage (I however think that the code is self explanatory) | |
| <ReactComment text={` | |
| Very long comment with html link | |
| <a href="https://gist.github.com/alexeychikk/bfe72a072a9a962f2da900b6151e4aae">Star me :)</a> | |
| `} /> | |
| */ | |
| import React, {Component, PropTypes} from 'react'; |
| <div style="font-family: sans-serif;"> | |
| <? var data = valid(); ?> | |
| <form id="form" name="form"> | |
| <? if(Object.prototype.toString.call(data) === '[object Array]') { ?> | |
| <? for (var i = 0; i < data.length; i++) { ?> | |
| <? for (var j = 0; j < data[i].length; j++) { ?> | |
| <input type="checkbox" id="ch<?= '' + i + j ?>" name="ch<?= '' + i + j ?>" value="<?= data[i][j] ?>"><?= data[i][j] ?><br> | |
| <? } ?> | |
| <? } ?> | |
| <? } else { ?> |
| var touchstartX = 0; | |
| var touchstartY = 0; | |
| var touchendX = 0; | |
| var touchendY = 0; | |
| var gesuredZone = document.getElementById('gesuredZone'); | |
| gesuredZone.addEventListener('touchstart', function(event) { | |
| touchstartX = event.screenX; | |
| touchstartY = event.screenY; |
| // Build a tree using a compacted object with no pointer for the left/right children | |
| function buildTree(A) { | |
| // Shuffle the array. so we gain a more balanced search tree | |
| A.sort(function() { return parseInt(Math.random()*3) - 1; }); | |
| var tree = {'0': A[0]}, current = 1; | |
| var inserted, node, treeSize = 1; | |
| // This will take O(N * log N) if we have a balanced tree | |
| // the worst case cost will be O(N^2) |