diff --git a/.gitignore b/.gitignore
index 476bcfa..cd894f4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,37 @@
-.project
-node_modules
+# dependencies
+/node_modules
package-lock.json
+
+# IDEs and editors
+/.idea
+*.iml
+.project
+.classpath
+.c9/
+*.launch
+.settings/
+*.sublime-workspace
+
+# IDE - VSCode
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+
+# misc
+/.sass-cache
+/connect.lock
+/coverage
+/libpeerconnection.log
+npm-debug.log
+yarn-error.log
+testem.log
+/typings
+
+# System Files
+.DS_Store
+Thumbs.db
+.vscode/
+
registry-data
diff --git a/dist/index.html b/dist/index.html
index 5caf748..2333361 100644
--- a/dist/index.html
+++ b/dist/index.html
@@ -13,4 +13,4 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
--->
Docker Registry UI
\ No newline at end of file
+-->Docker Registry UI
\ No newline at end of file
diff --git a/dist/scripts/init.js b/dist/scripts/init.js
new file mode 100644
index 0000000..90b8ebb
--- /dev/null
+++ b/dist/scripts/init.js
@@ -0,0 +1,27 @@
+const REGISTRY_SERVER_KEY = 'registryServer';
+let registryServersStr = localStorage.getItem(REGISTRY_SERVER_KEY);
+let registryServers = [];
+if (registryServersStr !== null){
+ let rs = JSON.parse(registryServersStr);
+ if (rs instanceof Array) {
+ registryServers = rs;
+ }
+}
+
+const apiHost = location.protocol+'//'+location.host;
+if (!registryServers.includes(apiHost)) {
+ let xhr = new XMLHttpRequest();
+ xhr.open('GET', apiHost+"/v2/", true);
+ xhr.onload = function (e) {
+ if (xhr.readyState === 4) {
+ if (xhr.status === 200) {
+ const version = xhr.getResponseHeader('Docker-Distribution-Api-Version');
+ if (version.startsWith('registry/2.')) {
+ registryServers.unshift(apiHost);
+ localStorage.setItem(REGISTRY_SERVER_KEY, JSON.stringify(registryServers));
+ }
+ }
+ }
+ };
+ xhr.send();
+}
diff --git a/src/index.html b/src/index.html
index edd9850..30ff624 100644
--- a/src/index.html
+++ b/src/index.html
@@ -32,6 +32,7 @@
+
diff --git a/src/scripts/init.js b/src/scripts/init.js
new file mode 100644
index 0000000..90b8ebb
--- /dev/null
+++ b/src/scripts/init.js
@@ -0,0 +1,27 @@
+const REGISTRY_SERVER_KEY = 'registryServer';
+let registryServersStr = localStorage.getItem(REGISTRY_SERVER_KEY);
+let registryServers = [];
+if (registryServersStr !== null){
+ let rs = JSON.parse(registryServersStr);
+ if (rs instanceof Array) {
+ registryServers = rs;
+ }
+}
+
+const apiHost = location.protocol+'//'+location.host;
+if (!registryServers.includes(apiHost)) {
+ let xhr = new XMLHttpRequest();
+ xhr.open('GET', apiHost+"/v2/", true);
+ xhr.onload = function (e) {
+ if (xhr.readyState === 4) {
+ if (xhr.status === 200) {
+ const version = xhr.getResponseHeader('Docker-Distribution-Api-Version');
+ if (version.startsWith('registry/2.')) {
+ registryServers.unshift(apiHost);
+ localStorage.setItem(REGISTRY_SERVER_KEY, JSON.stringify(registryServers));
+ }
+ }
+ }
+ };
+ xhr.send();
+}