Run
Old browser - save page
New browser - prepare to save page
New browser - save page
#1
(function(){ function evalta_onkeyup() { var code; var hr; var line_count; var lines; var ta; ta = document.getElementById("evalta"); code = ta.text ? ta.text : ta.value; lines = code.split("\n"); line_count = lines.length; ta.rows = (line_count > 7) ? "7" : line_count; hr = document.getElementById("evalhr"); hr.scrollIntoView(); ta.scrollIntoView(); } var eval_onclick; eval_onclick = function() { ({ execute: function(v) { v = {}; this.logs = document.getElementById("logs"); this.ta = document.getElementById("evalta"); if (typeof this.ta.text != "undefined") { this.code = this.ta.text; this.ta.text = ""; } else { this.code = this.ta.value; this.ta.value = ""; } this.ta.setAttribute("rows", "1"); this.log("code", this.code); this.result = (0, this.safeEvaluate)(this.code); if (this.result.thrown) { if (!(this.result.error instanceof Error)) { this.log("error", this.result.error); } else { if (typeof this.result.error.stack != "undefined") { this.log("error", this.result.error.stack); } else { v.errorLines = []; v.errorProperties = this.keys(this.result.error); for (v.i = 0; v.i < v.errorProperties.length; ++v.i) { v.errorProperty = v.errorProperties[v.i]; v.errorLines.push("[" + v.errorProperty + "]"); v.errorPropertyValue = this.result.error[v.errorProperty]; v.errorPropertyType = typeof v.errorPropertyValue; if (v.errorPropertyType == "string") { v.errorLines.push(v.errorPropertyValue); } else { try { v.errorLines.push([ v.errorPropertyValue ].join("")); } catch (e) { v.errorLines.push("[" + v.errorPropertyType + " value]"); } } v.errorLines.push(""); } this.log("error", v.errorLines.join("\n")); } } } else { this.log("value", this.result.value); } this.ta.scrollIntoView(); }, keys: function(object, v) { if (typeof Object.keys == "function") return Object.keys(object); v = {}; v.props = []; for (v.prop in object) v.props.push(v.prop); return v.props; }, log: function(type, message, v) { v = {}; v.now = new Date; message = ("" + message).replace(/\r\n/g, "\n").replace(/\r/g, "\n").replace(/\n/g, "\r"); v.p = document.createElement("p"); v.p.innerText = "[ahJ4s|" + v.now.getTime() + "|" + v.now.toString() + "|" + type + "]"; v.ta = document.createElement("textarea"); v.ta.setAttribute("cols", "73"); v.ta.setAttribute("rows", message.split("\r").length); v.ta.readOnly = true; v.ta_text = document.createTextNode(message); v.ta.appendChild(v.ta_text); this.logs.appendChild(v.p); this.logs.appendChild(v.ta); }, safeEvaluate: function(Bae8b_) { arguments = undefined; delete arguments; try { return { thrown: false, value: (0, eval)(Bae8b_) }; } catch (error) { return { thrown: true, error: error }; } } }).execute(); } var div = document.createElement("div"); div.setAttribute("id", "evaldiv"); div.innerHTML = ( "<div id=\"logs\"></div>\n" + "<hr>\n" + "<textarea id=\"evalta\" cols=\"69\" rows=\"1\" onkeyup=\"(" + evalta_onkeyup.toString().replace(/\s+/g, " ").replace(/&/g, "&").replace(/"/g, """) + ")();\"></textarea>\n" + "<button id=\"evalbutton\" onclick=\"(" + eval_onclick.toString().replace(/\s+/g, " ").replace(/&/g, "&").replace(/"/g, """) + ")();\">Eval</button>" + "<hr id=\"evalhr\">" ); document.body.appendChild(div); })();
#2
var err = new Error("test"); err.foo = function(){}; err.bar = { answer: 42 }; err.baz = document.getElementById; throw err;