add new code color using highlight.js but indentation has error

This commit is contained in:
wrmswindmill 2018-07-18 23:27:40 +08:00
parent f48f8b0cfc
commit 74449c6bd2
6 changed files with 31 additions and 30 deletions

View File

@ -587,7 +587,7 @@ class AddVoteView(View):
exist_records = Vote.objects.filter(user=request.user, vote_type_id=object_id, vote_type=vote_type)
if exist_records:
vote_before = exist_records[0].value
object.vote -= vote_before
object.voteup -= vote_before
object.save()
exist_records.delete()
return HttpResponse(json.dumps({"status": "success", "info": "cancel", "value": -(vote_before), "msg": "取消成功"}),
@ -600,7 +600,7 @@ class AddVoteView(View):
vote.vote_type_id = object_id
vote.value = vote_value
vote.save()
object.vote += int(vote_value)
object.voteup += int(vote_value)
object.save()
return HttpResponse(json.dumps({"status": "success", "msg": "点赞成功", "value": int(vote_value)}), content_type='application/json')
else:

View File

@ -568,7 +568,8 @@ a:hover {
padding: 15px 0px;
max-height: 600px;
overflow-y: auto;
z-index:3;
z-index:3;
color:black;
}
.loadCommentpanel-back, .loadQuestionpanel-back {
@ -628,6 +629,7 @@ a:hover {
border-radius: 4px;
right: 32px;
z-index: 3;
color:black;
}
.ques-title {

View File

@ -18,7 +18,7 @@ function getCookie(name) {
var csrftoken = getCookie('csrftoken');
function show_annotation(file_id, line_num) {
ev = window.event
ev = window.event;
var mousePos = mouseCoords(ev)
$.ajax({
@ -53,7 +53,7 @@ function show_annotation(file_id, line_num) {
function close_modify_anno(){
$(".modify_anno_div").remove();
ev = window.event
ev = window.event;
ev.stopPropagation();
}
@ -66,7 +66,7 @@ function inject_modifyAnno_html(item,file_id,linenum) {
'<a href="javascript:void(0)" onclick="close_modify_anno()">取消</a>'+
'</div>';
$(item).after(html_str)
ev = window.event
ev = window.event;
ev.stopPropagation();
}
@ -104,7 +104,7 @@ function modify_anno(file_id,line_num){
// FIXME
function show_issue_question(file_id, line_num, issue_ids) {
issueid_str=issue_ids.toString()
ev = window.event
ev = window.event;
var mousePos = mouseCoords(ev)
//发送问题id返回问题内容
$.ajax({
@ -223,7 +223,7 @@ function add_comment_action(item, id, type) {
}
}
});
ev = window.event
ev = window.event;
ev.stopPropagation();
}
@ -373,7 +373,7 @@ function submint_question(file_id, line_num, content) {
function search_symbol(args) {
ev = event || window.event
ev = window.event
var mousePos = mouseCoords(ev)
$.ajax({
@ -567,14 +567,14 @@ $(function () {
function addcomments(item) {
$(item).siblings(".comment-write").removeClass("none");
$(item).addClass("none");
ev = window.event
ev = window.event;
ev.stopPropagation();
}
function cancelcom(item) {
$(item).parents(".comment-write").siblings("#addcom").removeClass("none");
$(item).parents(".comment-write").addClass("none");
ev = window.event
ev = window.event;
ev.stopPropagation();
}
@ -713,14 +713,18 @@ function add_tab(project_id,path,filename) {
if (data.status === 'success') {
// 获取code-reading的内容并填充到对应的code-reading的Element
var content = data.html_str
// console.log(content);
div_codereading.innerHTML = content;
if(data.is_dir=="0"){
hljs.configure({useBR: false});
hljs.highlightBlock(div_codereading)
// .each(function(i, block) {
// hljs.highlightBlock(block);
// });
}
hljs.configure({useBR: false});
$('.code_Area').each(function(i, block) {
hljs.highlightBlock(block);
});
}
else {
div_codereading.innerHTML = "";
@ -807,7 +811,7 @@ function inject_addnoPanel_html(item,file_id,linenum) {
'</div>'+
'</div>';
$(item).after(html_str)
ev = window.event
ev = window.event;
ev.stopPropagation();
}

Binary file not shown.

View File

@ -1,12 +1,12 @@
{% load base_filter %}
<div class="code_file">
{% formatText2Line project.name file.path as lines %}
{% for linenum,line in lines.items %}
<div id="{{fileid}}_L{{ linenum }}" class="codeline" onmouseover='show_currentLine("{{fileid}}_{{linenum}}")' onmouseout='hide_currentLine("{{fileid}}_{{linenum}}")'>
<div id="{{fileid}}_L{{ linenum }}" class="codeline" onmouseover="show_currentLine('{{fileid}}_{{linenum}}')" onmouseout="hide_currentLine('{{fileid}}_{{linenum}}')">
<div id="linenum_{{ linenum }}" class="linenum">{{ linenum }}</div>
<div id="code_{{fileid}}_{{ linenum }}" class="sourcecode">
{{ line }}
{{ line | safe }}
</div>
<div id="linestatus_{{fileid}}_{{ linenum }}" class="linestatus">
@ -19,11 +19,11 @@
</span>
<span class="codeopration" id="codeopration_question_{{fileid}}_{{linenum}}">
{% if linenum in issues_count %}
<span id="questionums_{{ linenum }}" class="questionnums" onclick='show_issue_question({{ file.id }},{{ linenum }},"{{ issues | keyValue:linenum }}" )'>
<span id="questionums_{{ linenum }}" class="questionnums" onclick="show_issue_question({{ file.id }},{{ linenum }},'{{ issues|keyValue:linenum}}')">
{# {{ question_count | keyValue:linenum }} #}
</span>
{% elif linenum in questions_count %}
<span id="questionums_{{ linenum }}" class="questionnums" onclick='show_issue_question({{ file.id }},{{ linenum }},"[]" )'>
<span id="questionums_{{ linenum }}" class="questionnums" onclick='show_issue_question({{ file.id }},{{ linenum }},"[]")'>
</span>
{% endif %}
</span>
@ -32,6 +32,6 @@
<i class="fa fa-plus-circle color-grey-c"></i>
</span>
</div>
</div>
{% endfor %}
{% endfor %}
</div>

View File

@ -22,12 +22,7 @@
<!-- highlight.js -->
<link href="{% static 'css/monokai-sublime.css' %}" rel="stylesheet" />
<script type="application/javascript" src="{% static 'js/highlight.pack.js' %}"></script>
<!-- <script> hljs.configure({useBR: true});</script> -->
<script>
</script>
<script type="application/javascript" src="https://cdn.bootcss.com/highlight.js/9.12.0/highlight.min.js"></script>
<title>{{ project.name }}-{{ project.desc }}</title>
</head>