SOURCE

console 命令行工具 X clear

                    
>
console
<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<title>哲途成长</title>
		<link href="css/style.css" type="text/css" rel="stylesheet">
	</head>

	<body>
		<script type="text/javascript">
		  /*
		  * @ pwidth 设计稿的宽度
		  * @ prem 你要1rem比多少px  我的是1rem比100px
		  * */
		  (function (doc, win, pwidth, prem) {
		    var docEl = doc.documentElement,
		            resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
		            recalc = function () {
		              var clientWidth = docEl.clientWidth;
		              if (!clientWidth) return;
		              docEl.style.fontSize = clientWidth / pwidth * prem + 'px';
		            };
		    if (!doc.addEventListener) return;
		    win.addEventListener(resizeEvt, recalc, false);
		    doc.addEventListener('DOMContentLoaded', recalc, false);
		  })(document, window, 1920, 100);
		 
		</script>
		<header class="">
			<img class="logo" src="img/logo.png" />
			<div class="slogn">
				<h3>C++信息学课程</h3>
				<p> >>> CSP非专业级软件能量认证</p>
				<p> >>> 课程及在线编程系统</p>
			</div>
		</header>
		<div class="container">
			<div class="video" id="videoBox">
				<div id="videoList"></div>
				<div id="nodata" style="display: none;">
					<h2 class="list-title">课程列表</h2>
					<div class="error-box" style="display: block;"><img src="img/error.png" />暂时还没有课程哦</div>
				</div>
				<div id="pullup" class="error-box"><img src="img/pullup.png" />上拉显示更多</div>
				<div id="nomore" class="error-box"><img class="mR3" src="img/error.png" />没有更多数据了</div>
			</div>
			<div class="code">
				<ace-playground></ace-playground>
				<div id="ace-host">
					<!-- <h2 class="list-title"></h2> -->
					<div id="edit-code">
						<h2 class="list-title">输入C++语言程序</h2>
						<div id="ace-code"></div>
					</div>
					<div id="run-code">
						<div id="ace-buttons">
							<button id="compileBtn" onclick="compile()"><img src="img/run.png" />运行</button>
							<button class="img-btn btn-codefull" onclick="codeFull(true)"><img src="img/full.png" /></button>
							<button class="img-btn btn-esccodefull" onclick="codeFull(false)" style="display: none;"><img src="img/escfull.png" /></button>
						</div>
						<h2 class="list-title">运行结果</h2>
						<div id="ace-preview"></div>
						<p class="ace-preview-text">CPU时间:<span id="cpuTime"></span>&nbsp;&nbsp;&nbsp;&nbsp;占用内存:<span id="memory"></span>KB</p>
					</div>
				</div>
			</div>
		</div>
		<div id="footer" class="footer">
		    Copyright © 2020 Zenitour lnc All Rights Reserved 版权所有-哲途教育
		    <a href="http://beian.miit.gov.cn/" target="_blank">渝ICP备19012400号-1</a>
		    <a href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=50010302002798" target="_blank"><img src="img/beian.jpg" />渝公网安备 50010302002798号</a>
		</div>
		<script src="https://www.zenitour.com/mini/lib/jquery-2.1.1.min.js"></script>
		<script src="https://www.zenitour.com/mini/plugins/layer/layer.min.js"></script>
		<!-- load ace -->
		<script src="./js/ace.js"></script>
		<!-- ajax js -->
		<script src="https://www.zenitour.com/mini/js/service/HttpService.js"></script>
		<script>
			var codeEditor = null,
				previewEditor = null,
				ajax = new HttpService(),
				loadEnd = true,
				pageSize = 5;
			$(function() {
				loadVideo(1); //加载课程列表
				$('.container').css({
					height: window.innerHeight - $('header').outerHeight() - $('#footer').outerHeight()
				})
				//为解决360兼容模式获取window.innerHeight不正确的文件,适当延迟计算container高度
				setTimeout(function(){
					$('.container').css({
						height: window.innerHeight - $('header').outerHeight() - $('#footer').outerHeight()
					})
				},50)
				// class AcePlayground extends HTMLElement {
				// 	constructor() {
				// 		super();
				// 		var shadow = this.attachShadow({
				// 			mode: "open"
				// 		});
				// 		codeEditor = ace.edit(document.getElementById("ace-code"), {
				// 			theme: "ace/theme/xcode",
				// 			mode: "ace/mode/c_cpp",
				// 			value: '#include <iostream>\nusing namespace std;\n\nint main() {\nint x=10;\nint y=25;\nint z=x+y;\ncout<<"Sum of x+y = " << z;\n}',
				// 			autoScrollEditorIntoView: true
				// 		});
				// 		codeEditor.renderer.attachToShadowRoot();
				// 		previewEditor = ace.edit(document.getElementById("ace-preview"), {
				// 			theme: "ace/theme/twilight",
				// 			mode: "ace/mode/c_cpp",
				// 			value: "",
				// 			autoScrollEditorIntoView: true,
				// 			readOnly: true,
				// 			showLineNumbers: false,
				// 			showGutter: false,
				// 		});

				// 	}
				// }
				codeEditor = ace.edit(document.getElementById("ace-code"), {
					theme: "ace/theme/xcode",
					mode: "ace/mode/c_cpp",
					value: '#include <iostream>\nusing namespace std;\n\nint main() {\nint x=10;\nint y=25;\nint z=x+y;\ncout<<"Sum of x+y = " << z;\n}',
					autoScrollEditorIntoView: true
				});
				codeEditor.renderer.attachToShadowRoot();
				previewEditor = ace.edit(document.getElementById("ace-preview"), {
					theme: "ace/theme/twilight",
					mode: "ace/mode/c_cpp",
					value: "",
					autoScrollEditorIntoView: true,
					readOnly: true,
					showLineNumbers: false,
					showGutter: false,
				});
				// customElements.define('ace-playground', AcePlayground);
				// window.add = function() {
				// 	var el = document.createElement("ace-playground");
				// 	document.body.appendChild(el);
				// };
				//滚动到底部时重新加载数据详情
				$('#videoBox').scroll(function(e) {
					var nopage = $(this).data('nopage'),
						thisPage = $(this).data('thisPage'),
						totalPage = $(this).data('totalPage'),
						viewH = $(this).height(), //可见高度  
						contentH = $('#videoList').outerHeight(), //内容高度  
						scrollTop = $(this).scrollTop(); //滚动高度     
					//上一次的加载未完成,不加载下一页
					if (!loadEnd) return;
					//没有数据了,直接返回
					if (nopage) return;
					//到达底部100px时,加载新内容  
					if (scrollTop / (contentH - viewH) >= 0.95) {
						thisPage++;
						if (thisPage <= totalPage) {
							loadVideo(thisPage);
						}
					}
				});

			});

			function compile() {
				layer.load(1);
				ajax.post("compile/v1/excute/cpp17", {
					script: codeEditor.getValue()
				}, function(data) {
					if (data.code == "1001") {
						previewEditor.setValue(data.result.output);
						$('.ace-preview-text').show();
						$('#cpuTime').text(data.result.cpuTime);
						$('#memory').text(data.result.memory);
					} else {
						layer.msg(data.result);
					}
					layer.closeAll();
				});
			}
			function codeFull(full){
				if(full){
					$('.container,header').addClass('code-full');
					$('.btn-codefull').hide();
					$('.btn-esccodefull').show();
				}else{
					$('.container,header').removeClass('code-full');
					$('.btn-codefull').show();
					$('.btn-esccodefull').hide();
				}
			}
			function loadVideo(pageNo) {
				layer.load(1);
				loadEnd = false;
				ajax.post("project/list", {
					pageNo: pageNo,
					pageSize: pageSize
				}, function(data) {
					pageNo == 1 ? ($('#videoList').html(''), $('#pullup').hide(), $('#nomore').hide()) : '';
					$('#videoBox').data('thisPage', pageNo);
					loadEnd = true;
					layer.closeAll();
					var res = data.result;
					if (data.code == "1001" && res.list && res.list.length > 0) {
						res.list.map(function(item, i){
							$('#videoList').append(
							'<h2 class="list-title">' + item.name +//第' + ((pageNo - 1) * pageSize + i + 1) + '课:
								'</h2>'+
							'<div class="list-video">'+
								'<video src="' + item.vedioUrl +
								'" width="100%" controls="controls">'+
								'</video>'+
							'</div>');
						});
						//总页数
						var totalPage = Math.ceil(res.total / pageSize);
						$('#videoBox').data('totalPage', totalPage);
						pageNo < totalPage ? ($('#videoBox').data('nopage', false), $('#pullup').show(), $('#nomore').hide()) : ($(
							'#videoBox').data('nopage', true), $('#pullup').hide(), $('#nomore').show());
					} else {
						$('#nodata').show();
						// layer.msg(typeof(str)=='string'?res:'');
					}
				});
			}
		</script>
	</body>

</html>