Display an alert when CryptPad has a new version

pull/1/head
yflory 8 years ago
parent 21f9e31e75
commit 814c81fb13

@ -54,6 +54,10 @@ define(function () {
out.comingSoon = "Bientôt disponible..."; out.comingSoon = "Bientôt disponible...";
out.newVersion = '<b>CryptPad a été mis à jour !</b><br>' +
'Découvrez les nouveautés de la dernière version :<br>'+
'<a href="https://github.com/xwiki-labs/cryptpad/releases/tag/{0}" target="_blank">Notes de version pour CryptPad {0}</a>';
out.upgrade = "Améliorer"; out.upgrade = "Améliorer";
out.upgradeTitle = "Améliorer votre compte pour augmenter la limite de stockage"; out.upgradeTitle = "Améliorer votre compte pour augmenter la limite de stockage";
out.MB = "Mo"; out.MB = "Mo";

@ -56,6 +56,10 @@ define(function () {
out.comingSoon = "Coming soon..."; out.comingSoon = "Coming soon...";
out.newVersion = '<b>CryptPad has been updated!</b><br>' +
'Check out what\'s new in the latest version:<br>'+
'<a href="https://github.com/xwiki-labs/cryptpad/releases/tag/{0}" target="_blank">Release notes for CryptPad {0}</a>';
out.upgrade = "Upgrade"; out.upgrade = "Upgrade";
out.upgradeTitle = "Upgrade your account to increase the storage limit"; out.upgradeTitle = "Upgrade your account to increase the storage limit";
out.MB = "MB"; out.MB = "MB";

@ -23,7 +23,6 @@ define([
Additionally, there is some basic functionality for import/export. Additionally, there is some basic functionality for import/export.
*/ */
var common = window.Cryptpad = { var common = window.Cryptpad = {
Messages: Messages, Messages: Messages,
Clipboard: Clipboard Clipboard: Clipboard
@ -1296,6 +1295,25 @@ define([
return $userAdmin; return $userAdmin;
}; };
var CRYPTPAD_VERSION = 'cryptpad-version';
var updateLocalVersion = function () {
// Check for CryptPad updates
var urlArgs = Config.requireConf ? Config.requireConf.urlArgs : null;
if (!urlArgs) { return; }
var arr = /ver=([0-9.]+)(-[0-9]*)?/.exec(urlArgs);
var ver = arr[1];
if (!ver) { return; }
var verArr = ver.split('.');
if (verArr.length !== 3) { return; }
var stored = localStorage[CRYPTPAD_VERSION] || '0.0.0';
var storedArr = stored.split('.');
var shouldUpdate = parseInt(verArr[0]) > parseInt(storedArr[0]) ||
(parseInt(verArr[0]) === parseInt(storedArr[0]) &&
parseInt(verArr[1]) > parseInt(storedArr[1]));
if (!shouldUpdate) { return; }
Cryptpad.alert(Messages._getKey('newVersion', [ver]), null, true);
localStorage[CRYPTPAD_VERSION] = ver;
};
common.ready = (function () { common.ready = (function () {
var env = {}; var env = {};
@ -1313,6 +1331,9 @@ define([
block--; block--;
if (!block) { if (!block) {
initialized = true; initialized = true;
updateLocalVersion();
f(void 0, env); f(void 0, env);
} }
}; };

Loading…
Cancel
Save