Sha256: 4dcbdae1eb86ce9eb03e4ac2a4758c36d6e0b1e803c4a994f6faec0423594b32
Contents?: true
Size: 1.17 KB
Versions: 5
Compression:
Stored size: 1.17 KB
Contents
var error_log = function(data){ log("<span class='error'>" + data + '</div>') } var log = function(data){ var new_element = document.createElement('div'); new_element.innerHTML = data; document.getElementById('log_output').appendChild(new_element); }; var clear_log = function(){ document.getElementById('log_output').innerHTML=''; } /* * To avoid any kind of name conflict I am renaming trim to javascript_lab_trim * http://developer.loftdigital.com/blog/trim-a-string-in-javascript */ String.prototype.javascript_lab_trim = function() { return this.replace(/^\s+|\s+$/g, ''); } var processForm = function(){ try { var javascript_code = document.lab.javascript_code.value.javascript_lab_trim(); eval(javascript_code); }catch(e){ var error_text = 'Error: '+ e.name + ' ' + e.message; error_log(error_text); } return false; }; var verifyJsonForm = function(){ clear_log(); try { var json_input = document.lab.json_input.value.javascript_lab_trim(); var json_encoded = $.evalJSON(json_input); error_log('Valid JSON'); }catch(e){ var error_text = 'Error: ' + e.name + ' ' + e.message; error_log(error_text); } return false; };
Version data entries
5 entries across 5 versions & 1 rubygems