diff --git a/static/css/code_show.css b/static/css/code_show.css index b301630..630da76 100644 --- a/static/css/code_show.css +++ b/static/css/code_show.css @@ -437,10 +437,7 @@ a:hover { } .codeline { - min-width: 910px; width: 100%; - /*height: 23px;*/ - /*background: #f1efec;*/ display: flex; } @@ -1434,7 +1431,7 @@ pre.prettyprint { .mypre{ margin: 0 0 0; - overflow:visible !important; + overflow:auto; font-size: 16px; white-space:pre; } @@ -1492,25 +1489,37 @@ pre.prettyprint { .deg270{ transform: rotate(270deg) !important; - font-size: 18px; + font-size: 10px; color: #8F8986; + margin-left: 1.2px; } .deg90{ transform: rotate(90deg) !important; - font-size: 18px; + font-size: 10px; color: #8F8986; + margin-left: 0.6px; } .topthumbsThis{ - margin: 13px 0px 0px 15px; + margin:48px 0px 0px 17px; width: 27px; padding-left: 7px; } - +.topthumbsThis p{ + display: flex; +} .thumbsThisnth2{ - height: 20px; + line-height: 12px; + height: 12px; color: #000; text-align: center; - margin-left: -5px; + margin-left: 2px; + display: flex; +} +.margin003{ + margin: 0 0px -3px; +} +.margin023{ + margin: 0 2px -3px; } .newtopthumbs{ margin: 4px 0px 0px 16px; @@ -1518,7 +1527,7 @@ pre.prettyprint { padding-left: 8px; } .thumbsmarginLeft{ - margin-left: 0px; + margin-left: 2px; } .modify-anno{ float: right; @@ -1675,4 +1684,10 @@ animation: myfirst 10s; width: 87%; margin-left: 28px; padding: 13px 3px 13px 0px !important; +} +.newItemcommentPanel .pr .commentPanel .thumbsThis .mt15 .margin003{ + margin: 0 0px 0px; +} +.newItemcommentPanel .pr .commentPanel .thumbsThis .mt15 .margin023 { + margin: 0 2px 0px; } \ No newline at end of file diff --git a/static/js/source.js b/static/js/source.js index b686df0..d98cdd8 100644 --- a/static/js/source.js +++ b/static/js/source.js @@ -1,5 +1,18 @@ var flag = true;//左侧默认显示 +function setlocalStorage(id,value){ + var newlocalStoragevaule=localStorage.setItem(id,value); + return newlocalStoragevaule; +} +function getlocalStorage(id){ + var oldlocalStoragevaule=localStorage.getItem(id) + return oldlocalStoragevaule; +} +function deletelocalStorage(id){ + localStorage.removeItem(id); +} + + function getCookie(name) { var cookieValue = null; if (document.cookie && document.cookie !== '') { @@ -68,6 +81,14 @@ function close_modify_anno(){ //注入html代码 function inject_modifyAnno_html(item,file_id,linenum,anno_id) { + + + var modifyAnno_id= Number(getlocalStorage("modifyAnno_id")); + var modifyAnno_num=Number(getlocalStorage("modifyAnno_num")); + var modifyAnno_line=Number(getlocalStorage("modifyAnno_line")); + var modifyAnno_value=getlocalStorage("modifyAnno_value"); + + $("#modification").hide(); $(".modify_anno_div").remove(); $("#modify_anno_textarea").removeAttr("readonly"); @@ -83,6 +104,10 @@ function inject_modifyAnno_html(item,file_id,linenum,anno_id) { ev=arguments.callee.caller.arguments[0]||window.event; } ev.stopPropagation(); + + if(file_id===modifyAnno_id&&linenum===modifyAnno_num&&anno_id===modifyAnno_line){ + $("#modify_anno_textarea").val(modifyAnno_value); +} } // FIXME @@ -103,16 +128,26 @@ function modify_anno(file_id,line_num,anno_id){ beforeSend: function (xhr, settings) { xhr.setRequestHeader("X-CSRFToken", csrftoken); }, + timeout: 8000, success: function (data) { if (data.status === "success") { alert(data.msg) $("#ItemcommentPanel").remove() $("."+file_id+line_num).text(data.anno_content) - show_annotation(file_id,line_num) + show_annotation(file_id,line_num); + + deletelocalStorage("modifyAnno_id"); + deletelocalStorage("modifyAnno_num") + deletelocalStorage("modifyAnno_line") + deletelocalStorage("modifyAnno_value") }else{ alert(data.msg) } - } + },error:function(jqXHR, textStatus, errorThrown){ + if(textStatus == 'timeout'){ + alert('网络故障!'); + } + } }); } @@ -229,6 +264,7 @@ function add_comment_action(item, id, type) { data: { 'object_id': id, 'type': type, "content": content }, dataType: 'json', async: true, + timeout: 8000, beforeSend: function (xhr, settings) { xhr.setRequestHeader("X-CSRFToken", csrftoken); }, @@ -236,10 +272,17 @@ function add_comment_action(item, id, type) { if (data.status === 'success') { html_str = data.html_str show_new_comment(item, html_str); + deletelocalStorage("writetext_id"); + deletelocalStorage("writetext_value"); } else { alert(data.msg); } - } + },error:function(jqXHR, textStatus, errorThrown){ + alert(1) + if(textStatus == 'timeout'){ + alert('网络故障!'); + } + } }); ev = window.event; if(ev==undefined){ @@ -249,7 +292,7 @@ function add_comment_action(item, id, type) { } //添加评论 -function show_new_comment(item, html_str) { +function show_new_comment(item, html_str) {onclick="add_annotation(this,199,18)" $(item).parents(".parthalf_comment").after(html_str); $(item).parents(".comment-btn").find(".comment-write").addClass("none"); @@ -304,7 +347,6 @@ function add_annotation(item,file_id, line_num) { var selectValue = $(item).siblings(".put-select").find(".active").html().trim(); var text_context = "#addno-text-" + file_id+"-"+line_num; var content = $(text_context).val(); - console.log(content); if (content.trim().length == 0) { @@ -314,9 +356,16 @@ function add_annotation(item,file_id, line_num) { if (selectValue == "注释") { // 向addAnnatation中发请求 submit_annotation(file_id, line_num, content); - + deletelocalStorage("file_id"); + deletelocalStorage("line_num"); + deletelocalStorage("item_value"); + deletelocalStorage("status_value"); } else { submit_question(file_id, line_num, content); + deletelocalStorage("issuefile_id"); + deletelocalStorage("issueline_num"); + deletelocalStorage("issueitem_value"); + deletelocalStorage("status_value"); } } @@ -331,6 +380,7 @@ function submit_annotation(file_id, line_num, content) { beforeSend: function (xhr, settings) { xhr.setRequestHeader("X-CSRFToken", csrftoken); }, + timeout: 8000, success: function (data) { if (data.status == 'success') { // 因为可能注释或问题没有值的时候,不会为该代码块添加html代码,所以首先判断 @@ -352,7 +402,11 @@ function submit_annotation(file_id, line_num, content) { }else{ alert(data.msg) } - } + },error:function(jqXHR, textStatus, errorThrown){ + if(textStatus == 'timeout'){ + alert('网络故障!'); + } + } }); } @@ -641,7 +695,9 @@ $(function () { ev.stopPropagation(); }) }) -function addcomments(item) { +function addcomments(item,annopk) { + var annopkid= Number(getlocalStorage("writetext_id")); + var writetext_value= getlocalStorage("writetext_value") $(item).siblings(".comment-write").removeClass("none"); $(item).addClass("none"); ev = window.event; @@ -649,6 +705,9 @@ function addcomments(item) { ev=arguments.callee.caller.arguments[0]||window.event; } ev.stopPropagation(); + if(annopk===annopkid){ + $("#writetext_"+annopkid).val(writetext_value); + } } function cancelcom(item) { @@ -1073,19 +1132,131 @@ function close_tab(path) { // 对应目录级别的addnoPanel function show_next_addnoPanel(file_id){ + + var oldfile_id= Number(getlocalStorage("rightannotationid")); + var olditem_value=getlocalStorage("rightannotationvalue"); + $("#addno-panel-"+file_id).show(); ev = window.event; if(ev==undefined){ ev=arguments.callee.caller.arguments[0]||window.event; } - ev.stopPropagation(); + ev.stopPropagation() + + if(file_id===oldfile_id){ + $("#addno-text-"+file_id+"-0").val(olditem_value); + } + +} + +function Input_Content(item,file_id,line_num) { + var status_value= getlocalStorage("status_value"); + if(status_value==="注释"){ + setlocalStorage("item_value",item.value); + setlocalStorage("file_id",file_id); + setlocalStorage("line_num",line_num); + }else if(status_value==="问题"){ + setlocalStorage("issueitem_value",item.value); + setlocalStorage("issuefile_id",file_id); + setlocalStorage("issueline_num",line_num); + } + +} + +function Input_modifyAnno(item,file_id,line_num,row){ + setlocalStorage("modifyAnno_value",item.value); + setlocalStorage("modifyAnno_id",file_id); + setlocalStorage("modifyAnno_num",line_num); + setlocalStorage("modifyAnno_line",row); + +} + +function Input_writetext(item,annopk){ + setlocalStorage("writetext_value",item.value); + setlocalStorage("writetext_id",annopk); } +function addannotation(id,num){ + setlocalStorage("status_value","注释"); + var oldfile_id= Number(getlocalStorage("file_id")); + var oldline_num=Number(getlocalStorage("line_num")); + var olditem_value=getlocalStorage("item_value"); + $("#addno-text-"+id+"-"+num).val(" "); + if(oldfile_id!=null){ + if(id===oldfile_id&&num===oldline_num){ + $("#addno-text-"+oldfile_id+"-"+oldline_num).val(olditem_value); + } + } + +} +function addissue(id,num) { + setlocalStorage("status_value","问题"); + var oldline_num= Number(getlocalStorage("issueline_num")); + var oldfile_id=Number(getlocalStorage("issuefile_id")); + var olditem_value=getlocalStorage("issueitem_value"); + $("#addno-text-"+id+"-"+num).val(" "); + if(oldfile_id!=null){ + if(id===oldfile_id&&num===oldline_num){ + $("#addno-text-"+oldfile_id+"-"+oldline_num).val(olditem_value); + } + } + +} +function rightaddannotation(id,num){ + console.log(id) + console.log(num) + setlocalStorage("rightstatus_value","注释"); + var oldfile_id= Number(getlocalStorage("rightannotationid")); + var oldline_num=Number(getlocalStorage("rightannotationnum")); + var olditem_value=getlocalStorage("rightannotationvalue"); + $("#addno-text-"+id+"-"+num).val(" "); + if(oldfile_id!=null){ + if(id===oldfile_id&&num===oldline_num){ + $("#addno-text-"+id+"-"+num).val(olditem_value); + } + } + +} +function rightaddissue(id,num) { + console.log(id) + console.log(num) + setlocalStorage("rightstatus_value","问题"); + var oldline_num= Number(getlocalStorage("righissuenum")); + var oldfile_id=Number(getlocalStorage("righissuevid")); + var olditem_value=getlocalStorage("righissuevalue"); + $("#addno-text-"+id+"-"+num).val(" "); + if(oldfile_id!=null){ + if(id===oldfile_id&&num===oldline_num){ + $("#addno-text-"+id+"-"+num).val(olditem_value); + } + } + +} + +function Input_file(item,file_id,line_num){ + var status_value= getlocalStorage("rightstatus_value"); + if(status_value==="注释"){ + setlocalStorage("rightannotationvalue",item.value); + setlocalStorage("rightannotationid",file_id); + setlocalStorage("rightannotationnum",line_num); + }else if(status_value==="问题"){ + setlocalStorage("righissuevalue",item.value); + setlocalStorage("righissuevid",file_id); + setlocalStorage("righissuenum",line_num); + } + +} //注入html代码 function inject_addnoPanel_html(item,file_id,linenum) { - // console.log(file_id); - // console.log(linenum); + + var status_value= getlocalStorage("status_value"); + + var oldfile_id= Number(getlocalStorage("file_id")); + var oldline_num=Number(getlocalStorage("line_num")); + var olditem_value=getlocalStorage("item_value"); + + $("#ItemcommentPanel").remove(); $("#ItemquestionPanel").remove(); @@ -1093,10 +1264,10 @@ function inject_addnoPanel_html(item,file_id,linenum) { '
'+ ''+ - '注释'+ - '问题'+ + '注释'+ + '问题'+ '
'+ - ''+ + ''+ '提交'+ '{% endif %} -
{{ self_anno.voteup | add:self_anno.votedown }}
+{{ self_anno.voteup | add:self_anno.votedown }}
{% if self_anno.id in anno_vote_map and anno_vote_map|keyValue:self_anno.id == -1 %}@@ -25,21 +25,21 @@
{{ comment.voteup | add:comment.votedown}}
+{{ comment.voteup | add:comment.votedown}}
{% if comment.id in comment_vote_map and comment_vote_map|keyValue:comment.id == -1 %}{{ anno.voteup | add:anno.votedown }}
- {% if anno.id in anno_vote_map and anno_vote_map|keyValue:anno.id == -1 %} + {% if anno.id in anno_vote_map and anno_vote_map|keyValue:anno.id == -1 %}{{ comment.voteup | add:comment.votedown}}
+{{ comment.voteup | add:comment.votedown}}
{% if comment.id in comment_vote_map and comment_vote_map|keyValue:comment.id == -1 %}- 注释 - 问题 + 注释 + 问题 +
- + 提交{{ comment.voteup | add:comment.votedown}}
+{{ comment.voteup | add:comment.votedown}}
搜索结果
+候选函数