<link href="/static/codemirror/lib/codemirror.css" rel="stylesheet" > <script src="/static/codemirror/lib/codemirror.js"></script>
<link href="/static/codemirror/theme/3024-night.css" rel="stylesheet"> <link href="/static/codemirror/theme/erlang-dark.css" rel="stylesheet"> <script src="/static/codemirror/mode/shell/shell.js"></script> <script src="/static/codemirror/mode/perl/perl.js"></script> <script src="/static/codemirror/mode/python/python.js"></script>
<!--选择脚本编码代码-->
<div class="controls">
<input class="ck-code" type="radio" name="script_once_type" id="script_once_type1" checked> shell
<input class="ck-code" type="radio" name="script_once_type" id="script_once_type2"> bat
<input class="ck-code" type="radio" name="script_once_type" id="script_once_type3"> python
</div>
<!--选择脚本风格代码-->
<div class="controls">
<select id='select'>
<option>default</option>
<option>3024-night</option>
<option selected>erlang-dark</option>
</select>
</div>
<!--textarea-->
<textarea id="script_once_code">
#!/bin/sh
</textarea>
<textarea id="code2" class="hide">
#!/usr/bin/env python
# -*- coding: utf8 -*-
</textarea>
var editor = CodeMirror.fromTextArea($("#script_once_code")[0], { //script_once_code为你的textarea的ID号
lineNumbers: true,//是否显示行号
mode:"shell", //默认脚本编码
lineWrapping:true, //是否强制换行
});
//选择界面风格JS
$('#select').change(function(){
var theme = $('#select').val();
editor.setOption("theme", theme); //editor.setOption()为codeMirror提供的设置风格的方法
});
//选择脚本类型JS
var txt1=$("#script_once_code").val();
var txt2='';
var txt3=$("#code2").val();
$(".ck-code").click(function(){
var txt=editor.getValue(); //editor.getValue()获取textarea中的值
var lang=$(this).prop("id");
if(lang=="script_once_type1") {
editor.setOption("mode","shell");//editor.setOption()设置脚本类型
editor.setValue(txt1);// editor.setValue()设置textarea中的值
}
else if(lang=="script_once_type2") {
editor.setOption("mode","perl");
editor.setValue(txt2);
}
else {
editor.setOption("mode","python");
editor.setValue(txt3);
}
});
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有