diff --git a/app/badbrowser.html b/app/badbrowser.html new file mode 100644 index 00000000..3e5f7a43 --- /dev/null +++ b/app/badbrowser.html @@ -0,0 +1,107 @@ + + + + + + Telegram Web + + + + + + + + + + + + + +
+ +
+ + +
+ + +

Telegram Web

+ + + +
+ +

You are using outdated browser!

+ +
+

Sorry, your browser is not supported by Telegram Web.

+

In order to use Telegram secure messaging protocol - MTProto, Telegram Web utilizes modern HTML5 technologies.

+

Your browser doesn't support these features. Please download a modern browser and come back soon!

+
+ + + Download Mozilla Firefox + Download Google Chrome + +
+ +
+ + + + + + + + \ No newline at end of file diff --git a/app/css/app.css b/app/css/app.css index ab3d70d9..f3e19796 100644 --- a/app/css/app.css +++ b/app/css/app.css @@ -594,9 +594,9 @@ input.tg_range { width: 100%; max-width: 362px; display: inline-block; - background: #c7c7c7; - height: 3px; - line-height: 18px; + /*background: #c7c7c7;*/ + /*height: 18px; + line-height: 18px;*/ vertical-align: top; margin: 8px 0; border-radius: 2px; @@ -624,7 +624,6 @@ input.tg_range::-webkit-slider-thumb { border-radius: 6px; overflow: hidden; } - input.tg_range::-moz-range-thumb { border: 0; background: #568cb5; @@ -633,6 +632,29 @@ input.tg_range::-moz-range-thumb { border-radius: 6px; overflow: hidden; } +input.tg_range::-ms-track { + color: transparent; + border: 0; + cursor: pointer; + outline: none !important; + width: 100%; + max-width: 362px; + display: inline-block; + background: #c7c7c7; + height: 3px; + line-height: 18px; + vertical-align: top; + margin: 8px 0; + border-radius: 2px; +} +input.tg_range::-ms-thumb { + border: 0; + background: #568cb5; + width: 12px; + height: 12px; + border-radius: 6px; + overflow: hidden; +} .tg_form_group { @@ -688,6 +710,9 @@ input.tg_range::-moz-range-thumb { height: 160px; margin: 0 auto; } +img.welcome_logo { + background: none; +} .welcome_header { text-align: center; font-size: 24px; @@ -2649,3 +2674,21 @@ ce671b orange .changelog_version_changes_list li { line-height: 20px; } + + +.bad_browser_wrap { + border-radius: 4px; + border: 1px solid #ccc; + background: #FFF; + max-width: 600px; + margin: 50px auto 0; + padding: 40px; +} +.bad_browser_wrap h2 { + margin-top: 0; +} +.bad_browser_text { + font-size: 14px; + line-height: 160%; + margin: 25px 0 30px; +} \ No newline at end of file diff --git a/app/index.html b/app/index.html index c4bfed49..937ad49e 100644 --- a/app/index.html +++ b/app/index.html @@ -1,6 +1,9 @@ - + + Telegram Web @@ -37,7 +40,7 @@
- + diff --git a/app/js/controllers.js b/app/js/controllers.js index 3d4493b9..ddc81a12 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -1505,7 +1505,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) return; } - $scope.delete = function () { + $scope['delete'] = function () { var messageID = $scope.messageID; ErrorService.confirm({type: 'MESSAGE_DELETE'}).then(function () { AppMessagesManager.deleteMessages([messageID]); @@ -1714,7 +1714,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) }); }; - $scope.delete = function () { + $scope['delete'] = function () { var messageID = $scope.photoID; ErrorService.confirm({type: 'MESSAGE_DELETE'}).then(function () { AppMessagesManager.deleteMessages([messageID]); @@ -1744,7 +1744,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) }); }; - $scope.delete = function () { + $scope['delete'] = function () { var messageID = $scope.messageID; ErrorService.confirm({type: 'MESSAGE_DELETE'}).then(function () { AppMessagesManager.deleteMessages([messageID]); diff --git a/app/js/init.js b/app/js/init.js index 22e9a1b2..9f0ccc36 100644 --- a/app/js/init.js +++ b/app/js/init.js @@ -111,8 +111,13 @@ locale = (navigator.language || '').toLowerCase(); locale = Config.I18n.aliases[locale] || locale; } - if (!Config.Mobile && Config.I18n.supported.indexOf(locale) != -1) { - Config.I18n.locale = locale; + if (!Config.Mobile) { + for (var i = 0; i < Config.I18n.supported.length; i++) { + if (Config.I18n.supported[i] == locale) { + Config.I18n.locale = locale; + break; + } + } } bootReady.i18n_ng = Config.I18n.locale == defaultLocale; // Already included diff --git a/app/js/lib/crypto_worker.js b/app/js/lib/crypto_worker.js index 726e8e5b..676ee807 100644 --- a/app/js/lib/crypto_worker.js +++ b/app/js/lib/crypto_worker.js @@ -6,7 +6,7 @@ */ importScripts( - '../../vendor/console-polyfill/console-polyfill.js', + 'polyfill.js', 'bin_utils.js', '../../vendor/jsbn/jsbn_combined.js', '../../vendor/leemon_bigint/bigint.js', diff --git a/app/js/lib/mtproto_wrapper.js b/app/js/lib/mtproto_wrapper.js index 8b586da5..34762888 100644 --- a/app/js/lib/mtproto_wrapper.js +++ b/app/js/lib/mtproto_wrapper.js @@ -143,6 +143,7 @@ angular.module('izhukov.mtproto.wrapper', ['izhukov.utils', 'izhukov.mtproto']) console.error(dT(), 'Error', error.code, error.type, baseDcID, dcID); if (error.code == 401 && baseDcID == dcID) { Storage.remove('dc', 'user_auth'); + rejectPromise(error); } else if (error.code == 401 && baseDcID && dcID != baseDcID) { if (cachedExportPromise[dcID] === undefined) { @@ -175,7 +176,7 @@ angular.module('izhukov.mtproto.wrapper', ['izhukov.utils', 'izhukov.mtproto']) }); } else if (error.code == 303) { - var newDcID = error.type.match(/^(PHONE_MIGRATE_|NETWORK_MIGRATE_)(\d+)/)[2]; + var newDcID = error.type.match(/^(PHONE_MIGRATE_|NETWORK_MIGRATE_|USER_MIGRATE_)(\d+)/)[2]; if (newDcID != dcID) { if (options.dcID) { options.dcID = newDcID; diff --git a/app/js/lib/polyfill.js b/app/js/lib/polyfill.js new file mode 100644 index 00000000..fcb51ab9 --- /dev/null +++ b/app/js/lib/polyfill.js @@ -0,0 +1,98 @@ +// Console-polyfill. MIT license. +// https://github.com/paulmillr/console-polyfill +// Make it safe to do console.log() always. +(function (con) { + 'use strict'; + var prop, method; + var empty = {}; + var dummy = function() {}; + var properties = 'memory'.split(','); + var methods = ('assert,count,debug,dir,dirxml,error,exception,group,' + + 'groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,' + + 'time,timeEnd,trace,warn').split(','); + while (prop = properties.pop()) con[prop] = con[prop] || empty; + while (method = methods.pop()) con[method] = con[method] || dummy; +})(this.console = this.console || {}); + + +/* Array.indexOf polyfill */ +if (!Array.prototype.indexOf) { + Array.prototype.indexOf = function(searchElement, fromIndex) { + var k; + if (this == null) { + throw new TypeError('"this" is null or not defined'); + } + + var O = Object(this); + var len = O.length >>> 0; + if (len === 0) { + return -1; + } + var n = +fromIndex || 0; + + if (Math.abs(n) === Infinity) { + n = 0; + } + if (n >= len) { + return -1; + } + k = Math.max(n >= 0 ? n : len - Math.abs(n), 0); + while (k < len) { + if (k in O && O[k] === searchElement) { + return k; + } + k++; + } + return -1; + }; +} + +/* Array.isArray polyfill */ +if (!Array.isArray) { + Array.isArray = function(arg) { + return Object.prototype.toString.call(arg) === '[object Array]'; + }; +} + +/* Object.create polyfill */ +if (typeof Object.create != 'function') { + Object.create = (function() { + var Object = function() {}; + return function (prototype) { + if (arguments.length > 1) { + throw Error('Second argument not supported'); + } + if (typeof prototype != 'object') { + throw TypeError('Argument must be an object'); + } + Object.prototype = prototype; + var result = new Object(); + Object.prototype = null; + return result; + }; + })(); +} + +/* Function.bind polyfill */ +if (!Function.prototype.bind) { + Function.prototype.bind = function (oThis) { + if (typeof this !== "function") { + throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable"); + } + + var aArgs = Array.prototype.slice.call(arguments, 1), + fToBind = this, + fNOP = function () {}, + fBound = function () { + return fToBind.apply(this instanceof fNOP && oThis + ? this + : oThis, + aArgs.concat(Array.prototype.slice.call(arguments))); + }; + + fNOP.prototype = this.prototype; + fBound.prototype = new fNOP(); + + return fBound; + }; +} \ No newline at end of file diff --git a/app/js/lib/utils.js b/app/js/lib/utils.js index 837593b0..e03ca793 100644 --- a/app/js/lib/utils.js +++ b/app/js/lib/utils.js @@ -108,33 +108,6 @@ function listUniqSorted (list) { return resultList; } - -// Bind polyfill from MDN -if (!Function.prototype.bind) { - Function.prototype.bind = function (oThis) { - if (typeof this !== "function") { - // closest thing possible to the ECMAScript 5 - // internal IsCallable function - throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable"); - } - - var aArgs = Array.prototype.slice.call(arguments, 1), - fToBind = this, - fNOP = function () {}, - fBound = function () { - return fToBind.apply(this instanceof fNOP && oThis - ? this - : oThis, - aArgs.concat(Array.prototype.slice.call(arguments))); - }; - - fNOP.prototype = this.prototype; - fBound.prototype = new fNOP(); - - return fBound; - }; -} - function templateUrl (tplName) { return 'partials/' + (Config.Mobile ? 'mobile' : 'desktop') + '/' + tplName + '.html'; } diff --git a/app/js/services.js b/app/js/services.js index 4ba233ad..091d960c 100644 --- a/app/js/services.js +++ b/app/js/services.js @@ -424,7 +424,7 @@ angular.module('myApp.services', ['myApp.i18n']) return; } - this.continue(); + this['continue'](); } request.onerror = function (e) { diff --git a/gulpfile.js b/gulpfile.js index 92183f04..0d2b6f89 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -45,8 +45,8 @@ gulp.task('copy', function() { .pipe(gulp.dest('dist')), gulp.src(['app/img/**/*.wav']) .pipe(gulp.dest('dist/img')), - gulp.src('app/vendor/console-polyfill/console-polyfill.js') - .pipe(gulp.dest('dist/vendor/console-polyfill')), + gulp.src('app/js/polyfill.js') + .pipe(gulp.dest('dist/js/polyfill.js')), gulp.src('app/js/lib/bin_utils.js') .pipe(gulp.dest('dist/js/lib')), gulp.src('app/vendor/closure/long.js') diff --git a/cldr_localize.js b/scripts/cldr_localize.js similarity index 100% rename from cldr_localize.js rename to scripts/cldr_localize.js diff --git a/emoji_data/build.php b/scripts/emoji_data/build.php similarity index 100% rename from emoji_data/build.php rename to scripts/emoji_data/build.php diff --git a/emoji_data/emoji.json b/scripts/emoji_data/emoji.json similarity index 100% rename from emoji_data/emoji.json rename to scripts/emoji_data/emoji.json diff --git a/scripts/ua_handler.js b/scripts/ua_handler.js new file mode 100644 index 00000000..481377d1 --- /dev/null +++ b/scripts/ua_handler.js @@ -0,0 +1,94 @@ +var fs = require('fs'), path = require('path'); +var uaList = fs.readFileSync(path.join(__dirname, 'ua.txt')); + + +uaList = uaList.toString().split('\n'); + + +var OSs = {}; +var browsers = {}; +var browserVersions = {}; +var unknown = []; + +var osMatch = { + ios: /iOS|iPhone OS/i, + android: /Android/i, + linux: /Linux/i, + win: /Windows/i, + osx: /Mac|OS X/i, + blackberry: /BlackBerry|BB10/i, + series60: /Series 60|Series60/i, + series40: /Series 40|Series40/i, + j2me: /J2ME|MIDP/i +}; + +var browserMatch = { + opera: /opera/i, + ie: /msie|trident\//i, + chrome: /chrome/i, + chromium: /chromium/i, + safari: /safari|AppleWebKit/i, + firefox: /firefox/i, + blackberry: /BlackBerry/i +}; + +var featureMatch = { + ipad: /ipad/i, + opera_mobile: /opera mini|opera mobi/i, + opera_mini: /opera mini/i, + blackberry: /blackberry/i +}; + +uaList.forEach(function (uaName) { + var os = 'unknown'; + for (var curOs in osMatch) { + if (uaName.match(osMatch[curOs])) { + os = curOs; + break; + } + } + + var browser = 'unknown'; + for (var curBrowser in browserMatch) { + if (uaName.match(browserMatch[curBrowser])) { + browser = curBrowser; + break; + } + } + + var version = ( + uaName.match(/MSIE ([\d.]+)/) || + uaName.match( /.+(?:me|ox|on|rv|it|era|opr|ie)[\/: ]([\d.]+)/) || + [0,'0'] + )[1]; + + if (!OSs[os]) { + OSs[os] = 1; + } else { + OSs[os]++; + } + + if (!browsers[os + ' ' + browser]) { + browsers[os + ' ' + browser] = 1; + } else { + browsers[os + ' ' + browser]++; + } + + if (os == 'unknown' || browser == 'unknown') { + unknown.push(uaName); + } + + if (!browserVersions[os + ' ' + browser + ' ' + version]) { + browserVersions[os + ' ' + browser + ' ' + version] = 1; + } else { + browserVersions[os + ' ' + browser + ' ' + version]++; + } + +}) + + +console.log(OSs); +console.log(browsers); +console.log(browserVersions); +// console.log(unknown); +