123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307 |
- $(function() {
- $(".onlogin .headnavbtn li").eq(0).addClass("navcurrent");
- loginStatus();
- var userid = $.cookie("userid");
- var articleId;
- newslist();
-
- $("#workmysrc").on("click", ".newsadd", function() {
- newsBombBox();
- addDele();
- $("#inputb").on("click", function() {
- if($("#newsName").val()!=""){
- newsAdd();
- }else{
- $(".workmsg1").text("发布文章名称不能为空");
- }
-
- });
- });
-
- $("#workmysrc").on("click", ".resoumag", function() {
- articleId = $(this).attr("data-title");
- newsBombBox();
- addDele();
- modifyDisplay();
- $("#inputb").on("click", function() {
- if($("#newsName").val()!=""){
- $.MsgBox.Confirm("消息", "确定修改文章信息吗?", newsModify)
- }else{
- $(".workmsg1").text("发布文章名称不能为空");
- }
- });
- });
-
-
- function newslist() {
- $.ajax({
- "url": "/ajax/article/qaPro",
- "type": "get",
- "async": true,
- "data": {
- "professorId": userid
- },
- "beforeSend": function() {
- $("#newsbox").append('<img src="../images/loading.gif" class="loading" />');
- },
- "success": function(data) {
-
- if(data.success) {
- var add = '';
- $("#newsbox").html("");
- var addbut = ' <div class="addworkbtn newsadd" ></div>';
- $("#newsbox").append(addbut);
- for(var i = 0; i < data.data.length; i++) {
- var add = '<div class="addworkbtn-list addworkbtn-list2" ><div class="resoumag" data-title="">'
- add += '<div class="art_topicBox art_topicBox2"><div class="art_img" style=""></div>'
- add += '<div class="art_tbox"><h6 id="artical_topic" >'+ data.data[i].articleTitle + '</h6></div>'
- add += '</div><div class="tagsBox"><span></span></div>'
- add += '</div></div>';
- $add = $(add);
- $("#newsbox").append($add);
- $add.find('.resoumag').attr("data-title", data.data[i].articleId);
- $add.find('.tagsBox span').text(data.data[i].industry);
- if(data.data[i].articleImg) {
- $add.find(".art_img").attr("style", "background: url(/data/article/"+data.data[i].articleImg+") center center no-repeat;background-size:cover;");
- }
- $(".loading").remove();
- }
- } else {
- $.MsgBox.Alert('message', "系统异常!");
- }
- },
- "error": function() {
- $.MsgBox.Alert('message', 'failed')
- }
- });
- }
-
-
- function newsAdd(){
- var $data = {};
- $data.professorId = userid;
- $data.articleTitle = $("#newsName").val();
- $data.subject = captiureSubInd("SubjectList .deleteSubject");
- $data.industry = captiureSubInd("industryList .deleteIndustry");
- $data.articleContent = ue.getContent();
- if(cacheImageKey) {
- $data.articleImg = cacheImageKey;
- }
- $.ajax({
- "url" : "/ajax/article",
- "type" : "post" ,
- "dataType" : "json",
- "data" :$data,
- "success" : function(data) {
-
- if (data.success){
- newsname = data.data;
-
- $.MsgBox.Alert("消息","文章发表成功!");
- $("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
- newslist();
- $(".blackcover").remove();
- UE.delEditor('editor');
- } else {
- $.MsgBox.Alert("消息","文章发表失败!");
- }
- },
- "error":function(){
- $.MsgBox.Alert('消息','链接服务器超时')
- }
- });
- }
-
-
- function modifyDisplay(){
- $.ajax({
- "url" : "/ajax/article/query",
- "type" : "GET",
- "dataType" : "json",
- "data": {
- "articleId": articleId
- },
- "success" : function($data) {
-
- if ($data.success) {
- $("#newsName").val($data.data.articleTitle);
- industryShow($data.data.subject,"SubjectList","deleteSubject");
- industryShow($data.data.industry,"industryList","deleteIndustry");
- ue.ready(function() {
- if($data.data.articleContent==undefined){
- var datadescp ="";
- }else{
- var datadescp = $data.data.articleContent;
- }
- ue.setContent(datadescp);
- });
- if($data.data.articleImg) {
- var $liMages = $(
- '<div id="WU_FILE" class="file-item thumbnail ResImgBox" style="max-width:226px;width:226px;height: 226px;">'+
- '<img class="resImg headRadius resourceImg" style="display: inline;" src="data/article/'+$data.data.articleImg+'">'+
- '</div>'
- )
- }else{
- var $liMages = $(
- '<div id="WU_FILE" class="file-item thumbnail ResImgBox" style="max-width:226px;width:226px;height: 226px;">'+
- '<img class="resImg headRadius resourceImg" style="display: inline;" src="/images/default-artical.jpg">'+
- '</div>'
- )
- }
-
- $("#fileList").append($liMages);
- }
- },
- "error":function(){
- $.MsgBox.Alert('消息','链接服务器超时')
- }
- })
-
- $("#deletedResource").show();
-
- $("#deletedResource").on("click", function() {
-
- $.MsgBox.Confirm("消息", "执行删除后文章信息将无法恢复,确定继续吗?",newsDelet)
-
- });
- }
-
- function newsModify() {
- var $data = {};
- $data.articleId = articleId;
- $data.articleTitle = $("#newsName").val();
- $data.subject = captiureSubInd("SubjectList .deleteSubject");
- $data.industry = captiureSubInd("industryList .deleteIndustry");
- $data.articleContent = ue.getContent();
- if(cacheImageKey) {
- $data.articleImg = cacheImageKey;
- }
-
- $.ajax({
- "url" : "/ajax/article/updateArt",
- "type" : "POST",
- "dataType" : "json",
- "data" :$data,
- "success" : function($data) {
-
- if ($data.success) {
- newslist();
- $(".blackcover").remove();
- UE.delEditor('editor');
- }
- },
- "error":function(){
- $.MsgBox.Alert('消息','链接服务器超时')
- }
- })
-
- $("#deletedResource").show();
-
- $("#deletedResource").on("click", function() {
- $.MsgBox.Confirm("消息", "执行删除后文章信息将无法恢复,确定继续吗?",newsDelet)
- });
- }
-
-
- function newsDelet() {
- $.ajax({
- "url" : "/ajax/article/delete",
- "type" : "POST",
- "dataType" : "json",
- "data": {
- "articleId": articleId
- },
- "success" : function($data) {
- if ($data.success) {
- $(".blackcover").remove();
- UE.delEditor('editor');
- newslist();
- }
- },
- "error":function(){
- $.MsgBox.Alert('消息','链接服务器超时')
- }
- })
- }
-
-
- function captiureSubInd(subIndu) {
- var industrys = $("#" + subIndu + "");
- var industryAll = "";
- if(industrys.size() > 0) {
- for(var i = 0; i < industrys.size(); i++) {
- industryAll += industrys[i].innerText;
- industryAll += ',';
- };
- industryAll = industryAll.substring(0, industryAll.length - 1);
- }
- return industryAll;
- }
-
-
- function industryShow(data,industryList,deleteIndustry){
- if(data != undefined && data.length != 0 ){
- var subs = new Array();
- if(data.indexOf(',')){
- subs = data.split(',');
- }else{
- subs[0] = data;
- }
- if(subs.length>0){
- for (var i = 0; i < subs.length; i++)
- {
- $("#"+industryList+"").append("<div class='"+deleteIndustry+"'>"+ subs[i] +"<span class='removeNu'><img src='images/move.png'></span></div>");
- };
- }
- }
- }
-
- function addDele() {
- $("#industryList").on("click", ".removeNu", function() {
- $(this).parent().remove();
- });
- $("#industryAdd").click(function() {
- var val = $("#industry").val();
- if(val==""){
- $(".workmsg4").text("请填写应用行业");
- return;
- }
- var vallist = $("#industryList .deleteIndustry em");
- for(var i=0;i<vallist.length;i++){
- if(vallist[i].innerText==val){
- $(".workmsg4").text("不能添加重复内容");
- return;
- }
- }
- $("#industryList").append("<div class='deleteIndustry'><em>" + val + "</em><span class='removeNu'><img src='images/move.png'></span></div>")
- $("#industry").val("");
- $(".workmsg4").text("");
- });
-
- $("#SubjectList").on("click", ".removeNu", function() {
- $(this).parent().remove();
- });
-
- $("#subjectAdd").click(function() {
- var val = $("#subject").val();
- if(val==""){
- $(".workmsg3").text("请填写学术领域");
- return;
- }
- var vallist = $("#SubjectList .deleteSubject em");
- for(var i=0;i<vallist.length;i++){
- if(vallist[i].innerText==val){
- $(".workmsg3").text("不能添加重复内容");
- return;
- }
- }
- $("#SubjectList").append("<div class='deleteSubject'><em>" + val + "</em><span class='removeNu'><img src='images/move.png'></span></div>")
- $("#subject").val("");
- $(".workmsg3").text("");
- });
- }
- });
|