-
@@ -1111,6 +1154,7 @@
+
diff --git a/js/WhatsNew.js b/js/WhatsNew.js
new file mode 100644
index 0000000..28df392
--- /dev/null
+++ b/js/WhatsNew.js
@@ -0,0 +1,43 @@
+BR.WhatsNew = {
+ init: function () {
+ var self = this;
+ self.prepare(self.hasNewVersions());
+ $('#whatsnew').on('hidden.bs.modal', function () {
+ localStorage.setItem('changelogVersion', self.getLatestVersion());
+ // next time popup is open, by default we will see everything
+ self.prepare(false);
+ });
+ $('#whatsnew').on('shown.bs.modal', function () {
+ BR.message.hide();
+ document.getElementsByClassName('version')[0].classList.remove('version-new');
+ });
+ if (self.hasNewVersions()) {
+ BR.message.showInfo(i18next.t('whatsnew.new-version'));
+ document.getElementsByClassName('version')[0].classList.add('version-new');
+ }
+ },
+
+ getLatestVersion: function () {
+ return BR.changelog.match('
')[1];
+ },
+
+ hasNewVersions: function () {
+ return true;
+ if (!BR.Util.localStorageAvailable()) return false;
+
+ var currentVersion = localStorage.getItem('changelogVersion');
+
+ return !currentVersion || currentVersion < this.getLatestVersion();
+ },
+
+ prepare: function (newOnly) {
+ var currentVersion = localStorage.getItem('changelogVersion');
+ var container = document.querySelector('#whatsnew .modal-body');
+ var cl = BR.changelog;
+ if (newOnly && currentVersion) {
+ var head = '';
+ cl = cl.substring(0, cl.indexOf(head));
+ }
+ container.innerHTML = cl;
+ },
+};
diff --git a/js/control/Message.js b/js/control/Message.js
index 96f99ee..2867dd2 100644
--- a/js/control/Message.js
+++ b/js/control/Message.js
@@ -12,8 +12,19 @@ BR.Message = L.Class.extend({
_show: function (msg, type) {
var ele = L.DomUtil.get(this.id),
- iconClass = type === 'warning' ? 'fa-exclamation-triangle' : 'fa-times-circle',
- alertClass = type === 'warning' ? 'alert-warning' : 'alert-danger';
+ iconClass,
+ alertClass;
+ switch (type) {
+ case 'error':
+ iconClass = 'fa-times-circle';
+ alertClass = 'alert-danger';
+ case 'warning':
+ iconClass = 'fa-exclamation-triangle';
+ alertClass = 'alert-warning';
+ case 'info':
+ iconClass = 'fa-info-circle';
+ alertClass = 'alert-info';
+ }
L.DomEvent.disableClickPropagation(ele);
@@ -59,6 +70,10 @@ BR.Message = L.Class.extend({
showWarning: function (msg) {
this._show(msg, 'warning');
},
+
+ showInfo: function (msg) {
+ this._show(msg, 'info');
+ },
});
// static instance as global control
diff --git a/js/index.js b/js/index.js
index d8e82eb..aaa7037 100644
--- a/js/index.js
+++ b/js/index.js
@@ -452,6 +452,8 @@
},
urlHash
);
+
+ BR.WhatsNew.init();
}
i18next.on('languageChanged', function (detectedLanguage) {
diff --git a/locales/en.json b/locales/en.json
index cca67c5..cf2545b 100644
--- a/locales/en.json
+++ b/locales/en.json
@@ -281,5 +281,9 @@
"temporary-profile": "Note: Uploaded custom profiles are only cached temporarily on the server.
Please save your edits to your local PC.",
"tracks-load-error": "Error loading tracks: {{error}}",
"upload-error": "Upload error: {{error}}"
+ },
+ "whatsnew": {
+ "title": "What's new?",
+ "new-version": "A new version was released since your last visit. Click here to see what's new!"
}
}
diff --git a/package.json b/package.json
index b793544..0b45217 100644
--- a/package.json
+++ b/package.json
@@ -112,6 +112,7 @@
"gulp-zip": "^5.0.2",
"husky": "^4.3.4",
"i18next-scanner": "^3.0.0",
+ "marked": "^2.0.0",
"merge-stream": "^2.0.0",
"node-fetch": "^2.6.1",
"npmfiles": "^0.1.3",
diff --git a/yarn.lock b/yarn.lock
index b4cfefc..0c6db42 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -6514,6 +6514,11 @@ mapbbcode@MapBBCode/mapbbcode#v1.2.0:
version "1.2.0"
resolved "https://codeload.github.com/MapBBCode/mapbbcode/tar.gz/8407568e560008bb191ed5754ae83449cea574c2"
+marked@^2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/marked/-/marked-2.0.0.tgz#9662bbcb77ebbded0662a7be66ff929a8611cee5"
+ integrity sha512-NqRSh2+LlN2NInpqTQnS614Y/3NkVMFFU6sJlRFEpxJ/LHuK/qJECH7/fXZjk4VZstPW/Pevjil/VtSONsLc7Q==
+
matchdep@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/matchdep/-/matchdep-2.0.0.tgz#c6f34834a0d8dbc3b37c27ee8bbcb27c7775582e"
Please save your edits to your local PC.", "tracks-load-error": "Error loading tracks: {{error}}", "upload-error": "Upload error: {{error}}" + }, + "whatsnew": { + "title": "What's new?", + "new-version": "A new version was released since your last visit. Click here to see what's new!" } } diff --git a/package.json b/package.json index b793544..0b45217 100644 --- a/package.json +++ b/package.json @@ -112,6 +112,7 @@ "gulp-zip": "^5.0.2", "husky": "^4.3.4", "i18next-scanner": "^3.0.0", + "marked": "^2.0.0", "merge-stream": "^2.0.0", "node-fetch": "^2.6.1", "npmfiles": "^0.1.3", diff --git a/yarn.lock b/yarn.lock index b4cfefc..0c6db42 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6514,6 +6514,11 @@ mapbbcode@MapBBCode/mapbbcode#v1.2.0: version "1.2.0" resolved "https://codeload.github.com/MapBBCode/mapbbcode/tar.gz/8407568e560008bb191ed5754ae83449cea574c2" +marked@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/marked/-/marked-2.0.0.tgz#9662bbcb77ebbded0662a7be66ff929a8611cee5" + integrity sha512-NqRSh2+LlN2NInpqTQnS614Y/3NkVMFFU6sJlRFEpxJ/LHuK/qJECH7/fXZjk4VZstPW/Pevjil/VtSONsLc7Q== + matchdep@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/matchdep/-/matchdep-2.0.0.tgz#c6f34834a0d8dbc3b37c27ee8bbcb27c7775582e"