You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
341 lines
11 KiB
JavaScript
341 lines
11 KiB
JavaScript
|
|
$(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 += "<li name='lichapter'><a title=" + dom.ChapterName + " chapterid=" + dom.Id + "><div class=\"ellipsis\"><b class=\"ico " + PicCov1(dom.Id) + "\"></b>" + dom.ChapterName + "</div></a></li>";
|
|
$("#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 += "<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 + "','" + dom.Id + "')\" >预览</a>";
|
|
}
|
|
//else if (ShowTxtView(Extension)) {
|
|
|
|
// html += "<a href=\"javascript:void(0)\" onclick=\"showTxt('" + dom.FilePath + "','" + dom.FileName + "','" + dom.Id + "')\" >预览</a>";
|
|
//}
|
|
// html += "<a href=\'" + dom.FilePath + "'\">下载</a>";
|
|
html += "<a href=\"javascript:void(0)\" onclick=\"DownLoad('" + dom.FilePath + "','" + dom.ResourceName + "','" + dom.Id + "')\" >下载</a></div></div>";
|
|
html += "<p class='ellipsis' title=" + dom.ResourceName + ">" + dom.ResourceName + "</p></li>";
|
|
$("#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, "<br/>"));
|
|
|
|
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 += ' <img src="' + path + '" width="770px" height="470px" alt="上传网络可能遇到问题" />';
|
|
$("#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") {
|
|
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: "文件预览失败!",
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|