html实训

This commit is contained in:
daiao 2017-08-04 10:19:41 +08:00
parent 397e59e5d1
commit d2cede6754
3 changed files with 17 additions and 8 deletions

View File

@ -29,14 +29,12 @@
<% end %>
</div>
<script>
window.onload = function(){
<% if @shixun.language == "Html" %>
var hVal = setInterval(tpi_html_show, 1000);
<% end %>
};
// 如果是HTML实训则在效果显示栏渲染code
<% if @shixun.language == "Html" %>
var hVal = setInterval(tpi_html_show, 1000);
<% end %>
// 渲染用户的HTML的CODE。
function tpi_html_show(){
console.log(editor_CodeMirror.getValue());
$.ajax({
url: "<%= html_content_iframes_path %>",
type: "POST",
@ -145,19 +143,24 @@
// 加载页面
nEvalContent = $("#evaluating_contents");
nEvalInfo = $("#evaluating_info");
nHtmlContent = $("#html_contents");
nAjaxLoading = $("#evaluating_ajax_loading");
nHtmlAjaxLoading = $("#html_ajax_loading");
nInfoAjaxLoading = $("#info_ajax_loading");
nAjaxLoading.css("display","flex");
nInfoAjaxLoading.css("display","flex");
nHtmlAjaxLoading.css("display","flex");
nEvalContent.hide();
nEvalInfo.hide();
nHtmlContent.hide();
nAjaxLoading.show();
nInfoAjaxLoading.show();
nHtmlAjaxLoading.show();
nAjaxLoading.html("<embed src='/images/bigdata/loading2.svg' />");
nInfoAjaxLoading.html("<embed src='/images/bigdata/loading2.svg' />");
nHtmlAjaxLoading.html("<embed src='/images/bigdata/loading2.svg' />");
$("#code_test").html("<a class='task-btn mt8 mr15'>评测中..</a>");
clearInterval(hVal);
// 保存版本库代码
$.ajax({
type: "POST",
@ -182,9 +185,11 @@
i = i + 1;
console.log(i);
if(data.status == 2 || data.status == 0){
hVal = setInterval(tpi_html_show, 1000);
clearInterval(intId);
nEvalContent.show();
nEvalInfo.show();
nHtmlContent.show();
nAjaxLoading.val("");
nInfoAjaxLoading.val("");
nAjaxLoading.hide();
@ -225,9 +230,11 @@
}
// 访问60次即120s后后台还未改变状态即执行
if(i == 60){
hVal = setInterval(tpi_html_show, 1000);
clearInterval(intId);
nEvalContent.show();
nEvalInfo.show();
nHtmlContent.show();
nAjaxLoading.val("");
nInfoAjaxLoading.val("");
nAjaxLoading.hide();
@ -240,8 +247,10 @@
}
},
complete: function(XMLHttpRequest,status){if(status=='timeout'){
hVal = setInterval(tpi_html_show, 1000);
clearInterval(intId);
nEvalContent.show();
nHtmlContent.show();
nEvalInfo.show();
nAjaxLoading.val("");
nInfoAjaxLoading.val("");

View File

@ -24,7 +24,7 @@
<div class="fit -scroll">
<div class="-layout-v -fit">
<div class="-flex -scroll task-padding16 loading-center undis" id="html_ajax_loading"></div>
<div class="-flex -scroll task-padding16" id="evaluating_contents" style="background: #fff">
<div class="-flex -scroll task-padding16" id="html_contents" style="background: #fff">
</div>
</div>
</div>

View File

@ -1 +1 @@
$("#evaluating_contents").html('<%= j (render :partial => "iframes/html_show" ) %>');
$("#html_contents").html('<%= j (render :partial => "iframes/html_show" ) %>');