Browse Source

Added migrate to HTTPS modal

master
Igor Zhukov 10 years ago
parent
commit
48f393afc5
  1. 5
      app/js/controllers.js
  2. 6
      app/js/i18n.js
  3. 3
      app/js/lib/config.js
  4. 3
      app/js/locales/en-us.json
  5. 44
      app/js/services.js
  6. 1
      app/partials/desktop/confirm_modal.html

5
app/js/controllers.js

@ -34,7 +34,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -34,7 +34,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
return;
}
if (location.protocol == 'http:' &&
(location.host == 'zhukov.github.io' || location.host == 'web.telegram.org')) {
Config.App.domains.indexOf(location.hostname) != -1) {
location = 'https://web.telegram.org';
}
});
@ -300,7 +300,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -300,7 +300,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
ChangelogNotifyService.checkUpdate();
})
.controller('AppIMController', function ($scope, $location, $routeParams, $modal, $rootScope, $modalStack, MtpApiManager, AppUsersManager, AppChatsManager, ContactsSelectService, ChangelogNotifyService, ErrorService, AppRuntimeManager) {
.controller('AppIMController', function ($scope, $location, $routeParams, $modal, $rootScope, $modalStack, MtpApiManager, AppUsersManager, AppChatsManager, ContactsSelectService, ChangelogNotifyService, ErrorService, AppRuntimeManager, HttpsMigrateService) {
$scope.$on('$routeUpdate', updateCurDialog);
@ -428,6 +428,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -428,6 +428,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
}
ChangelogNotifyService.checkUpdate();
HttpsMigrateService.start();
})
.controller('AppImDialogsController', function ($scope, $location, $q, $timeout, $routeParams, MtpApiManager, AppUsersManager, AppChatsManager, AppMessagesManager, AppPeersManager, PhonebookContactsService, ErrorService) {

6
app/js/i18n.js

@ -22,8 +22,10 @@ angular.module('myApp.i18n', ['izhukov.utils']) @@ -22,8 +22,10 @@ angular.module('myApp.i18n', ['izhukov.utils'])
}
function parseMarkdownString(msgstr, msgid) {
msgstr = msgstr.replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>")
.replace(/\n/g, "<br/>");
msgstr = msgstr
.replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>")
.replace(/\n|&#10;/g, "<br/>");
return msgstr;
}

3
app/js/lib/config.js

@ -21,7 +21,8 @@ Config = window.Config || {}; @@ -21,7 +21,8 @@ Config = window.Config || {};
Config.App = {
id: 2496,
hash: '8da85b0d5bfe62527e5b244c209159c3',
version: '0.3.4'
version: '0.3.4',
domains: ['web.telegram.org', 'zhukov.github.io']
};
Config.Modes = {

3
app/js/locales/en-us.json

@ -127,7 +127,8 @@ @@ -127,7 +127,8 @@
"confirm_modal_forward_to_peer": "Forward to {peer}?",
"confirm_modal_send_to_peer": "Send to {peer}?",
"confirm_modal_share_file_peer": "Share with {peer}?",
"confirm_modal_apply_lang_with_reload_md": "Language preference was saved.\nReload the App now?",
"confirm_modal_apply_lang_with_reload_md": "Reload the App to apply language?",
"confirm_modal_migrate_to_https_md": "Telegram Web now supports additional SSL encryption. Would you like to switch to HTTPS?\nThe HTTP version will be disabled soon.",
"confirm_modal_are_u_sure": "Are you sure?",
"confirm_modal_logout_submit": "Log Out",

44
app/js/services.js

@ -3813,12 +3813,12 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -3813,12 +3813,12 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
},
selectContact: function (options) {
return select (false, options);
},
}
}
})
.service('ChangelogNotifyService', function (Storage, $rootScope, $http, $modal) {
.service('ChangelogNotifyService', function (Storage, $rootScope, $modal) {
function versionCompare (ver1, ver2) {
if (typeof ver1 !== 'string') {
@ -3882,3 +3882,43 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -3882,3 +3882,43 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
showChangelog: showChangelog
}
})
.service('HttpsMigrateService', function (ErrorService, Storage) {
var started = false;
function check () {
Storage.get('https_dismiss').then(function (ts) {
if (!ts || tsNow() > ts + 43200000) {
ErrorService.confirm({
type: 'MIGRATE_TO_HTTPS'
}).then(function () {
var popup;
try {
popup = window.open('https://web.telegram.org', '_blank');
} catch (e) {}
if (!popup) {
location = 'https://web.telegram.org';
}
}, function () {
Storage.set({https_dismiss: tsNow()});
});
}
});
}
function start () {
if (started ||
location.protocol != 'http:' ||
Config.App.domains.indexOf(location.hostname) == -1) {
return;
}
started = true;
setTimeout(check, 120000);
}
return {
start: start,
check: check
}
})

1
app/partials/desktop/confirm_modal.html

@ -36,6 +36,7 @@ @@ -36,6 +36,7 @@
</my-i18n-param>
</my-i18n>
<div ng-switch-when="APPLY_LANG_WITH_RELOAD" my-i18n="confirm_modal_apply_lang_with_reload_md"></div>
<div ng-switch-when="MIGRATE_TO_HTTPS" my-i18n="confirm_modal_migrate_to_https_md"></div>
<span ng-switch-default ng-switch="message.length > 0">
<span ng-switch-when="true" ng-bind="message"></span>
<span ng-switch-default my-i18n="confirm_modal_are_u_sure"></span>

Loading…
Cancel
Save