修复打开标签页对应url的bug
修改url地址栏的url应该放在open_tab()中
This commit is contained in:
wrmswindmill 2018-08-15 00:48:23 +08:00
parent bdd370c7f3
commit 83651aa687
2 changed files with 19 additions and 13 deletions

View File

@ -429,30 +429,29 @@ function show_navigation() {
success: function (data) {
if (data.status === 'success') {
var content = "";
var content = "<div id='navigation_tree'>";
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 = '';
str += "<div id=" + type + ">";
if(i==0){
str += "<div class='tags clearfix'><span style='float: left;'>" + type + "</span></div>";
}else{
str += "<div class='tags'>" + type + "</div>";
}
str += "<ul><li>";
str += type
if (obj.length > 1) {
var items = obj[i][1];
for (let j = 0; j < items.length; j++) {
var name = items[j][0];
var linenum = items[j][1];
str += "<a class='def' href='#"+file_id+"_L" + linenum + "'>" + name + "</a><br>" + "</div>";
str += "<ul><li>"
str += "<a class='def' href='#"+file_id+"_L" + linenum + "'>" + name + "</a>";
str += "</li></ul>"
}
}
str += "</div>";
str += "</li></ul>"
content += str;
}
content += "</div>"
// document.getElementById("annotation").style.display="block";
navigation_map.set(project_path + file_path, content)
$("#structure-context").html(content)
@ -622,6 +621,15 @@ function path_predeal(path){
// 打开一个已经存在的标签页
// 注意这个还得将对应的路径更改了
function open_tab(path) {
var ip=window.location.host; //端口号
// console.log(window.location.pathname); 端口号后面的路径
var projectName= $("#projectName").text();
var newhtefpath = "/projects/"+projectName+path;
var stateObject = {};
//修改地址栏中的地址
history.pushState(stateObject, ip, newhtefpath);
path_input=path
path = path_predeal(path)
@ -663,16 +671,14 @@ function open_tab(path) {
// 如果标签页已经存在,则打开对应的标签页
// 并调用open_tab
function add_tab(project_id,path,filename) {
var tree_node = $("#jstree").jstree("get_selected");
var path_before = path
//需要将path处理一下因为css样式中/以及.是不行的
tmp_index = path.indexOf("#");
if(tmp_index != -1){
path = path.substring(0,tmp_index)
}
var path_input = path;
path = path_predeal(path)

View File

@ -30,7 +30,6 @@
<title>{{ project.name }}-{{ project.desc }}</title>
</head>
<body id="codepanel">
<!-- 要求与codepeida的保持一致 -->
<div class="clearfix head">
@ -139,6 +138,7 @@
</div>
</div>
</div>
<span id="projectName">{{ project.name }}</span>
</body>
</html>