$(function () { var request = getRequest(); if ( JSON.stringify(request) == "{}" || request.id === undefined || request.q === undefined || request.t === undefined ) { console.log("argument error."); return; } var keywordControl = $("#keyword"); var currentPage = 0; var maxPage = -1; if (request.q !== undefined) keywordControl.val(request.q); $("#search").on("click", function (e) { e.preventDefault(); var inputValue = keywordControl.val().trim(); if (inputValue === "" || inputValue.replace(/[-_—]/g, "") === "") { keywordControl.focus(); return; } var keylist = encodeURIComponent(inputValue); window.location.href = "list_index.html?q=" + keylist + (request.t === undefined ? "" : "&t=" + request.t); }); $("#keyword").on("keyup", function (e) { e.preventDefault(); if (e.keyCode === 13) { $("#search").click(); } }); $('#loading').modal('show'); fetchJSON("/api/resource/up/view?id=" + request.id, {}, "get", function (ret) { $('#loading').modal('hide'); if (ret.code !== 0) console.log(ret.msg); }); fetchJSON("/api/resource/info?id=" + request.id, {}, "get", function (ret) { if (ret.code === 0) { var resource = ret.data; fetchJSON( "/api/query/query", {keyword: combineKeysToArray(resource.resourceName), type: request.t, page: 0, size: 10}, "post", function (ret) { if (ret.code === 0) { if (ret.data.resources.length != 0) { $("#relatedResourcesWrapper").css("display", "block"); fillRelatedResourceList(ret.data.resources, request.t, $("#relatedResources"), request.q); } } else console.log(ret.msg); } ); $("#title").html(resource.resourceName); $("#department").html(resource.submitDepartment); $("#author").html(resource.resourceAuthor); $("#submitDate").html(toDateString(resource.resourceCompletionDate)); $("#format").html(getFileExt(resource.resourceUrl)); var starWrapper = $("
", {class: "star pull-left"}); var starSpan = $("", {text: "满意度:"}); starWrapper.append(starSpan); var b = parseInt(resource.satisfaction / 20); var c = resource.satisfaction % 20 == 0 ? 0 : 1; var rank = b + c; for (var j = 0; j < 5; j++) { if (j < rank) starWrapper.append( $("", { id: "star" + j, class: "satisfaction icon cur", style: "cursor: pointer;", html: "  " }) ); else starWrapper.append( $("", { id: "star" + j, class: "satisfaction icon", style: "cursor: pointer;", html: "  " }) ); } var img = $("", { id: "player", width: "100%", height: "500px", src: urlBase + "/file/" + resource.resourceUrl }); $("#playerWrapper").append(img); $("#playerWrapper") .append($("
", {id: "placeholder"})); fetchJSON("/api/resource/imgRelationList?id=" + resource.id, {}, "get", function (ret) { if (ret.code === 0) { currentPage = 0; maxPage = ret.data.totalPage; $("
", {id: "imgListWrapper"}).insertAfter($("#placeholder")); var originImg = $("#player").prop('src'); $("#imgListWrapper").append($("

", { id: "imgListInfo", text: "相关图片(共" + ret.data.totalElement + "项 / 第" + (parseInt(currentPage, 10) + 1) + "页 / 共" + maxPage + "页 )", style: "margin-top: 40px; margin-bottom: 20px; color: blue;" })); $("#imgListWrapper").append($("
", { id: "imgContainer", style: "height: 100px; text-align: center;" })); for (var i = 0; i < ret.data.content.length; i++) { var img = $("", { src: decodeURIComponent(ret.data.content[i]), style: "padding: 5px", width: 100, height: 80 }); img.on('click', function () { $("#player").prop('src', this.src); }); $("#imgContainer").append(img); } $("#imgListWrapper").append($("
", {id: "btnContainer", style: "text-align: center;"})); $("#btnContainer").append($("
")) .append( $("