diff --git a/src/scripts/script.js b/src/scripts/script.js
index 5f08bdc..a48f4b2 100644
--- a/src/scripts/script.js
+++ b/src/scripts/script.js
@@ -85,7 +85,7 @@ registryUI.removeServer = function(url) {
}
registryUI.updateHistory = function(url) {
- history.pushState(null, '', (url ? '?url=' + registryUI.encodeURI(url) : '?') + window.location.hash);
+ registryUI.updateQueryString({ url: registryUI.encodeURI(url) })
registryUI._url = url;
}
@@ -100,10 +100,12 @@ registryUI.getUrlQueryParam = function () {
};
registryUI.encodeURI = function(url) {
+ if (!url) { return; }
return url.indexOf('&') < 0 ? window.encodeURIComponent(url) : btoa(url);
};
registryUI.decodeURI = function(url) {
+ if (!url) { return; }
return url.startsWith('http') ? window.decodeURIComponent(url) : atob(url);
};
diff --git a/src/scripts/utils.js b/src/scripts/utils.js
index 4087294..878685e 100644
--- a/src/scripts/utils.js
+++ b/src/scripts/utils.js
@@ -76,7 +76,7 @@ registryUI.getPage = function(elts, page, limit) {
registryUI.getNumPages = function(elts, limit) {
if (!limit) { limit = 100; }
if (!elts) { return 0; }
- return Math.trunc((elts.length / limit) % 10);
+ return Math.trunc((elts.length / limit) % 10) + 1;
}
registryUI.getPageLabels = function(page, nPages) {
@@ -95,4 +95,14 @@ registryUI.getPageLabels = function(page, nPages) {
pageLabels.push({'icon': 'last_page', page: nPages});
}
return pageLabels;
+}
+
+registryUI.updateQueryString = function(qs) {
+ var search = '';
+ for (var key in qs) {
+ if (qs[key] !== undefined) {
+ search += (search.length > 0 ? '&' : '?') +key + '=' + qs[key];
+ }
+ }
+ history.pushState(null, '', search + window.location.hash);
}
\ No newline at end of file
diff --git a/src/tags/app.tag b/src/tags/app.tag
index e9a6dd4..01c9175 100644
--- a/src/tags/app.tag
+++ b/src/tags/app.tag
@@ -231,6 +231,24 @@ along with this program. If not, see