<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:36:"./app/index/view/codephp/code_a.html";i:1602749956;}*/ ?>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<title><?php echo $c['title']; ?> | <?php echo set('title'); ?></title>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="keywords" content="<?php echo set('keywords'); ?>">
<meta name="description" content="<?php echo set('description'); ?>">
<link rel="stylesheet" type="text/css" href="<?php echo APP_P; ?>/css/reset.css"/>
<link rel="stylesheet" href="<?php echo APP_P; ?>/codemirror/lib/codemirror.css">
<link rel="stylesheet" href="<?php echo APP_P; ?>/codemirror/theme/monokai.css">
<link rel="stylesheet" href="<?php echo APP_P; ?>/codemirror/theme/cobalt.css">
<script src="<?php echo APP_P; ?>/codemirror/lib/codemirror.js"></script>
<script src="<?php echo APP_P; ?>/codemirror/addon/edit/closetag.js"></script>
<script src="<?php echo APP_P; ?>/codemirror/mode/xml/xml.js"></script>
<script src="<?php echo APP_P; ?>/codemirror/mode/javascript/javascript.js"></script>
<script src="<?php echo APP_P; ?>/codemirror/mode/css/css.js"></script>
<script src="<?php echo APP_P; ?>/codemirror/mode/htmlmixed/htmlmixed.js"></script>
<script src="<?php echo APP_P; ?>/codemirror/mode/php/php.js"></script>
<script src="<?php echo APP_P; ?>/codemirror/mode/clike/clike.js"></script>
<script src="<?php echo APP_P; ?>/js/jquery.min.js"></script>
<script src="<?php echo APP_P; ?>/js/pageEvent2.js"></script>
<style>
button{background: linear-gradient(to left, #96b97d, #4CAF50);line-height: 30px;z-index: 999;width: 100px;height: 30px;margin: 5px;font-family: 'Krona One',sans-serif;font-size: 16px;color: rgba(255,255,255,0.9);text-shadow: 1px 1px 2px rgba(0,0,0,0.5);cursor: pointer;border: none;border-radius: 5px;transition: 300ms;}
#yunxing{position: fixed;top: 0;right: 0;}
#xiugai{background: linear-gradient(to left, #ff5722, #ffc107);position: fixed;top: 0;right: 120px;}
</style>
</head>
<body>
<button class="button" id="yunxing">点击运行</button>
<?php if(session('userid')==1): ?>
<button class="button" id="xiugai">修改</button>
<?php endif; ?>
<xmp id="gethtml" style="display:none;"><?php echo dingyi($c['content'],$content); ?></xmp>
</body>
<script>
var gethtml = $("#gethtml").html();
var myTextArea = CodeMirror(document.body, {
lineNumbers: true,
mode: "application/x-httpd-php",
//theme: 'cobalt',
lineWrapping: true,
indentUnit: 2,
firstLineNumber: 1,
styleActiveLine: true,
matchBrackets: true,
autofocus: true,
tabSize : 4, // Tab缩进,默认4
value: gethtml,
autoCloseTags: true,
readOnly : false, // 是否只读,默认false
lineNumbers : true // 是否显示行号
});
var getValue = myTextArea.getValue();//获取编辑器内容
//myTextArea.replaceSelection('设置到编辑器');
//用户提交测试
//提交到b页面
pageEvent.storagesource = "storage";
var v = myTextArea.getValue();
$("#yunxing").click(function(){
$.ajax({
url: '<?php echo url('index/codephp/code_b'); ?>',
type: "POST",
dataType: "json",
data: {"content": ""+myTextArea.getValue()+"" },
success: function(data) {
if (v != "") {
pageEvent.send("myEvent<?php echo get('id'); ?>", {
msg: v,
time: Date.now()
});
}
},
error : function() {
if (v != "") {
pageEvent.send("myEvent<?php echo get('id'); ?>", {
msg: v,
time: Date.now()
});
}
}
});
});
//管理员修改
<?php if(session('userid')==1): ?>
$(document).ready(function(){
$("#xiugai").click(function(){
$.ajax({
url: '<?php echo url('index/api/codeUpdate'); ?>',
type: "POST",
dataType: "json",
data: {"id": "<?php echo get('id'); ?>","model": "codephp","content": ""+myTextArea.getValue()+"" },
success: function(data) {
if(data.code==1){
alert(data.msg);
//刷新父页面iframe框架
if (v != "") {
pageEvent.send("myEventf<?php echo $c['id']; ?>", {
msg: v,
time: Date.now()
});
}
} else {
alert(data.msg);
}
},
error : function() {
alert("异常");
}
});
});
});
<?php endif; ?>
</script>
</html>