2018-07-15 10:09:43 +08:00
|
|
|
|
var flag = true;//左侧默认显示
|
|
|
|
|
|
2018-09-17 16:53:03 +08:00
|
|
|
|
function hideModal(){
|
|
|
|
|
$("#popupAll").remove();
|
|
|
|
|
}
|
|
|
|
|
function pop_box_new(value, Width, Height,close){
|
|
|
|
|
|
|
|
|
|
if($("#popupAll").length > 0){
|
|
|
|
|
$("#popupAll").remove();
|
|
|
|
|
}
|
|
|
|
|
w = ($(window).width() - Width)/2;
|
|
|
|
|
h = ($(window).height() - Height)/2;
|
|
|
|
|
var html="<div class=\"popupAll none\" id='popupAll'><div class=\"pr\"><div id=\"popupWrap\"></div></div></div>";
|
|
|
|
|
if(close){
|
|
|
|
|
value="<a href='javascript:void(0)' id='closeIcon'><i class='iconfont icon-shanchudiao'></i></a>" + value;
|
|
|
|
|
}
|
|
|
|
|
$(document.body).append(html);
|
|
|
|
|
$("#popupWrap").html(value);
|
|
|
|
|
$('#popupWrap').css({"top": h+"px","left": w+"px","padding":"0","border":"none","position":"fixed","z-index":"99999","background-color":"#fff","border-radius":"10px"});
|
|
|
|
|
if(close){
|
|
|
|
|
$('#closeIcon').css({"top": "-26px","left": Width +"px","z-index":"100000"});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$("#popupWrap").parent().parent().show();
|
|
|
|
|
$('#popupAll').find("#closeIcon").click(function(){
|
|
|
|
|
$("#popupAll").hide();
|
|
|
|
|
});
|
|
|
|
|
$('#popupAll').find("a[class*='pop_close']").click(function(){
|
|
|
|
|
$("#popupAll").hide();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//拖拽
|
|
|
|
|
function Drag(id) {
|
|
|
|
|
this.div = document.getElementById(id);
|
|
|
|
|
if (this.div) {
|
|
|
|
|
this.div.style.cursor = "move";
|
|
|
|
|
this.div.style.position = "fixed";
|
|
|
|
|
}
|
|
|
|
|
this.disX = 0;
|
|
|
|
|
this.disY = 0;
|
|
|
|
|
var _this = this;
|
|
|
|
|
this.div.onmousedown = function (evt) {
|
|
|
|
|
_this.getDistance(evt);
|
|
|
|
|
document.onmousemove = function (evt) {
|
|
|
|
|
_this.setPosition(evt);
|
|
|
|
|
};
|
|
|
|
|
_this.div.onmouseup = function () {
|
|
|
|
|
_this.clearEvent();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Drag.prototype.getDistance = function (evt) {
|
|
|
|
|
var oEvent = evt || event;
|
|
|
|
|
this.disX = oEvent.clientX - this.div.offsetLeft;
|
|
|
|
|
this.disY = oEvent.clientY - this.div.offsetTop;
|
|
|
|
|
};
|
|
|
|
|
Drag.prototype.setPosition = function (evt) {
|
|
|
|
|
var oEvent = evt || event;
|
|
|
|
|
var l = oEvent.clientX - this.disX;
|
|
|
|
|
var t = oEvent.clientY - this.disY;
|
|
|
|
|
if (l <= 0) {
|
|
|
|
|
l = 0;
|
|
|
|
|
}
|
|
|
|
|
else if (l >= document.documentElement.clientWidth - this.div.offsetWidth) {
|
|
|
|
|
l = document.documentElement.clientWidth - this.div.offsetWidth;
|
|
|
|
|
}
|
|
|
|
|
if (t <= 0) {
|
|
|
|
|
t = 0;
|
|
|
|
|
}
|
|
|
|
|
else if (t >= document.documentElement.clientHeight - this.div.offsetHeight) {
|
|
|
|
|
t = document.documentElement.clientHeight - this.div.offsetHeight;
|
|
|
|
|
}
|
|
|
|
|
this.div.style.left = l + "px";
|
|
|
|
|
this.div.style.top = t + "px";
|
|
|
|
|
};
|
|
|
|
|
Drag.prototype.clearEvent = function () {
|
|
|
|
|
this.div.onmouseup = null;
|
|
|
|
|
document.onmousemove = null;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
new Drag("popupWrap");
|
|
|
|
|
|
|
|
|
|
$("#popupAll input, #popupAll textarea, #popupAll ul, #popupAll a,#shixun_search_form_div").mousedown(function(event){
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
new Drag("popupWrap");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//一个“知道了”按钮,title和宽度都作为参数
|
|
|
|
|
function sure_confirm_box(title,width,height,str){
|
|
|
|
|
var htmlvalue = '<div class="task-popup" style="width:'+width+'px;"><div class="task-popup-title clearfix">'+title+'</div>'+
|
|
|
|
|
'<div class="task-popup-content">' + str + '</div><div class="mb30 edu-txt-center clearfix">'+
|
|
|
|
|
'<a href="javascript:void(0)" class="task-btn task-btn-orange use_btn" onclick="hideModal();">知道了</a></div></div>';
|
|
|
|
|
pop_box_new(htmlvalue, width, height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function suofang(){
|
|
|
|
|
var html='<div><p class="mb20 font-16 edu-txt-center">可能会影响某些功能的正常使用</p><ul class="mb20 color-grey-6" style="width: 372px;margin:0px auto;">' +
|
|
|
|
|
'<li>1.请尝试调整浏览器缩放比例为<span class="color-orange mr5">100%</span>(快捷键ctrl+0)</li>' +
|
|
|
|
|
'<li>2.请尝试调整系统显示比例为<span class="color-orange mr5">100%</span>(控制面板/显示 设置)</li>' +
|
|
|
|
|
'</ul></div>';
|
|
|
|
|
sure_confirm_box("页面缩放比例不正确",600,310,html);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(window).resize(function() {
|
|
|
|
|
suofang();
|
|
|
|
|
})
|
|
|
|
|
|
2018-09-15 13:18:37 +08:00
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-07-15 10:09:43 +08:00
|
|
|
|
function getCookie(name) {
|
|
|
|
|
var cookieValue = null;
|
|
|
|
|
if (document.cookie && document.cookie !== '') {
|
|
|
|
|
var cookies = document.cookie.split(';');
|
|
|
|
|
for (var i = 0; i < cookies.length; i++) {
|
|
|
|
|
var cookie = jQuery.trim(cookies[i]);
|
|
|
|
|
// Does this cookie string begin with the name we want?
|
|
|
|
|
if (cookie.substring(0, name.length + 1) === (name + '=')) {
|
|
|
|
|
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return cookieValue;
|
|
|
|
|
}
|
|
|
|
|
var csrftoken = getCookie('csrftoken');
|
|
|
|
|
|
|
|
|
|
function show_annotation(file_id, line_num) {
|
2018-07-18 23:27:40 +08:00
|
|
|
|
ev = window.event;
|
2018-08-23 22:53:27 +08:00
|
|
|
|
if(ev==undefined){
|
|
|
|
|
ev=arguments.callee.caller.arguments[0]||window.event;
|
|
|
|
|
}
|
2018-07-15 10:09:43 +08:00
|
|
|
|
var mousePos = mouseCoords(ev)
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
cache: false,
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: '/operations/show_annotation/',
|
|
|
|
|
data: { 'file_id': file_id, 'line_num': line_num },
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
async: true,
|
|
|
|
|
beforeSend: function (xhr, settings) {
|
|
|
|
|
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
|
|
|
|
},
|
|
|
|
|
success: function (data) {
|
|
|
|
|
if (data.status === "success") {
|
|
|
|
|
//console.log("linestatus_"+line_num);
|
|
|
|
|
//$("#loadCommentpanel").html(data.html_str);
|
|
|
|
|
//$("#commentPanel").css("top", mousePos.y);
|
|
|
|
|
//$("#commentPanel").css("left", mousePos.x+35);
|
|
|
|
|
//$("#loadCommentpanel").show();
|
2018-07-17 22:06:28 +08:00
|
|
|
|
//console.log(data.html_str);
|
|
|
|
|
$("#ItemcommentPanel").remove()
|
|
|
|
|
var html="<div id='ItemcommentPanel'>"+data.html_str+"</div>"
|
|
|
|
|
$("#linestatus_"+file_id+"_"+line_num).append(html);
|
2018-09-20 18:25:36 +08:00
|
|
|
|
$( "#ItemcommentPanel" ).draggable();
|
2018-07-15 10:09:43 +08:00
|
|
|
|
}else{
|
|
|
|
|
alert(data.msg)
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-25 15:07:59 +08:00
|
|
|
|
},error:function(jqXHR, textStatus, errorThrown){
|
|
|
|
|
if(jqXHR.readyState===0&&jqXHR.status===0){
|
|
|
|
|
alert('网络故障,提交失败!请联网后重新提交');
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-15 10:09:43 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-17 22:06:28 +08:00
|
|
|
|
function close_modify_anno(){
|
2018-08-26 09:49:30 +08:00
|
|
|
|
$("#modification").show();
|
2018-07-17 22:06:28 +08:00
|
|
|
|
$(".modify_anno_div").remove();
|
2018-08-25 19:40:25 +08:00
|
|
|
|
$("#modify_anno_textarea").attr("readonly","readonly")
|
2018-09-04 15:16:57 +08:00
|
|
|
|
|
|
|
|
|
|
2018-07-18 23:27:40 +08:00
|
|
|
|
ev = window.event;
|
2018-08-23 22:53:27 +08:00
|
|
|
|
if(ev==undefined){
|
|
|
|
|
ev=arguments.callee.caller.arguments[0]||window.event;
|
|
|
|
|
}
|
2018-07-17 22:06:28 +08:00
|
|
|
|
ev.stopPropagation();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//注入html代码
|
2018-08-25 19:40:25 +08:00
|
|
|
|
function inject_modifyAnno_html(item,file_id,linenum,anno_id) {
|
2018-09-15 13:18:37 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
|
|
|
2018-08-26 09:49:30 +08:00
|
|
|
|
$("#modification").hide();
|
2018-08-25 19:40:25 +08:00
|
|
|
|
$(".modify_anno_div").remove();
|
|
|
|
|
$("#modify_anno_textarea").removeAttr("readonly");
|
|
|
|
|
$("#modify_anno_textarea").focus()
|
2018-09-04 15:16:57 +08:00
|
|
|
|
|
2018-07-17 22:06:28 +08:00
|
|
|
|
html_str = '<div class="modify_anno_div" style="display:block">'+
|
2018-08-26 09:49:30 +08:00
|
|
|
|
'<a href="javascript:void(0)" onclick="close_modify_anno()" class="btn fr mt10 mb10">取消</a>'+
|
|
|
|
|
'<a href="javascript:void(0)" onclick="modify_anno('+file_id+','+linenum+','+anno_id+')" class="btn btn-blue fr mt10 mb10 mr10">提交</a>'+
|
2018-07-17 22:06:28 +08:00
|
|
|
|
'</div>';
|
|
|
|
|
$(item).after(html_str)
|
2018-07-18 23:27:40 +08:00
|
|
|
|
ev = window.event;
|
2018-08-23 22:53:27 +08:00
|
|
|
|
if(ev==undefined){
|
|
|
|
|
ev=arguments.callee.caller.arguments[0]||window.event;
|
|
|
|
|
}
|
2018-07-17 22:06:28 +08:00
|
|
|
|
ev.stopPropagation();
|
2018-09-15 13:18:37 +08:00
|
|
|
|
|
|
|
|
|
if(file_id===modifyAnno_id&&linenum===modifyAnno_num&&anno_id===modifyAnno_line){
|
|
|
|
|
$("#modify_anno_textarea").val(modifyAnno_value);
|
|
|
|
|
}
|
2018-07-31 10:46:48 +08:00
|
|
|
|
}
|
2018-07-17 22:06:28 +08:00
|
|
|
|
|
|
|
|
|
// FIXME
|
2018-08-25 19:40:25 +08:00
|
|
|
|
function modify_anno(file_id,line_num,anno_id){
|
2018-07-17 22:06:28 +08:00
|
|
|
|
// 获取修改后的内容
|
2018-09-21 19:43:16 +08:00
|
|
|
|
function_name = "modify_anno("+file_id+","+line_num+","+anno_id+")"
|
|
|
|
|
make_button_disable($(".modify_anno_div a").last())
|
|
|
|
|
|
2018-07-17 22:06:28 +08:00
|
|
|
|
var content=$("#modify_anno_textarea").val();
|
2018-07-31 10:46:48 +08:00
|
|
|
|
if (content == null || content == undefined || content.trim() == '') {
|
2018-07-17 22:06:28 +08:00
|
|
|
|
alert("内容不能为空");
|
2018-09-21 19:43:16 +08:00
|
|
|
|
make_button_able($(".modify_anno_div a").last(),function_name)
|
2018-07-17 22:06:28 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$.ajax({
|
|
|
|
|
cache: false,
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: '/operations/modify_anno/',
|
2018-08-25 19:40:25 +08:00
|
|
|
|
data: { 'file_id': file_id, 'line_num': line_num,'anno_id':anno_id,'content':content },
|
2018-07-17 22:06:28 +08:00
|
|
|
|
dataType: 'json',
|
|
|
|
|
async: true,
|
|
|
|
|
beforeSend: function (xhr, settings) {
|
|
|
|
|
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
|
|
|
|
},
|
|
|
|
|
success: function (data) {
|
|
|
|
|
if (data.status === "success") {
|
|
|
|
|
alert(data.msg)
|
|
|
|
|
$("#ItemcommentPanel").remove()
|
2018-08-26 12:35:10 +08:00
|
|
|
|
$("."+file_id+line_num).text(data.anno_content)
|
2018-09-15 13:18:37 +08:00
|
|
|
|
show_annotation(file_id,line_num);
|
|
|
|
|
|
|
|
|
|
deletelocalStorage("modifyAnno_id");
|
|
|
|
|
deletelocalStorage("modifyAnno_num")
|
|
|
|
|
deletelocalStorage("modifyAnno_line")
|
|
|
|
|
deletelocalStorage("modifyAnno_value")
|
2018-07-17 22:06:28 +08:00
|
|
|
|
}else{
|
|
|
|
|
alert(data.msg)
|
|
|
|
|
}
|
2018-09-21 19:43:16 +08:00
|
|
|
|
make_button_able($(".modify_anno_div a").last(),function_name)
|
2018-09-15 13:18:37 +08:00
|
|
|
|
},error:function(jqXHR, textStatus, errorThrown){
|
2018-09-25 15:07:59 +08:00
|
|
|
|
if(jqXHR.readyState===0&&jqXHR.status===0){
|
|
|
|
|
alert('网络故障,提交失败!请联网后重新提交');
|
2018-09-21 19:43:16 +08:00
|
|
|
|
}
|
|
|
|
|
make_button_able($(".modify_anno_div a").last(),function_name)
|
|
|
|
|
}
|
2018-07-17 22:06:28 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-16 23:05:14 +08:00
|
|
|
|
|
2018-07-15 10:09:43 +08:00
|
|
|
|
// FIXME
|
|
|
|
|
function show_issue_question(file_id, line_num, issue_ids) {
|
|
|
|
|
issueid_str=issue_ids.toString()
|
2018-07-18 23:27:40 +08:00
|
|
|
|
ev = window.event;
|
2018-08-23 22:53:27 +08:00
|
|
|
|
if(ev==undefined){
|
|
|
|
|
ev=arguments.callee.caller.arguments[0]||window.event;
|
|
|
|
|
}
|
2018-07-15 10:09:43 +08:00
|
|
|
|
var mousePos = mouseCoords(ev)
|
|
|
|
|
//发送问题id,返回问题内容
|
|
|
|
|
$.ajax({
|
|
|
|
|
cache: false,
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: '/operations/show_issue_question/',
|
|
|
|
|
data: { 'file_id': file_id, 'line_num': line_num, 'issue_ids': issueid_str},
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
async: true,
|
|
|
|
|
beforeSend: function (xhr, settings) {
|
|
|
|
|
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
|
|
|
|
},
|
|
|
|
|
success: function (data) {
|
|
|
|
|
if(data.status=='success'){
|
|
|
|
|
var html="<div id='ItemquestionPanel'>"+data.html_str+"</div>";
|
2018-07-18 14:43:05 +08:00
|
|
|
|
$("#linestatus_"+file_id+"_"+line_num).append(html);
|
2018-07-15 10:09:43 +08:00
|
|
|
|
// $("#loadQuestionpanel").html(data.html_str);
|
|
|
|
|
if (data.issueAnswers) {
|
|
|
|
|
//字符串转换成整型数组
|
|
|
|
|
var dataStrArr = issueid_str.substring(1, issueid_str.length - 1).split(",")
|
|
|
|
|
var issue_ids = dataStrArr.map(function (data) {
|
|
|
|
|
return +data;
|
|
|
|
|
});
|
|
|
|
|
//
|
|
|
|
|
issueAnswers = JSON.parse(data.issueAnswers);
|
|
|
|
|
issueStandardAnswers = JSON.parse(data.issueStandardAnswers);
|
|
|
|
|
|
|
|
|
|
let count = 0;
|
|
|
|
|
for (let i = 0; i < issue_ids.length; i++) {
|
|
|
|
|
issue_id = issue_ids[i]
|
2018-07-31 10:46:48 +08:00
|
|
|
|
|
2018-07-15 10:09:43 +08:00
|
|
|
|
if (issue_id == issueAnswers[count].fields.issue) {
|
|
|
|
|
var radios = document.getElementsByName("issue_" + issue_id)
|
|
|
|
|
user_answer = issueAnswers[0].fields.content;
|
|
|
|
|
standard_answer = issueStandardAnswers[0].fields.choice_position;
|
|
|
|
|
if (user_answer == standard_answer) {
|
|
|
|
|
radios[user_answer - 1].parentNode.style.color = "green";
|
|
|
|
|
} else {
|
|
|
|
|
radios[parseInt(user_answer) - 1].parentNode.style.color = "red";
|
|
|
|
|
radios[parseInt(standard_answer) - 1].parentNode.style.color = "green";
|
|
|
|
|
}
|
|
|
|
|
document.getElementById("submit_onechoice_" + issue_id).style.display = "None";
|
|
|
|
|
count = count + 1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//$("#questionPanel").css("top", mousePos.y);
|
|
|
|
|
//$("#questionPanel").css("left", mousePos.x - 400);
|
|
|
|
|
//$("#loadQuestionpanel").show();
|
2018-09-20 18:25:36 +08:00
|
|
|
|
$( "#ItemquestionPanel" ).draggable();
|
2018-07-15 10:09:43 +08:00
|
|
|
|
}else{
|
|
|
|
|
alert(data.msg)
|
2018-07-31 10:46:48 +08:00
|
|
|
|
}
|
2018-09-25 15:07:59 +08:00
|
|
|
|
},error:function(jqXHR, textStatus, errorThrown){
|
|
|
|
|
if(jqXHR.readyState===0&&jqXHR.status===0){
|
|
|
|
|
alert('网络故障,提交失败!请联网后重新提交');
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-15 10:09:43 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function add_vote(type, id, num) {
|
|
|
|
|
// alert(1111)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function submit_onechoice_issue(issue_id) {
|
|
|
|
|
// 获取问题的内容
|
|
|
|
|
var content = $("input[name='issue_" + issue_id + "']:checked").val()
|
|
|
|
|
$.ajax({
|
|
|
|
|
cache: false,
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: '/operations/add_issue_answer/',
|
|
|
|
|
data: { 'content': content, 'issue_id': issue_id },
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
async: true,
|
|
|
|
|
beforeSend: function (xhr, settings) {
|
|
|
|
|
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
|
|
|
|
},
|
|
|
|
|
success: function (data) {
|
|
|
|
|
if (data.status === 'success') {
|
|
|
|
|
var radios = document.getElementsByName("issue_" + issue_id)
|
|
|
|
|
var choose = parseInt(content) - 1
|
|
|
|
|
if (content == data.standAnswer){
|
2018-07-31 10:46:48 +08:00
|
|
|
|
radios[choose].parentNode.style.color = "green";
|
2018-07-15 10:09:43 +08:00
|
|
|
|
}else{
|
|
|
|
|
radios[choose].parentNode.style.color = "red";
|
|
|
|
|
radios[parseInt(data.standAnswer)-1].parentNode.style.color = "green";
|
|
|
|
|
}
|
|
|
|
|
document.getElementById("submit_onechoice_"+issue_id).style.display="None";
|
|
|
|
|
} else {
|
|
|
|
|
alert(data.msg)
|
|
|
|
|
}
|
2018-09-25 15:07:59 +08:00
|
|
|
|
},error:function(jqXHR, textStatus, errorThrown){
|
|
|
|
|
if(jqXHR.readyState===0&&jqXHR.status===0){
|
|
|
|
|
alert('网络故障,提交失败!请联网后重新提交');
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-15 10:09:43 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function add_comment_action(item, id, type) {
|
|
|
|
|
var content = $("#writetext_" + id).val();
|
|
|
|
|
if (content == "") {
|
|
|
|
|
confirm("请输入评论内容");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//发送一个ajax请求
|
|
|
|
|
$.ajax({
|
|
|
|
|
cache: false,
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: '/operations/add_comment/',
|
|
|
|
|
data: { 'object_id': id, 'type': type, "content": content },
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
async: true,
|
|
|
|
|
beforeSend: function (xhr, settings) {
|
|
|
|
|
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
|
|
|
|
},
|
|
|
|
|
success: function (data) {
|
|
|
|
|
if (data.status === 'success') {
|
2018-08-08 15:35:38 +08:00
|
|
|
|
html_str = data.html_str
|
|
|
|
|
show_new_comment(item, html_str);
|
2018-09-15 13:18:37 +08:00
|
|
|
|
deletelocalStorage("writetext_id");
|
|
|
|
|
deletelocalStorage("writetext_value");
|
2018-07-15 10:09:43 +08:00
|
|
|
|
} else {
|
|
|
|
|
alert(data.msg);
|
|
|
|
|
}
|
2018-09-15 13:18:37 +08:00
|
|
|
|
},error:function(jqXHR, textStatus, errorThrown){
|
2018-09-25 15:07:59 +08:00
|
|
|
|
if(jqXHR.readyState===0&&jqXHR.status===0){
|
|
|
|
|
alert('网络故障,提交失败!请联网后重新提交');
|
|
|
|
|
}
|
2018-09-15 13:18:37 +08:00
|
|
|
|
}
|
2018-07-15 10:09:43 +08:00
|
|
|
|
});
|
2018-07-18 23:27:40 +08:00
|
|
|
|
ev = window.event;
|
2018-08-23 22:53:27 +08:00
|
|
|
|
if(ev==undefined){
|
|
|
|
|
ev=arguments.callee.caller.arguments[0]||window.event;
|
|
|
|
|
}
|
2018-07-15 10:09:43 +08:00
|
|
|
|
ev.stopPropagation();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//添加评论
|
2018-09-15 13:18:37 +08:00
|
|
|
|
function show_new_comment(item, html_str) {onclick="add_annotation(this,199,18)"
|
2018-08-08 15:35:38 +08:00
|
|
|
|
$(item).parents(".parthalf_comment").after(html_str);
|
2018-08-07 18:37:44 +08:00
|
|
|
|
|
2018-07-15 10:09:43 +08:00
|
|
|
|
$(item).parents(".comment-btn").find(".comment-write").addClass("none");
|
|
|
|
|
$(item).parents(".comment-btn").find("#addcom").removeClass("none");
|
|
|
|
|
$(item).siblings(".writetext").val("");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function add_question_answer(item,question_id) {
|
|
|
|
|
// 获取回答的内容
|
|
|
|
|
var content = $("#responseInput_" + question_id).val();
|
|
|
|
|
if (content == "") {
|
|
|
|
|
confirm("请输入回答内容");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$.ajax({
|
|
|
|
|
cache: false,
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: '/operations/add_question_answer/',
|
|
|
|
|
data: { 'question_id': question_id,"content": content},
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
async: true,
|
|
|
|
|
beforeSend: function (xhr, settings) {
|
|
|
|
|
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
|
|
|
|
},
|
|
|
|
|
success: function (data) {
|
|
|
|
|
if (data.status === 'success') {
|
|
|
|
|
var username = data.username;
|
|
|
|
|
show_new_question_answer(item, content, username);
|
|
|
|
|
} else {
|
|
|
|
|
alert(data.msg);
|
|
|
|
|
}
|
2018-09-25 15:07:59 +08:00
|
|
|
|
},error:function(jqXHR, textStatus, errorThrown){
|
|
|
|
|
if(jqXHR.readyState===0&&jqXHR.status===0){
|
|
|
|
|
alert('网络故障,提交失败!请联网后重新提交');
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-15 10:09:43 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function show_new_question_answer(item, content, username) {
|
|
|
|
|
|
|
|
|
|
var html = '<div class="comments clearfix"><div class="fl"><img src="/static/image/users/default.png" width="45px" height="45px" class="radius" /></div>'
|
|
|
|
|
html += '<div class="fl comments-right">'
|
|
|
|
|
html += '<div class="question-comment">';
|
|
|
|
|
html += '<p><span class="comments-name">' + username+'</span><span class="font-12 color-grey-c">10分钟前</span></p>';
|
|
|
|
|
html += '<div class="comments-content">'+content+'</div>';
|
|
|
|
|
html += '</div></div></div>'
|
|
|
|
|
|
|
|
|
|
$(item).parents(".responsePanel").before(html);
|
|
|
|
|
$(item).parent().siblings(".responseInput").val("");
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-29 11:50:45 +08:00
|
|
|
|
function delete_anno(file_id,line_num,anno_id){
|
|
|
|
|
$.ajax({
|
|
|
|
|
cache: false,
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: '/operations/delete/',
|
|
|
|
|
data: {'object_id':anno_id,"object_type":"Annotation"},
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
async: true,
|
|
|
|
|
beforeSend: function (xhr, settings) {
|
|
|
|
|
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
|
|
|
|
},
|
|
|
|
|
success: function (data) {
|
|
|
|
|
if (data.status == 'success') {
|
|
|
|
|
$("#ItemcommentPanel").remove()
|
|
|
|
|
$("."+file_id+line_num).remove()
|
|
|
|
|
$("#codeopration_anno_"+file_id+"_"+line_num).remove();
|
|
|
|
|
show_annotation(file_id,line_num);
|
|
|
|
|
layer.msg(data.msg);
|
|
|
|
|
}else{
|
|
|
|
|
layer.msg(data.msg);
|
|
|
|
|
}
|
|
|
|
|
},error:function(jqXHR, textStatus, errorThrown){
|
|
|
|
|
if(jqXHR.readyState===0&&jqXHR.status===0){
|
|
|
|
|
alert('网络故障,提交失败!请联网后重新提交');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
2018-07-15 10:09:43 +08:00
|
|
|
|
|
|
|
|
|
function add_annotation(item,file_id, line_num) {
|
2018-09-27 09:07:39 +08:00
|
|
|
|
|
2018-07-15 10:09:43 +08:00
|
|
|
|
// 获取当前是注释还是问题
|
2018-09-21 19:43:16 +08:00
|
|
|
|
function_name="add_annotation(this"+","+file_id+","+line_num+")"
|
|
|
|
|
make_button_disable($(item))
|
|
|
|
|
|
2018-07-15 10:09:43 +08:00
|
|
|
|
var selectValue = $(item).siblings(".put-select").find(".active").html().trim();
|
|
|
|
|
var text_context = "#addno-text-" + file_id+"-"+line_num;
|
|
|
|
|
var content = $(text_context).val();
|
2018-09-21 19:43:16 +08:00
|
|
|
|
|
2018-07-15 10:09:43 +08:00
|
|
|
|
if (content.trim().length == 0) {
|
|
|
|
|
alert("内容不能为空")
|
2018-09-21 19:43:16 +08:00
|
|
|
|
$(item).attr('disabled',false);
|
|
|
|
|
$(item).attr("onclick","add_annotation(this"+","+file_id+","+line_num+")")
|
|
|
|
|
|
2018-07-15 10:09:43 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (selectValue == "注释") {
|
|
|
|
|
// 向addAnnatation中发请求
|
2018-08-07 23:00:10 +08:00
|
|
|
|
submit_annotation(file_id, line_num, content);
|
2018-09-15 13:18:37 +08:00
|
|
|
|
deletelocalStorage("file_id");
|
|
|
|
|
deletelocalStorage("line_num");
|
|
|
|
|
deletelocalStorage("item_value");
|
|
|
|
|
deletelocalStorage("status_value");
|
2018-07-15 10:09:43 +08:00
|
|
|
|
} else {
|
2018-08-07 23:00:10 +08:00
|
|
|
|
submit_question(file_id, line_num, content);
|
2018-09-15 13:18:37 +08:00
|
|
|
|
deletelocalStorage("issuefile_id");
|
|
|
|
|
deletelocalStorage("issueline_num");
|
|
|
|
|
deletelocalStorage("issueitem_value");
|
|
|
|
|
deletelocalStorage("status_value");
|
2018-07-15 10:09:43 +08:00
|
|
|
|
}
|
2018-09-21 19:43:16 +08:00
|
|
|
|
make_button_able($(item),function_name)
|
2018-07-15 10:09:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-07 23:00:10 +08:00
|
|
|
|
function submit_annotation(file_id, line_num, content) {
|
2018-09-29 11:50:45 +08:00
|
|
|
|
// 因为可能注释或问题没有值的时候,不会为该代码块添加html代码,所以首先判断
|
|
|
|
|
// 然后将注释数+1
|
|
|
|
|
var codeopration_anno_div = $("#codeopration_anno_"+file_id+"_" + line_num).html()
|
|
|
|
|
var str = '<span id="annonums_' + line_num + '" class="annonums" onclick="show_annotation(' + file_id + ',' + line_num + ')">';
|
|
|
|
|
str +='</span>';
|
|
|
|
|
$("#codeopration_anno_" + +file_id + "_" + line_num).html(str);
|
|
|
|
|
$(".addno-panel").hide();
|
|
|
|
|
$(".source-addno-panel").remove();
|
|
|
|
|
// show_annotation(file_id,line_num);
|
|
|
|
|
//将注释添加到当前行的上一行
|
|
|
|
|
var contenthtml ='<div class="linenum"></div>'+'<div class="sourcecode">'+'<div class="mypre newaddmypre hljs-comment ' + file_id+line_num + '">'+"//"+ content+'</div>'+'</div>'+'<div class="linestatus"></div>';
|
|
|
|
|
var html = '<div class="newcodeline newcodelinebox">'+contenthtml+'</div>';
|
|
|
|
|
var id=file_id+'_'+"L"+line_num;
|
|
|
|
|
$("#"+id).before(html);
|
2018-09-27 09:07:39 +08:00
|
|
|
|
$.ajax({
|
|
|
|
|
cache: false,
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: '/operations/add_annotation/',
|
|
|
|
|
data: { 'file_id': file_id, 'linenum': line_num, 'content': content },
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
async: true,
|
|
|
|
|
beforeSend: function (xhr, settings) {
|
|
|
|
|
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
|
|
|
|
},
|
|
|
|
|
success: function (data) {
|
|
|
|
|
if (data.status == 'success') {
|
|
|
|
|
layer.msg('提交成功');
|
2018-07-16 10:34:51 +08:00
|
|
|
|
}else{
|
2018-09-29 11:50:45 +08:00
|
|
|
|
layer.msg(data.msg);
|
2018-07-15 10:09:43 +08:00
|
|
|
|
}
|
2018-09-15 13:18:37 +08:00
|
|
|
|
},error:function(jqXHR, textStatus, errorThrown){
|
2018-09-25 15:07:59 +08:00
|
|
|
|
if(jqXHR.readyState===0&&jqXHR.status===0){
|
|
|
|
|
alert('网络故障,提交失败!请联网后重新提交');
|
|
|
|
|
}
|
2018-09-15 13:18:37 +08:00
|
|
|
|
}
|
2018-07-15 10:09:43 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-08-18 22:49:28 +08:00
|
|
|
|
|
2018-08-07 23:00:10 +08:00
|
|
|
|
function submit_question(file_id, line_num, content) {
|
2018-07-15 10:09:43 +08:00
|
|
|
|
$.ajax({
|
|
|
|
|
cache: false,
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: '/operations/add_question/',
|
|
|
|
|
data: { 'file_id': file_id, 'linenum': line_num, 'content': content },
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
async: true,
|
|
|
|
|
beforeSend: function (xhr, settings) {
|
|
|
|
|
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
|
|
|
|
},
|
|
|
|
|
success: function (data) {
|
|
|
|
|
if (data.status == 'success') {
|
|
|
|
|
var codeopration_anno_div = $("#codeopration_question_" + file_id + "_" + line_num).html()
|
|
|
|
|
if (codeopration_anno_div.trim().length == 0) {
|
|
|
|
|
var str = '<span id="questionums_' + line_num + '" class="questionnums" onclick="show_issue_question(' + file_id + ',' + line_num + ',[])">';
|
|
|
|
|
str += '</span>'
|
|
|
|
|
$("#codeopration_question_" + file_id + "_" + line_num).html(str);
|
2018-07-31 10:46:48 +08:00
|
|
|
|
}
|
|
|
|
|
$(".addno-panel").hide();
|
2018-07-18 14:43:05 +08:00
|
|
|
|
$(".source-addno-panel").remove();
|
|
|
|
|
show_issue_question(file_id,line_num,[]);
|
2018-07-15 10:09:43 +08:00
|
|
|
|
// else {
|
|
|
|
|
// var question_before = $("#questionums_" + line_num).text();
|
|
|
|
|
// $("#questionums_" + line_num).html(parseInt(question_before) + 1);
|
|
|
|
|
// }
|
2018-07-18 14:43:05 +08:00
|
|
|
|
}else{
|
|
|
|
|
alert(data.msg);
|
2018-07-15 10:09:43 +08:00
|
|
|
|
}
|
2018-09-25 15:07:59 +08:00
|
|
|
|
},error:function(jqXHR, textStatus, errorThrown){
|
|
|
|
|
if(jqXHR.readyState===0&&jqXHR.status===0){
|
|
|
|
|
alert('网络故障,提交失败!请联网后重新提交');
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-15 10:09:43 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-04 15:16:57 +08:00
|
|
|
|
function closeX_search(){
|
|
|
|
|
$("#search_response").hide();
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-05 16:32:40 +08:00
|
|
|
|
function search_symbol(args,line_num,function_name) {
|
2018-07-15 10:09:43 +08:00
|
|
|
|
|
2018-09-03 21:01:58 +08:00
|
|
|
|
// ev = window.event
|
|
|
|
|
ev = window.event;
|
|
|
|
|
if(ev==undefined){
|
2018-08-23 22:53:27 +08:00
|
|
|
|
ev=arguments.callee.caller.arguments[0]||window.event;
|
|
|
|
|
}
|
2018-07-15 10:09:43 +08:00
|
|
|
|
var mousePos = mouseCoords(ev)
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
2018-09-05 16:32:40 +08:00
|
|
|
|
cache: true,
|
2018-07-15 10:09:43 +08:00
|
|
|
|
type: "POST",
|
|
|
|
|
url: '/operations/show_method_info/',
|
2018-09-05 16:32:40 +08:00
|
|
|
|
data: { 'args': args,"line_num":line_num,"function_name":function_name },
|
2018-07-15 10:09:43 +08:00
|
|
|
|
dataType: 'json',
|
|
|
|
|
async: true,
|
|
|
|
|
beforeSend: function (xhr, settings) {
|
|
|
|
|
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
|
|
|
|
},
|
|
|
|
|
success: function (data) {
|
|
|
|
|
if (data.status === 'success') {
|
|
|
|
|
// console.log(context);
|
2018-09-04 15:16:57 +08:00
|
|
|
|
$("#search_response").css("top", 400);
|
2018-07-15 10:09:43 +08:00
|
|
|
|
$("#search_response").css("left", mousePos.x);
|
2018-09-04 15:16:57 +08:00
|
|
|
|
$(".search-title").remove();
|
|
|
|
|
$(".resultform").remove();
|
|
|
|
|
$("#search_response").append(data.html_str);
|
2018-07-15 10:09:43 +08:00
|
|
|
|
$("#search_response").show();
|
2018-09-20 18:25:36 +08:00
|
|
|
|
$( "#search_response" ).draggable();
|
2018-09-03 21:01:58 +08:00
|
|
|
|
ev.stopPropagation();
|
2018-09-20 18:25:36 +08:00
|
|
|
|
|
2018-07-15 10:09:43 +08:00
|
|
|
|
}
|
2018-09-25 15:07:59 +08:00
|
|
|
|
},error:function(jqXHR, textStatus, errorThrown){
|
|
|
|
|
if(jqXHR.readyState===0&&jqXHR.status===0){
|
|
|
|
|
alert('网络故障,提交失败!请联网后重新提交');
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-15 10:09:43 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
2018-09-05 16:32:40 +08:00
|
|
|
|
function onClick_FeedbackButton(answer_type,file_id,path_and_lineno,line_num,function_name) {
|
|
|
|
|
// 获取到当前的答案
|
|
|
|
|
$.ajax({
|
|
|
|
|
cache: false,
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: '/operations/submit_search_answer/',
|
|
|
|
|
data: {'file_id':file_id,"path_and_lineno":path_and_lineno,"answer_type":answer_type,"line_num":line_num,"function_name":function_name},
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
async: true,
|
|
|
|
|
beforeSend: function (xhr, settings) {
|
|
|
|
|
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
|
|
|
|
},
|
|
|
|
|
success: function (data) {
|
2018-09-17 09:03:40 +08:00
|
|
|
|
// alert("Thanks for your support for the improvement of Accuracy of search results")
|
2018-09-20 18:25:36 +08:00
|
|
|
|
layer.msg('操作成功');
|
2018-09-25 15:07:59 +08:00
|
|
|
|
},error:function(jqXHR, textStatus, errorThrown){
|
|
|
|
|
if(jqXHR.readyState===0&&jqXHR.status===0){
|
|
|
|
|
alert('网络故障,提交失败!请联网后重新提交');
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-09-05 16:32:40 +08:00
|
|
|
|
});
|
|
|
|
|
|
2018-09-04 15:16:57 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-07-15 10:09:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
navigation_map = new Map()
|
|
|
|
|
|
|
|
|
|
function show_navigation() {
|
|
|
|
|
// 首先要获取当前打开的标签页,或者也可以获取当前的路径
|
|
|
|
|
// 获取当前的项目名称
|
|
|
|
|
var file_path=document.getElementsByClassName("filename")[0].innerHTML;
|
2018-08-18 22:49:28 +08:00
|
|
|
|
var project_path=$("#projectName").text()
|
2018-07-15 10:09:43 +08:00
|
|
|
|
if( navigation_map.has(project_path+file_path)){
|
|
|
|
|
content = navigation_map.get(project_path + file_path);
|
|
|
|
|
$("#structure-context").html(content)
|
2018-08-15 10:57:02 +08:00
|
|
|
|
// 加载navigation_tree
|
|
|
|
|
deal_for_navigation_tree()
|
2018-07-15 10:09:43 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
2018-07-31 10:46:48 +08:00
|
|
|
|
|
2018-07-15 10:09:43 +08:00
|
|
|
|
$.ajax({
|
|
|
|
|
cache: false,
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: '/operations/show_navigation/',
|
|
|
|
|
data: { 'project_path': project_path, 'file_path': file_path },
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
async: true,
|
|
|
|
|
beforeSend: function (xhr, settings) {
|
|
|
|
|
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
success: function (data) {
|
|
|
|
|
if (data.status === 'success') {
|
2018-08-15 00:48:23 +08:00
|
|
|
|
var content = "<div id='navigation_tree'>";
|
2018-07-15 10:09:43 +08:00
|
|
|
|
var obj = data.msg;
|
|
|
|
|
var file_id = data.file_id
|
|
|
|
|
for (let i = 0; i < obj.length; i++) {
|
|
|
|
|
var type = obj[i][0];
|
|
|
|
|
var str = '';
|
2018-08-15 00:48:23 +08:00
|
|
|
|
str += "<ul><li>";
|
|
|
|
|
str += type
|
2018-07-15 10:09:43 +08:00
|
|
|
|
|
2018-08-19 17:38:22 +08:00
|
|
|
|
var items = obj[i][1];
|
|
|
|
|
for (let j = 0; j < items.length; j++) {
|
|
|
|
|
var name = items[j][0];
|
|
|
|
|
var linenum = items[j][1];
|
|
|
|
|
str += "<ul><li data-jstree='{\"icon\":\"fa fa-file-code-o color-blue\"}'>"
|
|
|
|
|
str += "<a class='def' href='#"+file_id+"_L" + linenum + "'>" + name + "</a>";
|
|
|
|
|
str += "</li></ul>"
|
2018-07-15 10:09:43 +08:00
|
|
|
|
}
|
2018-09-04 15:16:57 +08:00
|
|
|
|
|
2018-08-15 00:48:23 +08:00
|
|
|
|
str += "</li></ul>"
|
2018-07-15 10:09:43 +08:00
|
|
|
|
content += str;
|
|
|
|
|
}
|
2018-08-15 00:48:23 +08:00
|
|
|
|
content += "</div>"
|
2018-07-15 10:09:43 +08:00
|
|
|
|
// document.getElementById("annotation").style.display="block";
|
|
|
|
|
navigation_map.set(project_path + file_path, content)
|
2018-08-15 10:57:02 +08:00
|
|
|
|
$("#structure-context").html(content);
|
|
|
|
|
// 加载navigation_tree
|
|
|
|
|
deal_for_navigation_tree()
|
2018-07-15 10:09:43 +08:00
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
navigation_map.set(project_path + file_path, "")
|
|
|
|
|
$("#structure-context").html("")
|
|
|
|
|
}
|
2018-09-25 15:07:59 +08:00
|
|
|
|
},error:function(jqXHR, textStatus, errorThrown){
|
|
|
|
|
if(jqXHR.readyState===0&&jqXHR.status===0){
|
|
|
|
|
alert('网络故障,提交失败!请联网后重新提交');
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-15 10:09:43 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-15 10:57:02 +08:00
|
|
|
|
|
|
|
|
|
function deal_for_navigation_tree(){
|
2018-09-18 13:47:22 +08:00
|
|
|
|
try{
|
|
|
|
|
$("#navigation_tree").jstree();
|
|
|
|
|
$("#navigation_tree").jstree().open_all();
|
|
|
|
|
$("#navigation_tree li").click(function(){
|
|
|
|
|
location.href = $(this).find("a").attr("href");
|
|
|
|
|
});
|
|
|
|
|
}catch(error){
|
|
|
|
|
console.log(error)
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-15 10:57:02 +08:00
|
|
|
|
}
|
2018-07-15 10:09:43 +08:00
|
|
|
|
function show_currentLine(linenum) {
|
2018-07-18 21:07:03 +08:00
|
|
|
|
// document.getElementById("code_" + linenum).style.backgroundColor = '#f1efec';
|
2018-09-19 17:55:06 +08:00
|
|
|
|
document.getElementById("addanno_" + linenum).style.visibility="visible";
|
2018-07-15 10:09:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function hide_currentLine(linenum) {
|
2018-07-18 21:07:03 +08:00
|
|
|
|
// document.getElementById("code_" + linenum).style.backgroundColor = 'white';
|
2018-09-19 17:55:06 +08:00
|
|
|
|
document.getElementById("addanno_" + linenum).style.visibility="hidden";
|
2018-07-15 10:09:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$(function () {
|
2018-07-31 10:46:48 +08:00
|
|
|
|
|
2018-07-15 10:09:43 +08:00
|
|
|
|
$("#filelist-content .item").click(function () {
|
|
|
|
|
if ($(this).siblings(".sub-item").length > 0 && $(this).attr("show") == "0") {
|
|
|
|
|
$(this).siblings(".sub-item").show();
|
|
|
|
|
$(this).attr("show", "1");
|
|
|
|
|
} else if ($(this).attr("show") == "1") {
|
|
|
|
|
$(this).siblings(".sub-item").hide();
|
|
|
|
|
$(this).attr("show", "0");
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
$(".left-tab li").click(function () {
|
|
|
|
|
// alert("left-tab li")
|
|
|
|
|
$(".left-tab li").removeClass("active");
|
|
|
|
|
$(this).addClass("active");
|
|
|
|
|
$(".left-rightlist").hide();
|
|
|
|
|
|
|
|
|
|
$(".left-rightlist").eq($(this).index()).show();
|
|
|
|
|
|
|
|
|
|
if (flag == false) {
|
|
|
|
|
$("#right_code").css("width", "80%");
|
|
|
|
|
$(".left").animate({ "width": "20%" }, 1000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
/*隐藏左侧部分*/
|
|
|
|
|
$(".hideleft").click(function () {
|
|
|
|
|
var wid = $(".left").width();
|
|
|
|
|
$(".left").animate({ "width": "50px" }, 800);
|
|
|
|
|
$(".left-tab li").removeClass("active");
|
|
|
|
|
$("#right_code").width(parseInt($("#right_code").width()) + wid);
|
|
|
|
|
flag = false;
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//滚动codepanel隐藏搜索结果
|
|
|
|
|
$("#right_code").scroll(function () {
|
|
|
|
|
$("#search_response").hide();
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
$(".addno-panel").click(function (event) {
|
2018-08-23 22:53:27 +08:00
|
|
|
|
ev = window.event;
|
|
|
|
|
if(ev==undefined){
|
|
|
|
|
ev=arguments.callee.caller.arguments[0]||window.event;
|
|
|
|
|
}
|
|
|
|
|
ev.stopPropagation();
|
2018-07-15 10:09:43 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
$(".addanno").live("click",function (event) {
|
|
|
|
|
$(".addno-panel").hide();
|
|
|
|
|
$(this).siblings(".addno-panel").show();
|
|
|
|
|
$(".addanno").find("i").removeClass("color-dark-57").addClass("color-grey-c");
|
|
|
|
|
$(this).find("i").removeClass("color-grey-c").addClass("color-dark-57");
|
2018-08-23 22:53:27 +08:00
|
|
|
|
ev = window.event;
|
|
|
|
|
if(ev==undefined){
|
|
|
|
|
ev=arguments.callee.caller.arguments[0]||window.event;
|
|
|
|
|
}
|
|
|
|
|
ev.stopPropagation();
|
2018-07-15 10:09:43 +08:00
|
|
|
|
})
|
|
|
|
|
|
2018-07-31 10:46:48 +08:00
|
|
|
|
$("body").click(function (event) {
|
2018-07-15 10:09:43 +08:00
|
|
|
|
//隐藏添加注释或者问题的弹框
|
2018-07-31 10:46:48 +08:00
|
|
|
|
$(".addno-panel").hide();
|
2018-07-15 10:09:43 +08:00
|
|
|
|
$(".source-addno-panel").remove();
|
2018-07-31 10:46:48 +08:00
|
|
|
|
$(".addanno").find("i").removeClass("color-dark-57").addClass("color-grey-c");
|
2018-07-15 10:09:43 +08:00
|
|
|
|
//隐藏评论弹框
|
|
|
|
|
if($(event.target).parents("#ItemcommentPanel").length == 0){
|
|
|
|
|
$("#ItemcommentPanel").hide();
|
|
|
|
|
$("#ItemcommentPanel").remove();
|
|
|
|
|
}
|
|
|
|
|
//隐藏问题弹框
|
|
|
|
|
if($(event.target).parents("#ItemquestionPanel").length == 0){
|
|
|
|
|
$("#ItemquestionPanel").hide();
|
|
|
|
|
$("#ItemquestionPanel").remove();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
$("body").on('click', '.addno-panel', function(e) {
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("#ItemcommentPanel").on('click', '#commentPanel', function (e) {
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("#loadQuestionpanel").on('click', '#questionPanel', function (e) {
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//隐藏问题框
|
|
|
|
|
$("#loadQuestionpanel").click(function (event) {
|
|
|
|
|
$("#loadQuestionpanel").hide();
|
|
|
|
|
})
|
|
|
|
|
//点击问题框里的内容,阻止冒泡
|
|
|
|
|
$("#questionPanel").click(function (event) {
|
2018-08-23 22:53:27 +08:00
|
|
|
|
ev = window.event;
|
|
|
|
|
if(ev==undefined){
|
|
|
|
|
ev=arguments.callee.caller.arguments[0]||window.event;
|
|
|
|
|
}
|
|
|
|
|
ev.stopPropagation();
|
2018-07-15 10:09:43 +08:00
|
|
|
|
})
|
|
|
|
|
})
|
2018-09-15 13:18:37 +08:00
|
|
|
|
function addcomments(item,annopk) {
|
|
|
|
|
var annopkid= Number(getlocalStorage("writetext_id"));
|
|
|
|
|
var writetext_value= getlocalStorage("writetext_value")
|
2018-07-15 10:09:43 +08:00
|
|
|
|
$(item).siblings(".comment-write").removeClass("none");
|
|
|
|
|
$(item).addClass("none");
|
2018-07-18 23:27:40 +08:00
|
|
|
|
ev = window.event;
|
2018-08-23 22:53:27 +08:00
|
|
|
|
if(ev==undefined){
|
|
|
|
|
ev=arguments.callee.caller.arguments[0]||window.event;
|
|
|
|
|
}
|
2018-07-15 10:09:43 +08:00
|
|
|
|
ev.stopPropagation();
|
2018-09-15 13:18:37 +08:00
|
|
|
|
if(annopk===annopkid){
|
|
|
|
|
$("#writetext_"+annopkid).val(writetext_value);
|
|
|
|
|
}
|
2018-07-15 10:09:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function cancelcom(item) {
|
|
|
|
|
$(item).parents(".comment-write").siblings("#addcom").removeClass("none");
|
|
|
|
|
$(item).parents(".comment-write").addClass("none");
|
2018-07-18 23:27:40 +08:00
|
|
|
|
ev = window.event;
|
2018-08-23 22:53:27 +08:00
|
|
|
|
if(ev==undefined){
|
|
|
|
|
ev=arguments.callee.caller.arguments[0]||window.event;
|
|
|
|
|
}
|
2018-07-15 10:09:43 +08:00
|
|
|
|
ev.stopPropagation();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//隐藏右侧部分
|
|
|
|
|
function colserightpanel() {
|
|
|
|
|
if (flag) {
|
|
|
|
|
$(".codereading").css("width", "80%");
|
|
|
|
|
} else {
|
|
|
|
|
var rightwid = $(".right").width();
|
|
|
|
|
var codewid = $(".codereading").width();
|
|
|
|
|
$(".codereading").css("width", parseInt(codewid) + parseInt(rightwid));
|
|
|
|
|
}
|
|
|
|
|
$(".right").addClass("none");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function mouseCoords(ev) {
|
|
|
|
|
if (ev.pageX || ev.pageY) {
|
|
|
|
|
return {
|
|
|
|
|
x: ev.pageX,
|
|
|
|
|
y: ev.pageY
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return {
|
|
|
|
|
x: ev.clientX + document.body.scrollLeft - document.body.clientLeft,
|
|
|
|
|
y: ev.clientY + document.body.scrollTop - document.body.clientTop
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var tabSet = new Set();
|
2018-08-07 15:15:10 +08:00
|
|
|
|
// var issue_map = new Map();
|
|
|
|
|
var right_map = new Map();
|
|
|
|
|
var tree_nodes = new Map();
|
2018-07-15 10:09:43 +08:00
|
|
|
|
|
|
|
|
|
function path_predeal(path){
|
|
|
|
|
// path = path.replace('.', '');
|
|
|
|
|
// path = path.replace('/', '_');
|
|
|
|
|
path = path.split('.').join('');
|
|
|
|
|
path = path.split('/').join('_');
|
|
|
|
|
return path;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-05 14:06:54 +08:00
|
|
|
|
function url_deal(path,archor){
|
2018-08-15 00:48:23 +08:00
|
|
|
|
var projectName= $("#projectName").text();
|
2018-09-05 14:06:54 +08:00
|
|
|
|
var ip=window.location.host; //端口号
|
2018-08-15 00:48:23 +08:00
|
|
|
|
var newhtefpath = "/projects/"+projectName+path;
|
|
|
|
|
var stateObject = {};
|
2018-08-27 17:03:33 +08:00
|
|
|
|
if(path==""){
|
|
|
|
|
newhtefpath += "/";
|
|
|
|
|
}
|
2018-08-15 00:48:23 +08:00
|
|
|
|
//修改地址栏中的地址
|
|
|
|
|
history.pushState(stateObject, ip, newhtefpath);
|
2018-09-05 14:06:54 +08:00
|
|
|
|
if(archor!=null){
|
|
|
|
|
location.href=archor
|
|
|
|
|
// history.replaceState(null,null,location.href);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 打开一个已经存在的标签页
|
|
|
|
|
// 注意这个还得将对应的路径更改了
|
|
|
|
|
function open_tab(path,archor) {
|
2018-09-16 23:05:14 +08:00
|
|
|
|
try{
|
2018-09-05 14:06:54 +08:00
|
|
|
|
// console.log(window.location.pathname); 端口号后面的路径
|
2018-09-16 23:05:14 +08:00
|
|
|
|
path_input=path
|
|
|
|
|
path = path_predeal(path)
|
2018-07-15 10:09:43 +08:00
|
|
|
|
|
2018-09-16 23:05:14 +08:00
|
|
|
|
$('#jstree').jstree("deselect_all", true);
|
|
|
|
|
$('#jstree').jstree("select_node", tree_nodes[path]);
|
2018-08-07 15:15:10 +08:00
|
|
|
|
|
2018-09-16 23:05:14 +08:00
|
|
|
|
var tabcontent = document.getElementsByClassName("codereading");
|
|
|
|
|
for (var i = 0; i < tabcontent.length; i++) {
|
|
|
|
|
tabcontent[i].style.display = "none";
|
|
|
|
|
}
|
2018-07-15 10:09:43 +08:00
|
|
|
|
|
2018-09-16 23:05:14 +08:00
|
|
|
|
var tab_items = document.getElementsByClassName("tab_item");
|
|
|
|
|
for (var i = 0; i < tab_items.length; i++) {
|
|
|
|
|
// debugger;
|
|
|
|
|
tab_items[i].className = tab_items[i].className.replace(" active", "");
|
|
|
|
|
}
|
2018-07-15 10:09:43 +08:00
|
|
|
|
|
2018-09-16 23:05:14 +08:00
|
|
|
|
document.getElementById("code_" + path).style.display = "block";
|
|
|
|
|
document.getElementById("tab_" + path).style.display = "block";
|
|
|
|
|
document.getElementById("tab_" + path).className += " active";
|
2018-07-15 10:09:43 +08:00
|
|
|
|
|
2018-09-16 23:05:14 +08:00
|
|
|
|
url_deal(path_input,archor)
|
2018-09-05 14:06:54 +08:00
|
|
|
|
|
2018-09-16 23:05:14 +08:00
|
|
|
|
document.getElementsByClassName("filename")[0].innerHTML = path_input;
|
|
|
|
|
|
|
|
|
|
if((path in right_map)){
|
|
|
|
|
$("#right_panel").html(right_map[path]);
|
|
|
|
|
}
|
2018-08-07 15:15:10 +08:00
|
|
|
|
|
2018-09-16 23:05:14 +08:00
|
|
|
|
// if(!issue_map.has(path)){
|
|
|
|
|
// window.setTimeout(function () { $("#hotest_issue").html(issue_map[path]) }, 3000);
|
|
|
|
|
// }else{
|
|
|
|
|
// $("#hotest_issue").html(issue_map[path]);
|
|
|
|
|
// }
|
|
|
|
|
show_navigation();
|
|
|
|
|
}catch(error) {
|
2018-09-18 13:47:22 +08:00
|
|
|
|
console.log(error);
|
2018-09-16 23:05:14 +08:00
|
|
|
|
// expected output: SyntaxError: unterminated string literal
|
|
|
|
|
// Note - error messages will vary depending on browser
|
2018-07-15 10:09:43 +08:00
|
|
|
|
}
|
2018-09-16 23:05:14 +08:00
|
|
|
|
|
2018-08-07 15:15:10 +08:00
|
|
|
|
|
2018-07-15 10:09:43 +08:00
|
|
|
|
}
|
2018-08-19 19:35:33 +08:00
|
|
|
|
|
2018-08-20 13:44:14 +08:00
|
|
|
|
function generate_codereading_content(lines,self_annos,fileid,annos_count,issues_count,questions_count,issues,language){
|
2018-08-19 19:35:33 +08:00
|
|
|
|
var htmlstr = '<div class="code_file">'
|
|
|
|
|
for(linenum in lines){
|
|
|
|
|
line = lines[linenum]
|
|
|
|
|
// 如果当前行有注释,则先生成注释行
|
|
|
|
|
if(linenum in self_annos){
|
2018-08-26 12:35:10 +08:00
|
|
|
|
htmlstr += generate_codereading_anno_line(fileid,linenum,self_annos)
|
2018-08-19 19:35:33 +08:00
|
|
|
|
}
|
|
|
|
|
// 无论当前行是否有注释,都应该生成代码行
|
2018-08-20 13:44:14 +08:00
|
|
|
|
htmlstr += generate_codereading_line(fileid,linenum,annos_count,issues_count,questions_count,line,issues,language)
|
2018-08-19 19:35:33 +08:00
|
|
|
|
}
|
|
|
|
|
htmlstr += '</div>'
|
|
|
|
|
return htmlstr
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-26 12:35:10 +08:00
|
|
|
|
function generate_codereading_anno_line(file_id,linenum,self_annos){
|
2018-08-19 19:35:33 +08:00
|
|
|
|
var htmlstr = ''
|
2018-08-20 16:18:53 +08:00
|
|
|
|
htmlstr += '<div class="newcodeline newcodelinebox">'
|
2018-08-19 19:35:33 +08:00
|
|
|
|
htmlstr += '<div class="sourcecode">'
|
2018-09-21 09:44:38 +08:00
|
|
|
|
htmlstr += '<div class="mypre mypre newmypre hljs-comment '+file_id+linenum+' ">'
|
2018-08-19 19:35:33 +08:00
|
|
|
|
htmlstr += self_annos[linenum]
|
2018-09-21 09:44:38 +08:00
|
|
|
|
htmlstr += '</div >'
|
2018-08-19 19:35:33 +08:00
|
|
|
|
htmlstr += '</div>'
|
|
|
|
|
htmlstr += '<div class="linestatus"></div>'
|
|
|
|
|
htmlstr += '</div>'
|
|
|
|
|
return htmlstr
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-20 13:44:14 +08:00
|
|
|
|
function generate_codereading_line(fileid,linenum,annos_count,issues_count,questions_count,line,issues,language){
|
2018-08-19 21:30:41 +08:00
|
|
|
|
var htmlstr = '<div id="'+fileid+'_L'+linenum+'" class="codeline codelinebox" onmouseover="show_currentLine(\''+fileid+'_'+linenum+'\')" onmouseout="hide_currentLine(\''+fileid+'_'+linenum+'\')">'
|
2018-09-03 21:01:58 +08:00
|
|
|
|
htmlstr += generate_codereading_linenum_and_codeline(linenum,line,language,fileid)
|
2018-08-19 21:30:41 +08:00
|
|
|
|
htmlstr += generate_codereading_linestatus(fileid,linenum,annos_count,issues_count,questions_count,issues)
|
2018-08-19 19:35:33 +08:00
|
|
|
|
htmlstr += '</div>'
|
|
|
|
|
return htmlstr
|
2018-09-04 15:16:57 +08:00
|
|
|
|
}
|
2018-09-03 21:01:58 +08:00
|
|
|
|
|
2018-09-05 16:32:40 +08:00
|
|
|
|
function add_hrefTag_into_line(line,file_id,line_num){
|
2018-09-03 21:01:58 +08:00
|
|
|
|
var regex = /\w+\(/g
|
|
|
|
|
var strs = line.match(regex)
|
|
|
|
|
if(strs!=null){
|
|
|
|
|
for(var i=0;i<strs.length;i++){
|
|
|
|
|
function_name = strs[i].substring(0,strs[i].length-1)
|
2018-09-05 16:32:40 +08:00
|
|
|
|
var search_symbol_str = '<text onclick="search_symbol(\'file_id='+String(file_id)+"&defs="+String(function_name)+'\','+String(line_num)+',\''+String(function_name)+'\')">'+function_name+"</text>"
|
2018-09-03 21:01:58 +08:00
|
|
|
|
var replace_str = '<a href="javascript:void(0)">'+search_symbol_str+'</a>('
|
|
|
|
|
line=line.replace(strs[i],replace_str)
|
|
|
|
|
}
|
2018-09-04 15:16:57 +08:00
|
|
|
|
|
2018-09-03 21:01:58 +08:00
|
|
|
|
return line
|
|
|
|
|
}
|
|
|
|
|
return line
|
2018-08-19 19:35:33 +08:00
|
|
|
|
}
|
2018-09-04 15:16:57 +08:00
|
|
|
|
|
2018-08-19 19:35:33 +08:00
|
|
|
|
|
2018-09-03 21:01:58 +08:00
|
|
|
|
function generate_codereading_linenum_and_codeline(linenum,line,language,file_id){
|
2018-09-05 16:32:40 +08:00
|
|
|
|
var line= add_hrefTag_into_line(line,file_id,linenum)
|
2018-09-04 15:16:57 +08:00
|
|
|
|
var htmlstr = ''
|
2018-08-19 19:35:33 +08:00
|
|
|
|
htmlstr += '<div class="linenum">'
|
|
|
|
|
htmlstr += linenum.toString()
|
|
|
|
|
htmlstr += '</div>'
|
|
|
|
|
htmlstr += '<div class="sourcecode">'
|
2018-08-20 13:44:14 +08:00
|
|
|
|
htmlstr += '<pre class="mypre" style="">'
|
|
|
|
|
htmlstr += '<code class="'+language+' mypre">'
|
2018-08-19 19:35:33 +08:00
|
|
|
|
htmlstr += line
|
2018-08-20 13:44:14 +08:00
|
|
|
|
htmlstr += '</code>'
|
2018-08-19 19:35:33 +08:00
|
|
|
|
htmlstr += '</pre>'
|
|
|
|
|
htmlstr += '</div>'
|
|
|
|
|
return htmlstr
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-21 08:56:56 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function newshow_currentLine(fileid,linenum){
|
|
|
|
|
$("#"+fileid+"_L"+linenum+">"+".sourcecode").css("background","#323438");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function newhide_currentLine(fileid,linenum){
|
|
|
|
|
$("#"+fileid+"_L"+linenum+">"+".sourcecode").css("background","#23241f");
|
|
|
|
|
}
|
2018-08-19 21:30:41 +08:00
|
|
|
|
function generate_codereading_linestatus(fileid,linenum,annos_count,issues_count,questions_count,issues){
|
2018-09-04 15:16:57 +08:00
|
|
|
|
var htmlstr = ''
|
|
|
|
|
|
2018-09-21 08:56:56 +08:00
|
|
|
|
htmlstr += '<div id="linestatus_'+fileid+'_'+linenum+'" class="linestatus" onmouseover="newshow_currentLine('+fileid+','+linenum+')" onmouseout="newhide_currentLine('+fileid+','+linenum+')">'
|
2018-08-19 19:35:33 +08:00
|
|
|
|
htmlstr += '<span class="codeopration" id="codeopration_anno_'+fileid+'_'+linenum+'">'
|
|
|
|
|
if(linenum in annos_count){
|
|
|
|
|
htmlstr += '<span class="annonums" onclick="show_annotation('+fileid+','+linenum+')"></span>'
|
2018-09-04 15:16:57 +08:00
|
|
|
|
}
|
|
|
|
|
htmlstr += '</span>'
|
2018-08-19 19:35:33 +08:00
|
|
|
|
htmlstr += '<span class="codeopration" id="codeopration_question_'+fileid+'_'+linenum+'">'
|
2018-08-19 21:30:41 +08:00
|
|
|
|
if(linenum in questions_count){
|
2018-08-19 19:35:33 +08:00
|
|
|
|
htmlstr += '<span class="questionnums" onclick="show_issue_question('+fileid+','+linenum+',\'[]\')"></span>'
|
|
|
|
|
}
|
2018-08-19 21:30:41 +08:00
|
|
|
|
else if(linenum in issues_count){
|
|
|
|
|
htmlstr += '<span class="questionnums" onclick="show_issue_question('+fileid+','+linenum+',\'['+issues[linenum]+']\')"></span>'
|
|
|
|
|
}
|
2018-09-04 15:16:57 +08:00
|
|
|
|
htmlstr += '</span>'
|
2018-08-19 19:35:33 +08:00
|
|
|
|
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">'
|
2018-09-04 15:16:57 +08:00
|
|
|
|
htmlstr += '</span>'
|
2018-08-19 19:35:33 +08:00
|
|
|
|
htmlstr += '</div>'
|
2018-09-04 15:16:57 +08:00
|
|
|
|
return htmlstr
|
2018-09-21 08:56:56 +08:00
|
|
|
|
|
|
|
|
|
// onmouseover="show_currentLine(\''+fileid+'_'+linenum+'\')" onmouseout="hide_currentLine(\''+fileid+'_'+linenum+'\')"
|
2018-08-19 19:35:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-15 10:09:43 +08:00
|
|
|
|
// 添加一个新的标签页,
|
|
|
|
|
// 如果标签页不存在,则创建一个新的标签页,然后调用open_tab
|
|
|
|
|
// 如果标签页已经存在,则打开对应的标签页
|
|
|
|
|
// 并调用open_tab
|
2018-09-05 14:06:54 +08:00
|
|
|
|
function get_path_link_and_archor(path){
|
|
|
|
|
tmp_index = path.indexOf("#");
|
|
|
|
|
if(tmp_index != -1){
|
|
|
|
|
path_after = path.substring(0,tmp_index)
|
|
|
|
|
archor = path.substring(tmp_index)
|
|
|
|
|
return [path_after,archor]
|
|
|
|
|
}
|
|
|
|
|
return [path,null]
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-15 10:09:43 +08:00
|
|
|
|
function add_tab(project_id,path,filename) {
|
2018-09-04 15:16:57 +08:00
|
|
|
|
|
2018-08-27 22:10:55 +08:00
|
|
|
|
// var tree_node = $("#jstree").jstree("get_selected");
|
2018-07-31 10:46:48 +08:00
|
|
|
|
var path_before = path
|
2018-09-27 10:47:50 +08:00
|
|
|
|
|
2018-09-05 14:06:54 +08:00
|
|
|
|
var returnValue = get_path_link_and_archor(path)
|
2018-09-27 10:47:50 +08:00
|
|
|
|
// 正常应该得到的path为normal path
|
|
|
|
|
var normal_path = returnValue[0]
|
2018-09-05 14:06:54 +08:00
|
|
|
|
var archor = returnValue[1]
|
2018-07-15 10:09:43 +08:00
|
|
|
|
|
2018-09-27 10:47:50 +08:00
|
|
|
|
path = path_predeal(normal_path)
|
2018-07-15 10:09:43 +08:00
|
|
|
|
if (tabSet.has(path)) {
|
2018-09-27 10:47:50 +08:00
|
|
|
|
open_tab(normal_path,archor)
|
2018-07-15 10:09:43 +08:00
|
|
|
|
} else {
|
|
|
|
|
var tab_tag = document.getElementsByClassName("tab_head")[0];
|
|
|
|
|
//添加tab
|
|
|
|
|
/*<li class="tab_item" id="tab_src_net_micode_notes_widget_NoteWidgetProvider">
|
|
|
|
|
<a href="javascript:void(0)" onclick="open_tab('src_net_micode_notes_widget_NoteWidgetProvider')">NoteWidgetProvider.java</a>
|
|
|
|
|
<a href="javascript:void(0)" onclick="close_tab('src_net_micode_notes_widget_NoteWidgetProvider')">×</a>
|
|
|
|
|
</li> */
|
|
|
|
|
var li_tab_item = document.createElement("li")
|
|
|
|
|
li_tab_item.className = "tab_item";
|
|
|
|
|
li_tab_item.id = "tab_" + path;
|
|
|
|
|
|
|
|
|
|
var tag_a1 = document.createElement("a");
|
|
|
|
|
tag_a1.href ="javascript:void(0)";
|
2018-07-31 10:46:48 +08:00
|
|
|
|
|
|
|
|
|
// filename也要进行判断
|
|
|
|
|
tmp_index = filename.indexOf("#");
|
|
|
|
|
if(tmp_index != -1){
|
|
|
|
|
filename = filename.substring(0,tmp_index)
|
|
|
|
|
}
|
2018-07-15 10:09:43 +08:00
|
|
|
|
tag_a1.textContent = filename
|
|
|
|
|
tag_a1.onclick = (function () {
|
|
|
|
|
return function () {
|
2018-09-27 10:47:50 +08:00
|
|
|
|
open_tab(normal_path,null);
|
2018-07-15 10:09:43 +08:00
|
|
|
|
}
|
|
|
|
|
})();
|
2018-07-31 10:46:48 +08:00
|
|
|
|
|
2018-07-15 10:09:43 +08:00
|
|
|
|
var tag_a2 = document.createElement("a")
|
|
|
|
|
tag_a2.href = "javascript:void(0)";
|
2018-07-31 10:46:48 +08:00
|
|
|
|
tag_a2.textContent = '×'
|
2018-07-15 10:09:43 +08:00
|
|
|
|
tag_a2.onclick = (function () {
|
|
|
|
|
return function () {
|
2018-09-27 10:47:50 +08:00
|
|
|
|
close_tab(normal_path);
|
2018-07-15 10:09:43 +08:00
|
|
|
|
}
|
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
li_tab_item.appendChild(tag_a1)
|
|
|
|
|
li_tab_item.appendChild(tag_a2)
|
|
|
|
|
tab_tag.appendChild(li_tab_item)
|
|
|
|
|
|
|
|
|
|
// 添加对应的code-reading的Element
|
|
|
|
|
var div_code = document.getElementsByClassName("code_Area")[0]
|
|
|
|
|
var div_codereading = document.createElement("div")
|
|
|
|
|
|
|
|
|
|
div_codereading.id = "code_" + path;
|
|
|
|
|
div_codereading.className = "codereading";
|
2018-09-18 09:42:31 +08:00
|
|
|
|
// div_codereading.style.overflowY="auto";
|
2018-07-15 10:09:43 +08:00
|
|
|
|
div_code.appendChild(div_codereading)
|
|
|
|
|
|
2018-09-17 16:36:01 +08:00
|
|
|
|
$.ajax({
|
|
|
|
|
cache: false,
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: '/operations/right/',
|
2018-09-27 10:47:50 +08:00
|
|
|
|
data: { 'project_id': project_id, 'path': normal_path},
|
2018-09-17 16:36:01 +08:00
|
|
|
|
dataType: 'json',
|
|
|
|
|
async: true,
|
|
|
|
|
beforeSend: function (xhr, settings) {
|
|
|
|
|
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
|
|
|
|
},
|
|
|
|
|
success: function (data) {
|
|
|
|
|
if (data.status === 'success') {
|
|
|
|
|
right_map[path] = data.html_str;
|
|
|
|
|
$("#right_panel").html(right_map[path]);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
right_map[path] = ""
|
|
|
|
|
}
|
2018-09-25 15:07:59 +08:00
|
|
|
|
},error:function(jqXHR, textStatus, errorThrown){
|
|
|
|
|
if(jqXHR.readyState===0&&jqXHR.status===0){
|
|
|
|
|
alert('网络故障,提交失败!请联网后重新提交');
|
|
|
|
|
}
|
2018-09-17 16:36:01 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
2018-07-15 10:09:43 +08:00
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
cache: false,
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: '/operations/get_codereading_content/',
|
2018-09-27 10:47:50 +08:00
|
|
|
|
data: { 'project_id': project_id, 'path': normal_path },
|
2018-07-15 10:09:43 +08:00
|
|
|
|
dataType: 'json',
|
|
|
|
|
async: true,
|
|
|
|
|
beforeSend: function (xhr, settings) {
|
|
|
|
|
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
success: function (data) {
|
|
|
|
|
if (data.status === 'success') {
|
|
|
|
|
// 获取code-reading的内容,并填充到对应的code-reading的Element
|
2018-07-18 23:27:40 +08:00
|
|
|
|
|
|
|
|
|
if(data.is_dir=="0"){
|
2018-08-20 13:44:14 +08:00
|
|
|
|
var content = generate_codereading_content(data.lines,data.self_annos,data.fileid,data.annos_count,data.issues_count,data.questions_count,data.issues,data.language)
|
2018-08-19 19:35:33 +08:00
|
|
|
|
div_codereading.innerHTML = content;
|
2018-09-27 10:47:50 +08:00
|
|
|
|
open_tab(normal_path,archor);
|
2018-09-16 21:03:36 +08:00
|
|
|
|
|
2018-07-18 23:27:40 +08:00
|
|
|
|
hljs.configure({useBR: false});
|
2018-08-20 13:44:14 +08:00
|
|
|
|
// hljs.highlightBlock(div_codereading)
|
|
|
|
|
$('#code_'+path+' pre code').each(function(i, block) {
|
|
|
|
|
hljs.highlightBlock(block);
|
|
|
|
|
});
|
2018-07-18 23:27:40 +08:00
|
|
|
|
// .each(function(i, block) {
|
|
|
|
|
// hljs.highlightBlock(block);
|
|
|
|
|
// });
|
2018-08-19 19:35:33 +08:00
|
|
|
|
}else{
|
|
|
|
|
var content = data.html_str
|
|
|
|
|
div_codereading.innerHTML = content;
|
2018-09-27 10:47:50 +08:00
|
|
|
|
open_tab(normal_path,archor);
|
2018-07-18 23:27:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-31 10:46:48 +08:00
|
|
|
|
// 如果包含#
|
|
|
|
|
// tmp_index = path_before.indexOf("#");
|
|
|
|
|
// if(tmp_index != -1){
|
|
|
|
|
// var hash = path_before.substring(tmp_index)
|
|
|
|
|
// }
|
|
|
|
|
// console.log(hash)
|
|
|
|
|
// location.hash=hash
|
2018-07-15 10:09:43 +08:00
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
div_codereading.innerHTML = "";
|
|
|
|
|
}
|
2018-09-25 15:07:59 +08:00
|
|
|
|
},error:function(jqXHR, textStatus, errorThrown){
|
|
|
|
|
if(jqXHR.readyState===0&&jqXHR.status===0){
|
|
|
|
|
alert('网络故障,提交失败!请联网后重新提交');
|
|
|
|
|
}
|
2018-07-15 10:09:43 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
2018-07-18 21:07:03 +08:00
|
|
|
|
|
2018-09-27 10:47:50 +08:00
|
|
|
|
open_tab(normal_path,archor);
|
2018-09-16 21:03:36 +08:00
|
|
|
|
|
2018-08-07 15:15:10 +08:00
|
|
|
|
// 现在Hotest Question 模块先不用了
|
|
|
|
|
// // 填充hotest_question
|
|
|
|
|
// $.ajax({
|
|
|
|
|
// cache: false,
|
|
|
|
|
// type: "POST",
|
|
|
|
|
// url: '/operations/get_hotest_issues/',
|
2018-09-27 10:47:50 +08:00
|
|
|
|
// data: { 'project_id': project_id, 'path': normal_path,"question_num":5 },
|
2018-08-07 15:15:10 +08:00
|
|
|
|
// dataType: 'json',
|
|
|
|
|
// async: true,
|
|
|
|
|
// beforeSend: function (xhr, settings) {
|
|
|
|
|
// xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
|
|
|
|
// },
|
|
|
|
|
// success: function (data) {
|
|
|
|
|
// if (data.status === 'success') {
|
|
|
|
|
// issue_map[path] = data.html_str;
|
|
|
|
|
// }
|
|
|
|
|
// else {
|
|
|
|
|
// issue_map[path] = ""
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// });
|
2018-07-31 10:46:48 +08:00
|
|
|
|
|
2018-09-27 10:47:50 +08:00
|
|
|
|
highlight_jstree_node(project_id,normal_path);
|
2018-08-30 16:50:30 +08:00
|
|
|
|
|
2018-07-15 10:09:43 +08:00
|
|
|
|
tabSet.add(path);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-09-27 10:47:50 +08:00
|
|
|
|
|
|
|
|
|
function highlight_jstree_node(project_id,path_after){
|
|
|
|
|
path = path_predeal(path_after)
|
|
|
|
|
$.ajax({
|
|
|
|
|
cache: false,
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: '/operations/get_jstree_id/',
|
|
|
|
|
data: { 'project_id': project_id, 'path': path_after},
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
async: true,
|
|
|
|
|
beforeSend: function (xhr, settings) {
|
|
|
|
|
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
|
|
|
|
},
|
|
|
|
|
success: function (data) {
|
|
|
|
|
if (data.status === 'success') {
|
|
|
|
|
var tree_node = data.jstree_id
|
|
|
|
|
tree_nodes[path]=tree_node
|
|
|
|
|
$('#jstree').jstree("deselect_all", true);
|
|
|
|
|
$('#jstree').jstree("select_node", tree_nodes[path]);
|
2018-09-27 23:37:06 +08:00
|
|
|
|
// location.href="#"+tree_node
|
2018-09-27 10:47:50 +08:00
|
|
|
|
}
|
|
|
|
|
},error:function(jqXHR, textStatus, errorThrown){
|
|
|
|
|
if(jqXHR.readyState===0&&jqXHR.status===0){
|
|
|
|
|
alert('网络故障,提交失败!请联网后重新提交');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2018-07-15 10:09:43 +08:00
|
|
|
|
// 这里也可以更改为item,传入this
|
|
|
|
|
function close_tab(path) {
|
|
|
|
|
// 将当前的当前Element的父节点isplay:none
|
|
|
|
|
// 将对应的code-reading区域设置为display:none
|
|
|
|
|
path = path_predeal(path)
|
|
|
|
|
|
|
|
|
|
var element = document.getElementById("tab_" + path);
|
|
|
|
|
var previosuElement = element.previousElementSibling;
|
|
|
|
|
var nextElement = element.nextElementSibling;
|
|
|
|
|
|
|
|
|
|
document.getElementById("code_" + path).remove()
|
|
|
|
|
element.remove()
|
|
|
|
|
tabSet.delete(path)
|
|
|
|
|
|
|
|
|
|
// 如果该标签页有上一个标签,将此标签的上一个标签页打开
|
|
|
|
|
if (previosuElement != undefined) {
|
|
|
|
|
var path = previosuElement.id.substr(4);
|
2018-09-05 14:06:54 +08:00
|
|
|
|
open_tab(path,null)
|
2018-07-15 10:09:43 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 如果该标签页有下一个兄弟标签,将此标签的下一个标签页打开
|
|
|
|
|
if (nextElement != undefined) {
|
|
|
|
|
var path = nextElement.id.substr(4);
|
2018-09-05 14:06:54 +08:00
|
|
|
|
open_tab(path,null);
|
2018-07-15 10:09:43 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 对应目录级别的addnoPanel
|
|
|
|
|
function show_next_addnoPanel(file_id){
|
2018-09-15 13:18:37 +08:00
|
|
|
|
|
|
|
|
|
var oldfile_id= Number(getlocalStorage("rightannotationid"));
|
|
|
|
|
var olditem_value=getlocalStorage("rightannotationvalue");
|
|
|
|
|
|
2018-07-15 10:09:43 +08:00
|
|
|
|
$("#addno-panel-"+file_id).show();
|
2018-08-23 22:53:27 +08:00
|
|
|
|
ev = window.event;
|
|
|
|
|
if(ev==undefined){
|
|
|
|
|
ev=arguments.callee.caller.arguments[0]||window.event;
|
|
|
|
|
}
|
2018-09-15 13:18:37 +08:00
|
|
|
|
ev.stopPropagation()
|
|
|
|
|
|
|
|
|
|
if(file_id===oldfile_id){
|
|
|
|
|
$("#addno-text-"+file_id+"-0").val(olditem_value);
|
|
|
|
|
}
|
2018-09-20 18:25:36 +08:00
|
|
|
|
$("#addno-panel-"+file_id).draggable();
|
2018-09-15 13:18:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Input_Content(item,file_id,line_num) {
|
|
|
|
|
var status_value= getlocalStorage("status_value");
|
2018-09-17 18:43:47 +08:00
|
|
|
|
if(status_value==="注释"||!status_value){
|
2018-09-15 13:18:37 +08:00
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-15 10:09:43 +08:00
|
|
|
|
}
|
2018-09-15 13:18:37 +08:00
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-15 10:09:43 +08:00
|
|
|
|
|
2018-09-15 13:18:37 +08:00
|
|
|
|
}
|
|
|
|
|
function rightaddannotation(id,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) {
|
|
|
|
|
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");
|
2018-09-17 18:43:47 +08:00
|
|
|
|
if(status_value==="注释"||!status_value){
|
2018-09-15 13:18:37 +08:00
|
|
|
|
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);
|
|
|
|
|
}
|
2018-07-17 22:06:28 +08:00
|
|
|
|
|
2018-09-15 13:18:37 +08:00
|
|
|
|
}
|
2018-07-15 10:09:43 +08:00
|
|
|
|
//注入html代码
|
|
|
|
|
function inject_addnoPanel_html(item,file_id,linenum) {
|
2018-09-18 09:42:31 +08:00
|
|
|
|
$(".source-addno-panel").remove();
|
2018-09-15 13:18:37 +08:00
|
|
|
|
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");
|
|
|
|
|
|
|
|
|
|
|
2018-07-15 10:09:43 +08:00
|
|
|
|
$("#ItemcommentPanel").remove();
|
|
|
|
|
$("#ItemquestionPanel").remove();
|
2018-07-31 10:46:48 +08:00
|
|
|
|
|
2018-09-20 18:25:36 +08:00
|
|
|
|
html_str = '<div class="addno-panel source-addno-panel" id="addno-panelsource-addno-panel" style="display:block">'+
|
2018-07-15 10:09:43 +08:00
|
|
|
|
'<div class="trangle-op"></div>'+
|
|
|
|
|
'<div class="put-content">'+
|
2018-09-27 09:07:39 +08:00
|
|
|
|
'<div class="put-content newput-selectspanactive">为该行或该代码块添加注释或者提问:</div>'+
|
2018-07-15 10:09:43 +08:00
|
|
|
|
'<p class="put-select clearfix" id="addno-select-'+linenum+'">'+
|
2018-09-15 13:18:37 +08:00
|
|
|
|
'<span class="active put-selectspanactive" onclick=\'$(this).siblings("span").removeClass("active");$(this).addClass("active");addannotation('+file_id+','+linenum+');\'>注释</span>'+
|
|
|
|
|
'<span class="put-selectspanactive" onclick=\'$(this).siblings("span").removeClass("active"); $(this).addClass("active");addissue('+file_id+','+linenum+');\'>问题</span>'+
|
2018-07-15 10:09:43 +08:00
|
|
|
|
'</p>'+
|
2018-09-15 13:18:37 +08:00
|
|
|
|
'<textarea id="addno-text-'+file_id+'-'+linenum+'" oninput="Input_Content(this,'+file_id+','+linenum+')" class="put-text" placeholder="输入注释或者问题"> </textarea>'+
|
2018-09-21 19:43:16 +08:00
|
|
|
|
'<a href="javascript:void(0)" onclick="add_annotation(this,'+file_id+','+linenum+')" class="btn btn-blue submit fr" id="submit">提交</a>'+
|
2018-07-15 10:09:43 +08:00
|
|
|
|
'</div>'+
|
|
|
|
|
'</div>';
|
|
|
|
|
$(item).after(html_str)
|
2018-07-18 23:27:40 +08:00
|
|
|
|
ev = window.event;
|
2018-08-23 22:53:27 +08:00
|
|
|
|
if(ev==undefined){
|
|
|
|
|
ev=arguments.callee.caller.arguments[0]||window.event;
|
|
|
|
|
}
|
2018-07-15 10:09:43 +08:00
|
|
|
|
ev.stopPropagation();
|
2018-09-15 13:18:37 +08:00
|
|
|
|
if(file_id===oldfile_id&&linenum===oldline_num){
|
|
|
|
|
$("#addno-text-"+file_id+"-"+linenum).val(olditem_value);
|
|
|
|
|
}
|
2018-09-20 18:25:36 +08:00
|
|
|
|
$( "#addno-panelsource-addno-panel" ).draggable();
|
2018-07-31 10:46:48 +08:00
|
|
|
|
}
|
2018-07-15 10:09:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function add_dir_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();
|
|
|
|
|
|
|
|
|
|
if (content.trim().length == 0) {
|
|
|
|
|
alert("内容不能为空")
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (selectValue == "注释") {
|
|
|
|
|
// 向addAnnatation中发请求
|
2018-08-07 23:00:10 +08:00
|
|
|
|
submit_dir_annotation(file_id, line_num, content);
|
2018-07-15 10:09:43 +08:00
|
|
|
|
} else {
|
2018-08-07 23:00:10 +08:00
|
|
|
|
submit_dir_question(file_id, line_num, content);
|
2018-07-15 10:09:43 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-07 15:15:10 +08:00
|
|
|
|
function show_dir_annotation(file_id){
|
|
|
|
|
ev = window.event;
|
2018-08-23 22:53:27 +08:00
|
|
|
|
if(ev==undefined){
|
|
|
|
|
ev=arguments.callee.caller.arguments[0]||window.event;
|
|
|
|
|
}
|
2018-08-07 15:15:10 +08:00
|
|
|
|
var mousePos = mouseCoords(ev);
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
cache: false,
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: '/operations/show_annotation/',
|
|
|
|
|
data: { 'file_id': file_id, 'line_num': 0 },
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
async: true,
|
|
|
|
|
beforeSend: function (xhr, settings) {
|
|
|
|
|
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
|
|
|
|
},
|
|
|
|
|
success: function (data) {
|
|
|
|
|
if (data.status === "success") {
|
|
|
|
|
//console.log("linestatus_"+line_num);
|
|
|
|
|
//$("#loadCommentpanel").html(data.html_str);
|
|
|
|
|
//$("#commentPanel").css("top", mousePos.y);
|
|
|
|
|
//$("#commentPanel").css("left", mousePos.x+35);
|
|
|
|
|
//$("#loadCommentpanel").show();
|
|
|
|
|
//console.log(data.html_str);
|
|
|
|
|
$("#ItemcommentPanel").remove()
|
|
|
|
|
var html="<div id='ItemcommentPanel' style='margin-top: 70px;'>"+data.html_str+"</div>"
|
|
|
|
|
$("#dir_anno_"+file_id).append(html);
|
|
|
|
|
}else{
|
|
|
|
|
alert(data.msg)
|
|
|
|
|
}
|
2018-09-25 15:07:59 +08:00
|
|
|
|
},error:function(jqXHR, textStatus, errorThrown){
|
|
|
|
|
if(jqXHR.readyState===0&&jqXHR.status===0){
|
|
|
|
|
alert('网络故障,提交失败!请联网后重新提交');
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-08-07 15:15:10 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function show_dir_issue_question(file_id){
|
|
|
|
|
ev = window.event;
|
2018-08-23 22:53:27 +08:00
|
|
|
|
if(ev==undefined){
|
|
|
|
|
ev=arguments.callee.caller.arguments[0]||window.event;
|
|
|
|
|
}
|
2018-08-07 15:15:10 +08:00
|
|
|
|
var mousePos = mouseCoords(ev)
|
|
|
|
|
//发送问题id,返回问题内容
|
|
|
|
|
$.ajax({
|
|
|
|
|
cache: false,
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: '/operations/show_issue_question/',
|
|
|
|
|
data: { 'file_id': file_id, 'line_num': 0, 'issue_ids': "[]"},
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
async: true,
|
|
|
|
|
beforeSend: function (xhr, settings) {
|
|
|
|
|
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
|
|
|
|
},
|
|
|
|
|
success: function (data) {
|
|
|
|
|
if(data.status=='success'){
|
|
|
|
|
var html="<div id='ItemquestionPanel' style='margin-top:70px;'>"+data.html_str+"</div>";
|
|
|
|
|
$("#dir_question_"+file_id).append(html);
|
|
|
|
|
// $("#loadQuestionpanel").html(data.html_str);
|
|
|
|
|
if (data.issueAnswers) {
|
|
|
|
|
//字符串转换成整型数组
|
|
|
|
|
var dataStrArr = issueid_str.substring(1, issueid_str.length - 1).split(",")
|
|
|
|
|
var issue_ids = dataStrArr.map(function (data) {
|
|
|
|
|
return +data;
|
|
|
|
|
});
|
|
|
|
|
//
|
|
|
|
|
issueAnswers = JSON.parse(data.issueAnswers);
|
|
|
|
|
issueStandardAnswers = JSON.parse(data.issueStandardAnswers);
|
|
|
|
|
|
|
|
|
|
let count = 0;
|
|
|
|
|
for (let i = 0; i < issue_ids.length; i++) {
|
|
|
|
|
issue_id = issue_ids[i]
|
|
|
|
|
|
|
|
|
|
if (issue_id == issueAnswers[count].fields.issue) {
|
|
|
|
|
var radios = document.getElementsByName("issue_" + issue_id)
|
|
|
|
|
user_answer = issueAnswers[0].fields.content;
|
|
|
|
|
standard_answer = issueStandardAnswers[0].fields.choice_position;
|
|
|
|
|
if (user_answer == standard_answer) {
|
|
|
|
|
radios[user_answer - 1].parentNode.style.color = "green";
|
|
|
|
|
} else {
|
|
|
|
|
radios[parseInt(user_answer) - 1].parentNode.style.color = "red";
|
|
|
|
|
radios[parseInt(standard_answer) - 1].parentNode.style.color = "green";
|
|
|
|
|
}
|
|
|
|
|
document.getElementById("submit_onechoice_" + issue_id).style.display = "None";
|
|
|
|
|
count = count + 1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//$("#questionPanel").css("top", mousePos.y);
|
|
|
|
|
//$("#questionPanel").css("left", mousePos.x - 400);
|
|
|
|
|
//$("#loadQuestionpanel").show();
|
|
|
|
|
}else{
|
|
|
|
|
alert(data.msg)
|
|
|
|
|
}
|
2018-09-25 15:07:59 +08:00
|
|
|
|
},error:function(jqXHR, textStatus, errorThrown){
|
|
|
|
|
if(jqXHR.readyState===0&&jqXHR.status===0){
|
|
|
|
|
alert('网络故障,提交失败!请联网后重新提交');
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-08-07 15:15:10 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
2018-07-15 10:09:43 +08:00
|
|
|
|
|
2018-08-07 23:00:10 +08:00
|
|
|
|
function submit_dir_annotation(file_id, line_num, content) {
|
2018-07-15 10:09:43 +08:00
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
cache: false,
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: '/operations/add_annotation/',
|
|
|
|
|
data: { 'file_id': file_id, 'linenum': line_num, 'content': content },
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
async: true,
|
|
|
|
|
beforeSend: function (xhr, settings) {
|
|
|
|
|
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
|
|
|
|
},
|
|
|
|
|
success: function (data) {
|
|
|
|
|
if (data.status == 'success') {
|
|
|
|
|
var value = $("#dir_anno_" + file_id).html()
|
|
|
|
|
if (value.trim().length == 0) {
|
|
|
|
|
$("#dir_anno_" + +file_id).html(1);
|
|
|
|
|
}else{
|
|
|
|
|
$("#dir_anno_" + +file_id).html(parseInt(value) + 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-08-07 15:15:10 +08:00
|
|
|
|
$(".addno-panel").hide();
|
|
|
|
|
$(".source-addno-panel").remove();
|
|
|
|
|
show_dir_annotation(file_id);
|
2018-09-25 15:07:59 +08:00
|
|
|
|
},error:function(jqXHR, textStatus, errorThrown){
|
|
|
|
|
if(jqXHR.readyState===0&&jqXHR.status===0){
|
|
|
|
|
alert('网络故障,提交失败!请联网后重新提交');
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-15 10:09:43 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-08-07 23:00:10 +08:00
|
|
|
|
function submit_dir_question(file_id, line_num, content) {
|
2018-07-15 10:09:43 +08:00
|
|
|
|
$.ajax({
|
|
|
|
|
cache: false,
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: '/operations/add_question/',
|
|
|
|
|
data: { 'file_id': file_id, 'linenum': line_num, 'content': content },
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
async: true,
|
|
|
|
|
beforeSend: function (xhr, settings) {
|
|
|
|
|
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
|
|
|
|
},
|
|
|
|
|
success: function (data) {
|
|
|
|
|
if (data.status == 'success') {
|
|
|
|
|
var value = $("#dir_question_" + file_id).html()
|
|
|
|
|
if (value.trim().length == 0) {
|
|
|
|
|
$("#dir_question_" + +file_id).html(1);
|
|
|
|
|
} else {
|
|
|
|
|
$("#dir_question_" + +file_id).html(parseInt(value) + 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-08-07 15:15:10 +08:00
|
|
|
|
$(".addno-panel").hide();
|
|
|
|
|
$(".source-addno-panel").remove();
|
|
|
|
|
show_dir_issue_question(file_id);
|
2018-09-25 15:07:59 +08:00
|
|
|
|
},error:function(jqXHR, textStatus, errorThrown){
|
|
|
|
|
if(jqXHR.readyState===0&&jqXHR.status===0){
|
|
|
|
|
alert('网络故障,提交失败!请联网后重新提交');
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-15 10:09:43 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-13 09:34:45 +08:00
|
|
|
|
// 这下面5个函数,与上面dir的区别就是:
|
|
|
|
|
// 上面的针对文件夹,margin-top是70px的,
|
|
|
|
|
// 下面的针对文件,margin-top是140px的,仅此而已
|
|
|
|
|
function add_file_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();
|
|
|
|
|
|
|
|
|
|
if (content.trim().length == 0) {
|
|
|
|
|
alert("内容不能为空")
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (selectValue == "注释") {
|
|
|
|
|
// 向addAnnatation中发请求
|
|
|
|
|
submit_file_annotation(file_id, line_num, content);
|
2018-09-15 13:18:37 +08:00
|
|
|
|
deletelocalStorage("rightannotationid");
|
|
|
|
|
deletelocalStorage("rightannotationnum");
|
|
|
|
|
deletelocalStorage("rightannotationvalue");
|
|
|
|
|
deletelocalStorage("rightstatus_value");
|
2018-08-13 09:34:45 +08:00
|
|
|
|
} else {
|
|
|
|
|
submit_file_question(file_id, line_num, content);
|
2018-09-15 13:18:37 +08:00
|
|
|
|
alert(1)
|
|
|
|
|
deletelocalStorage("righissuevid");
|
|
|
|
|
deletelocalStorage("righissuenum");
|
|
|
|
|
deletelocalStorage("righissuevalue");
|
|
|
|
|
deletelocalStorage("rightstatus_value");
|
2018-08-13 09:34:45 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function show_file_annotation(file_id){
|
|
|
|
|
ev = window.event;
|
2018-08-23 22:53:27 +08:00
|
|
|
|
if(ev==undefined){
|
|
|
|
|
ev=arguments.callee.caller.arguments[0]||window.event;
|
|
|
|
|
}
|
2018-08-13 09:34:45 +08:00
|
|
|
|
var mousePos = mouseCoords(ev);
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
cache: false,
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: '/operations/show_annotation/',
|
|
|
|
|
data: { 'file_id': file_id, 'line_num': 0 },
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
async: true,
|
|
|
|
|
beforeSend: function (xhr, settings) {
|
|
|
|
|
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
|
|
|
|
},
|
|
|
|
|
success: function (data) {
|
|
|
|
|
if (data.status === "success") {
|
2018-09-15 13:18:37 +08:00
|
|
|
|
|
2018-08-13 09:34:45 +08:00
|
|
|
|
$("#ItemcommentPanel").remove()
|
2018-09-21 17:27:47 +08:00
|
|
|
|
var html="<div id='ItemcommentPanel' class='newItemcommentPanel' style='margin-top:275px; margin-right: 55px;'>"+data.html_str+"</div>"
|
2018-08-13 09:34:45 +08:00
|
|
|
|
$("#dir_anno_"+file_id).append(html);
|
2018-09-20 18:25:36 +08:00
|
|
|
|
$( "#ItemcommentPanel" ).draggable();
|
2018-08-13 09:34:45 +08:00
|
|
|
|
}else{
|
|
|
|
|
alert(data.msg)
|
|
|
|
|
}
|
2018-09-25 15:07:59 +08:00
|
|
|
|
},error:function(jqXHR, textStatus, errorThrown){
|
|
|
|
|
if(jqXHR.readyState===0&&jqXHR.status===0){
|
|
|
|
|
alert('网络故障,提交失败!请联网后重新提交');
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-08-13 09:34:45 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function show_file_issue_question(file_id){
|
|
|
|
|
ev = window.event;
|
2018-08-23 22:53:27 +08:00
|
|
|
|
if(ev==undefined){
|
|
|
|
|
ev=arguments.callee.caller.arguments[0]||window.event;
|
|
|
|
|
}
|
2018-08-13 09:34:45 +08:00
|
|
|
|
var mousePos = mouseCoords(ev)
|
|
|
|
|
//发送问题id,返回问题内容
|
|
|
|
|
$.ajax({
|
|
|
|
|
cache: false,
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: '/operations/show_issue_question/',
|
|
|
|
|
data: { 'file_id': file_id, 'line_num': 0, 'issue_ids': "[]"},
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
async: true,
|
|
|
|
|
beforeSend: function (xhr, settings) {
|
|
|
|
|
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
|
|
|
|
},
|
|
|
|
|
success: function (data) {
|
|
|
|
|
if(data.status=='success'){
|
2018-09-21 17:27:47 +08:00
|
|
|
|
var html="<div id='ItemquestionPanel' style='margin-top:276px;margin-right: 50px;'>"+data.html_str+"</div>";
|
2018-08-13 09:34:45 +08:00
|
|
|
|
$("#dir_question_"+file_id).append(html);
|
|
|
|
|
// $("#loadQuestionpanel").html(data.html_str);
|
|
|
|
|
if (data.issueAnswers) {
|
|
|
|
|
//字符串转换成整型数组
|
|
|
|
|
var dataStrArr = issueid_str.substring(1, issueid_str.length - 1).split(",")
|
|
|
|
|
var issue_ids = dataStrArr.map(function (data) {
|
|
|
|
|
return +data;
|
|
|
|
|
});
|
|
|
|
|
//
|
|
|
|
|
issueAnswers = JSON.parse(data.issueAnswers);
|
|
|
|
|
issueStandardAnswers = JSON.parse(data.issueStandardAnswers);
|
|
|
|
|
|
|
|
|
|
let count = 0;
|
|
|
|
|
for (let i = 0; i < issue_ids.length; i++) {
|
|
|
|
|
issue_id = issue_ids[i]
|
|
|
|
|
|
|
|
|
|
if (issue_id == issueAnswers[count].fields.issue) {
|
|
|
|
|
var radios = document.getElementsByName("issue_" + issue_id)
|
|
|
|
|
user_answer = issueAnswers[0].fields.content;
|
|
|
|
|
standard_answer = issueStandardAnswers[0].fields.choice_position;
|
|
|
|
|
if (user_answer == standard_answer) {
|
|
|
|
|
radios[user_answer - 1].parentNode.style.color = "green";
|
|
|
|
|
} else {
|
|
|
|
|
radios[parseInt(user_answer) - 1].parentNode.style.color = "red";
|
|
|
|
|
radios[parseInt(standard_answer) - 1].parentNode.style.color = "green";
|
|
|
|
|
}
|
|
|
|
|
document.getElementById("submit_onechoice_" + issue_id).style.display = "None";
|
|
|
|
|
count = count + 1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//$("#questionPanel").css("top", mousePos.y);
|
|
|
|
|
//$("#questionPanel").css("left", mousePos.x - 400);
|
|
|
|
|
//$("#loadQuestionpanel").show();
|
2018-09-20 18:25:36 +08:00
|
|
|
|
$( "#ItemquestionPanel" ).draggable();
|
2018-08-13 09:34:45 +08:00
|
|
|
|
}else{
|
|
|
|
|
alert(data.msg)
|
|
|
|
|
}
|
2018-09-25 15:07:59 +08:00
|
|
|
|
},error:function(jqXHR, textStatus, errorThrown){
|
|
|
|
|
if(jqXHR.readyState===0&&jqXHR.status===0){
|
|
|
|
|
alert('网络故障,提交失败!请联网后重新提交');
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-08-13 09:34:45 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function submit_file_annotation(file_id, line_num, content) {
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
cache: false,
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: '/operations/add_annotation/',
|
|
|
|
|
data: { 'file_id': file_id, 'linenum': line_num, 'content': content },
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
async: true,
|
|
|
|
|
beforeSend: function (xhr, settings) {
|
|
|
|
|
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
|
|
|
|
},
|
|
|
|
|
success: function (data) {
|
|
|
|
|
if (data.status == 'success') {
|
|
|
|
|
$(".addno-panel").hide();
|
|
|
|
|
$(".source-addno-panel").remove();
|
|
|
|
|
show_file_annotation(file_id);
|
|
|
|
|
}else{
|
2018-08-24 17:29:21 +08:00
|
|
|
|
alert(data.msg)
|
2018-08-13 09:34:45 +08:00
|
|
|
|
}
|
2018-09-04 15:16:57 +08:00
|
|
|
|
|
2018-09-25 15:07:59 +08:00
|
|
|
|
},error:function(jqXHR, textStatus, errorThrown){
|
|
|
|
|
if(jqXHR.readyState===0&&jqXHR.status===0){
|
|
|
|
|
alert('网络故障,提交失败!请联网后重新提交');
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-08-13 09:34:45 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function submit_file_question(file_id, line_num, content) {
|
|
|
|
|
$.ajax({
|
|
|
|
|
cache: false,
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: '/operations/add_question/',
|
|
|
|
|
data: { 'file_id': file_id, 'linenum': line_num, 'content': content },
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
async: true,
|
|
|
|
|
beforeSend: function (xhr, settings) {
|
|
|
|
|
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
|
|
|
|
},
|
|
|
|
|
success: function (data) {
|
|
|
|
|
if (data.status == 'success') {
|
|
|
|
|
var value = $("#dir_question_" + file_id).html()
|
|
|
|
|
if (value.trim().length == 0) {
|
|
|
|
|
$("#dir_question_" + +file_id).html(1);
|
|
|
|
|
} else {
|
|
|
|
|
$("#dir_question_" + +file_id).html(parseInt(value) + 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$(".addno-panel").hide();
|
|
|
|
|
$(".source-addno-panel").remove();
|
|
|
|
|
show_file_issue_question(file_id);
|
2018-09-25 15:07:59 +08:00
|
|
|
|
},error:function(jqXHR, textStatus, errorThrown){
|
|
|
|
|
if(jqXHR.readyState===0&&jqXHR.status===0){
|
|
|
|
|
alert('网络故障,提交失败!请联网后重新提交');
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-08-13 09:34:45 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-09-21 19:43:16 +08:00
|
|
|
|
function make_button_disable(item){
|
|
|
|
|
item.removeAttr("onclick");
|
|
|
|
|
item.attr('disabled',true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function make_button_able(item,function_name){
|
|
|
|
|
item.attr('disabled',false);
|
|
|
|
|
item.attr("onclick",function_name);
|
|
|
|
|
}
|
2018-07-15 10:09:43 +08:00
|
|
|
|
|
|
|
|
|
function thumbsAnno(item,anno_id,vote_value) {
|
|
|
|
|
// 获取当前的vote
|
2018-09-21 19:43:16 +08:00
|
|
|
|
function_name = "thumbsAnno(this"+","+anno_id+","+vote_value+")"
|
|
|
|
|
make_button_disable($(item))
|
|
|
|
|
|
2018-08-08 11:32:43 +08:00
|
|
|
|
vote_tag = $("#annosum_"+anno_id)
|
2018-07-15 10:09:43 +08:00
|
|
|
|
vote_before = parseInt(vote_tag.text())
|
|
|
|
|
$.ajax({
|
|
|
|
|
cache: false,
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: '/operations/add_vote/',
|
|
|
|
|
data: { 'vote_type': "annotation", 'object_id': anno_id, 'vote_value': vote_value },
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
async: true,
|
|
|
|
|
beforeSend: function (xhr, settings) {
|
|
|
|
|
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
|
|
|
|
},
|
|
|
|
|
success: function (data) {
|
|
|
|
|
if (data.status == 'success') {
|
2018-08-08 11:32:43 +08:00
|
|
|
|
vote_now = vote_before + parseInt( data.value)
|
|
|
|
|
vote_tag.text(vote_now)
|
|
|
|
|
deal_votetag_color(vote_tag,data.msg,vote_value)
|
2018-07-15 10:09:43 +08:00
|
|
|
|
}else{
|
|
|
|
|
alert(data.msg);
|
|
|
|
|
}
|
2018-09-21 19:43:16 +08:00
|
|
|
|
make_button_able($(item),function_name)
|
2018-09-25 15:07:59 +08:00
|
|
|
|
},error:function(jqXHR, textStatus, errorThrown){
|
|
|
|
|
if(jqXHR.readyState===0&&jqXHR.status===0){
|
|
|
|
|
alert('网络故障,提交失败!请联网后重新提交');
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-15 10:09:43 +08:00
|
|
|
|
});
|
2018-08-08 11:32:43 +08:00
|
|
|
|
// 更改当前的vote,默认+1
|
|
|
|
|
}
|
2018-07-15 10:09:43 +08:00
|
|
|
|
|
2018-08-08 11:32:43 +08:00
|
|
|
|
function thumbsComment(item,comment_id,vote_value) {
|
2018-09-21 19:43:16 +08:00
|
|
|
|
function_name = "thumbsComment(this"+","+comment_id+","+vote_value+")"
|
|
|
|
|
make_button_disable($(item))
|
2018-08-08 11:32:43 +08:00
|
|
|
|
// 获取当前的vote
|
|
|
|
|
vote_tag = $("#comment_"+comment_id)
|
|
|
|
|
vote_before = parseInt(vote_tag.text())
|
|
|
|
|
$.ajax({
|
|
|
|
|
cache: false,
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: '/operations/add_vote/',
|
|
|
|
|
data: { 'vote_type': "annotation_comment", 'object_id': comment_id, 'vote_value': vote_value },
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
async: true,
|
|
|
|
|
beforeSend: function (xhr, settings) {
|
|
|
|
|
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
|
|
|
|
},
|
|
|
|
|
success: function (data) {
|
|
|
|
|
if (data.status == 'success') {
|
|
|
|
|
vote_now = vote_before + parseInt( data.value)
|
|
|
|
|
vote_tag.text(vote_now)
|
|
|
|
|
deal_votetag_color(vote_tag,data.msg,vote_value)
|
|
|
|
|
// }
|
|
|
|
|
}else{
|
|
|
|
|
alert(data.msg);
|
|
|
|
|
}
|
2018-09-21 19:43:16 +08:00
|
|
|
|
make_button_able($(item),function_name)
|
2018-09-25 15:07:59 +08:00
|
|
|
|
},error:function(jqXHR, textStatus, errorThrown){
|
|
|
|
|
if(jqXHR.readyState===0&&jqXHR.status===0){
|
|
|
|
|
alert('网络故障,提交失败!请联网后重新提交');
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-08-08 11:32:43 +08:00
|
|
|
|
});
|
2018-07-15 10:09:43 +08:00
|
|
|
|
// 更改当前的vote,默认+1
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-21 19:43:16 +08:00
|
|
|
|
//
|
|
|
|
|
|
2018-08-08 11:32:43 +08:00
|
|
|
|
function deal_votetag_color(vote_tag,msg,vote_value){
|
|
|
|
|
if(msg=='cancel success'){
|
|
|
|
|
// 那么将颜色都变为正常
|
|
|
|
|
vote_tag.parent().prev().children().removeClass("thumbs_active")
|
|
|
|
|
vote_tag.parent().next().children().removeClass("thumbs_active")
|
|
|
|
|
}else{
|
|
|
|
|
//把一个变为正常,另一个变为红色
|
|
|
|
|
if(vote_value==1){
|
|
|
|
|
vote_tag.parent().prev().children().addClass("thumbs_active")
|
|
|
|
|
vote_tag.parent().next().children().removeClass("thumbs_active")
|
|
|
|
|
}else{
|
|
|
|
|
vote_tag.parent().prev().children().removeClass("thumbs_active")
|
|
|
|
|
vote_tag.parent().next().children().addClass("thumbs_active")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-09-27 10:47:50 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function get_addtab_paras(){
|
|
|
|
|
var url = window.location.href;
|
2018-07-15 10:09:43 +08:00
|
|
|
|
$.ajax({
|
|
|
|
|
cache: false,
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: '/operations/get_addtab_paras/',
|
|
|
|
|
data: { 'url': url },
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
async: true,
|
|
|
|
|
beforeSend: function (xhr, settings) {
|
|
|
|
|
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
|
|
|
|
},
|
|
|
|
|
success: function (data) {
|
|
|
|
|
if (data.status === 'success') {
|
2018-08-07 15:15:10 +08:00
|
|
|
|
// 展开当前标签对应的节点
|
2018-08-30 15:17:01 +08:00
|
|
|
|
project_id=data.project_id
|
|
|
|
|
path = data.path
|
2018-09-27 10:47:50 +08:00
|
|
|
|
filename = data.filename
|
|
|
|
|
url_deal(get_path_link_and_archor(path)[0],null)
|
2018-07-15 10:09:43 +08:00
|
|
|
|
add_tab(data.project_id, data.path, data.filename)
|
2018-09-27 10:47:50 +08:00
|
|
|
|
// 加载页面后再加载jstree
|
|
|
|
|
load_jstree(data.project_id,data.path)
|
2018-07-15 10:09:43 +08:00
|
|
|
|
}
|
2018-09-25 15:07:59 +08:00
|
|
|
|
},error:function(jqXHR, textStatus, errorThrown){
|
|
|
|
|
if(jqXHR.readyState===0&&jqXHR.status===0){
|
|
|
|
|
alert('网络故障,提交失败!请联网后重新提交');
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-15 10:09:43 +08:00
|
|
|
|
});
|
2018-09-27 10:47:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-28 15:19:55 +08:00
|
|
|
|
|
|
|
|
|
function remove_jstree_content(){
|
|
|
|
|
for(var i=0;i<localStorage.length;i++){
|
|
|
|
|
var key =localStorage.key(i);
|
|
|
|
|
if(key.startsWith("jstree-")){
|
|
|
|
|
deletelocalStorage(key);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-09-27 10:47:50 +08:00
|
|
|
|
function load_jstree(project_id,path){
|
2018-09-27 17:52:11 +08:00
|
|
|
|
|
|
|
|
|
// display_loading();
|
2018-09-27 10:47:50 +08:00
|
|
|
|
var url = window.location.href;
|
|
|
|
|
var projectName= $("#projectName").text();
|
|
|
|
|
// 先从本地缓存中取,如果没有再向服务器请求
|
2018-09-28 15:19:55 +08:00
|
|
|
|
// var compressed_content = getlocalStorage("jstree-"+projectName)
|
|
|
|
|
// if(compressed_content !=null){
|
|
|
|
|
// jstree_content = LZString.decompress(compressed_content)
|
|
|
|
|
// init_jstree(project_id,path,jstree_content)
|
|
|
|
|
// }
|
|
|
|
|
jstree_content = getlocalStorage("jstree-"+projectName)
|
|
|
|
|
if(jstree_content != null){
|
2018-09-27 10:47:50 +08:00
|
|
|
|
init_jstree(project_id,path,jstree_content)
|
2018-09-28 15:19:55 +08:00
|
|
|
|
}
|
|
|
|
|
else{
|
2018-09-27 10:47:50 +08:00
|
|
|
|
$.ajax({
|
|
|
|
|
cache: false,
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: '/projects/get_project_jstree/',
|
|
|
|
|
data: { 'project_name': projectName },
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
async: true,
|
|
|
|
|
beforeSend: function (xhr, settings) {
|
|
|
|
|
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
|
|
|
|
},
|
|
|
|
|
success: function (data) {
|
|
|
|
|
if (data.status === 'success') {
|
|
|
|
|
try{
|
2018-09-28 15:19:55 +08:00
|
|
|
|
// compressed_content = LZString.compress(data.jstree_content)
|
|
|
|
|
// setlocalStorage("jstree-"+projectName,compressed_content)
|
|
|
|
|
remove_jstree_content()
|
|
|
|
|
setlocalStorage("jstree-"+projectName,data.jstree_content)
|
2018-09-27 10:47:50 +08:00
|
|
|
|
}catch(error){
|
|
|
|
|
console.log(error)
|
|
|
|
|
}finally{
|
|
|
|
|
init_jstree(project_id,path,data.jstree_content)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},error:function(jqXHR, textStatus, errorThrown){
|
|
|
|
|
if(jqXHR.readyState===0&&jqXHR.status===0){
|
|
|
|
|
alert('网络故障,提交失败!请联网后重新提交');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function init_jstree(project_id,path,content){
|
|
|
|
|
$("#filelist-content").html(content)
|
2018-09-27 17:52:11 +08:00
|
|
|
|
$(".spinner").after(content);
|
2018-09-27 10:47:50 +08:00
|
|
|
|
$('#jstree').jstree();
|
2018-09-27 17:52:11 +08:00
|
|
|
|
$(".spinner").remove();
|
2018-09-27 10:47:50 +08:00
|
|
|
|
$("#jstree").jstree("open_node", $("#j1_1"));
|
|
|
|
|
$("#jstree").css("visibility","visible");
|
|
|
|
|
highlight_jstree_node(project_id,path)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$(function(){
|
|
|
|
|
get_addtab_paras()
|
2018-08-31 10:52:07 +08:00
|
|
|
|
})
|
2018-09-20 18:25:36 +08:00
|
|
|
|
|
2018-09-21 17:27:47 +08:00
|
|
|
|
// window.onload=function(){
|
|
|
|
|
// var a=$(".jstree-node").attr("aria-selected");
|
|
|
|
|
// var b=$(".jstree-anchor");
|
|
|
|
|
// for(var i = 0; i<b.length; i++){
|
|
|
|
|
// console.log(b[i])
|
|
|
|
|
// }
|
|
|
|
|
// // console.log(a)
|
|
|
|
|
// // console.log(b)
|
|
|
|
|
// };
|