From b687d4c088e5a7c8e5c37125be3a72164928d59f Mon Sep 17 00:00:00 2001 From: zhengzhirong Date: Thu, 13 Dec 2018 19:33:36 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20=E9=87=87=E7=94=A8=E9=80=92?= =?UTF-8?q?=E5=BD=92=E6=96=B9=E6=B3=95=E5=8A=A0=E8=BD=BD=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E7=BB=93=E6=9E=84=20/=20=E5=90=8C=E6=AD=A5history=20state?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.js | 58 ++++++++++++++++++++++++++++++++++++++------------- manifest.json | 4 ++-- 2 files changed, 45 insertions(+), 17 deletions(-) diff --git a/main.js b/main.js index 74c1b38..25f0c39 100644 --- a/main.js +++ b/main.js @@ -44,7 +44,31 @@ var vm = { vm.repository_ref = $('#repository_ref').val(); //console.info(vm) }, - loadNode: function (parentNode) { + loadRecursiveTree: function() { + const path = $('#path').val().split('/') + const ztree = vm.getZTree() + const self = this + function exec(treeArr) { + const p = path.shift() + const node = treeArr.filter(function(each) { + return each.name === p + })[0] + if(!node) { + return + } + const ztreeNode = ztree.getNodeByParam("id", node.id) + if(path.length) { + self.loadNode(ztreeNode, function(treeArr) { + ztree.expandNode(ztreeNode, true) + exec(treeArr) + }) + } else { + ztree.selectNode(ztreeNode); + } + } + this.loadNode(null, exec) + }, + loadNode: function (parentNode, cb) { if (parentNode && (parentNode.zAsync || parentNode.isAjaxing)) { return; } @@ -65,11 +89,11 @@ var vm = { ref: vm.repository_ref }; - if (vm.rss_mode) { - param.rss_token = vm.rss_token; - } else { - param.private_token = vm.private_token; - } + // if (vm.rss_mode) { + // param.rss_token = vm.rss_token; + // } else { + // param.private_token = vm.private_token; + // } $.get(vm.apiRepoTree, param, function (result) { if (parentNode) { @@ -90,6 +114,7 @@ var vm = { } } vm.getZTree().addNodes(parentNode, i, treeArr); + cb && cb(treeArr) }); }, loadRecursiveNode: function () { @@ -99,11 +124,11 @@ var vm = { ref_name: vm.repository_ref }; - if (vm.rss_mode) { - param.rss_token = vm.rss_token; - } else { - param.private_token = vm.private_token; - } + // if (vm.rss_mode) { + // param.rss_token = vm.rss_token; + // } else { + // param.private_token = vm.private_token; + // } $.get(vm.apiRepoTree, param, function (result) { var treeArr = []; @@ -224,8 +249,9 @@ var vm = { $.fn.zTree.init($("#gitlabTreeView"), setting); }, selectNode: function (treeNode) { + var href if (treeNode.type === 'blob') { - var href = window.location.origin + '/' + vm.shortcuts_project + '/blob/' + vm.repository_ref + '/' + treeNode.path; + href = window.location.origin + '/' + vm.shortcuts_project + '/blob/' + vm.repository_ref + '/' + treeNode.path; //加载文件信息 $.ajax({ @@ -254,7 +280,7 @@ var vm = { } }) } else if (treeNode.type === 'tree') { - var href = window.location.origin + '/' + vm.shortcuts_project + '/tree/' + vm.repository_ref + '/' + treeNode.path; + href = window.location.origin + '/' + vm.shortcuts_project + '/tree/' + vm.repository_ref + '/' + treeNode.path; $.ajax({ type: "GET", url: href, @@ -270,6 +296,8 @@ var vm = { } }) } + document.title = treeNode.path + window.history.pushState(null, null, href) }, //得到树对象 getZTree: function () { @@ -462,7 +490,7 @@ var vm = { vm.initTree(); if (vm.setting.recursive) { - vm.loadRecursiveNode(); + vm.loadRecursiveTree(); } else { vm.loadNode(null); } @@ -472,4 +500,4 @@ var vm = { $(function () { vm.init(); -}); \ No newline at end of file +}); diff --git a/manifest.json b/manifest.json index d16830a..4ae1f00 100755 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "name": "Gitlab TreeView", - "version": "1.6", + "version": "1.6.1", "manifest_version": 2, "author": "linsage", "description": "Code tree for Gitlab", @@ -41,4 +41,4 @@ ], "run_at": "document_start" }] -} \ No newline at end of file +} From da6c1c08ac0052854545fda24fff8e445bc458de Mon Sep 17 00:00:00 2001 From: zWingz Date: Thu, 21 Feb 2019 15:55:42 +0800 Subject: [PATCH 2/5] =?UTF-8?q?fix:=20=F0=9F=90=9B=20fix=20per=5Fpage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.js b/main.js index 25f0c39..a619c10 100644 --- a/main.js +++ b/main.js @@ -86,7 +86,8 @@ var vm = { var param = { id: vm.project_id, path: parentNode ? parentNode.path : null, - ref: vm.repository_ref + ref: vm.repository_ref, + per_page: 9999 }; // if (vm.rss_mode) { From 1f24f76224b0a2ce237346ef1499314d6da3b74e Mon Sep 17 00:00:00 2001 From: zWingz Date: Thu, 21 Feb 2019 15:56:32 +0800 Subject: [PATCH 3/5] =?UTF-8?q?chore:=20=F0=9F=A4=96=20update=20manifest.j?= =?UTF-8?q?son?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manifest.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index 4ae1f00..ba035a1 100755 --- a/manifest.json +++ b/manifest.json @@ -1,10 +1,10 @@ { "name": "Gitlab TreeView", - "version": "1.6.1", + "version": "1.6.2", "manifest_version": 2, "author": "linsage", "description": "Code tree for Gitlab", - "homepage_url": "https://github.com/linsage/gitlab-treeview", + "homepage_url": "https://github.com/zWingz/gitlab-treeview", "permissions": [ "storage" ], From 0286aca69c75f0d1ec0d8fc63378a76784b93af7 Mon Sep 17 00:00:00 2001 From: zWingz Date: Thu, 9 May 2019 10:52:40 +0800 Subject: [PATCH 4/5] docs: update info --- .idea/vcs.xml | 6 ------ README.md | 42 ++++++++++++++++++++++-------------------- background.js | 5 +++-- manifest.json | 11 ++++------- 4 files changed, 29 insertions(+), 35 deletions(-) delete mode 100644 .idea/vcs.xml diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/README.md b/README.md index c9d0cca..f7689c2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # GitLab-TreeView -Chrome extension to show a code tree on GitLab :) +Chrome extension to show a code tree on GitLab :) ## Features @@ -17,26 +17,28 @@ Chrome extension to show a code tree on GitLab :) ![](https://ws2.sinaimg.cn/large/006tNc79gy1fi3ighoji0g30zk0m8du9.gif) - ## Change Log - - v1.6 - - api V3 to api V4 - - v1.5 - - add expand the current file path - - v1.4 - - fix bug On gitlab 10.x, don't cover header and sidebar - - container width resizable - - v1.3 - - fix bug On gitlab 10.x, rss_token instead of private_token. - - v1.2 - - add css loading - - add options setting - - search file - - load entire tree at once - - v1.1 - - basic function - - v1.0 - - initial version + +- v1.6.3 + - fix bug on gitlab api +- v1.6 + - api V3 to api V4 +- v1.5 + - add expand the current file path +- v1.4 + - fix bug On gitlab 10.x, don't cover header and sidebar + - container width resizable +- v1.3 + - fix bug On gitlab 10.x, rss_token instead of private_token. +- v1.2 + - add css loading + - add options setting + - search file + - load entire tree at once +- v1.1 + - basic function +- v1.0 + - initial version ## More diff --git a/background.js b/background.js index d5e2830..636d745 100644 --- a/background.js +++ b/background.js @@ -1,7 +1,8 @@ // current tab. function openSupport(tab) { - window.open("https://chrome.google.com/webstore/detail/gitlab-treeview/" + chrome.runtime.id + "/support"); + // window.open("https://chrome.google.com/webstore/detail/gitlab-treeview-fork/" + chrome.runtime.id + "/support"); + window.open("https://github.com/zWingz/gitlab-treeview") } // When the browser action is clicked, call the -chrome.browserAction.onClicked.addListener(openSupport); \ No newline at end of file +chrome.browserAction.onClicked.addListener(openSupport); diff --git a/manifest.json b/manifest.json index ba035a1..64a1367 100755 --- a/manifest.json +++ b/manifest.json @@ -1,8 +1,8 @@ { - "name": "Gitlab TreeView", - "version": "1.6.2", + "name": "Gitlab TreeView Fork", + "version": "1.0.0", "manifest_version": 2, - "author": "linsage", + "author": "zWing", "description": "Code tree for Gitlab", "homepage_url": "https://github.com/zWingz/gitlab-treeview", "permissions": [ @@ -18,10 +18,7 @@ "persistent": false }, "browser_action": { - "default_icon": { - "19": "images/gitlab.png", - "38": "images/gitlab.png" - }, + "default_icon": "images/gitlab.png", "default_title": "Gitlab TreeView" }, "web_accessible_resources": ["css/*", "fonts/*"], From 1cdff8ef4c8dc1e8e2790040fd5436f015e8ea01 Mon Sep 17 00:00:00 2001 From: zWingz Date: Thu, 9 May 2019 10:56:44 +0800 Subject: [PATCH 5/5] docs: update readme --- README.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f7689c2..a820682 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # GitLab-TreeView +> fork from [gitlab-treeview](https://github.com/linsage/gitlab-treeview) and fix some bug + Chrome extension to show a code tree on GitLab :) ## Features @@ -11,7 +13,8 @@ Chrome extension to show a code tree on GitLab :) ## Installation -[Chrome](https://chrome.google.com/webstore/detail/gitlab-treeview/kfjchffabpogdehadpflljaikjicdpng) + +[release](https://github.com/zWingz/gitlab-treeview/releases) ## Screenshot @@ -39,8 +42,3 @@ Chrome extension to show a code tree on GitLab :) - basic function - v1.0 - initial version - -## More - -- Email:[linsage@live.com](mailto:linsage@live.com) -- Blog:[https://linsage.com](https://linsage.com)