|
|
/// <reference path="../Common/dialogHelper.js" />
|
|
|
|
|
|
|
|
|
$(function () {
|
|
|
GetTheoryChaptList();
|
|
|
// GetResourceList();
|
|
|
|
|
|
|
|
|
|
|
|
$("#FileUpload").click(function () {
|
|
|
FileUpload();
|
|
|
});
|
|
|
//文件选择
|
|
|
$("#FileChoose").click(function () {
|
|
|
$("#HFilePath").click();
|
|
|
});
|
|
|
|
|
|
////将file的值赋值给input
|
|
|
//$("#HFilePath").live("change", function () {
|
|
|
// var filepath = $(this).val();
|
|
|
// $("#filePath").val(filepath);
|
|
|
//});
|
|
|
|
|
|
$("#btnAdd").click(function () {
|
|
|
|
|
|
// $("#addpop").show();
|
|
|
// $(".windowBg").show();
|
|
|
$("#txtResourceName").val("");
|
|
|
$("#filePath").val("");
|
|
|
$("#fileDiv").html("");
|
|
|
$("#fileDiv").html("<input class=\"file-field IEUploadButton\" style=\"width:60px;\" type=\"file\" id=\"HFilePath\" name=\"HFilePath\" onchange=\"$('#filePath').val($(this).val())\" accept=\".jpg,.gif,.bmp,.jpeg,.png,.doc,.xls,.txt,.ppt,.pptx,.xlsx,.docx,.swf,.pdf,.avi,.rmvb,.mpg,.wmv,.mp4,.3gp,.zip,.rar\"><input class=\"btn btn-small btn-blue\" type=\"button\" value=\"浏览\" id=\"FileChoose\">");
|
|
|
$("#FileUpload").unbind("click").bind("click", function () { FileUpload(); });
|
|
|
dialogHelper.Show("addpop", 756);
|
|
|
});
|
|
|
|
|
|
$("#btnAddchapter").click(function () {
|
|
|
dialogHelper.Show("divAddChapter", 500);
|
|
|
// $("#divAddChapter").show();
|
|
|
// $(".windowBg").show();
|
|
|
$("#txtChapterName").val("");
|
|
|
});
|
|
|
|
|
|
$("#btnEditchapter").unbind("click").click(function () {
|
|
|
|
|
|
//$("#popChapterManage").show();
|
|
|
GetTheoryChaptertable();
|
|
|
dialogHelper.Show("popChapterManage", 500);
|
|
|
$("#closeChapterManage").addClass("btn-blue").attr("disabled", false)
|
|
|
});
|
|
|
|
|
|
$(".pop-button .btn1").click(function () {
|
|
|
dialogHelper.Close("divAddChapter");
|
|
|
});
|
|
|
|
|
|
$("#btnSaveChapter").click(function () {
|
|
|
AddSave(0);
|
|
|
});
|
|
|
|
|
|
$("#closeChapterManage").click(function () {
|
|
|
dialogHelper.Close("popChapterManage");
|
|
|
});
|
|
|
|
|
|
$("li[name='lichapter']").live("click", function () {
|
|
|
$("li[name='lichapter'] .active").removeClass("active")
|
|
|
$(this).children().addClass("active");
|
|
|
$("#hdchapterId").val($("li[name='lichapter'] .active").attr("chapterid"));
|
|
|
$("#resourceList").empty();
|
|
|
GetResourceList();
|
|
|
});
|
|
|
|
|
|
$("#addclose").click(function () {
|
|
|
dialogHelper.Close("addpop");
|
|
|
$("#txtResourceName").val("");
|
|
|
$("#filePath").val("");
|
|
|
});
|
|
|
|
|
|
$("#popChapterManage .JS-edit").live("click", function () {
|
|
|
$("#closeChapterManage").removeClass("btn-blue").attr("disabled", true);
|
|
|
|
|
|
//if ($(":input[name='txteditchapterName']").length >= 1)
|
|
|
//{
|
|
|
// dialogHelper.Error({ content: "有未保存的章节,请先保存!" });
|
|
|
// return;
|
|
|
//}
|
|
|
|
|
|
if ($(this).text() == "编辑") {
|
|
|
if ($(":input[name='txteditchapterName']").length >= 1) {
|
|
|
dialogHelper.Error({ content: "有未保存的章节,请先保存!" });
|
|
|
return;
|
|
|
}
|
|
|
$(this).text("保存");
|
|
|
var input = $(this).parent().siblings(".input");
|
|
|
var inputtext = input.text();
|
|
|
//if (inputtext == "请输入章节名称")
|
|
|
//{ inputtext = ""; }
|
|
|
input.html("<input id='txteditchapterName' style='width:98%;' name='txteditchapterName' class='ipt-text grid-12 IsMaxLength IsMinLength IsRequired' type='text' value='' minlength='2' maxlength='20' msgname='章节名称'>");
|
|
|
input.find("input").val(inputtext);
|
|
|
//不能翻页
|
|
|
$("#pages3 a").unbind("click").bind("click", function () {
|
|
|
dialogHelper.Error({ content: "有未保存的章节,请先保存!" });
|
|
|
})
|
|
|
|
|
|
}
|
|
|
else {
|
|
|
var chapterId = $(this).attr("aId");
|
|
|
EditChapter(chapterId);
|
|
|
}
|
|
|
|
|
|
//$(this).toggle(function () {
|
|
|
// $(this).text("保存");
|
|
|
// var input = $(this).parent().siblings(".input");
|
|
|
// var inputtext = input.text();
|
|
|
// if (inputtext == "请输入章节名称")
|
|
|
// { inputtext = "";}
|
|
|
// input.html("<input id='txteditchapterName' style='width:98%;' name='txteditchapterName' class='ipt-text grid-12 IsMaxLength IsMinLength IsRequired' type='text' value='' minlength='2' maxlength='20' msgname='章节名称'>");
|
|
|
// input.find("input").val(inputtext);
|
|
|
// //不能翻页
|
|
|
// $("#pages3 a").unbind("click").bind("click", function () {
|
|
|
// dialogHelper.Error({ content: "有未保存的章节,请先保存!" });
|
|
|
// })
|
|
|
//},
|
|
|
// function () {
|
|
|
// var chapterId = $(this).attr("aId");
|
|
|
// EditChapter(chapterId);
|
|
|
// });
|
|
|
|
|
|
////先触发click,不然第一次失效
|
|
|
//$(this).trigger("click");
|
|
|
});
|
|
|
|
|
|
});
|
|
|
//获取章节列表,左侧菜单
|
|
|
function GetTheoryChaptList() {
|
|
|
pageResourceHelper.Init({
|
|
|
url: "/Teacher/Resource/GetTheoryChaptList",
|
|
|
type: "POST",
|
|
|
pageDiv: "#pages",
|
|
|
async: false,
|
|
|
bind: function (data) {
|
|
|
var html = "";
|
|
|
if (data.Data.length > 0) {
|
|
|
$(data.Data).each(function (index, dom) {
|
|
|
html += "<li name='lichapter'><a style=\"font-size: 16px;\" title=" + dom.ChapterName + " chapterId=" + dom.Id + ">" + dom.ChapterName + "</a></li>";
|
|
|
$("#ultheoryChapter").html(html);
|
|
|
});
|
|
|
}
|
|
|
else { $("#ultheoryChapter").html(html); }
|
|
|
$("#ultheoryChapter li:eq(0) a").addClass("active");
|
|
|
$("#hdchapterId").val($("li[name='lichapter'] .active").attr("chapterid"));
|
|
|
//翻页时防止,下一页的章节下无菜单,显示的是上一页选中章节的资源,先清空,再加载资源
|
|
|
$("#resourceList").empty();
|
|
|
GetResourceList();
|
|
|
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
//获取章节列表,章节管理表
|
|
|
function GetTheoryChaptertable(currIndex) {
|
|
|
if (currIndex == undefined) {
|
|
|
currIndex = 1;
|
|
|
}
|
|
|
|
|
|
pageHelper.Init({
|
|
|
url: "/Teacher/Resource/GetTheoryChaptList",
|
|
|
type: "POST",
|
|
|
pageDiv: "#pages3",
|
|
|
async: false,
|
|
|
pageIndex: currIndex,
|
|
|
bind: function (data) {
|
|
|
var html = "";
|
|
|
$(data.Data).each(function (index, dom) {
|
|
|
|
|
|
//每行html
|
|
|
var trHtml = "";
|
|
|
trHtml += "<tr>";
|
|
|
trHtml += "<td class=\"input\"><div class=\"ellipsis\" title=\"{0}\">{0}</div></td>";
|
|
|
if (dom.ChapterSource == EnumList.CaseSource.Custom) {
|
|
|
trHtml += "<td class=\"operate\"><a aid=\"" + dom.Id + "\" title=\"编辑\" class=\"JS-edit\" >编辑</a><a title=\"删除\" href=\"javascript:DelChapter({1});\">删除</a></td>";
|
|
|
}
|
|
|
else {//内置章节没有编辑
|
|
|
trHtml += "<td class=\"operate\"><a title=\"删除\" href=\"javascript:DelChapter({1});\">删除</a></td>"
|
|
|
}
|
|
|
trHtml += "</tr>";
|
|
|
//拼接tbody
|
|
|
html += StringHelper.FormatStr(trHtml,
|
|
|
dom.ChapterName, //1 章节名称
|
|
|
dom.Id
|
|
|
);
|
|
|
});
|
|
|
|
|
|
$("#chaptertable").html(html);
|
|
|
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
//获取资源列表
|
|
|
function GetResourceList() {
|
|
|
|
|
|
pageHelper.Init({
|
|
|
url: "/Teacher/Resource/GetResourceList",
|
|
|
type: "POST",
|
|
|
pageDiv: "#pages1",
|
|
|
async: false,
|
|
|
data:
|
|
|
{
|
|
|
ChapterId: $("#hdchapterId").val(),
|
|
|
UserId: $("#hduserId").val()
|
|
|
},
|
|
|
bind: function (data) {
|
|
|
var html = "";
|
|
|
$(data.Data).each(function (index, dom) {
|
|
|
var length = dom.FilePath.length;
|
|
|
var Extension = dom.FilePath.substring(dom.FilePath.lastIndexOf(".") + 1, length);
|
|
|
html += "<li><div class='img'>";
|
|
|
html += "<img src=\"../../../../Content/images/" + PicCov(Extension) + "\"><div class='text'>";
|
|
|
if (ShowFileView1(Extension)) {
|
|
|
html += "<a href=\"javascript:void(0)\" onclick=\"ShowLoad('" + dom.FilePath + "','" + dom.FileName + "','" + dom.Id + "')\" >预览</a>";
|
|
|
}
|
|
|
else if (ShowImgView(Extension)) {
|
|
|
html += "<a href=\"javascript:void(0)\" onclick=\"showImage('" + dom.FilePath + "')\" >预览</a>";
|
|
|
}
|
|
|
//else if (ShowTxtView(Extension)) {
|
|
|
// html += "<a href=\"javascript:void(0)\" onclick=\"showTxt('" + dom.FilePath + "','" + dom.FileName + "')\" >预览</a>";
|
|
|
//}
|
|
|
// html += "<a href=\'" + dom.FilePath + "'\">下载</a>";
|
|
|
html += "<a href=\"javascript:void(0)\" onclick=\"DownLoad('" + dom.FilePath + "','" + dom.ResourceName + "')\" >下载</a>";
|
|
|
if (dom.Source == 2) {//来源为自定义
|
|
|
html += "<a href=\"javascript:void(0)\" onclick=\"DelResource('" + dom.Id + "')\" >删除</a>"
|
|
|
}
|
|
|
html += "</div></div><p class='ellipsis' title="+dom.ResourceName+">" + dom.ResourceName + "</p></li>";
|
|
|
$("#resourceList").html(html);
|
|
|
});
|
|
|
|
|
|
}
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//文件上传
|
|
|
function FileUpload() {
|
|
|
if (!VerificationHelper.checkFrom("addpop"))
|
|
|
return;
|
|
|
var chapterId = $("#hdchapterId").val();//章节Id
|
|
|
var resourceName = $.trim($("#txtResourceName").val())
|
|
|
// resourceName.substring(1, resourceName.length - 1).substring(0, resourceName.length - 2).replace('"', '\"');
|
|
|
// alert(resourceName);
|
|
|
// alert($("#txtResourceName").val(resourceName));
|
|
|
//if(resourceName=="\"\"")
|
|
|
//{
|
|
|
|
|
|
//}
|
|
|
resourceName = resourceName.replace(/[<>&"]/g, function (c) { return { '<': '<', '>': '>', '&': '&', '"': '"', '"': '"', "'": '′', "'": '′' }[c]; })
|
|
|
|
|
|
|
|
|
if (GetResourceNum(chapterId)) {
|
|
|
dialogHelper.Error({
|
|
|
content: "本章节资源数量超过最大限制30个!"
|
|
|
})
|
|
|
|
|
|
return;
|
|
|
}
|
|
|
if (IsExists(chapterId, resourceName)) {
|
|
|
dialogHelper.Error({
|
|
|
content: "本章节已存在该资源名称,请重新命名"
|
|
|
})
|
|
|
return;
|
|
|
}
|
|
|
if (chapterId != "" && chapterId != 0) {
|
|
|
|
|
|
var filePath = $("#filePath").val();
|
|
|
if (filePath == "") {
|
|
|
dialogHelper.Error({ context: "请选择要上传的文件!" });
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
$(".window-mask,.progressBar").show();
|
|
|
$("#FileUpload").unbind("click");
|
|
|
//文件上传
|
|
|
$.ajaxFileUpload({
|
|
|
url: "/Teacher/Resource/UploadFile",
|
|
|
secureuri: false,
|
|
|
fileElementId: 'HFilePath',
|
|
|
dataType: 'json',
|
|
|
data: {
|
|
|
theoryChapterId: chapterId,
|
|
|
resourceName: resourceName,
|
|
|
// userId:1 //userId
|
|
|
},
|
|
|
success: function (data, status) {
|
|
|
$(".window-mask,.progressBar").hide();
|
|
|
if (data.IsSuccess)
|
|
|
{
|
|
|
dialogHelper.Success({
|
|
|
content: "资源上传成功",
|
|
|
success: function () {
|
|
|
$(".warn-box").hide();
|
|
|
$("#HFilePath").val("");
|
|
|
$("#txtResourceName").val("");
|
|
|
$("#filePath").val("");
|
|
|
dialogHelper.Close("addpop");
|
|
|
$("#resourceList").empty();
|
|
|
$("#FileUpload").unbind("click").bind("click", function () { FileUpload(); });
|
|
|
GetResourceList();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
}
|
|
|
else {
|
|
|
if (data.error != "" && data.error != undefined && data.error != "您上传的资源超过200M,请重新上传") {
|
|
|
dialogHelper.Error({
|
|
|
content: "您上传的文件格式不正确,请重新上传!",
|
|
|
success: function () {
|
|
|
|
|
|
}
|
|
|
});
|
|
|
$("#filePath").val("");
|
|
|
$("#FileUpload").unbind("click").bind("click", function () { FileUpload(); });
|
|
|
}
|
|
|
else {
|
|
|
dialogHelper.Error({
|
|
|
content: "您上传的资源超过200M,请重新上传!",
|
|
|
success: function () {
|
|
|
|
|
|
}
|
|
|
});
|
|
|
$("#filePath").val("");
|
|
|
$("#FileUpload").unbind("click").bind("click", function () { FileUpload(); });
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
},
|
|
|
error: function (data, status, e) {
|
|
|
dialogHelper.Error({ context: "上传异常" });
|
|
|
$("#FileUpload").unbind("click").bind("click", function () { FileUpload(); });
|
|
|
}
|
|
|
});
|
|
|
|
|
|
}
|
|
|
else { dialogHelper.Error({ context: "系统出错,没有选中章节" }); }
|
|
|
|
|
|
}
|
|
|
//文件下载
|
|
|
function DownLoad(path, name) {
|
|
|
location.href = "/Teacher/Resource/DownloadFile?path=" + encodeURIComponent(path)
|
|
|
+ "&name=" + encodeURIComponent(name) + "&randomId=" + Math.random();
|
|
|
}
|
|
|
|
|
|
//显示图标转换
|
|
|
function PicCov(Extension) {
|
|
|
var ResourceFile = "picture-icon.png";
|
|
|
if (Extension == "jpg" || Extension == "gif" || Extension == "bmp" || Extension == "jpeg" || Extension == "png" || Extension == "psd") {
|
|
|
ResourceFile = "picture-icon.png";
|
|
|
}
|
|
|
else if (Extension == "doc" || Extension == "docx") {
|
|
|
ResourceFile = "word-icon.png";
|
|
|
} else if (Extension == "xls" || Extension == "xlsx") {
|
|
|
ResourceFile = "excel-icon.png";
|
|
|
} else if (Extension == "exe") {
|
|
|
ResourceFile = "picture-icon.png";
|
|
|
} else if (Extension == "txt") {
|
|
|
ResourceFile = "text-icon.png";
|
|
|
} else if (Extension == "ppt" || Extension == "pptx") {
|
|
|
ResourceFile = "ppt-icon.png";
|
|
|
} else if (Extension == "avi" || Extension == "rmvb"
|
|
|
|| Extension == "3gp" || Extension == "mpg"
|
|
|
|| Extension == "mpeg" || Extension == "wmv"
|
|
|
|| Extension == "mp4" || Extension == "swf") {
|
|
|
ResourceFile = "avi-icon.png";
|
|
|
}
|
|
|
else if (Extension == "zip" || Extension == "rar") {
|
|
|
ResourceFile = "zip-icon.png";
|
|
|
}
|
|
|
else if (Extension == "pdf")
|
|
|
{ ResourceFile = "pdf-icon.png" }
|
|
|
return ResourceFile;
|
|
|
}
|
|
|
|
|
|
//删除资源
|
|
|
function DelResource(id) {
|
|
|
dialogHelper.Confirm({
|
|
|
content: "确定删除该资源?",
|
|
|
success: function () {
|
|
|
|
|
|
$.ajax({
|
|
|
url: "/Teacher/Resource/DelResource",
|
|
|
async: false,
|
|
|
type: "POST",
|
|
|
data: { Id: id },
|
|
|
success: function (data) {
|
|
|
|
|
|
if (data) {
|
|
|
dialogHelper.Success({
|
|
|
content: "删除资源成功!",
|
|
|
success: function () {
|
|
|
|
|
|
}
|
|
|
});
|
|
|
|
|
|
}
|
|
|
$("#resourceList").empty();
|
|
|
GetResourceList();
|
|
|
},
|
|
|
error: function (msg) {
|
|
|
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
//取选项章节下资源的数量
|
|
|
function GetResourceNum() {
|
|
|
var result = 0;
|
|
|
$.ajax({
|
|
|
url: "/Teacher/Resource/GetResourceNum",
|
|
|
async: true,
|
|
|
type: "POST",
|
|
|
data: { chapterId: $("#hdchapterId").val() },
|
|
|
success: function (data) {
|
|
|
result = data.Data;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function ShowLoad(path, name, Id) {
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
|
url: "/Teacher/Resource/GetResource",
|
|
|
async: true,
|
|
|
type: "post",
|
|
|
data: { id: Id },
|
|
|
success: function (data) {
|
|
|
|
|
|
|
|
|
if (data.ConvertStatus == "1") {
|
|
|
var keydate = name.substring(0, 6);
|
|
|
path = path.substring(0, path.lastIndexOf('.'));
|
|
|
var keyhtml2 = "";
|
|
|
keyhtml2 += '<object id="embedfile1" type="application/x-shockwave-flash" width="0px" height="0">';
|
|
|
// keyhtml2 += '<param id="paramfile1" name="src" value="' + path + '.jpg" />';
|
|
|
|
|
|
keyhtml2 += '<param name="play" value="true" />';
|
|
|
keyhtml2 += '<param name="loop" value="true" />';
|
|
|
keyhtml2 += '<param name="wmode" value="transparent" />';
|
|
|
keyhtml2 += '<param name="scale" value="showall" />';
|
|
|
keyhtml2 += '<param name="menu" value="true" />';
|
|
|
keyhtml2 += '<param name="devicefont" value="false" />';
|
|
|
keyhtml2 += '<param name="salign" value="" />';
|
|
|
keyhtml2 += '<param name="allowScriptAccess" value="sameDomain" />';
|
|
|
keyhtml2 += '<param name="allowFullScreen" value="true" />';
|
|
|
keyhtml2 += '<a href="http://www.adobe.com/go/getflash">'
|
|
|
keyhtml2 += '<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif"alt="获得 Adobe Flash Player" />';
|
|
|
keyhtml2 += '</a></object>';
|
|
|
keyhtml2 += ' <div id="flashContent" style="position: relative; top: 0px; left: 0px;"></div>'
|
|
|
$("#imgPop100 #rongqi2").html("");
|
|
|
$("#imgPop100 #rongqi2").append(keyhtml2);
|
|
|
|
|
|
|
|
|
keybody = keybody.replace(/replaceDate/, keydate).replace(/replaceName/, name);
|
|
|
flashvars.bookUrl = keyhead + path + ".swf";
|
|
|
flashvars.bookId = name;
|
|
|
|
|
|
swfobject.embedSWF("/Content/FlashReader/TextReader.swf", "flashContent", "770", "470", swfVersionStr, xiSwfUrlStr, flashvars, params, attributes, null);
|
|
|
|
|
|
// $("#imgPop100").show();
|
|
|
dialogHelper.Show("imgPop100", 820);
|
|
|
} else if (data.ConvertStatus == "0") {
|
|
|
dialogHelper.Confirm({
|
|
|
content: "文件转换中,请等待。。。",
|
|
|
success: function () {
|
|
|
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
} else {
|
|
|
dialogHelper.Error({
|
|
|
content: "文件转换失败,请重新上传!",
|
|
|
//success: function () {
|
|
|
|
|
|
//}
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
//只显示指定预览文件的按钮
|
|
|
function ShowFileView(Extension) {
|
|
|
if (Extension == "doc" || Extension == "docx" || Extension == "xls" || Extension == "xlsx" || Extension == "ppt" || Extension == "pptx" || Extension == "pdf") {
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
function ShowFileView1(Extension) {
|
|
|
if ( Extension == "ppt" || Extension == "pptx" || Extension == "pdf") {
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
//只显示指定预览文件的按钮
|
|
|
function ShowImgView(Extension) {
|
|
|
if (Extension == "jpg" || Extension == "gif" || Extension == "bmp" || Extension == "jpeg" || Extension == "png" || Extension == "psd") {
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
function ShowTxtView(Extension) {
|
|
|
if (Extension == "txt") {
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
//显示文本格式
|
|
|
function showTxt(path, name) {
|
|
|
$.ajax({
|
|
|
url: "/Teacher/Resource/ShowTxt?t=" + Math.random,
|
|
|
async: false,
|
|
|
type: "Post",
|
|
|
data: {
|
|
|
path: path,
|
|
|
name: name
|
|
|
},
|
|
|
success: function (data) {
|
|
|
|
|
|
$(".article").html("");
|
|
|
$(".article").html(data.replace(/[<>&"]/g, function (c) { return { '<': '<', '>': '>', '&': '&', '"': '"', '"': '"', "'": '′', "'": '′' }[c]; }).replace(/\r\n/g, "<br/>"));
|
|
|
// $("#Title").html(data.Title);
|
|
|
// PopUp(pop100);
|
|
|
dialogHelper.Show("pop100", 820);
|
|
|
|
|
|
|
|
|
},
|
|
|
error: function (msg) {
|
|
|
$(".background,.progressBar").hide();
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
}
|
|
|
//显示图片文件
|
|
|
function showImage(path) {
|
|
|
var imghtml = "";
|
|
|
imghtml += ' <img src="' + path + '" width="770px" height="470px" alt="上传网络可能遇到问题" />';
|
|
|
$("#imgPop100 #rongqi2").html("");
|
|
|
$("#imgPop100 #rongqi2").append(imghtml);
|
|
|
// PopUp(imgPop100);
|
|
|
dialogHelper.Show("imgPop100", 820);
|
|
|
}
|
|
|
|
|
|
|
|
|
//新增章节保存
|
|
|
function AddSave(id) {
|
|
|
if (!VerificationHelper.checkFrom("divAddChapter"))
|
|
|
return;
|
|
|
if (id==0&&GetChapterNum())
|
|
|
{
|
|
|
dialogHelper.Error({ content: "保存失败,章节数量大于50!" });
|
|
|
return;
|
|
|
}
|
|
|
$.ajax({
|
|
|
url: "/Teacher/Resource/AddandUpdateChapter",
|
|
|
type: "POST",
|
|
|
async: false,
|
|
|
data: {
|
|
|
Id: id,
|
|
|
ChapterName: $.trim($("#txtChapterName").val()),
|
|
|
ChapterSource: EnumList.CaseSource.Custom,
|
|
|
|
|
|
},
|
|
|
success: function (data) {
|
|
|
dialogHelper.Success({
|
|
|
content: "保存成功!",
|
|
|
success: function () {
|
|
|
GetTheoryChaptList();
|
|
|
dialogHelper.Close("divAddChapter");
|
|
|
}
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
//获取资源数量
|
|
|
function GetChapterNum() {
|
|
|
var res = false;
|
|
|
|
|
|
$.ajax({
|
|
|
url: "/Teacher/Resource/GetChapterNum",
|
|
|
type: "POST",
|
|
|
async: false,
|
|
|
data: {
|
|
|
|
|
|
},
|
|
|
success: function (data) {
|
|
|
if (data >= 50) {
|
|
|
res = true;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
|
|
|
//删除章节
|
|
|
function DelChapter(id) {
|
|
|
dialogHelper.Confirm({
|
|
|
content: "删除章节将删除其下的所有资源,确定删除吗?",
|
|
|
success: function () {
|
|
|
$.ajax({
|
|
|
url: "/Teacher/Resource/DelChapter",
|
|
|
type: "POST",
|
|
|
async: false,
|
|
|
data: {
|
|
|
chapterId: id,
|
|
|
},
|
|
|
success: function (data) {
|
|
|
dialogHelper.Success({
|
|
|
content: "删除成功!",
|
|
|
success: function () {
|
|
|
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// var currIndex = $("#pages3 .cur").text();
|
|
|
|
|
|
|
|
|
GetTheoryChaptertable(1);
|
|
|
GetTheoryChaptList();
|
|
|
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
//编辑章节
|
|
|
function EditChapter(id) {
|
|
|
$("#aId" + id).text("保存");
|
|
|
var input = $("#aId" + id).parent().siblings(".input");
|
|
|
var inputtext = input.text();
|
|
|
input.html("<input id='' class='ipt-text grid-12' type='text' value=''>");
|
|
|
input.find("input").val(inputtext);
|
|
|
|
|
|
}
|
|
|
|
|
|
//获取资源数量
|
|
|
function GetResourceNum(chapterId) {
|
|
|
var res = false;
|
|
|
|
|
|
$.ajax({
|
|
|
url: "/Teacher/Resource/GetResourceNum",
|
|
|
type: "POST",
|
|
|
async: false,
|
|
|
data: {
|
|
|
chapterId: chapterId
|
|
|
},
|
|
|
success: function (data) {
|
|
|
if (data >= 30) {
|
|
|
res = true;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
//新增资源名称判重
|
|
|
function IsExists(chapterId, resourceName) {
|
|
|
var res = false;
|
|
|
$.ajax({
|
|
|
url: "/Teacher/Resource/IsExists",
|
|
|
type: "POST",
|
|
|
async: false,
|
|
|
data: {
|
|
|
chapterId: chapterId,
|
|
|
resourceName: resourceName
|
|
|
},
|
|
|
success: function (data) {
|
|
|
|
|
|
res = data;
|
|
|
|
|
|
}
|
|
|
});
|
|
|
return res;
|
|
|
|
|
|
}
|
|
|
//编辑章节
|
|
|
function EditChapter(chapterId)
|
|
|
{
|
|
|
//if ($.trim($("#txteditchapterName").val()) == "请输入章节名称")
|
|
|
//{
|
|
|
// $("#txteditchapterName").val("");
|
|
|
//}
|
|
|
if (!VerificationHelper.checkFrom("popChapterManage"))
|
|
|
return;
|
|
|
|
|
|
$.ajax({
|
|
|
url: "/Teacher/Resource/AddandUpdateChapter",
|
|
|
type: "POST",
|
|
|
async: true,
|
|
|
data: {
|
|
|
Id: chapterId,
|
|
|
ChapterName: $.trim($("#txteditchapterName").val()),
|
|
|
ChapterSource: EnumList.CaseSource.Custom,
|
|
|
|
|
|
},
|
|
|
success: function (data) {
|
|
|
dialogHelper.Success({
|
|
|
content: "保存成功!",
|
|
|
success: function () {
|
|
|
|
|
|
}
|
|
|
});
|
|
|
$(this).text("编辑");
|
|
|
var inputtext = $(this).parent().siblings(".input").find("input").val();
|
|
|
$(this).parent().siblings(".input").html(inputtext);
|
|
|
},
|
|
|
complete: function () {
|
|
|
var currIndex = $("#pages3 .cur").text();
|
|
|
GetTheoryChaptertable(currIndex);
|
|
|
GetTheoryChaptList();
|
|
|
|
|
|
$("#closeChapterManage").addClass("btn-blue").attr("disabled", false)
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|