var term,protocol,socketURL,socket,terminalContainer=document.getElementById("terminal-container");function assert(e,t){if(!e)throw t||"Assertion failed"}function opt_hidesidebar(){return"no"==getParameterByName("sidebar")}function opt_largeconsole(){return"true"==getParameterByName("largeconsole")}function opt_autorun(){return"true"==getParameterByName("autorun")}function opt_autoreplay(){return"true"==getParameterByName("autoreplay")}var debug_perf_param=null;function opt_debugperf(){if(null==debug_perf_param){var e=getParameterByName("debug_perf");debug_perf_param="true"==e}return debug_perf_param}function getParameterByName(e,t){t||(t=window.location.href),e=e.replace(/[\[\]]/g,"\\$&");var n=new RegExp("[?&]"+e+"(=([^&#]*)|&|#|$)").exec(t);return n?n[2]?decodeURIComponent(n[2].replace(/\+/g," ")):"":null}var delete_cookie=function(e){document.cookie=e+"=;expires=Thu, 01 Jan 1970 00:00:01 GMT;"},CLIENT_VERSION="1.2";function get_socket(){delete_cookie("SERVERID"),delete_cookie("SPSERVERID");var e=io.connect("//"+document.location.host,{query:"client_version="+CLIENT_VERSION+"&uni="+getParameterByName("uni")+"&debug_perf="+getParameterByName("debug_perf")});return e.io.reconnectionAttempts(10),e}function disconnect_socket(){socket.disconnected||socket.disconnect()}var connection_callback_waiting=!1;function try_socket_connection(e,t){ide.server_connected||(disable_btn("control-btn-",["run","run_x","debug"]),e&&(connection_callback_waiting=!0,socket.once("connect",function(){connection_callback_waiting=!1,e(t)})),socket.io.reconnecting||socket.connect())}function socket_on_reconnect_failed(){connect_attempt_count=0,$("#connectingMessage").hide(),enable_btn("control-btn-",["run","run_x","debug"]),connection_callback_waiting&&$("#serverDisconnectedModal").modal("show")}function socket_on_connect_error(){++connect_attempt_count>=3&&connection_callback_waiting&&$("#connectingMessage").show()}socket=get_socket();var gccterm,connect_attempt_count=0;function bind_socket_handlers(){socket.on("connect",socket_on_connect),socket.on("perf_data",e=>console.log(e)),socket.on("connect_failed",function(){console.log("Connection failed")}),socket.on("reconnect",function(){console.log("ReConnectioning")}),socket.on("connect_error",socket_on_connect_error),socket.on("connect_timeout",function(){console.log("Connect timeout")}),socket.on("reconnect_failed",socket_on_reconnect_failed),socket.on("compile_error",socket_on_compile_error),socket.on("compile_success",socket_on_compile_success),socket.on("display_ready",socket_on_display_ready),socket.on("update_version",socket_on_update_version),socket.on("console_exit",socket_on_console_exit),socket.on("gdbexit",socket_on_gdbexit),socket.on("output",socket_on_output),socket.on("filewatch",socket_on_filewatch),socket.on("runoutput",socket_on_runoutput),socket.on("debugoutput",socket_on_debugoutput),socket.on("gdb_state",socket_on_gdb_state),socket.on("gui_info",socket_on_gui_info),socket.on("disconnect",socket_on_disconnect),socket.on("gdbsessionlimit",socket_on_gdbsessionlimit),socket.on("emptysource",socket_on_emptysource),socket.on("filelimitexceed",socket_on_filelimitexceed),socket.on("maxdebugsession",socket_on_maxdebugsession),socket.on("gui_cmd_reply",socket_on_gui_cmd_reply)}var ide=new Object;ide.test=new Object,ide.test.testing=!1,ide.running,ide.debugging,ide.output=new Object,ide.initialize=function(){this.btnRunObj=$("#control-btn-run"),this.btnDebugObj=$("#control-btn-debug"),this.btnStopObj=$("#control-btn-stop"),enable_btn("control-btn-",["run","run_x","debug"])},ide.debug=function(e){ide.run_gui_cmd({cmd:e},!0)},ide.output.hide=function(){$("#stdout-container .msg").html(""),$("#stderr-container .msg").html("")},ide.output.show=function(e,t){$("#stdout-wrapper").show(),e&&$("#stderr-wrapper").show(),$("#tab-stdin").hide(),"out"==t?($("#console-title-bar .tab-stdout").show(),$("#console-title-bar .tab-stderr").show(),$('.nav-tabs a[href="#tab-stdout"]').tab("show")):"err"==t?($("#console-title-bar .tab-stderr").show(),$('.nav-tabs a[href="#tab-stderr"]').tab("show")):"stdin"==t&&($("#tab-stdin").show(),$("#console-title-bar .tab-stdin").show(),$('.nav-tabs a[href="#tab-stdin"]').tab("show"))};var compile_error_tags=[],uniq_hint_errors=[],hint_errors=[];function display_debug_tip(){var e=get_src_filename($("#lang-select").val());for(key in compile_error_tags)switch(key){case"conio_h":display_dialog('Hint to resolve compiler error: "conio.h: No such file or directory"',"Possible Solution:
Don't include 'conio.h' and comment out functions (e.g. clrscr(), getch()) used from 'conio.h'

Explaination:
Seems like your program is written for Turbo C or Borland C compiler which support non-standard header file 'conio.h'
OnlineGDB runs C/C++ programs with gcc/g++, which doesn't support conio.h
So to resovle error don't use conio.h and functions from 'conio.h' (e.g. clrscr(), getch())");break;case"iostream_h":display_dialog('Hint to resolve compiler error: "iostream.h: No such file or directory"',"Possible Solution:
Use #include <iostream> instead of #include <iostream.h>

Explaination:
Seems like your program is written for Turbo C or Borland C compiler which has '.h' extension for C++ header files.
OnlineGDB runs C++ programs with g++, which doesn't need '.h' extension.
So instead of <iostream> , <iostream.h> should be used to resolve this error. ");break;case"iostream_in_c":display_dialog('Hint to resolve compiler error: "iostream: No such file or directory"',"Possible Solution:
Choose 'C++' in Language settings available in top-right corner.

Explaination:
Seems like you are trying to run C++ program, but in Language settings you have selected 'C'. Since 'C' doesn't have any such header file named 'iostream', compiler throws this error.
So choosing 'C++' in language setting should resolve this error.");break;case"multiple_main":display_dialog('Hint to resolve error: "multiple definition of `main\' "',"Possible Solution:
Write your 'main' function in "+e+" file.

Explaination:
Seems like you have created multiple files and have written 'main' function in more than 1 files. Compiler would give error if it finds 'main' function in multiple files.
To resolve error, write your 'main' function only in "+e+" file.")}}hint_errors.conio_h="To resolve this error you should comment out include of 'conio.h' and functions used from it (e.g. getch(), clrscr())

Because 'conio.h' isn't supported by gcc compiler, which is used by OnlineGDB server.",hint_errors.iostream_h="To resolve this error you should use #include <‍iostream>‍ instead of #include <‍iostream.h>‍

Because OnlineGDB uses gcc compiler, which doesn't need '.h' extension for C++ header files.",hint_errors.iostream_in_c="To resolve this error choose C++ in language settings available on top-right corner.

The reason you are getting this error is you are trying to run C++ program with C compiler.",hint_errors.multiple_main="To resolve this error you should write your 'main' function only in main.c or main.cpp file.

The reason you are getting this error is because you have created multiple files which is having main function. You shouldn't write main function in more than 1 files.",hint_errors.stray_342="The reason of this error is because your source code contains non-ascii characters. Perhaps source code is copied from somewhere else, where double quotes are written in unicode character format.
For example, instead of "Hello" it has “Hello”
Note that second hello is written inside double quotes which is in unicode format, which compiler can't understand.
To resolve error, replace unicode quotes with ascii quotes.";var $popover_hint=null;function close_popover(){$popover_hint&&$popover_hint.attr("aria-describedby")&&$popover_hint.trigger("click")}function test_case_html(e){var t='
';return e?(t+=''+e.test.name+""+("Pass"==e.status?''+e.status+"":''+e.status+"")+'
"):(t+="This test case information is not visible.",t+="")}function generate_test_case_list(e){if(!e||0==e.length)return"";for(var t="",n=0;n",r=e.test_result.test_total;a+=e.test_result.test_passed+" test(s) passed out of "+r+" test(s)",display_dialog("Test Result",a+="

"+generate_test_case_list(e.test_result.results)),n="stdin"}else if(e.compile)o+="Compiled Successfully. ",ide.compile_stderr&&(e.stderr=e.stderr?e.stderr:"",e.stderr=ide.compile_stderr+"\n"+e.stderr),e.run_error?(o+=e.run_error,i.status="RUNTIME ERROR",i.memory=e.memory,i.time=e.time):e.runtime_exceed?(i.status="RUNTIME EXCEED",o+=" Runtime Exceed. Click here to know possible reasons for runtime exceed.",e.stderr&&(t=!0,n="err",$("#stderr-container .msg").text($("
").text(e.stderr).text())),e.stdout&&(n="out",$("#stdout-container .msg").text($("
").text(e.stdout).text())),n="out"):(i.status="RAN SUCCESSFULLY",i.memory=e.memory,i.time=e.time,i.stderr=e.stderr,i.stdout=e.stdout,i.exit_status=e.exit_status.trim(),o+=" memory: "+e.memory,o+=" time: "+e.time,"0"!=e.exit_status.trim()?o+=" exit code: "+e.exit_status.trim():(o+=" exit code: "+e.exit_status.trim(),$("#ide-output-exit-code-wrapper").addClass("text-success"),$("#ide-output-exit-code-wrapper").removeClass("text-danger")),e.stderr&&(t=!0,n="err",$("#stderr-container .msg").text($("
").text(e.stderr).text())),e.stdout&&(n="out",$("#stdout-container .msg").text($("
").text(e.stdout).text())),n="out");else if(compile_error_tags=[],uniq_hint_errors=[],e.compiletime_exceed)o+="Compile Time Exceed",n="out",i.status="COMPILE TIME EXCEED";else if(e.writefile_error)o+="Compilation failed due to internal server error. Please try again or contact us if problem persists.",n="out",i.status="COMPILE TIME SERVER ERROR";else{i.status="COMPILE ERROR",i.stderr=e.stderr,i.stdout=e.stdout,o="Compilation failed due to following error(s). ",$("#ide-compile-result").html(o),n="err",t=!0;for(var s=$("
").text(e.stderr).text().match(/[^\r\n]+/g),l="",d=0;d-1||c.indexOf(": fatal error:")>-1||c.indexOf(": undefined reference to")>-1||c.indexOf(": multiple definition of")>-1||c.indexOf(": first defined here")>-1)&&socket.emit("compiler_error",c);var _=!1;if(u){var m=u[0].split(":")[1],g=u[0].split(":")[0];ide.editor.if_file_exists(g)&&(c=c.replace(/^.*\:[0-9]+/,''+u+""),_=!0)}if(c&&(c.indexOf(": error:")>-1||c.indexOf(": fatal error:")>-1||c.indexOf(": undefined reference to")>-1||c.indexOf(": multiple definition of")>-1||c.indexOf(": first defined here")>-1)){var p=null;c.indexOf("conio.h: No such")>-1?p="conio_h":c.indexOf("iostream.h: No such")>-1?p="iostream_h":c.indexOf(": iostream: No such")>-1?p="iostream_in_c":c.indexOf("multiple definition of `main'")>-1?p="multiple_main":(c.indexOf("stray ‘\\342’")>-1||c.indexOf("stray '\\342'")>-1)&&(uniq_hint_errors.stray_342||(p="stray_342",uniq_hint_errors.stray_342=!0));var f='';p&&(c=(c=(c=c.replace(": fatal error:",": fatal error: "+f)).replace(": error:",": fatal error: "+f)).replace(": multiple definition of"," "+f+" : multiple definition of")),l+=''+c+"\r\n"}else c.indexOf(": warning:")>-1?l+=''+c+"\r\n":c.indexOf(": note:")>-1?l+=''+c+"\r\n":l+=_?c+"\r\n":encodeHtmlEntity(c)+"\r\n"}$("#stderr-container .msg").html(l),($popover_hint=$('#stderr-container .msg [data-toggle="popover"]')).popover({placement:"auto",trigger:"click",container:"body",html:!0,placement:"top",template:''}),setTimeout(function(){$popover_hint.trigger("click")},500),ide.on_compiler_error&&ide.on_compiler_error(),display_debug_tip()}$("#ide-run-result").html(o),this.show(t,n),i.files=ide.editor.get_files(),ide.result_callback&&ide.result_callback(i)};var editor=null;ide.gotoLine=function(e,t){ide.editor.gotoFileLine(new FileLine(e,t))},ide.output.setCompile=function(e){e?$("#ide-compile-status").html('Successfully Compiled.'):$("#ide-compile-status").html('Compilation Error(s).')},ide.set_gui_state=function(e){"PROGRAM_PAUSED"==e&&(ide.set_active_line(),term.focus()),ide.last_gui_state=e,"DEBUG_INIT"==e?($("#debug_window_call_stack table tbody").html(""),$("#debug_window_local_variables table tbody").html(""),$("#debug_window_breakpoints table tbody").html(""),delete ide.active_frame):"PROGRAM_NOT_EXIST"==e?(enable_btn("debug_btn_",["run"]),disable_btn("debug_btn_",["pause","cont","step","next","finish"]),ide.remove_active_line(),delete ide.active_frame):"PROGRAM_RUNNING"==e?(disable_btn("debug_btn_",["run","cont","step","next","finish"]),enable_btn("debug_btn_",["pause"]),ide.remove_active_frame(),ide.remove_active_line(),term.focus()):(e="PROGRAM_PAUSED")&&(disable_btn("debug_btn_",["pause"]),enable_btn("debug_btn_",["cont","step","next","finish"]),term.focus())},ide.set_active_line=function(){var e=null;void 0===ide.active_frame&&($("#debug_window_call_stack tbody tr").each(function(){var t=$(this).attr("data-file"),n=$(this).attr("data-line");if(is_user_src_file(t)){if((ide.debugger==DEBUGGER_CC||ide.debugger==DEBUGGER_JAVA)&&e)return;e=n=new FileLine(t,n)}}),e&&(ide.editor.gotoFileLine(e),ide.editor.removeMarkerById(ide.editor.last_marker_id),ide.editor.last_marker_id=ide.editor.addMarker(e,"myMarker","fullLine")))},ide.remove_active_frame=function(){if(null!=ide.active_frame){var e="#debug_window_call_stack tbody tr[data-frame-num='"+ide.active_frame+"']";$(e).removeClass("active"),ide.active_frame=void 0,ide.hightlight_active_frame_line(new FileLine("",-1))}},ide.remove_active_line=function(){ide.editor.removeMarkerById(ide.editor.last_marker_id),delete ide.editor.last_marker_id},ide.fadeConsole=function(e){e&&ide.fadeMessage(e),$("#console-fadder").show()},ide.unfadeConsole=function(){$("#console-fadder").hide()},ide.fadeMessage=function(e){$("#console-fadder .msg").text(e)},ide.showinfo=function(){$("#infoModal").modal("show")},ide.openTerminalSettings=function(){$("#popup-terminal-settings").show()},ide.closeTerminalSettings=function(){$("#popup-terminal-settings").hide()},ide.showsettings=function(){$("#popup-settings").show()},ide.test.verify=function(e){this.testing&&this.verify_output(e)},ide.closegdb=function(){term&&term.attachAddon.dispose(),msg="\n...Disconnected from gdb...",term&&term.write(msg),ide.remove_active_frame(),ide.remove_active_line(),live_ide&&ide.editor.setReadOnly(!1)};var socket_on_connect=function(e){ide.server_connected=!0,ide.initialize(),connect_attempt_count=0,$("#connectingMessage").hide(),opt_autorun()&&$("#control-btn-run").click()},socket_on_compile_error=function(){ide.running?was_interactive_run&&ide.unfadeConsole():ide.unfadeConsole()},socket_on_compile_success=function(e){if(debug_perf("compile_request","end"),e){ide.compile_stdout=e.stdout,ide.compile_stderr=e.stderr;var t="";if(e.stdout&&(t+=e.stdout),e.stderr){for(var n="",o=e.stderr.match(/[^\r\n]+/g),i=0;i-1?n+=""+a+"\r\n":a.indexOf(": note: ")>-1&&(n+=""+a+"\r\n")}t+=n}t=t.replace(/\r?\n/g,"\r\n"),term&&term.write(t)}ide.running?was_interactive_run?ide.unfadeConsole():ide.fadeMessage("Compiled sucessfully. Now running Program..."):ide.unfadeConsole()};function handle_vnc_window_connect(){if(!handle_vnc_window_connect._initialized){handle_vnc_window_connect._initialized=!0;var e=window.addEventListener?"addEventListener":"attachEvent";(0,window[e])("attachEvent"===e?"onmessage":"message",function(e){"display_connected"!==e.data&&"display_connected"!==e.message||socket.emit("display_connected")})}}var socket_on_display_ready=function(){console.log("display_ready");var e=ide.graphics_window;e&&(e.location.href="/vnc/vnc_lite.html?scale=true&token="+get_socket_id(),handle_vnc_window_connect())};function display_compiler_flags_box(){$("#compilerFlagsModal").modal("show")}function display_update_version_popup(){$("#newVersionModal").modal("show")}var socket_on_update_version=function(){display_update_version_popup()},socket_on_console_exit=function(){if(term){if(ide.running_state="FINISHED",term.attachAddon.dispose(),term.write("\r\nPress ENTER to exit console."),live_ide&&ide.editor.setReadOnly(!1),disable_btn("control-btn-",["stop"]),enable_btn("control-btn-",["run","run_x","debug","beautify","newfile"]),debug_perf("run_request","end"),opt_debugperf()&&(console.log(perf_bins),perf_bins=null),opt_autoreplay())return void close_run_console();term.onData(function(e){(e.indexOf("\r")>-1||e.indexOf("\n")>-1)&&close_run_console()})}},socket_on_gdbexit=function(){ide.closegdb(),close_debug_console()},socket_on_output=function(e){null==gccterm&&((gccterm=new Terminal).open(terminalContainer),gccterm.fitAddon.fit()),gccterm.write(e)},socket_on_filewatch=function(e){switch(e.event){case"add":case"change":var t={};t.name=e.path,t.content=e.content,ide.editor.compare_file(t)||ide.editor.set_files([t]);break;case"unlink":ide.editor.delete_file(e.path)}},socket_on_runoutput=function(e){if(e.lang&&"html"==e.lang){ide.unfadeConsole();var t='';return $("#interactive-terminal-container").html(t),void enable_btn("control-btn-",["run","run_x","debug","beautify","newfile"])}ide.running_state="FINISHED",ide.test.verify(e),ide.output.display(e),ide.unfadeConsole(),close_run_console(),enable_btn("control-btn-",["run","run_x","debug","beautify","newfile"])},socket_on_debugoutput=function(e){ide.output.display(e),close_debug_console()},socket_on_gdb_state=function(e){$("#ogdb_status").text(e)};const DEBUGGER_PYTHON="debugger_python",DEBUGGER_CC="debugger_cc",DEBUGGER_JAVA="debugger_java",DEBUGGER_RUBY="debugger_ruby";function check_server_connection(e,t){return close_popover(),!!ide.server_connected||(try_socket_connection(e,t),!1)}function is_user_src_file(e){return ide.editor.if_file_exists(e)}function quoteattr(e,t){return t=t?" ":"\n",(""+e).replace(/&/g,"&").replace(/'/g,"'").replace(/"/g,""").replace(//g,">").replace(/\r\n/g,t).replace(/[\r\n]/g,t)}function escape(e){return""+e}ide.hightlight_active_frame_line=function(e){-1!=e.line?(ide.editor.gotoFileLine(e),ide.editor.removeMarkerById(ide.editor.last_frame_marker_id),ide.editor.last_frame_marker_id=ide.editor.addMarker(e,"active_frame_line_marker","fullLine")):ide.editor.removeMarkerById(ide.editor.last_frame_marker_id)};var encodeHtmlEntity=function(e){for(var t=[],n=e.length-1;n>=0;n--)t.unshift(["&#",e[n].charCodeAt(),";"].join(""));return t.join("")};function adjustDebugPanSize(){ide.debugging||($("#ide-split-pane .split-pane-component:first").css("width","100%"),$("#ide-split-pane .split-pane-component:last").css("left","100%"),$("#ide-split-pane .split-pane-divider:last").css("left","100%"))}function fold_left_bar(){$("#btn_close_header").hide(),$("#left-component").width("50px"),$("#right-component").css({left:"50px"}),ide.debugging||($("#right-left-component").css({width:"100%"}),$("#my-divider2").css({left:"100%"}),$("#right-right-component").css({left:"100%"})),$("#left-component .to_be_hidden").hide(),$("#header_logo a").attr("href","javaScript:void(0);"),$("#header_logo a").click(function(e){$("#btn_close_header").show(),$("#left-component").width("20%"),$("#right-component").css({left:"20%"}),$("#left-component .to_be_hidden").show()})}function gui_call_stack_clear(){$("#debug_window_call_stack tbody").html("")}function gui_call_stack_add_frame(e){e&&$("#debug_window_call_stack tbody").append(''+e.frame_no+""+encodeHtmlEntity(e.fun_name)+""+encodeHtmlEntity(e.file_name)+":"+e.line+"")}function gui_call_stack_post_processing(e){if(void 0!==ide.active_frame){var t="#debug_window_call_stack tbody tr[data-frame-num='"+ide.active_frame+"']";$(t).addClass("active");var n=$(t).attr("data-file"),o=$(t).attr("data-line");if(is_user_src_file(n)){var i=new FileLine(n,o);ide.hightlight_active_frame_line(i)}}}function gui_breakpoints_clear(){var e='
';ide.debugger!=DEBUGGER_JAVA?e+="":e+="",e+="
#Description
Description
",$("#debug_window_breakpoints").html(e),$("#debug_window_breakpoints table").colResizable({liveDrag:!0})}function gui_local_variables_reset(){ide.debugger!=DEBUGGER_PYTHON?($("#debug_window_local_variables").html('
VariableValue
'),$("#debug_window_local_variables table").colResizable({liveDrag:!0})):$("#debug_window_local_variables").html("")}function gui_display_expr_window_reset(){ide.debugger==DEBUGGER_CC?($("#debug-pan .panel-display-expression").show(),$("#debug_window_display_expression").show()):($("#debug-pan .panel-display-expression").hide(),$("#debug_window_display_expression").hide())}function gui_registers_window_reset(){var e=$("#lang-select").find(":selected").val();ide.debugger==DEBUGGER_CC&&"asm_gcc"==e?($("#debug-pan .panel-registers").show(),$("#debug_window_registers").show()):($("#debug-pan .panel-registers").hide(),$("#debug_window_registers").hide())}var gui_breakpoints_list=[];function gui_breakpoints_list_clear(){gui_breakpoints_list=[]}function gui_breakpoints_add(e){var t="y"==e.enabled?'checked="checked"':"",n="";if(e.bp_desc)n=e.bp_desc;else if("breakpoint"==e.type)""==e.address?n="Pending in "+e.what:e.file?(e.what&&(n+="in "+e.what),n+=" at "+e.file+":"+e.line):n=e.what?e.what:"at "+e.address;else{if(!(e.type="hw watchpoint"))throw"unexpected breakpoint type";n="watchpoint on "+e.what}if(ide.editor.if_file_exists(e.file)){var o=new Breakpoint(e.file,e.line);o.filename in gui_breakpoints_list||(gui_breakpoints_list[o.filename]=[]),ide.editor.setBreakpoint(o),gui_breakpoints_list[o.filename].push(parseInt(o.line))}var i='';ide.debugger!=DEBUGGER_JAVA&&(i+=""+e.num+""),i+=""+n+'",$("#debug_window_breakpoints tbody").append(i)}function gui_breakpoints_post_processing(){var e=ide.editor.getBreakpoints();for(filename_key in e)for(i in e[filename_key].breakpoints)filename_key in gui_breakpoints_list&&-1!=gui_breakpoints_list[filename_key].indexOf(parseInt(i)+1)||ide.editor.clearBreakpoint(new Breakpoint(filename_key,parseInt(i)+1))}function handle_gui_frames(e){gui_call_stack_clear();for(var t=0;t
"),$("#local_info").jsonView(e.variables);else{$("#debug_window_local_variables tbody").html("");for(var t=0;t"+n.name+""+encodeHtmlEntity(n.val)+"")}}}function handle_gui_registers(e){$("#debug_window_registers tbody").html("");for(var t=0;t"+n.name+""+encodeHtmlEntity(n.val)+"")}}function handle_gui_breakpoints(e){gui_breakpoints_clear(),gui_breakpoints_list_clear();for(var t=0;t"+n+""+quoteattr(t)+'"),!1):($("#debug_window_display_expression tbody").append(''+e+""+quoteattr(t)+'"),!0)},ide.remove_watch_expr=function(e){var t="#debug_window_display_expression tr[data-expr='"+e+"']";return!!$(t).length&&($(t).remove(),!0)};var socket_on_disconnect=function(){ide.server_connected=!1,(ide.running&&"FINISHED"!=ide.running_state||ide.debugging)&&$("#serverDisconnectedModal").modal("show"),ide.running&&close_run_console(),ide.debugging&&(ide.closegdb(),close_debug_console())},socket_on_gdbsessionlimit=function(){ide.unfadeConsole(),alert("Maximum session limit reached. Please try after a while.")},socket_on_emptysource=function(){ide.unfadeConsole(),alert("Source code is empty")},socket_on_filelimitexceed=function(e){ide.unfadeConsole(),"src"==e.file&&alert("Source file can't be larger than "+e.limit),"stdin"==e.file&&alert("Stdin file can't be larger than "+e.limit)},socket_on_maxdebugsession=function(e){ide.closegdb(),close_debug_console(),alert(e)},gui_cmd_id=0;ide.run_gui_cmd=function(e,t,n){var o=!1;t&&(o=!0),socket.emit("run_gui_cmd",{cmd:e.cmd,args:e.args,console_cmd:o,id:gui_cmd_id++}),term&&term.focus()};var socket_on_gui_cmd_reply=function(e){};function add_watch_expr(e){if(13==event.keyCode){var t=e.value.trim();ide.set_watch_expr(t,"")&&socket.emit("add_watch_expr",t),$(e).val("")}}function remove_watch(e){ide.remove_watch_expr(e)&&socket.emit("remove_watch_expr",e)}function term_is_enabled(e){return"RUNNING_GUI_CMD"!=$("#ogdb_status").text()}function parse_console_output(e,t){if(!t)return t;if(t.indexOf("")>=0)for(var n=t.split("").length-1;n;){new Audio("data:audio/wav;base64,//uQRAAAAWMSLwUIYAAsYkXgoQwAEaYLWfkWgAI0wWs/ItAAAGDgYtAgAyN+QWaAAihwMWm4G8QQRDiMcCBcH3Cc+CDv/7xA4Tvh9Rz/y8QADBwMWgQAZG/ILNAARQ4GLTcDeIIIhxGOBAuD7hOfBB3/94gcJ3w+o5/5eIAIAAAVwWgQAVQ2ORaIQwEMAJiDg95G4nQL7mQVWI6GwRcfsZAcsKkJvxgxEjzFUgfHoSQ9Qq7KNwqHwuB13MA4a1q/Dm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kId44S71j0c8eV9yDK6uPRzx5X18eDvjvQ6yKo9ZSS6l//8elePK/Lf//IInrOF/FvDoADYAGBMGb7FtErm5MXMlmPAJQVgWta7Zx2go+8xJ0UiCb8LHHdftWyLJE0QIAIsI+UbXu67dZMjmgDGCGl1H+vpF4NSDckSIkk7Vd+sxEhBQMRU8j/12UIRhzSaUdQ+rQU5kGeFxm+hb1oh6pWWmv3uvmReDl0UnvtapVaIzo1jZbf/pD6ElLqSX+rUmOQNpJFa/r+sa4e/pBlAABoAAAAA3CUgShLdGIxsY7AUABPRrgCABdDuQ5GC7DqPQCgbbJUAoRSUj+NIEig0YfyWUho1VBBBA//uQZB4ABZx5zfMakeAAAAmwAAAAF5F3P0w9GtAAACfAAAAAwLhMDmAYWMgVEG1U0FIGCBgXBXAtfMH10000EEEEEECUBYln03TTTdNBDZopopYvrTTdNa325mImNg3TTPV9q3pmY0xoO6bv3r00y+IDGid/9aaaZTGMuj9mpu9Mpio1dXrr5HERTZSmqU36A3CumzN/9Robv/Xx4v9ijkSRSNLQhAWumap82WRSBUqXStV/YcS+XVLnSS+WLDroqArFkMEsAS+eWmrUzrO0oEmE40RlMZ5+ODIkAyKAGUwZ3mVKmcamcJnMW26MRPgUw6j+LkhyHGVGYjSUUKNpuJUQoOIAyDvEyG8S5yfK6dhZc0Tx1KI/gviKL6qvvFs1+bWtaz58uUNnryq6kt5RzOCkPWlVqVX2a/EEBUdU1KrXLf40GoiiFXK///qpoiDXrOgqDR38JB0bw7SoL+ZB9o1RCkQjQ2CBYZKd/+VJxZRRZlqSkKiws0WFxUyCwsKiMy7hUVFhIaCrNQsKkTIsLivwKKigsj8XYlwt/WKi2N4d//uQRCSAAjURNIHpMZBGYiaQPSYyAAABLAAAAAAAACWAAAAApUF/Mg+0aohSIRobBAsMlO//Kk4soosy1JSFRYWaLC4qZBYWFRGZdwqKiwkNBVmoWFSJkWFxX4FFRQWR+LsS4W/rFRb/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////VEFHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAU291bmRib3kuZGUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMjAwNGh0dHA6Ly93d3cuc291bmRib3kuZGUAAAAAAAAAACU=").play(),n--}return t.indexOf("...Program finished with exit code")<0&&(e.content+=t),t.indexOf("Error: Could not find or load main class Main")>-1&&display_dialog("Main.java file must have public class with name 'Main'","You must declared Main class which contains 'main' method, which is entry point of program execution."),(t.indexOf("Java HotSpot(TM) 64-Bit Server VM warning:")>-1||t.indexOf("Can't detect initial thread stack location - find_vma failed")>-1)&&(t=""),t}function checklinenumber(e){return null}function socketAddon(e){var t=e,n=this,o=function(t){n.terminal.tty_chunk_to_process++,n.terminal.tty_bytes_to_process+=t.length,t=parse_console_output(n.terminal,t),n.terminal.tty_chunk_to_process>50||n.terminal.tty_bytes_to_process>10240?(n.terminal.write(t,function(){e.emit("tty_sync_ack")}),n.terminal.tty_chunk_to_process=0,n.terminal.tty_bytes_to_process=0):n.terminal.write(t)};return this.activate=function(e){this.terminal=e,e.content="",e.tty_chunk_to_process=0,e.tty_bytes_to_process=0,e.tty_ack_sent_cnt=0,e.get_content=function(){return term.content},console.log("activated socket addon"),t.on("message",o),t.on("error",function(){this.dispose()}),t.on("close",function(){this.dispose()}),e.onData(function(e){t.send(e)})},this.dispose=function(){t.removeEventListener("message",o),console.log("disposed socketAddon")},this}function createTerminal(e){for(;e.children.length;)e.removeChild(e.children[0]);(term=new Terminal({cursorBlink:!0})).editor=editor;var t=new socketAddon(socket);term.attachAddon=t,socket.on("message",function(e){});var n=new FitAddon.FitAddon;term.loadAddon(n),term.attachCustomKeyEventHandler(term_is_enabled),term.open(e),term.fitAddon=n,n.fit(),ide.initTerminalGUI(),runRealTerminal()}function runRealTerminal(){term.focus(),term.attachAddon.activate(term),term._initialized=!0}function runFakeTerminal(){if(!term._initialized){term._initialized=!0;term.prompt=function(){term.write("\r\n$ ")},term.writeln("Welcome to xterm.js"),term.writeln("This is a local terminal emulation, without a real terminal in the back-end."),term.writeln("Type some keys and commands to play around."),term.writeln(""),term.prompt(),term.on("key",function(e,t){var n=!(t.altKey||t.altGraphKey||t.ctrlKey||t.metaKey);13==t.keyCode?term.prompt():8==t.keyCode?term.x>2&&term.write("\b \b"):n&&term.write(e)}),term.on("paste",function(e,t){term.write(e)})}}function savefile(e,t){if(e instanceof Array){for(var n=0;n102400)return alert("'"+e[n].name+"' file can't be larger than 100 KB"),!1}else if(e.trim(),e.length>204800)return alert("Source file can't be larger than 200 KB"),!1;return!(t&&t.length>102400)||(alert("stdin file can't be larger than 100 KB"),!1)}ide.setBreakpoint=function(e,t){if(term){var n;if(ide.debugger==DEBUGGER_JAVA)n=e.filename.substring(0,e.filename.lastIndexOf("."))+":"+e.line;else n=e.filename+":"+e.line;ide.run_gui_cmd({cmd:"set_bp",args:n})}},ide.clearBreakpoint=function(e,t){if(term){var n=[];if($("#debug_window_breakpoints tbody tr").each(function(){var t=$(this).attr("data-file"),o=$(this).attr("data-line"),i=$(this).attr("data-bp-num");is_user_src_file(t)&&""+o==""+e.line&&n.push(i)}),n.length)if(ide.debugger==DEBUGGER_JAVA)for(i in n){var o=get_java_bp_desc(n[i]);ide.run_gui_cmd({cmd:"remove_bp",args:o})}else{o=n.join(" ");ide.run_gui_cmd({cmd:"remove_bp",args:o})}}};var on_file_uploaded=function(){var e=this.files;0!=e.length&&new Promise(function(t){var n=new FileReader;n.readAsText(e[0]),n.onload=function(){t({name:e[0].name,content:n.result})}}).then(function(e){var t=ide.editor.get_files();1==t.length&&"source code"==t[0].name?ide.editor.setValue(e.content):(ide.editor.set_files([e]),ide.gotoLine(e.name,1)),ide.editor.focus()})};function downloadCode(){var e=ide.editor.getFile();$.download("/download",[{key:"file",data:JSON.stringify(e)}])}function beautifyCode(){var e={src:ide.editor.getValue(),lang:ide.getCurrentLang(),ts:ide.getCurrentEditorTabSpace()},t=ide.editor.getCursorPosition();disable_btn("control-btn-",["beautify"]),ide.editor.setReadOnly(!0),$.ajax({type:"POST",data:JSON.stringify(e),contentType:"application/json",url:"/beautify",success:function(e){"OK"==e.result?ide.editor.setValue(e.src):alert("Opps! Couldn't beautify code. Please try again."),ide.editor.gotoLine(t.row+1,t.column,!1),ide.editor.focus(),ide.editor.setReadOnly(!1),enable_btn("control-btn-",["beautify"])},error:function(){ide.editor.setReadOnly(!1),enable_btn("control-btn-",["beautify"])}})}function collaborate(){socket.emit("gui_event","collaborate")}function testAssignment(){}function render_grading_box(e){var t=$("#grade_sub_id").val(),n=$("#sub_grade").val(),o=$("#ass_id").val();render_GradeInputBox(t,n,function(){window.location.href="/t/as/"+o+"/sub/evaluate",getQueryStringValue("autoclose")&&window.close()}),setTimeout(function(){$("#grade_input_box_wrapper input").focus()},300)}function markAssignmentSubmissionGrade(e,t){void 0===t&&(t=""),display_dialog("Mark Grade","
",{on_load:render_grading_box,ok_btn:!1})}function markDoneAssignment(e){var t=$("#ass_id").val();$.ajax({type:"POST",data:JSON.stringify({status:"C"}),contentType:"application/json",url:"/sub/status/"+e,error:function(e){display_dialog("Error while marking submission. Please try again.")},success:function(e){console.log(e),"OK"!=e.result?(display_dialog("Error while submission. Please try again."),ide.unfadeConsole()):(window.location.href="/t/as/"+t+"/sub/evaluate",getQueryStringValue("autoclose")&&window.close())}})}function getUrlVars(){for(var e,t=[],n=window.location.href.slice(window.location.href.indexOf("?")+1).split("&"),o=0;o'),$("#upload_file_container input").on("change",on_file_uploaded),$("#upload_file_container input").click()},jQuery.download=function(e,t){for(var n=$("
").attr("action",e).attr("method","post"),o=0;o").attr("type","hidden").attr("name",t[o].key).attr("value",t[o].data);n.append(i)}n.appendTo("body").submit().remove()};var rr_events=[],rr_ss_id=null;function getRREvents(){return rr_events}function submitAssignment(){var e=getSnippet();e.sub_id=null,e.replay_events=getRREvents(),e.ss_id=rr_ss_id;var t=$("#ass_id").val();getUrlVars().preview;window.location!==window.parent.location?(disable_btn("control-btn-",["submit","save"]),isStudentSubmission&&track_event("submission","run"),ide.fadeConsole("Submitting Assignment..."),$.ajax({type:"POST",data:JSON.stringify(e),contentType:"application/json",url:"/s/as/submit/"+t,error:function(e){ide.unfadeConsole(),display_dialog("Error while submission. Please try again."),enable_btn("control-btn-",["submit","save"])},success:function(e){if(enable_btn("control-btn-",["submit","save"]),"DUE_DATE_EXPIRED"==e.result){var n={on_load:function(e){render_RequestButton({wrapper_elem:$(e).find(".request_btn_wrapper").get(0),text:"Send Request to extend due date",endpoint_url:"/s/as/"+t+"/request_extend_due_date"})}};display_dialog("Submission failed because due date is expired",$("#duedate_expired_template").html(),n),ide.unfadeConsole()}else if("ERROR"==e.result)display_dialog("Submission failed because of following reason",e.error_message),ide.unfadeConsole();else if("OK"!=e.result)display_dialog("Error while submission. Please try again."),ide.unfadeConsole();else if(project_saved=!0,window.location!==window.parent.location){var o=e.autolock?"refreshbacktoclass":"refreshwindow";window.parent.postMessage(JSON.stringify({action:o}),"*")}else window.location.href="/s/as/solve/"+t}})):display_dialog("Submission is not allowed in preview mode.")}function saveCode(e){var t=!!e&&e.new_folder,n=e?e.callback:null,o=e?e.parent_id:null;!!e&&e.show_dest_folder?$("#saveCodeModal .destination_folder").show():$("#saveCodeModal .destination_folder").hide();var i="Please login to save snippet to your personal account";if(t&&(i="Seems like you have been logged out. Please login again to create folder."),!popUpLogin(i,saveCode)){var a="Save Project",r="Name of Project:",s=function(){shareCode(!0)};t&&(a="New Folder",r="Name of new folder:",s=function(){shareCode(!1,{new_folder:!0,parent_id:o,callback:n})});var l=$("#ass_id").val();project_uid||l?t?shareCode(!1,{new_folder:!0,parent_id:o,callback:n}):shareCode(!0):($("#saveCodeModal").find(".modal-title").text(a),$("#saveCodeModal").find(".name_label").text(r),$("#saveCodeModal").find(".btn_save").off("click").on("click",s),$("#saveCodeModal").modal("show"),$("#saveCodeModal").off("shown.bs.modal").on("shown.bs.modal",function(){$("#project_name").focus()}))}}function update_navbar_with_projet_title(e){var t='
  • Create New Project
  • ';$("#navbar-ide").replaceWith(t),$("#navbar_project_title").length&&$("#navbar_project_title").text(e)}function getSnippet(){var e=ide.editor.get_files(),t="",n="S",o=$("#lang-select").find(":selected").val();1==e.length&&0==e[0].readonly_ranges.length&&"java"!=o?t=e[0].content:(t=JSON.stringify(e),n="M");var i=$("#stdinput").val(),a=$("#cmd_line_args").val(),r=$("input[name='input_method']:checked").val();return{src:t,stdin:i,lang:o,cmd_line_args:a,input_method:r="text"==r?"T":"I",type:n}}function share_code_snippet_modal(e,t,n){var o="https://"+location.hostname+(location.port?":"+location.port:""),i="//"+location.hostname+(location.port?":"+location.port:"");i+="/embed/js/"+e+"?theme="+$("#settings-editor-theme").val(),o=(o+="/"+e).replace("//www.","//"),i='