");
window.frames["iframe_show2943"].document.write(decodeHtml($("textarea#stepcodeTextarea2943").val()));
window.frames["iframe_show2943"].document.close();
$(window.frames["iframe_show2943"]).load(function(){
$("#iframe_show2943").height($("#iframe_show2943").contents().find("body").height()+showittryitheight);
});
$("#iframe_show2943").height($("#iframe_show2943").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<style>
table{
border-collapse:collapse;
width:90%;
}
tr{
border-bottom-style: solid;
border-bottom-width: 1px;
border-bottom-color: lightgray;
height:35px;
}
td{
width:25%;
text-align:center;
}
a{
text-decoration: none;
color:skyblue;
}
</style>
<script>
var col = 0;
var reverse = false;
function sort(column){
if(column == col)
reverse = !reverse;
col = column;
var tbody = document.getElementById("tbody");
//通过getElementsByTagName取出来是一个Collection
var trsCollection = document.getElementsByTagName("tr");
//因为Collection没有自带的排序函数,所以需要转换为数组,利用数组自带的排序
var trs =new Array();
for (var i=1; i <trsCollection.length; i++) {
trs.push(trsCollection[i]);
}
trs.sort(comparator);
for (var i=0; i <trs.length; i++) {
tbody.appendChild(trs[i]);
}
}
function comparator(tr1,tr2){
var td1 = tr1.children[col].innerHTML; //取某一行的第col列中的内容
var td2 = tr2.children[col].innerHTML;
if(reverse)
return td1.localeCompare(td2);
else
return td2.localeCompare(td1);
}
</script>
<table>
<tbody id="tbody">
<tr >
<td ><a href="javascript:void(0)" onclick="sort(0)">id</a></td>
<td ><a href="javascript:void(0)" onclick="sort(1)">名称</a></td>
<td ><a href="javascript:void(0)" onclick="sort(2)">血量</a></td>
<td ><a href="javascript:void(0)" onclick="sort(3)">伤害</a></td>
</tr>
<tr >
<td>1</td>
<td>gareen</td>
<td>340</td>
<td>58</td>
</tr>
<tr >
<td>2</td>
<td>teemo</td>
<td>320</td>
<td>76</td>
</tr>
<tr >
<td>3</td>
<td>annie</td>
<td>380</td>
<td>38</td>
</tr>
<tr >
<td>4</td>
<td>deadbrother</td>
<td>400</td>
<td>90</td>
</tr>
</tbody>
</table>
<style>
table{
border-collapse:collapse;
width:90%;
}
tr{
border-bottom-style: solid;
border-bottom-width: 1px;
border-bottom-color: lightgray;
height:35px;
}
td{
width:25%;
text-align:center;
}
a{
text-decoration: none;
color:skyblue;
}
</style>
<script>
var col = 0;
var reverse = false;
function sort(column){
if(column == col)
reverse = !reverse;
col = column;
var tbody = document.getElementById("tbody");
//通过getElementsByTagName取出来是一个Collection
var trsCollection = document.getElementsByTagName("tr");
//因为Collection没有自带的排序函数,所以需要转换为数组,利用数组自带的排序
var trs =new Array();
for (var i=1; i <trsCollection.length; i++) {
trs.push(trsCollection[i]);
}
trs.sort(comparator);
for (var i=0; i <trs.length; i++) {
tbody.appendChild(trs[i]);
}
}
function comparator(tr1,tr2){
var td1 = tr1.children[col].innerHTML; //取某一行的第col列中的内容
var td2 = tr2.children[col].innerHTML;
if(reverse)
return td1.localeCompare(td2);
else
return td2.localeCompare(td1);
}
</script>
<table>
<tbody id="tbody">
<tr >
<td ><a href="javascript:void(0)" onclick="sort(0)">id</a></td>
<td ><a href="javascript:void(0)" onclick="sort(1)">名称</a></td>
<td ><a href="javascript:void(0)" onclick="sort(2)">血量</a></td>
<td ><a href="javascript:void(0)" onclick="sort(3)">伤害</a></td>
</tr>
<tr >
<td>1</td>
<td>gareen</td>
<td>340</td>
<td>58</td>
</tr>
<tr >
<td>2</td>
<td>teemo</td>
<td>320</td>
<td>76</td>
</tr>
<tr >
<td>3</td>
<td>annie</td>
<td>380</td>
<td>38</td>
</tr>
<tr >
<td>4</td>
<td>deadbrother</td>
<td>400</td>
<td>90</td>
</tr>
</tbody>
</table>
");
window.frames["iframe2943"].document.write(decodeHtml(code2943));
window.frames["iframe2943"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe2943"]).load(function(){
$("#iframe2943").height($("#iframe2943").contents().find("body").height()+showittryitheight);
});
$("#iframe2943").height($("#iframe2943").contents().find("body").height()+showittryitheight);
alreadyWriteCode2943 = code2943;
$("#rendering2943").hide();
$("#rendered2943").show();
}
var tRereshRetry2DemoPanel2943 = setInterval(rereshRetry2DemoPanel2943,1000);
var binded2943 = false;
$("textarea#stepcodeTextarea2943").keyup(function(){
if(!binded2943){
$(window).bind('beforeunload',function(){
binded2943 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code2943 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code2943!=newCode){
// window.frames["iframe2943"].document.write("
");
// window.frames["iframe2943"].document.write(decodeHtml($("textarea#stepcodeTextarea2943").val()));
// window.frames["iframe2943"].document.close();
// $(window.frames["iframe2943"]).load(function(){
// $("#iframe2943").height($("#iframe2943").contents().find("body").height()+showittryitheight);
// });
// code2943 = newCode;
// }
});
$(".tryButton2943").click(function(){
$("#tryDiv2943").show();
$("#stepcodeTextarea2943").focus();
$("#stepcodeTextarea2943").height(200);
$("#iframe2943").height(0);
window.frames["iframe2943"].document.write("
");
window.frames["iframe2943"].document.write(decodeHtml($("textarea#stepcodeTextarea2943").val()));
window.frames["iframe2943"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe2943"]).load(function(){
$("#iframe2943").height($("#iframe2943").contents().find("body").height()+showittryitheight);
});
$("#iframe2943").height($("#iframe2943").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor2943.focus();
editor2943.setSize(null, "250");
$("#rendering2943").hide();
$("#rendered2943").hide();
});
var mixedMode = {
name: "htmlmixed",
scriptTypes: [{matches: /\/x-handlebars-template|\/x-mustache/i,
mode: null},
{matches: /(text|application)\/(x-)?vb(a|script)/i,
mode: "vbscript"}]
};
var editor2943 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea2943"), {
lineNumbers: true,
styleActiveLine: true,
matchBrackets: true,
mode:"text/html",
theme:"eclipse",
selectionPointer: true,
lineWrapping: true,
extraKeys: {
"Alt-/": "autocomplete",
"Ctrl-F": "findPersistent",
"F8": function(cm) {
cm.setOption("fullScreen", !cm.getOption("fullScreen"));
},
"Esc": function(cm) {
if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
}
}
});
editor2943.on("change",function(doc){
if(!binded2943){
$(window).bind('beforeunload',function(){
binded2943 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code2943 = newCode;
$("textarea#stepcodeTextarea2943").val(newCode);
if(alreadyWriteCode2943!=code2943){
lastModifedTime2943 = new Date().getTime();
$("#rendering2943").show();
$("#rendered2943").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor2943 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor2943.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv2943").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|