/** * Documentation JS * @author lucas@pieui.com */ (function(window) { if(typeof window.wisDOM == 'undefined') { return false; } var $ = window.wisDOM; // Things to do on domready $(function() { // Code text boxes p.demoCodeTextBoxes($('textarea.demoCode')); }); var p = {}; p.demoCodeTextBoxes = function(wdObj) { var i = wdObj.length, box; var button = $({ 'button.demoCode': 'Update gadget' }); var buttonFN = function() { var js = $(this).prev().val(); try { eval(js); } catch(err) { alert('Sorry, there must be an error in your code, please check and try again.'); } }; while(i--) { box = $(wdObj[i]); box.attr({'spellcheck':false}); button.clone().bind('click',buttonFN).insertAfter(box); } }; })(window);