$(function () { GetTheoryChaptList(); // GetResourceList(); $("li[name='lichapter']").live("click", function () { $("li[name='lichapter'] .active").removeClass("active") $(this).children().addClass("active"); $("#hdchapterId").val($("li[name='lichapter'] .active").attr("chapterid")); $("#labcurchapterName").text($("li[name='lichapter'] .active").text()) $("#ulstudentresource").empty(); GetResourceList(); }); $("#labcurchapterName").text($("li[name='lichapter'] .active").text()) $(".pop-button .btn").click(function () { $(".popup").hide(); $(".windowBg").hide(); }); }) //获取章节列表 function GetTheoryChaptList() { pageResourceHelper.Init({ url: "/Student/StuResource/GetTheoryChaptList", type: "POST", pageDiv: "#pages", async: false, data: { }, bind: function (data) { var html = ""; $(data.Data).each(function (index, dom) { html += "
  • " + dom.ChapterName + "
  • "; $("#ultheoryChapter").html(html); }); $("#ultheoryChapter li:eq(0) a").addClass("active"); $("#hdchapterId").val($("li[name='lichapter'] .active").attr("chapterid")); $("#labcurchapterName").text($("li[name='lichapter'] .active").text()) //翻页时防止,下一页的章节下无菜单,显示的是上一页选中章节的资源,先清空,再加载资源 $("#ulstudentresource").empty(); GetResourceList(); } }); } function PicCov1(Id) { var html = "menu-icon30"; if (Id < 4) { html = "menu-icon" + (Id + 6); } else if (Id == 4) { html = "menu-icon29" } else if (Id < 13) { html = "menu-icon" + (Id + 5); } return html; } //获取资源列表 function GetResourceList() { pageHelper.Init({ url: "/Student/StuResource/GetResourceList", type: "POST", pageDiv: "#pages1", data: { ChapterId: $("#hdchapterId").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 += "
  • "; html += "
    "; if (ShowFileView1(Extension)) { html += "预览"; } else if (ShowImgView(Extension)) { html += "预览"; } //else if (ShowTxtView(Extension)) { // html += "预览"; //} // html += "下载"; //html += "下载
    "; html += "

    " + dom.ResourceName + "

  • "; $("#ulstudentresource").html(html); }); } }); } //显示图标转换 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 DownLoad(path, name, Id) { $.ajax({ url: "/Student/StuResource/GetResource", async: true, type: "post", data: { id: Id }, success: function (data) { if (data==null) { dialogHelper.Error({ content: "该资源已失效,请联系教师或管理员", }); return; } else { location.href = "/Student/StuResource/DownloadFile?path=" + encodeURIComponent(path) + "&name=" + encodeURIComponent(name) + "&randomId=" + Math.random(); } } }); } function ShowFileView1(Extension) { if (Extension == "ppt" || Extension == "pptx" || Extension == "pdf") { return true; } return false; } //只显示指定预览文件的按钮 function ShowFileView(Extension) { if (Extension == "doc" || Extension == "docx" || Extension == "xls" || Extension == "xlsx" || 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, Id) { $.ajax({ url: "/Student/StuResource/GetResource", async: true, type: "post", data: { id: Id }, success: function (data) { if (data==null) { dialogHelper.Error({ content: "该资源已失效,请联系教师或管理员", }); return; } else { $.ajax({ url: "/Student/StuResource/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, "
    ")); dialogHelper.Show("pop100", 820); }, error: function (msg) { dialogHelper.Error({ content: "加载条款信息失败,请尝试刷新!" }); } }); } } }); } //显示图片文件 function showImage(path, Id) { $.ajax({ url: "/Student/StuResource/GetResource", async: true, type: "post", data: { id: Id }, success: function (data) { if (data==null) { dialogHelper.Error({ content: "该资源已失效,请联系教师或管理员", }); return; } var imghtml = ""; imghtml += ' 上传网络可能遇到问题'; $("#imgPop100 #rongqi2").html(""); $("#imgPop100 #rongqi2").append(imghtml); //PopUp(imgPop100); dialogHelper.Show("imgPop100", 820); } }); // $("#imgPop100").show(); } //预览 function ShowLoad(path, name, Id) { $.ajax({ url: "/Student/StuResource/GetResource", async: true, type: "post", data: { id: Id }, success: function (data) { if (data==null) { dialogHelper.Error({ content: "该资源已失效,请联系教师或管理员", }); return; } if (data.ConvertStatus == "1") { path = path.substring(0, path.lastIndexOf('.')); var keyhtml2 = ""; $("#imgPop100 #rongqi2").html(""); $("#imgPop100 #rongqi2").append(keyhtml2); dialogHelper.Show("imgPop100", 820); //var keydate = name.substring(0, 6); //path = path.substring(0, path.lastIndexOf('.')); //var keyhtml2 = ""; //keyhtml2 += ''; //// keyhtml2 += ''; //keyhtml2 += ''; //keyhtml2 += ''; //keyhtml2 += ''; //keyhtml2 += ''; //keyhtml2 += ''; //keyhtml2 += ''; //keyhtml2 += ''; //keyhtml2 += ''; //keyhtml2 += ''; //keyhtml2 += '' //keyhtml2 += '获得 Adobe Flash Player'; //keyhtml2 += ''; //keyhtml2 += '
    ' //$("#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: "文件预览失败!", }); } } }); }