+ $("#analyze").prop('disabled', false)
+ }
+
+ function exception(ex) {
+ console.debug("Tool invocation failed, with:\n" + $("#console").text() + "\n" + ex )
+ _gaq.push(['_trackEvent', 'Bug', 'Analysis', $("#console").text()])
+ $("#fatal-error").show()
+ $("#analyze").prop('disabled', true)
+ }
+
+ function stdout(text) {
+ $("#console").append(text + "<br>")
+ }
+
+ function exec() {
+ $("#working").show()
+ $("#consolePanel").hide()
+
+ // Clean output console
+ $("#console").text("")
+
+ // Get code
+ var input = editor.getValue()
+
+ // Update GA stats
+ _gaq.push(['_trackEvent', 'Action', 'Analyze'])
+
+ // Invoke the full Nit program
+ if(typeof(Worker) !== "undefined") {
+ // Async version
+ $("#analyze").prop('disabled', true)
+ worker.postMessage(input)
+ } else {
+ // Sync version
+ _gaq.push(['_trackEvent', 'Bug', 'No Webworkers', $("#console").text()])
+ Module = Pep8Module
+ try {
+ run_analysis = Module.cwrap('pep8analysis_web___CString_run_analysis', null, ['string'])
+ run_analysis(input)
+
+ complete()
+ } catch(e) {
+ exception(e)
+ }
+ }