由于换了渲染器, 不支持内嵌HTML了, 以下是源码:
点我查看完整代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
| <!DOCTYPE html> <html lang="zh">
<head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Coliru_Run_Code_Online</title> </head> <style type="text/css" media="screen"> .main { float: left; width: 100%; } #editor { display: block; margin-left: auto; margin-right: auto; padding: 1em; padding-bottom: 30%; } .box { font-family: "Consolas", Helvetica, sans-serif; margin-left: auto; margin-right: auto; padding: 1em; background-color: #272822; color: aliceblue; } </style>
<body> <div class="main"> <div style="display: block;"> <div class="version" style="float: left; display: inline-block;"> <select id="version"> <option value="c++98">C++</option> <option value="c++11" selected = "selected">C++11</option> <option value="c++14">C++14</option> <option value="c++17">C++17</option> <option value="c++20">C++20</option> </select> </div> <div style="float: left; display: inline-block;"> <button type="button" onclick="getOutput()">Run It!</button> </div> <div style="float: right; display: inline-block;"> <span>Powered by <a href="https://coliru.stacked-crooked.com/">Coliru</a> online compiler</span> </div> </div> <br /> <div id="editor"></div> <h3>Input: </h3> <div id="inputBox" contenteditable="true" class="box"></div> <h3>Output: </h3> <div id="outputBox" contenteditable="true" class="box"></div> </div> <script src="https://cdn.bootcdn.net/ajax/libs/ace/test/ace.js"></script> <script type="text/javascript"> ace.require("ace/ext/language_tools"); var editor = ace.edit("editor"); editor.setTheme("ace/theme/monokai"); editor.getSession().setMode("ace/mode/c_cpp"); editor.setFontSize(16); editor.session.setTabSize(4); function stdVersion() { var version = document.getElementById("version").value; return version; } function getOutput() { var code = editor.getSession().getValue(); var output = document.getElementById("outputBox"); var inputData = document.getElementById("inputBox").innerText; var http = new XMLHttpRequest(); http.open("POST", "https://coliru.stacked-crooked.com/compile", false); http.send(JSON.stringify({ "cmd": "g++ -std=" + stdVersion() + " -O2 -Wall main.cpp && ./a.out << EOF\n" + inputData + "\nEOF", "src": code})); output.innerText = http.response;
} </script> </body> </html>
|