/* Copyright (C) 2013 Povilas Kanapickas This file is part of cppreference.com This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ String.prototype.trim = function () { return this.replace(/^\s+|\s+$/g, ""); }; /* We add two new divs for the live editor and the program output. The divs are inserted after the geshi code and output respectively. This way the ACE editor and the compilation output are independent from the static geshi text. We can easily switch between the live editor and the static version. */ function Editor(root) { var cmd_info_cxx = { cc: [ { title: 'GCC 4.6', cmd: 'g++-4.6 -std=c++98 ' }, { title: 'GCC 4.7', cmd: 'g++-4.7 -std=c++98 ' }, { title: 'GCC 4.7 (C++11)', cmd: 'g++-4.7 -std=c++11 ' }, { title: 'GCC 4.8', cmd: 'g++-4.8 -std=c++98 ' }, { title: 'GCC 4.8 (C++11)', cmd: 'g++-4.8 -std=c++11 ' }, { title: 'GCC 4.9', cmd: 'g++-4.9 -std=c++98 ' }, { title: 'GCC 4.9 (C++11)', cmd: 'g++-4.9 -std=c++11 ' }, { title: 'GCC 4.9 (C++14)', cmd: 'g++-4.9 -std=c++14 ' }, { title: 'GCC 5.2 (C++98)', cmd: 'g++-5.2 -std=c++98 ' }, { title: 'GCC 5.2 (C++11)', cmd: 'g++-5.2 -std=c++11 ' }, { title: 'GCC 5.2 (C++14)', cmd: 'g++-5.2 -std=c++14 ' }, { title: 'GCC 5.2 (C++17)', cmd: 'g++-5.2 -std=c++1z ' }, { title: 'clang 3.6', cmd: 'clang++ -std=c++98 ' }, { title: 'clang 3.6 (C++11)', cmd: 'clang++ -std=c++11 -stdlib=libc++ ', opt_suff: ' -lsupc++ ' }, { title: 'clang 3.6 (C++14)', cmd: 'clang++ -std=c++14 -stdlib=libc++ ', opt_suff: ' -lsupc++ ' }, { title: 'clang 3.6 (C++17)', cmd: 'clang++ -std=c++1z -stdlib=libc++ ', opt_suff: ' -lsupc++ ' } ], default_id: 10, opt: ' -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors main.cpp -lm ', } var cmd_info_c = { cc: [ { title: 'GCC 4.6', cmd: 'gcc-4.6 -x c -std=c89 ' }, { title: 'GCC 4.7', cmd: 'gcc-4.7 -x c -std=c89 ' }, { title: 'GCC 4.8', cmd: 'gcc-4.8 -x c -std=c89 ' }, { title: 'GCC 4.8 (C99)', cmd: 'g++-4.8 -x c -std=c99 ' }, { title: 'GCC 4.9', cmd: 'gcc-4.9 -x c -std=c89 ' }, { title: 'GCC 4.9 (C99)', cmd: 'g++-4.9 -x c -std=c99 ' }, { title: 'GCC 4.9 (C11)', cmd: 'g++-4.9 -x c -std=c11 ' }, { title: 'GCC 5.2 (C89)', cmd: 'gcc-5.2 -x c -std=c89 ' }, { title: 'GCC 5.2 (C99)', cmd: 'g++-5.2 -x c -std=c99 ' }, { title: 'GCC 5.2 (C11)', cmd: 'g++-5.2 -x c -std=c11 ' }, { title: 'clang 3.6', cmd: 'clang -x c -std=c89 -Wno-newline-eof ' }, { title: 'clang 3.6 (C99)', cmd: 'clang++ -x c -std=c99 -Wno-newline-eof '}, { title: 'clang 3.6 (C11)', cmd: 'clang++ -x c -std=c11 -Wno-newline-eof '} ], default_id: 9, opt: ' -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors main.cpp -lm ', } this.check_is_cxx = function() { if (mw.config.get('wgTitle').indexOf('c/') == 0) { return false; } else { return true; } }; if (this.check_is_cxx()) { this.cmd_info = cmd_info_cxx; } else { this.cmd_info = cmd_info_c; } this.cmd_run_normal = ' 2>&1 | sed "s/^/☘/"; if [ -x a.out ]; then ./a.out | sed "s/^/☢/"; fi' this.cmd_run_share = ' && ./a.out'; this.el = {}; this.el.root = root; this.is_orig = true; this.el.action_bar = this.el.root.children('.t-example-live-link:first'); // initialize the action bar this.el.run_init_btn = this.el.action_bar.children('.coliru-btn-run-init'); this.el.run_btn = $('
Run
') .addClass('coliru-btn coliru-btn-run') .hide().appendTo(this.el.action_bar); this.el.share_btn = $('
Share
') .addClass('coliru-btn coliru-btn-share') .hide().appendTo(this.el.action_bar); this.el.exit_btn = $('
Exit
') .addClass('coliru-btn coliru-btn-exit') .hide().appendTo(this.el.action_bar); this.el.cc_select_div = $('
') .addClass('coliru-select-compiler') .hide().appendTo(this.el.action_bar); this.el.cc_select = $('