修复打开标签页对应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) { success: function (data) {
if (data.status === 'success') { if (data.status === 'success') {
var content = ""; var content = "<div id='navigation_tree'>";
var obj = data.msg; var obj = data.msg;
var file_id = data.file_id var file_id = data.file_id
for (let i = 0; i < obj.length; i++) { for (let i = 0; i < obj.length; i++) {
var type = obj[i][0]; var type = obj[i][0];
var str = ''; var str = '';
str += "<div id=" + type + ">"; str += "<ul><li>";
if(i==0){ str += type
str += "<div class='tags clearfix'><span style='float: left;'>" + type + "</span></div>";
}else{
str += "<div class='tags'>" + type + "</div>";
}
if (obj.length > 1) { if (obj.length > 1) {
var items = obj[i][1]; var items = obj[i][1];
for (let j = 0; j < items.length; j++) { for (let j = 0; j < items.length; j++) {
var name = items[j][0]; var name = items[j][0];
var linenum = items[j][1]; 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 += str;
} }
content += "</div>"
// document.getElementById("annotation").style.display="block"; // document.getElementById("annotation").style.display="block";
navigation_map.set(project_path + file_path, content) navigation_map.set(project_path + file_path, content)
$("#structure-context").html(content) $("#structure-context").html(content)
@ -622,6 +621,15 @@ function path_predeal(path){
// 打开一个已经存在的标签页 // 打开一个已经存在的标签页
// 注意这个还得将对应的路径更改了 // 注意这个还得将对应的路径更改了
function open_tab(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_input=path
path = path_predeal(path) path = path_predeal(path)
@ -665,14 +673,12 @@ function open_tab(path) {
function add_tab(project_id,path,filename) { function add_tab(project_id,path,filename) {
var tree_node = $("#jstree").jstree("get_selected"); var tree_node = $("#jstree").jstree("get_selected");
var path_before = path var path_before = path
//需要将path处理一下因为css样式中/以及.是不行的 //需要将path处理一下因为css样式中/以及.是不行的
tmp_index = path.indexOf("#"); tmp_index = path.indexOf("#");
if(tmp_index != -1){ if(tmp_index != -1){
path = path.substring(0,tmp_index) path = path.substring(0,tmp_index)
} }
var path_input = path; var path_input = path;
path = path_predeal(path) path = path_predeal(path)

View File

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