dev_bj
cxt 5 years ago
commit f73afb5f2f

@ -749,6 +749,7 @@ class ShixunsController < ApplicationController
@main_type = MirrorRepository.published_main_mirror
@small_type = MirrorRepository.published_small_mirror
respond_to do |format|
format.html{render :layout => 'base_edu'}
format.json
@ -817,7 +818,7 @@ class ShixunsController < ApplicationController
ShixunServiceConfig.create!(:shixun_id => @shixun.id, :mirror_repository_id => mirror)
end
end
# 自动构建版本库
#自动构建版本库
repository = Repository.new
repository.shixun = @shixun
repository.type = 'Repository::Gitlab'
@ -1168,6 +1169,8 @@ class ShixunsController < ApplicationController
@small_type = MirrorRepository.published_small_mirror
@shixun_main_mirror = @shixun.mirror_repositories.published_main_mirror.first
# 权限
logger.info("###########{User.current.admin?}")
logger.info("#########business:##{User.current.business?}")
@power = (@shixun.status < 2 ? true : ( User.current.admin? ? true : false))
# unless @repository.nil?
# gitlab_address = Redmine::Configuration['gitlab_address']

@ -273,6 +273,10 @@ class Shixun < ActiveRecord::Base
return name
end
def child_mirror_ids
self.mirror_repositories.where(:main_type => 0).pluck(:id)
end
def mirror_name
self.mirror_repositories.map(&:type_name).blank? ? "" : self.mirror_repositories.map(&:type_name)
end

@ -71,7 +71,7 @@
<div class="down-select" id="shixun_small_language_option" style="padding: 2px 0px">
<% @small_type.try(:each) do |type| %>
<p data-shixun-value="<%= type.id %>">
<input type="checkbox" class="magic-checkbox" id="mirror_<%= type.id %>" value="<%= type.type_name %>"/>
<input type="checkbox" class="magic-checkbox" id="mirror_<%= type.id %>" value="<%= type.type_name %>" <%= @shixun.child_mirror_ids.include?(type.id) ? "checked" : ""%>/>
<label style="top:0px" for="mirror_<%= type.id %>"><%= type.type_name %></label>
</p>
<% end %>
@ -294,82 +294,19 @@
</div>
</div>
<% end %>
<% if User.current.admin? || User.current.business? %>
<div class="edu-back-white padding40-20 mb20">
<p class="color-grey-6 font-16 mb30">服务配置</p>
<% @shixun.shixun_service_configs.each do |config| %>
<p class="color-grey-6 font-16 mt30" id="shixun_scenario_type_name"><%= config.mirror_repository.try(:type_name) %></p>
<input type="hidden" name="mirror_id[]" id="shixun_scenario_type_name_id" value="<%= config.mirror_repository.try(:id) %>'">
<div class="clearfix mb5">
<label class="panel-form-label fl">CPU(核)</label>
<div class="pr fl with80 status_con">
<input type="text" name="cpu_limit[]" value="<%= config.cpu_limit %>" class="panel-box-sizing task-form-100 task-height-40"
placeholder="请输入类别名称"/>
</div>
<div class="cl"></div>
</div>
<div class="clearfix mb5">
<label class="panel-form-label fl">最低CPU(核)</label>
<div class="pr fl with80 status_con">
<input type="text" name="lower_cpu_limit[]" value="<%= config.lower_cpu_limit %>" class="panel-box-sizing task-form-100 task-height-40"
placeholder="请输入类别名称"/>
</div>
<div class="cl"></div>
</div>
<div class="clearfix mb5">
<label class="panel-form-label fl">内存限制(M)</label>
<div class="pr fl with80 status_con">
<input type="text" name="memory_limit[]" value="<%= config.memory_limit %>" class="panel-box-sizing task-form-100 task-height-40"
placeholder="请输入类别名称"/>
</div>
<div class="cl"></div>
</div>
<div class="clearfix mb5">
<label class="panel-form-label fl">内存要求(M)</label>
<div class="pr fl with20 status_con">
<input type="text" name="request_limit[]" value="<%= config.request_limit %>" class="panel-box-sizing task-form-100 task-height-40"
placeholder="请输入类别名称"/>
</div>
<label class="panel-form-label fl" style="width: 48%">温馨提示纯编程类型实训建议使用默认值对于大数据等建议使用最大内存的30%</label>
<div class="cl"></div>
</div>
<div class="edu-back-white padding40-20 mb20">
<!-- <div class="clearfix mb5">-->
<!-- <label class="panel-form-label fl">磁盘限制(K)</label>-->
<!-- <div class="pr fl with80 status_con">-->
<!-- <input type="text" name="resource_limit[]" value="<%#= config.resource_limit %>" class="panel-box-sizing task-form-100 task-height-40"-->
<!-- placeholder="请输入类别名称"/>-->
<!-- </div>-->
<!-- <div class="cl"></div>-->
<!-- </div>-->
<% end %>
<div id='result'></div>
</div>
<% end %>
<div class="clearfix mt30">
<a href="javascript:void(0)" class="defalutSubmitbtn fl mr20" onclick="submit_edit_shixun(<%= @shixun.id %>);">保存</a>
<%= link_to "取消", settings_shixun_path(@shixun), :class => "defalutCancelbtn fl" %>
</div>
<% end %>
</div>
<script id="t:edit-setting-list" type="text/html">
<!if(list.length>0) { !>
<!for(var i=0;i<list.length;i++){!>
<p class="color-grey-6 font-16 mt30" id="shixun_scenario_type_name">
<!=listname[i]!>
</p>
<input type="hidden" name="mirror_id[]" value=<!=list[i]!> >
<p class="color-grey-6 font-16 mb30">服务配置</p>
<% @shixun.shixun_service_configs.each do |config| %>
<div id="<%= config.mirror_repository.try(:id) %>" >
<p class="color-grey-6 font-16 mt30" id="shixun_scenario_type_name"><%= config.mirror_repository.try(:type_name) %></p>
<input type="hidden" name="mirror_id[]" id="shixun_scenario_type_name_id" value="<%= config.mirror_repository.try(:id) %>">
<div class="clearfix mb5">
<label class="panel-form-label fl">CPU(核)</label>
<div class="pr fl with80 status_con">
<input type="text" name="cpu_limit[]" value="1" class="panel-box-sizing task-form-100 task-height-40"
<input type="text" <%= User.current.admin? ? "" : "readonly" %> name="cpu_limit[]" value="<%= config.cpu_limit %>" class="panel-box-sizing task-form-100 task-height-40"
placeholder="请输入类别名称"/>
</div>
<div class="cl"></div>
@ -377,7 +314,7 @@
<div class="clearfix mb5">
<label class="panel-form-label fl">最低CPU(核)</label>
<div class="pr fl with80 status_con">
<input type="text" name="lower_cpu_limit[]" value="0.1" class="panel-box-sizing task-form-100 task-height-40"
<input type="text" name="lower_cpu_limit[]" <%= User.current.admin? ? "" : "readonly" %> value="<%= config.lower_cpu_limit %>" class="panel-box-sizing task-form-100 task-height-40"
placeholder="请输入类别名称"/>
</div>
<div class="cl"></div>
@ -385,7 +322,7 @@
<div class="clearfix mb5">
<label class="panel-form-label fl">内存限制(M)</label>
<div class="pr fl with80 status_con">
<input type="text" name="memory_limit[]" value="1024" class="panel-box-sizing task-form-100 task-height-40"
<input type="text" name="memory_limit[]" <%= User.current.admin? ? "" : "readonly" %> value="<%= config.memory_limit %>" class="panel-box-sizing task-form-100 task-height-40"
placeholder="请输入类别名称"/>
</div>
<div class="cl"></div>
@ -393,305 +330,380 @@
<div class="clearfix mb5">
<label class="panel-form-label fl">内存要求(M)</label>
<div class="pr fl with20 status_con">
<input type="text" name="request_limit[]" value="10" class="panel-box-sizing task-form-100 task-height-40"
<input type="text" name="request_limit[]" <%= User.current.admin? ? "" : "readonly" %> value="<%= config.request_limit %>" class="panel-box-sizing task-form-100 task-height-40"
placeholder="请输入类别名称"/>
</div>
<label class="panel-form-label fl" style="width: 48%">温馨提示纯编程类型实训建议使用默认值对于大数据等建议使用最大内存的30%</label>
<div class="cl"></div>
</div>
</div>
<!-- <div class="clearfix mb5">-->
<!-- <label class="panel-form-label fl">磁盘限制(K)</label>-->
<!-- <div class="pr fl with80 status_con">-->
<!-- <input type="text" name="resource_limit[]" value="<%#= config.resource_limit %>" class="panel-box-sizing task-form-100 task-height-40"-->
<!-- placeholder="请输入类别名称"/>-->
<!-- </div>-->
<!-- <div class="cl"></div>-->
<!-- </div>-->
<% end %>
<div id='result'></div>
</div>
<div class="clearfix mt30">
<a href="javascript:void(0)" class="defalutSubmitbtn fl mr20" onclick="submit_edit_shixun(<%= @shixun.id %>);">保存</a>
<%= link_to "取消", settings_shixun_path(@shixun), :class => "defalutCancelbtn fl" %>
</div>
<% end %>
</div>
<script id="t:edit-setting-list" type="text/html">
<!}!>
<!}else{!><!}!>
<!if(list.length>0) { !>
<!for(var i=0;i
<list.length
;i++){!>
<div id=<!=list[i]!>>
<p class="color-grey-6 font-16 mt30" id="shixun_scenario_type_name">
<!=listname[i]!>
</p>
<input type="hidden" name="mirror_id[]" value=<!=list[i]!>>
<div class="clearfix mb5">
<label class="panel-form-label fl">CPU(核)</label>
<div class="pr fl with80 status_con">
<input type="text" name="cpu_limit[]" <%= User.current.admin? ? "" : "readonly" %> value="1" class="panel-box-sizing task-form-100 task-height-40"
placeholder="请输入类别名称"/>
</div>
<div class="cl"></div>
</div>
<div class="clearfix mb5">
<label class="panel-form-label fl">最低CPU(核)</label>
<div class="pr fl with80 status_con">
<input type="text" name="lower_cpu_limit[]" <%= User.current.admin? ? "" : "readonly" %> value="0.1" class="panel-box-sizing task-form-100 task-height-40"
placeholder="请输入类别名称"/>
</div>
<div class="cl"></div>
</div>
<div class="clearfix mb5">
<label class="panel-form-label fl">内存限制(M)</label>
<div class="pr fl with80 status_con">
<input type="text" name="memory_limit[]" <%= User.current.admin? ? "" : "readonly" %> value="1024" class="panel-box-sizing task-form-100 task-height-40"
placeholder="请输入类别名称"/>
</div>
<div class="cl"></div>
</div>
<div class="clearfix mb5">
<label class="panel-form-label fl">内存要求(M)</label>
<div class="pr fl with20 status_con">
<input type="text" name="request_limit[]" <%= User.current.admin? ? "" : "readonly" %> value="10" class="panel-box-sizing task-form-100 task-height-40"
placeholder="请输入类别名称"/>
</div>
<label class="panel-form-label fl" style="width: 48%">温馨提示纯编程类型实训建议使用默认值对于大数据等建议使用最大内存的30%</label>
<div class="cl"></div>
</div>
</div>
<!}!>
<!}else{!><!}!>
</script>
<script>
//配置-信息提交
function submit_edit_shixun(id) {
if (regex_shixun_name() && regex_public_unit() && regex_tech_platform()) {
if (script_Codemirror.getValue().trim() == "") {
$("#test_script_code").show();
$(document).scrollTop(parseInt($("#test_script_code").offset().top) - 150);
return;
} else {
$("#test_script_code").hide();
}
if ($("#shixun_exec_time").val() == "")
return;
$("#edit_shixun_" + id).submit();
}
}
function get_mirror_script() {
$select.siblings("input[type=hidden]").attr("value", hideValue);
$select.siblings("input[type=text]").attr("value", textValue);
$parent.hide();
var script_id = $("#shixun_scenario").val();
$.ajax({
url: "<%= get_script_contents_shixun_path(@shixun) %>",
data: {script_id: script_id},
success: function (data) {
script_Codemirror.setValue(data.contents);
$("#script_description").html(data.description);
notice_box("评测脚本生成成功!");
},
error: function () {
notice_box("获取脚本失败!")
}
})
}
//自定义模板弹框
function define_temp() {
var html = "<%= j(render :partial => 'define_scenario') %>";
pop_box_new(html, 400, 400);
}
//下拉框
$("[select-for]").append("<i class='fa fa-sort-desc lesson_img color-grey-8'></i>");
$("[select-for]").hover(function () {
$(this).find(".down-select").show();
}, function () {
$(this).find(".down-select").hide();
});
var $select, hideValue, textValue, $parent;
$("[select-for] .down-select p").live("click", function () {
$select = $(this).parents(".down-select");
hideValue = $(this).attr("data-shixun-value");
textValue = $(this).html().trim();
$("#shixun_scenario_type_name").html(textValue)
$parent = $(this).parent();
var parentId = $(this).parent().attr("id");
if (parentId != "shixun_scenario_option") {
$select.siblings("input[type=hidden]").attr("value", hideValue);
$select.siblings("input[type=text]").attr("value", textValue);
$parent.hide();
}
if (parentId == "shixun_language_option") {
var mirror_id = $("#shixun_main_language").val();
$("#shixun_scenario_type_name_id").val(mirror_id)
$.ajax({
url: "<%= get_mirror_script_shixuns_path %>",
data: {mirror_id: mirror_id},
success: function (data) {
var lens = data.length;
var htmlContents = "";
$("#shixun_scenario").val("");
$("#shixun_scenario_name").val("");
for (var i = 0; i < lens; i++) {
htmlContents += "<p data-shixun-value=\"" + data[i].mirror_script.id + "\" " + "title=\"" + data[i].mirror_script.script_type + "\">" + data[i].mirror_script.script_type + "</p>"
}
$("#shixun_scenario_option").html(htmlContents);
},
error: function () {
notice_box("获取技术平台失败!")
}
});
}
if (parentId == "shixun_scenario_option") {
op_confirm_tip("原有脚本将被新的脚本覆盖,无法撤销<br/>是否确认执行覆盖操作", "get_mirror_script");
}
});
$("input[name='webssh']").on("click", function () {
if ($(this).val() == 2) {
$("#multi_webssh").parent().show();
} else {
$("#multi_webssh").parent().hide();
$("#multi_webssh").attr("checked", false);
}
});
/*----------------------------选择镜像小类别--------------*/
$("[select-more]").append("<i class='fa fa-sort-desc lesson_img color-grey-8'></i>");
$("[select-more]").hover(function () {
$(this).find(".down-select").show();
}, function () {
$(this).find(".down-select").hide();
});
$("[select-more] .down-select p input").bind("click", function (){
var bt=baidu.template;
bt.LEFT_DELIMITER='<!';
bt.RIGHT_DELIMITER='!>';
var all = $(this).parents(".down-select");
var arr = "";
var arrs=[];
var idarr = [];
for (var i = 0; i < all.find("input").length; i++) {
if (all.find("input").eq(i).is(':checked')) {
arr += ";" + (all.find("input").eq(i).attr("value"));
arrs.push(all.find("input").eq(i).attr("value"))
idarr.push(all.find("input").eq(i).parents("p").attr("data-shixun-value"));
}
}
var data={
"listname":arrs,
"list":idarr
};
debugger
var htmlidarr=bt('t:edit-setting-list',data);
document.getElementById('result').innerHTML=htmlidarr;
$("input[name='small_type']").val(idarr);
$(this).parents().prev("input").val(arr.substring(1));
//$(this).parents(".down-select").hide();
});
$(function () {
//选择自定义脚本
$("#diy_script").click(function () {
var html = "<%= j(render :partial => 'define_scenario') %>";
pop_box_new(html, 400, 400);
});
$("#webssh").on("click", function () {
$(this).val() == '0' ? $(this).val('1') : $(this).val("0");
});
$("#vnc").on("click", function () {
$(this).val() == '0' ? $(this).val('1') : $(this).val("0");
});
$("#can_copy").on("click", function () {
$(this).val() == '0' ? $(this).val('1') : $(this).val("0");
});
$("#unlock_test_set").on("click", function () {
$(this).val() == '0' ? $(this).val('1') : $(this).val("0");
});
$("#code_hidden").on("click", function () {
$(this).val() == '0' ? $(this).val('1') : $(this).val("0");
});
$("#forbid_copy").on("click", function () {
$(this).val() == '0' ? $(this).val('1') : $(this).val("0");
});
$("#hide_code").on("click", function () {
$(this).val() == '0' ? $(this).val('1') : $(this).val("0");
});
$("#task_pass").on("click", function () {
$(this).val() == '0' ? $(this).val('1') : $(this).val("0");
});
$("#scope-down-list").find("li").live("click", function () {
var ul = $(this).parent("ul");
var div = $(this).parents("#unit-input-part");
var value = $(this).html();
ul.siblings("#for_part_search").val(value);
var width = value.length * 2;
var label = "<label class=\"fl unit-part mb10\"><input type='text' size='" + width + "' id='scope_partment' name='scope_partment[]' readonly value='" + value + "'><span class=\"color-orange03 ml5 eud-pointer\">×</span></label>";
div.before(label);
ul.siblings("#for_part_search").attr("data-value-was", value);
$("#person-unit").hide();
$("#scope-down-list").hide();
});
$(".unit-part").find("span").live("click", function () {
$(this).parents(".unit-part").remove();
});
if ($("#public-part").is(":checked")) {
$("#person-unit").show();
$("#person-unit").find("input").val("");
<script>
//配置-信息提交
function submit_edit_shixun(id) {
if (regex_shixun_name() && regex_public_unit() && regex_tech_platform()) {
if (script_Codemirror.getValue().trim() == "") {
$("#test_script_code").show();
$(document).scrollTop(parseInt($("#test_script_code").offset().top) - 150);
return;
} else {
$("#test_script_code").hide();
}
if ($("#shixun_exec_time").val() == "")
return;
$("#edit_shixun_" + id).submit();
}
}
function get_mirror_script() {
$select.siblings("input[type=hidden]").attr("value", hideValue);
$select.siblings("input[type=text]").attr("value", textValue);
$parent.hide();
var script_id = $("#shixun_scenario").val();
$.ajax({
url: "<%= get_script_contents_shixun_path(@shixun) %>",
data: {script_id: script_id},
success: function (data) {
script_Codemirror.setValue(data.contents);
$("#script_description").html(data.description);
notice_box("评测脚本生成成功!");
},
error: function () {
notice_box("获取脚本失败!")
}
})
}
//自定义模板弹框
function define_temp() {
var html = "<%= j(render :partial => 'define_scenario') %>";
pop_box_new(html, 400, 400);
}
//下拉框
$("[select-for]").append("<i class='fa fa-sort-desc lesson_img color-grey-8'></i>");
$("[select-for]").hover(function () {
$(this).find(".down-select").show();
}, function () {
$(this).find(".down-select").hide();
});
var $select, hideValue, textValue, $parent;
$("[select-for] .down-select p").live("click", function () {
$select = $(this).parents(".down-select");
hideValue = $(this).attr("data-shixun-value");
textValue = $(this).html().trim();
$("#shixun_scenario_type_name").html(textValue)
$parent = $(this).parent();
var parentId = $(this).parent().attr("id");
if (parentId != "shixun_scenario_option") {
$select.siblings("input[type=hidden]").attr("value", hideValue);
$select.siblings("input[type=text]").attr("value", textValue);
$parent.hide();
}
if (parentId == "shixun_language_option") {
var mirror_id = $("#shixun_main_language").val();
$("#shixun_scenario_type_name_id").val(mirror_id)
$.ajax({
url: "<%= get_mirror_script_shixuns_path %>",
data: {mirror_id: mirror_id},
success: function (data) {
var lens = data.length;
var htmlContents = "";
$("#shixun_scenario").val("");
$("#shixun_scenario_name").val("");
for (var i = 0; i < lens; i++) {
htmlContents += "<p data-shixun-value=\"" + data[i].mirror_script.id + "\" " + "title=\"" + data[i].mirror_script.script_type + "\">" + data[i].mirror_script.script_type + "</p>"
}
$("#shixun_scenario_option").html(htmlContents);
},
error: function () {
notice_box("获取技术平台失败!")
}
});
}
if (parentId == "shixun_scenario_option") {
op_confirm_tip("原有脚本将被新的脚本覆盖,无法撤销<br/>是否确认执行覆盖操作", "get_mirror_script");
}
});
$("input[name='webssh']").on("click", function () {
if ($(this).val() == 2) {
$("#multi_webssh").parent().show();
} else {
$("#multi_webssh").parent().hide();
$("#multi_webssh").attr("checked", false);
}
});
/*----------------------------选择镜像小类别--------------*/
$("[select-more]").append("<i class='fa fa-sort-desc lesson_img color-grey-8'></i>");
$("[select-more]").hover(function () {
$(this).find(".down-select").show();
}, function () {
$(this).find(".down-select").hide();
});
$("[select-more] .down-select p input").bind("click", function () {
var bt = baidu.template;
bt.LEFT_DELIMITER = '<!';
bt.RIGHT_DELIMITER = '!>';
var all = $(this).parents(".down-select");
var arr = "";
var arrs = [];
var idarr = [];
var noidarr=[];
for (var i = 0; i < all.find("input").length; i++) {
if (all.find("input").eq(i).is(':checked')) {
arr += ";" + (all.find("input").eq(i).attr("value"));
arrs.push(all.find("input").eq(i).attr("value"))
idarr.push(all.find("input").eq(i).parents("p").attr("data-shixun-value"));
}else{
noidarr.push(all.find("input").eq(i).parents("p").attr("data-shixun-value"));
}
}
for(var i=0; i<noidarr.length; i++){
$("#"+noidarr[i]).remove();
}
var data = {
"listname": arrs,
"list": idarr,
"admin":<%= User.current.admin? %>
};
var htmlidarr = bt('t:edit-setting-list', data);
document.getElementById('result').innerHTML = htmlidarr;
$("input[name='small_type']").val(idarr);
$(this).parents().prev("input").val(arr.substring(1));
//$(this).parents(".down-select").hide();
});
$(function () {
//选择自定义脚本
$("#diy_script").click(function () {
var html = "<%= j(render :partial => 'define_scenario') %>";
pop_box_new(html, 400, 400);
});
$("#webssh").on("click", function () {
$(this).val() == '0' ? $(this).val('1') : $(this).val("0");
});
$("#vnc").on("click", function () {
$(this).val() == '0' ? $(this).val('1') : $(this).val("0");
});
$("#can_copy").on("click", function () {
$(this).val() == '0' ? $(this).val('1') : $(this).val("0");
});
$("#unlock_test_set").on("click", function () {
$(this).val() == '0' ? $(this).val('1') : $(this).val("0");
});
$("#code_hidden").on("click", function () {
$(this).val() == '0' ? $(this).val('1') : $(this).val("0");
});
$("#forbid_copy").on("click", function () {
$(this).val() == '0' ? $(this).val('1') : $(this).val("0");
});
$("#hide_code").on("click", function () {
$(this).val() == '0' ? $(this).val('1') : $(this).val("0");
});
$("#task_pass").on("click", function () {
$(this).val() == '0' ? $(this).val('1') : $(this).val("0");
});
$("#scope-down-list").find("li").live("click", function () {
var ul = $(this).parent("ul");
var div = $(this).parents("#unit-input-part");
var value = $(this).html();
ul.siblings("#for_part_search").val(value);
var width = value.length * 2;
var label = "<label class=\"fl unit-part mb10\"><input type='text' size='" + width + "' id='scope_partment' name='scope_partment[]' readonly value='" + value + "'><span class=\"color-orange03 ml5 eud-pointer\">×</span></label>";
div.before(label);
ul.siblings("#for_part_search").attr("data-value-was", value);
$("#person-unit").hide();
$("#scope-down-list").hide();
});
$(".unit-part").find("span").live("click", function () {
$(this).parents(".unit-part").remove();
});
if ($("#public-part").is(":checked")) {
$("#person-unit").show();
$("#person-unit").find("input").val("");
// $(".unit-part").remove();
$("#unit-all").show();
}
$("input[name='public_degree']").live("click", function () {
var item = $(this).attr("id");
if ($(this).is(":checked") && item == "public-part") {
$("#person-unit").show();
$("#person-unit").find("input").val("");
//$(".unit-part").remove();
$("#unit-all").show();
} else {
$("#unit-all").hide();
}
});
$("body").on("click", function (e) {
//alert($(e.target).attr("id"));
if ($(e.target).attr("id") != "person-unit") {
$("#scope-down-list").hide();
}
});
//设置编辑时显示的单位
$(".unit-part input").each(function () {
$(this).attr("size", parseInt($(this).val().length) * 2);
})
});
//申请新建
function post_apply() {
var html = "<%= escape_javascript(render :partial => 'shixuns/apply_setnew') %>";
pop_box_new(html, 460, 416);
}
var setting_editormd = editormd("setting_introduction", {
width: "100%",
height: 210,
syncScrolling: "single",
//你的lib目录的路径我这边用JSP做测试的
path: "/editormd/lib/",
tex: true,
toolbarIcons: function () {
// Or return editormd.toolbarModes[name]; // full, simple, mini
// Using "||" set icons align right.
return ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear"]
},
toolbarCustomIcons: {
testIcon: "<a type=\"inline\" class=\"latex\" ><div class='zbg'></div></a>",
testIcon1: "<a type=\"latex\" class=\"latex\" ><div class='zbg_latex'></div></a>"
},
onload: function () {
$("#setting_introduction [type=\"latex\"]").bind("click", function () {
setting_editormd.cm.replaceSelection("```latex");
setting_editormd.cm.replaceSelection("\n");
setting_editormd.cm.replaceSelection("\n");
setting_editormd.cm.replaceSelection("```");
var __Cursor = setting_editormd.cm.getDoc().getCursor();
setting_editormd.cm.setCursor(__Cursor.line - 1, 0);
});
$("#setting_introduction [type=\"inline\"]").bind("click", function () {
setting_editormd.cm.replaceSelection("$$$$");
var __Cursor = setting_editormd.cm.getDoc().getCursor();
setting_editormd.cm.setCursor(__Cursor.line, __Cursor.ch - 2);
setting_editormd.cm.focus();
});
$("[type=\"inline\"]").attr("title", "行内公式");
$("[type=\"latex\"]").attr("title", "多行公式");
},
//这个配置在simple.html中并没有但是为了能够提交表单使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中方便post提交表单。
saveHTMLToTextarea: true,
autoFocus: false,
// 用于增加自定义工具栏的功能可以直接插入HTML标签不使用默认的元素创建图标
dialogMaskOpacity: 0.6,
placeholder: "请输入完成当前任务依赖的知识点或者其它相关信息",
imageUpload: true,
imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"],
imageUploadURL: "<%= upload_with_markdown_path(:container_id => @shixun.id, :container_type => @shixun.class) %>" //url
});
md_elocalStorage(setting_editormd, "shixun_edit_<%= User.current.id %>", "in");
var script_Codemirror = CodeMirror.fromTextArea(document.getElementById("shixun_script"), {
lineNumbers: true,
theme: "default",
// extraKeys: {"Ctrl-Q": "autocomplete"}, // 快捷键
indentUnit: 4, //代码缩进为一个tab的距离
matchBrackets: true,
autoRefresh: true,
smartIndent: true,//智能换行
styleActiveLine: true,
lint: true
});
script_Codemirror.setSize("auto", "600px");
// 非管理员只能查看
</script>
$("#unit-all").show();
}
$("input[name='public_degree']").live("click", function () {
var item = $(this).attr("id");
if ($(this).is(":checked") && item == "public-part") {
$("#person-unit").show();
$("#person-unit").find("input").val("");
//$(".unit-part").remove();
$("#unit-all").show();
} else {
$("#unit-all").hide();
}
});
$("body").on("click", function (e) {
//alert($(e.target).attr("id"));
if ($(e.target).attr("id") != "person-unit") {
$("#scope-down-list").hide();
}
});
//设置编辑时显示的单位
$(".unit-part input").each(function () {
$(this).attr("size", parseInt($(this).val().length) * 2);
})
});
//申请新建
function post_apply() {
var html = "<%= escape_javascript(render :partial => 'shixuns/apply_setnew') %>";
pop_box_new(html, 460, 416);
}
var setting_editormd = editormd("setting_introduction", {
width: "100%",
height: 210,
syncScrolling: "single",
//你的lib目录的路径我这边用JSP做测试的
path: "/editormd/lib/",
tex: true,
toolbarIcons: function () {
// Or return editormd.toolbarModes[name]; // full, simple, mini
// Using "||" set icons align right.
return ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear"]
},
toolbarCustomIcons: {
testIcon: "<a type=\"inline\" class=\"latex\" ><div class='zbg'></div></a>",
testIcon1: "<a type=\"latex\" class=\"latex\" ><div class='zbg_latex'></div></a>"
},
onload: function () {
$("#setting_introduction [type=\"latex\"]").bind("click", function () {
setting_editormd.cm.replaceSelection("```latex");
setting_editormd.cm.replaceSelection("\n");
setting_editormd.cm.replaceSelection("\n");
setting_editormd.cm.replaceSelection("```");
var __Cursor = setting_editormd.cm.getDoc().getCursor();
setting_editormd.cm.setCursor(__Cursor.line - 1, 0);
});
$("#setting_introduction [type=\"inline\"]").bind("click", function () {
setting_editormd.cm.replaceSelection("$$$$");
var __Cursor = setting_editormd.cm.getDoc().getCursor();
setting_editormd.cm.setCursor(__Cursor.line, __Cursor.ch - 2);
setting_editormd.cm.focus();
});
$("[type=\"inline\"]").attr("title", "行内公式");
$("[type=\"latex\"]").attr("title", "多行公式");
},
//这个配置在simple.html中并没有但是为了能够提交表单使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中方便post提交表单。
saveHTMLToTextarea: true,
autoFocus: false,
// 用于增加自定义工具栏的功能可以直接插入HTML标签不使用默认的元素创建图标
dialogMaskOpacity: 0.6,
placeholder: "请输入完成当前任务依赖的知识点或者其它相关信息",
imageUpload: true,
imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"],
imageUploadURL: "<%= upload_with_markdown_path(:container_id => @shixun.id, :container_type => @shixun.class) %>" //url
});
md_elocalStorage(setting_editormd, "shixun_edit_<%= User.current.id %>", "in");
var script_Codemirror = CodeMirror.fromTextArea(document.getElementById("shixun_script"), {
lineNumbers: true,
theme: "default",
// extraKeys: {"Ctrl-Q": "autocomplete"}, // 快捷键
indentUnit: 4, //代码缩进为一个tab的距离
matchBrackets: true,
autoRefresh: true,
smartIndent: true,//智能换行
styleActiveLine: true,
lint: true
});
script_Codemirror.setSize("auto", "600px");
// 非管理员只能查看
</script>
Loading…
Cancel
Save