parent
ea38005262
commit
41bfe77314
|
@ -191,7 +191,6 @@ class ShowNavigationView(View):
|
|||
project_id = Project.objects.get(name=project_path)
|
||||
file_id = File.objects.get(project_id=project_id,path=file_path).pk
|
||||
response = response.replace("]],[","]]|[")
|
||||
print(response)
|
||||
if response:
|
||||
all_symbols = []
|
||||
for symbol in response.split("|"):
|
||||
|
@ -785,8 +784,8 @@ class Get_CodeReading_Content_View(View):
|
|||
html_str = get_dir_info(project_id,path)
|
||||
return HttpResponse(json.dumps({"status": "success", "html_str": html_str,"is_dir":"1"}), content_type='application/json')
|
||||
else:
|
||||
self_annos,annos_count,issues_count,questions_count,fileid,lines = get_code(request,project_id,path)
|
||||
return HttpResponse(json.dumps({"status": "success", "is_dir":"0","self_annos":self_annos,"annos_count":annos_count,"issues_count":issues_count,"questions_count":questions_count,"fileid":fileid,"lines":lines}), content_type='application/json')
|
||||
self_annos,annos_count,issues_count,questions_count,fileid,lines,issues = get_code(request,project_id,path)
|
||||
return HttpResponse(json.dumps({"status": "success", "is_dir":"0","self_annos":self_annos,"annos_count":annos_count,"issues_count":issues_count,"questions_count":questions_count,"fileid":fileid,"lines":lines,"issues":issues}), content_type='application/json')
|
||||
# html_str = html_str.replace('style="background-color: white;"',"")
|
||||
def get_self_annos_by_fileid(user_id,file_id):
|
||||
self_anno_map = {}
|
||||
|
@ -837,7 +836,7 @@ def get_code(request,project_id,path):
|
|||
# 获取文件内容,并存到字典中。key为行号,value为对应的内容
|
||||
lines = get_filecontent(project.name,path)
|
||||
# html_str = render_to_string('projects/filesub/code-reading.html', locals())
|
||||
return self_annos,annos_count,issues_count,questions_count,fileid,lines
|
||||
return self_annos,annos_count,issues_count,questions_count,fileid,lines,issues
|
||||
|
||||
|
||||
def choose_issue(file, issue_type=1, issue_info=1):
|
||||
|
|
|
@ -445,7 +445,7 @@ a:hover {
|
|||
|
||||
.sourcecode {
|
||||
float: left;
|
||||
height: 100%;
|
||||
height: 40px;
|
||||
width: 85%;
|
||||
/*line-height: 20px;*/
|
||||
background-color: #26292b!important;
|
||||
|
@ -1400,7 +1400,7 @@ color: #FFF !important;
|
|||
}
|
||||
|
||||
.mypre{
|
||||
margin: 0 0 0 -106px;
|
||||
margin: 0 0 0;
|
||||
overflow:visible !important;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
|
|
@ -326,7 +326,8 @@ function submit_annotation(file_id, line_num, content) {
|
|||
var contenthtml ='<div class="linenum"></div>'+'<div class="sourcecode">'+'<pre class="mypre newaddmypre hljs-comment ' + file_id+line_num + '">'+data.anno_content+'</pre>'+'</div>'+'<div class="linestatus"></div>';
|
||||
var html = '<div class="codeline codelinebox">'+contenthtml+'</div>';
|
||||
var id=file_id+'_'+"L"+line_num;
|
||||
$("#"+id).before(html)
|
||||
console.log(html)
|
||||
$("#"+id).before(html);
|
||||
}else{
|
||||
alert("您已经添加过注释了")
|
||||
//alert(data.msg);
|
||||
|
@ -676,7 +677,7 @@ function open_tab(path) {
|
|||
show_navigation();
|
||||
}
|
||||
|
||||
function generate_codereading_content(lines,self_annos,fileid,annos_count,issues_count,questions_count){
|
||||
function generate_codereading_content(lines,self_annos,fileid,annos_count,issues_count,questions_count,issues){
|
||||
var htmlstr = '<div class="code_file">'
|
||||
for(linenum in lines){
|
||||
line = lines[linenum]
|
||||
|
@ -685,7 +686,7 @@ function generate_codereading_content(lines,self_annos,fileid,annos_count,issues
|
|||
htmlstr += generate_codereading_anno_line(linenum,self_annos)
|
||||
}
|
||||
// 无论当前行是否有注释,都应该生成代码行
|
||||
htmlstr += generate_codereading_line(fileid,linenum,annos_count,issues_count,questions_count,line)
|
||||
htmlstr += generate_codereading_line(fileid,linenum,annos_count,issues_count,questions_count,line,issues)
|
||||
}
|
||||
htmlstr += '</div>'
|
||||
return htmlstr
|
||||
|
@ -704,10 +705,10 @@ function generate_codereading_anno_line(linenum,self_annos){
|
|||
return htmlstr
|
||||
}
|
||||
|
||||
function generate_codereading_line(fileid,linenum,annos_count,issues_count,questions_count,line){
|
||||
var htmlstr = '<div id="'+fileid+'L_'+linenum+'" class="codeline codelinebox" onmouseover="show_currentLine(\''+fileid+'_'+linenum+'\')" onmouseout="hide_currentLine(\''+fileid+'_'+linenum+'\')">'
|
||||
function generate_codereading_line(fileid,linenum,annos_count,issues_count,questions_count,line,issues){
|
||||
var htmlstr = '<div id="'+fileid+'_L'+linenum+'" class="codeline codelinebox" onmouseover="show_currentLine(\''+fileid+'_'+linenum+'\')" onmouseout="hide_currentLine(\''+fileid+'_'+linenum+'\')">'
|
||||
htmlstr += generate_codereading_linenum_and_codeline(linenum,line)
|
||||
htmlstr += generate_codereading_linestatus(fileid,linenum,annos_count,issues_count,questions_count)
|
||||
htmlstr += generate_codereading_linestatus(fileid,linenum,annos_count,issues_count,questions_count,issues)
|
||||
htmlstr += '</div>'
|
||||
return htmlstr
|
||||
}
|
||||
|
@ -726,7 +727,7 @@ function generate_codereading_linenum_and_codeline(linenum,line){
|
|||
return htmlstr
|
||||
}
|
||||
|
||||
function generate_codereading_linestatus(fileid,linenum,annos_count,issues_count,questions_count){
|
||||
function generate_codereading_linestatus(fileid,linenum,annos_count,issues_count,questions_count,issues){
|
||||
var htmlstr = ''
|
||||
|
||||
htmlstr += '<div id="linestatus_'+fileid+'_'+linenum+'" class="linestatus">'
|
||||
|
@ -736,9 +737,12 @@ function generate_codereading_linestatus(fileid,linenum,annos_count,issues_count
|
|||
}
|
||||
htmlstr += '</span>'
|
||||
htmlstr += '<span class="codeopration" id="codeopration_question_'+fileid+'_'+linenum+'">'
|
||||
if(linenum in issues_count || linenum in questions_count){
|
||||
if(linenum in questions_count){
|
||||
htmlstr += '<span class="questionnums" onclick="show_issue_question('+fileid+','+linenum+',\'[]\')"></span>'
|
||||
}
|
||||
else if(linenum in issues_count){
|
||||
htmlstr += '<span class="questionnums" onclick="show_issue_question('+fileid+','+linenum+',\'['+issues[linenum]+']\')"></span>'
|
||||
}
|
||||
htmlstr += '</span>'
|
||||
htmlstr += '<span id="addanno_'+fileid+'_'+linenum+'" class="addanno" onclick="inject_addnoPanel_html(this,'+fileid+','+linenum+')">'
|
||||
htmlstr += '<img src="/static/image/newadd.png" class="mr3 rightimgcommentblue">'
|
||||
|
@ -830,7 +834,7 @@ function add_tab(project_id,path,filename) {
|
|||
// 获取code-reading的内容,并填充到对应的code-reading的Element
|
||||
|
||||
if(data.is_dir=="0"){
|
||||
var content = generate_codereading_content(data.lines,data.self_annos,data.fileid,data.annos_count,data.issues_count,data.questions_count)
|
||||
var content = generate_codereading_content(data.lines,data.self_annos,data.fileid,data.annos_count,data.issues_count,data.questions_count,data.issues)
|
||||
div_codereading.innerHTML = content;
|
||||
hljs.configure({useBR: false});
|
||||
hljs.highlightBlock(div_codereading)
|
||||
|
|
Loading…
Reference in New Issue