Browse Source

Update 2016-07-05T14:59:56.467Z

gh-pages
Igor Zhukov 9 years ago
parent
commit
5d050df89a
  1. 92
      app.manifest
  2. 1
      badbrowser.html
  3. 11
      css/app.css
  4. 1958
      css/badbrowser.css
  5. 7
      css/desktop.css
  6. 3
      css/mobile.css
  7. 6
      index.html
  8. 78457
      js/app.js
  9. 8
      js/background.js
  10. 588
      js/lib/bin_utils.js
  11. 30
      js/lib/crypto_worker.js
  12. 145
      js/lib/polyfill.js
  13. 1
      js/lib/push_worker.js
  14. 26
      js/locales/en-us.json
  15. 1
      manifest.json
  16. 260
      service_worker.js
  17. 15
      vendor/angular/i18n/angular-locale_de-de.js
  18. 15
      vendor/angular/i18n/angular-locale_en-us.js
  19. 15
      vendor/angular/i18n/angular-locale_es-es.js
  20. 15
      vendor/angular/i18n/angular-locale_it-it.js
  21. 15
      vendor/angular/i18n/angular-locale_nl-nl.js
  22. 15
      vendor/angular/i18n/angular-locale_pt-br.js
  23. 15
      vendor/angular/i18n/angular-locale_ru-ru.js
  24. 4
      webogram.appcache

92
app.manifest

@ -1,92 +0,0 @@
CACHE MANIFEST
# Time: Sun Jun 12 2016 22:29:17 GMT+0300 (MSK)
CACHE:
favicon.ico
favicon_unread.ico
css/app.css
css/desktop.css
css/mobile.css
img/Manytabs.png
img/Manytabs_2x.png
img/Telegram.png
img/Telegram.svg
img/Telegram72.png
img/Telegram72_2x.png
img/Telegram_2x.png
img/blank.gif
img/emojisprite_0.png
img/emojisprite_1.png
img/emojisprite_2.png
img/emojisprite_3.png
img/emojisprite_4.png
img/iphone_home120.png
img/iphone_startup.png
img/logo_share.png
img/sound_a.mp3
js/app.js
nacl/mtproto_crypto.nmf
nacl/mtproto_crypto.pexe
img/changelog/card_wecandoit.png
img/icons/AboutLogos.png
img/icons/AboutLogos_2x.png
img/icons/General.png
img/icons/General_2x.png
img/icons/IconsetSmiles.png
img/icons/IconsetSmiles_2x.png
img/icons/IconsetW.png
img/icons/IconsetW_2x.png
img/icons/Major.png
img/icons/Major_2x.png
img/icons/MobileIcons.png
img/icons/MobileIcons_2x.png
img/icons/PhotoIcons.png
img/icons/PhotoIcons_2x.png
img/icons/ProfileIcons.png
img/icons/ProfileIcons_2x.png
img/placeholders/[email protected]
img/placeholders/[email protected]
img/placeholders/[email protected]
img/placeholders/[email protected]
img/placeholders/[email protected]
img/placeholders/PhotoThumbConversation.gif
img/placeholders/PhotoThumbModal.gif
img/placeholders/[email protected]
img/placeholders/[email protected]
img/placeholders/[email protected]
img/placeholders/[email protected]
img/placeholders/[email protected]
img/placeholders/[email protected]
img/placeholders/[email protected]
img/placeholders/[email protected]
img/placeholders/VideoThumbConversation.gif
img/placeholders/VideoThumbModal.gif
js/lib/bin_utils.js
js/lib/crypto_worker.js
js/lib/polyfill.js
js/locales/de-de.json
js/locales/en-us.json
js/locales/es-es.json
js/locales/it-it.json
js/locales/nl-nl.json
js/locales/pt-br.json
js/locales/ru-ru.json
vendor/closure/long.js
vendor/cryptoJS/crypto.js
vendor/jsbn/jsbn_combined.js
vendor/leemon_bigint/bigint.js
vendor/rusha/rusha.js
vendor/angular/i18n/angular-locale_de-de.js
vendor/angular/i18n/angular-locale_en-us.js
vendor/angular/i18n/angular-locale_es-es.js
vendor/angular/i18n/angular-locale_it-it.js
vendor/angular/i18n/angular-locale_nl-nl.js
vendor/angular/i18n/angular-locale_pt-br.js
vendor/angular/i18n/angular-locale_ru-ru.js
NETWORK:
http://*
https://*
*

1
badbrowser.html

@ -0,0 +1 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns=http://www.w3.org/1999/xhtml xml:lang=en lang=en style="display:block; overflow: auto; background: #f8f8f8;"><head><meta charset=utf-8><meta name=viewport content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"><title>Telegram Web</title><link rel=stylesheet href=css/badbrowser.css><link rel=icon href=favicon.ico type=image/x-icon></head><body class="non_osx is_1x"><div class=welcome_form style="padding-bottom: 50px; clear: both;"><div class=bad_browser_wrap><h2>Your browser is outdated!</h2><div class=bad_browser_text><p>Don't take this personally, but your browser is too old to run <strong>Telegram Web</strong>.<br>We require HTML5 support for the MTProto secure messaging protocol to work.</p><p>Unfortunately, your current browser doesn't support HTML5.<br>Please download a modern browser and come back soon!</p></div><a class="btn btn-primary btn-lg pull-right" href=//firefox.com target=_blank>Download Mozilla Firefox</a> <a class="btn btn-primary btn-lg" href=//google.com/chrome target=_blank>Download Google Chrome</a></div></div></body></html>

11
css/app.css

@ -1383,8 +1383,9 @@ i.icon-verified{display:inline-block;width:17px;height:17px;vertical-align:text-
.im_dialog_message_wtyping .im_dialog_message_typing{display:block}
a.im_dialog .im_dialog_chat_from_wrap,a.im_dialog .im_short_message_media,a.im_dialog .im_short_message_service{color:#3a6d99}
a.im_dialog .im_short_message_text{color:grey}
a.im_dialog .im_dialog_draft_from{color:#c05f5a}
a.im_dialog:hover .im_short_message_text,a.im_dialog_selected .im_short_message_text{color:#698192}
.active a.im_dialog .im_dialog_chat_from_wrap,.active a.im_dialog .im_dialog_message,.active a.im_dialog .im_short_message_media,.active a.im_dialog .im_short_message_service,.active a.im_dialog .im_short_message_text{color:#fff}
.active a.im_dialog .im_dialog_chat_from_wrap,.active a.im_dialog .im_dialog_draft_from,.active a.im_dialog .im_dialog_message,.active a.im_dialog .im_short_message_media,.active a.im_dialog .im_short_message_service,.active a.im_dialog .im_short_message_text{color:#fff}
.im_dialog_peer{color:#222;font-weight:700;margin-top:2px;margin-bottom:2px}
.active .im_dialog_peer{color:#fff}
.im_dialog_badge{background:#64c270;font-size:11px;padding:5px;border-radius:11px;min-width:21px;text-align:center;margin-top:4px}
@ -1439,6 +1440,8 @@ div.im_message_video_thumb{position:relative}
.im_message_webpage_wrap{margin:3px 0;border-left:2px solid #7eaad1;padding-left:12px}
.im_message_webpage_site{color:#999;font-weight:400;line-height:120%;margin-bottom:3px}
.im_message_webpage_title{font-weight:700}
.im_message_sign{padding-top:1px}
.im_message_sign_link{pointer-events:none;color:#adadad;font-size:.95em}
.icon-circle{display:none;width:.5em;height:.5em;border-radius:.5em;background:#999;overflow:hidden;vertical-align:middle;margin:-2px 3px 0}
.im_message_webpage_description{margin:2px 0}
.im_message_webpage_article_photo{display:block;margin:5px 0 5px 5px}
@ -1550,7 +1553,7 @@ a.im_message_fwd_photo{position:absolute;margin-top:1px}
.reply_markup_row:last-child{padding-bottom:0}
.reply_markup_scrollable_wrap.active-scrollbar .reply_markup_row{margin-right:6px}
.reply_markup_button_wrap{display:inline-block;padding:0 4px}
.reply_markup_button{color:#3a6d99;display:block;width:100%;background:#f0f4f7;height:30px;font-size:13px;margin:0;padding:6px}
.reply_markup_button{color:#3a6d99;display:block;width:100%;background:#f0f4f7;height:30px;font-size:13px;margin:0;padding:6px;overflow:hidden;text-overflow:ellipsis}
.reply_markup_h1 .reply_markup_button{height:170px}
.reply_markup_h2 .reply_markup_button{height:81px}
.reply_markup_h3 .reply_markup_button{height:51px}
@ -1838,8 +1841,8 @@ img.chat_modal_participant_photo{width:40px;height:40px}
.stickerset_actions{padding:10px 20px;height:50px;text-align:center}
.stickerset_modal_loading{text-align:center;color:#999;font-size:16px;line-height:18px;padding:1px 50px;margin:0}
.confirm_modal_window .modal-dialog,.error_modal_window .modal-dialog,.md_simple_modal_window .modal-dialog{max-width:348px}
.im_message_focus .audio_player_duration,.im_message_focus .audio_player_size,.im_message_focus .im_message_date,.im_message_focus .im_message_document_size,.im_message_focus .im_message_fwd_date,.im_message_focus .im_message_views_cnt{color:#899daf}
.im_message_focus .im_message_outer_wrap{background-color:rgba(242,246,250,0);animation-name:im_message_focus_fade;-webkit-animation-timing-function:ease-in;animation-timing-function:ease-out;animation-duration:4s}
.im_message_focus_active .audio_player_duration,.im_message_focus_active .audio_player_size,.im_message_focus_active .im_message_date,.im_message_focus_active .im_message_document_size,.im_message_focus_active .im_message_fwd_date,.im_message_focus_active .im_message_sign_link,.im_message_focus_active .im_message_views_cnt{color:#899daf}
.im_message_focus_active .im_message_outer_wrap{background-color:rgba(242,246,250,0);animation-name:im_message_focus_fade;-webkit-animation-timing-function:ease-in;animation-timing-function:ease-out;animation-duration:4s}
@keyframes im_message_focus_fade{from{background-color:#f2f6fa}
to{background-color:rgba(242,246,250,0)}}
.user_color_1,.user_color_1:hover{color:#8365ab}

1958
css/badbrowser.css

File diff suppressed because it is too large Load Diff

7
css/desktop.css

@ -775,12 +775,14 @@ a.footer_link.active:active {
.im_message_selected .im_message_audio_size,
.im_message_selected .im_message_fwd_date,
.im_message_selected .im_message_views_cnt,
.im_message_selected .im_message_sign_link,
.im_history_select_active .im_message_outer_wrap:hover .im_message_date,
.im_history_select_active .im_message_outer_wrap:hover .im_message_document_size,
.im_history_select_active .im_message_outer_wrap:hover .im_message_audio_duration,
.im_history_select_active .im_message_outer_wrap:hover .im_message_audio_size,
.im_history_select_active .im_message_outer_wrap:hover .im_message_fwd_date,
.im_history_select_active .im_message_outer_wrap:hover .im_message_views_cnt {
.im_history_select_active .im_message_outer_wrap:hover .im_message_views_cnt,
.im_history_select_active .im_message_outer_wrap:hover .im_message_sign_link {
color: #899daf;
}
.icon-select-tick {
@ -894,6 +896,9 @@ a.footer_link.active:active {
text-overflow: ellipsis;
vertical-align: bottom;
}
a.peer_select_modal_share_link {
color: #999 !important;
}
@media (max-height: 600px), (max-width: 1010px) {
.im_page_wrap {
border-bottom: 0;

3
css/mobile.css

@ -710,6 +710,9 @@ a.im_message_author_via .im_message_fwd_author {
font-size: 13px;
font-weight: normal;
}
.im_history_messages_group .im_message_sign_link {
font-size: 12px;
}
.im_grouped_short a.im_message_from_photo,
.im_grouped_short a.im_message_author,
.im_grouped_short a.im_message_author_via,

6
index.html

@ -1,5 +1 @@
<!doctype html><html lang=en manifest=webogram.appcache ng-csp xmlns:ng=http://angularjs.org id=ng-app><head><meta charset=utf-8><meta name=viewport content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"><title>Telegram Web</title><link rel=stylesheet href=css/app.css><style>
html {
display: none;
}
</style><link rel=icon href=favicon.ico type=image/x-icon><link rel=apple-touch-icon href=img/iphone_home120.png><link rel=apple-touch-icon sizes=120x120 href=img/iphone_home120.png><link rel=apple-touch-startup-image media="(device-width: 320px)" href=img/iphone_startup.png><meta name=apple-mobile-web-app-title content="Telegram Web"><meta name=mobile-web-app-capable content=yes><meta name=apple-mobile-web-app-capable content=yes><meta name=apple-mobile-web-app-status-bar-style content=black-translucent><meta name=theme-color content=#497495><meta name=google content=notranslate><meta property=og:title content="Telegram Web"><meta property=og:url content="https://web.telegram.org/"><meta property=og:image content=https://web.telegram.org/img/logo_share.png><meta property=og:site_name content="Telegram Web"><meta property=og:description content="Welcome to the Web application of Telegram messenger. See https://github.com/zhukov/webogram for more info."></head><body><div class=page_wrap ng-view></div><div id=notify_sound></div><script src=js/app.js></script></body></html>
<!doctype html><html lang=en manifest=webogram.appcache ng-csp xmlns:ng=http://angularjs.org id=ng-app style="display: none;"><head><meta charset=utf-8><meta name=viewport content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"><title>Telegram Web</title><link rel=stylesheet href=css/app.css><link rel=manifest href=manifest.json><link rel=icon href=favicon.ico type=image/x-icon><link rel=apple-touch-icon href=img/iphone_home120.png><link rel=apple-touch-icon sizes=120x120 href=img/iphone_home120.png><link rel=apple-touch-startup-image media="(device-width: 320px)" href=img/iphone_startup.png><meta name=apple-mobile-web-app-title content="Telegram Web"><meta name=mobile-web-app-capable content=yes><meta name=apple-mobile-web-app-capable content=yes><meta name=apple-mobile-web-app-status-bar-style content=black-translucent><meta name=theme-color content=#497495><meta name=google content=notranslate><meta property=og:title content="Telegram Web"><meta property=og:url content="https://web.telegram.org/"><meta property=og:image content=https://web.telegram.org/img/logo_share.png><meta property=og:site_name content="Telegram Web"><meta property=og:description content="Welcome to the Web application of Telegram messenger. See https://github.com/zhukov/webogram for more info."></head><body><div class=page_wrap ng-view></div><div id=notify_sound></div><script src=js/app.js></script></body></html>

78457
js/app.js

File diff suppressed because one or more lines are too long

8
js/background.js

@ -5,9 +5,9 @@
* https://github.com/zhukov/webogram/blob/master/LICENSE
*/
chrome.app.runtime.onLaunched.addListener(function(launchData) {
chrome.app.runtime.onLaunched.addListener(function (launchData) {
chrome.app.window.create('../index.html', {
id: 'webogram-chat',
id: 'webogram-chat',
innerBounds: {
width: 1000,
height: 700
@ -15,5 +15,5 @@ chrome.app.runtime.onLaunched.addListener(function(launchData) {
minWidth: 320,
minHeight: 400,
frame: 'chrome'
});
});
})
})

588
js/lib/bin_utils.js

@ -6,76 +6,77 @@
*/
function bigint (num) {
return new BigInteger(num.toString(16), 16);
return new BigInteger(num.toString(16), 16)
}
function bigStringInt (strNum) {
return new BigInteger(strNum, 10);
return new BigInteger(strNum, 10)
}
function dHexDump (bytes) {
var arr = [];
var arr = []
for (var i = 0; i < bytes.length; i++) {
if (i && !(i % 2)) {
if (!(i % 16)) {
arr.push("\n");
arr.push('\n')
} else if (!(i % 4)) {
arr.push(' ');
arr.push(' ')
} else {
arr.push(' ');
arr.push(' ')
}
}
arr.push((bytes[i] < 16 ? '0' : '') + bytes[i].toString(16));
arr.push((bytes[i] < 16 ? '0' : '') + bytes[i].toString(16))
}
console.log(arr.join(''));
console.log(arr.join(''))
}
function bytesToHex (bytes) {
bytes = bytes || [];
var arr = [];
bytes = bytes || []
var arr = []
for (var i = 0; i < bytes.length; i++) {
arr.push((bytes[i] < 16 ? '0' : '') + (bytes[i] || 0).toString(16));
arr.push((bytes[i] < 16 ? '0' : '') + (bytes[i] || 0).toString(16))
}
return arr.join('');
return arr.join('')
}
function bytesFromHex (hexString) {
var len = hexString.length,
i,
start = 0,
bytes = [];
i
var start = 0
var bytes = []
if (hexString.length % 2) {
bytes.push(parseInt(hexString.charAt(0), 16));
start++;
bytes.push(parseInt(hexString.charAt(0), 16))
start++
}
for (i = start; i < len; i += 2) {
bytes.push(parseInt(hexString.substr(i, 2), 16));
bytes.push(parseInt(hexString.substr(i, 2), 16))
}
return bytes;
return bytes
}
function bytesToBase64 (bytes) {
var mod3, result = '';
var mod3
var result = ''
for (var nLen = bytes.length, nUint24 = 0, nIdx = 0; nIdx < nLen; nIdx++) {
mod3 = nIdx % 3;
nUint24 |= bytes[nIdx] << (16 >>> mod3 & 24);
mod3 = nIdx % 3
nUint24 |= bytes[nIdx] << (16 >>> mod3 & 24)
if (mod3 === 2 || nLen - nIdx === 1) {
result += String.fromCharCode(
uint6ToBase64(nUint24 >>> 18 & 63),
uint6ToBase64(nUint24 >>> 12 & 63),
uint6ToBase64(nUint24 >>> 6 & 63),
uint6ToBase64(nUint24 & 63)
);
nUint24 = 0;
)
nUint24 = 0
}
}
return result.replace(/A(?=A$|$)/g, '=');
return result.replace(/A(?=A$|$)/g, '=')
}
function uint6ToBase64 (nUint6) {
@ -89,580 +90,579 @@ function uint6ToBase64 (nUint6) {
? 43
: nUint6 === 63
? 47
: 65;
: 65
}
function base64ToBlob(base64str, mimeType) {
var sliceSize = 1024;
var byteCharacters = atob(base64str);
var bytesLength = byteCharacters.length;
var slicesCount = Math.ceil(bytesLength / sliceSize);
var byteArrays = new Array(slicesCount);
function base64ToBlob (base64str, mimeType) {
var sliceSize = 1024
var byteCharacters = atob(base64str)
var bytesLength = byteCharacters.length
var slicesCount = Math.ceil(bytesLength / sliceSize)
var byteArrays = new Array(slicesCount)
for (var sliceIndex = 0; sliceIndex < slicesCount; ++sliceIndex) {
var begin = sliceIndex * sliceSize;
var end = Math.min(begin + sliceSize, bytesLength);
var begin = sliceIndex * sliceSize
var end = Math.min(begin + sliceSize, bytesLength)
var bytes = new Array(end - begin);
for (var offset = begin, i = 0 ; offset < end; ++i, ++offset) {
bytes[i] = byteCharacters[offset].charCodeAt(0);
var bytes = new Array(end - begin)
for (var offset = begin, i = 0; offset < end; ++i, ++offset) {
bytes[i] = byteCharacters[offset].charCodeAt(0)
}
byteArrays[sliceIndex] = new Uint8Array(bytes);
byteArrays[sliceIndex] = new Uint8Array(bytes)
}
return blobConstruct(byteArrays, mimeType);
return blobConstruct(byteArrays, mimeType)
}
function dataUrlToBlob(url) {
// var name = 'b64blob ' + url.length;
// console.time(name);
var urlParts = url.split(',');
var base64str = urlParts[1];
var mimeType = urlParts[0].split(':')[1].split(';')[0];
var blob = base64ToBlob(base64str, mimeType);
// console.timeEnd(name);
return blob;
function dataUrlToBlob (url) {
// var name = 'b64blob ' + url.length
// console.time(name)
var urlParts = url.split(',')
var base64str = urlParts[1]
var mimeType = urlParts[0].split(':')[1].split(';')[0]
var blob = base64ToBlob(base64str, mimeType)
// console.timeEnd(name)
return blob
}
function blobConstruct (blobParts, mimeType) {
var blob;
var blob
try {
blob = new Blob(blobParts, {type: mimeType});
blob = new Blob(blobParts, {type: mimeType})
} catch (e) {
var bb = new BlobBuilder;
angular.forEach(blobParts, function(blobPart) {
bb.append(blobPart);
});
blob = bb.getBlob(mimeType);
var bb = new BlobBuilder
angular.forEach(blobParts, function (blobPart) {
bb.append(blobPart)
})
blob = bb.getBlob(mimeType)
}
return blob;
return blob
}
function bytesCmp (bytes1, bytes2) {
var len = bytes1.length;
var len = bytes1.length
if (len != bytes2.length) {
return false;
return false
}
for (var i = 0; i < len; i++) {
if (bytes1[i] != bytes2[i]) {
return false;
return false
}
}
return true;
return true
}
function bytesXor (bytes1, bytes2) {
var len = bytes1.length,
bytes = [];
var len = bytes1.length
var bytes = []
for (var i = 0; i < len; ++i) {
bytes[i] = bytes1[i] ^ bytes2[i];
bytes[i] = bytes1[i] ^ bytes2[i]
}
return bytes;
return bytes
}
function bytesToWords (bytes) {
if (bytes instanceof ArrayBuffer) {
bytes = new Uint8Array(bytes);
bytes = new Uint8Array(bytes)
}
var len = bytes.length,
words = [], i;
var len = bytes.length
var words = []
var i
for (i = 0; i < len; i++) {
words[i >>> 2] |= bytes[i] << (24 - (i % 4) * 8);
words[i >>> 2] |= bytes[i] << (24 - (i % 4) * 8)
}
return new CryptoJS.lib.WordArray.init(words, len);
return new CryptoJS.lib.WordArray.init(words, len)
}
function bytesFromWords (wordArray) {
var words = wordArray.words,
sigBytes = wordArray.sigBytes,
bytes = [];
var words = wordArray.words
var sigBytes = wordArray.sigBytes
var bytes = []
for (var i = 0; i < sigBytes; i++) {
bytes.push((words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff);
bytes.push((words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)
}
return bytes;
return bytes
}
function bytesFromBigInt (bigInt, len) {
var bytes = bigInt.toByteArray();
var bytes = bigInt.toByteArray()
if (len && bytes.length < len) {
var padding = [];
var padding = []
for (var i = 0, needPadding = len - bytes.length; i < needPadding; i++) {
padding[i] = 0;
padding[i] = 0
}
if (bytes instanceof ArrayBuffer) {
bytes = bufferConcat(padding, bytes);
bytes = bufferConcat(padding, bytes)
} else {
bytes = padding.concat(bytes);
bytes = padding.concat(bytes)
}
}
else {
}else {
while (!bytes[0] && (!len || bytes.length > len)) {
bytes = bytes.slice(1);
bytes = bytes.slice(1)
}
}
return bytes;
return bytes
}
function bytesFromLeemonBigInt (bigInt, len) {
var str = bigInt2str(bigInt, 16);
return bytesFromHex(str);
var str = bigInt2str(bigInt, 16)
return bytesFromHex(str)
}
function bytesToArrayBuffer (b) {
return (new Uint8Array(b)).buffer;
return (new Uint8Array(b)).buffer
}
function convertToArrayBuffer(bytes) {
function convertToArrayBuffer (bytes) {
// Be careful with converting subarrays!!
if (bytes instanceof ArrayBuffer) {
return bytes;
return bytes
}
if (bytes.buffer !== undefined &&
bytes.buffer.byteLength == bytes.length * bytes.BYTES_PER_ELEMENT) {
return bytes.buffer;
bytes.buffer.byteLength == bytes.length * bytes.BYTES_PER_ELEMENT) {
return bytes.buffer
}
return bytesToArrayBuffer(bytes);
return bytesToArrayBuffer(bytes)
}
function convertToUint8Array(bytes) {
function convertToUint8Array (bytes) {
if (bytes.buffer !== undefined) {
return bytes;
return bytes
}
return new Uint8Array(bytes);
return new Uint8Array(bytes)
}
function convertToByteArray(bytes) {
function convertToByteArray (bytes) {
if (Array.isArray(bytes)) {
return bytes;
return bytes
}
bytes = convertToUint8Array(bytes);
var newBytes = [];
bytes = convertToUint8Array(bytes)
var newBytes = []
for (var i = 0, len = bytes.length; i < len; i++) {
newBytes.push(bytes[i]);
newBytes.push(bytes[i])
}
return newBytes;
return newBytes
}
function bytesFromArrayBuffer (buffer) {
var len = buffer.byteLength,
byteView = new Uint8Array(buffer),
bytes = [];
var len = buffer.byteLength
var byteView = new Uint8Array(buffer)
var bytes = []
for (var i = 0; i < len; ++i) {
bytes[i] = byteView[i];
bytes[i] = byteView[i]
}
return bytes;
return bytes
}
function bufferConcat(buffer1, buffer2) {
var l1 = buffer1.byteLength || buffer1.length,
l2 = buffer2.byteLength || buffer2.length;
var tmp = new Uint8Array(l1 + l2);
tmp.set(buffer1 instanceof ArrayBuffer ? new Uint8Array(buffer1) : buffer1, 0);
tmp.set(buffer2 instanceof ArrayBuffer ? new Uint8Array(buffer2) : buffer2, l1);
function bufferConcat (buffer1, buffer2) {
var l1 = buffer1.byteLength || buffer1.length
var l2 = buffer2.byteLength || buffer2.length
var tmp = new Uint8Array(l1 + l2)
tmp.set(buffer1 instanceof ArrayBuffer ? new Uint8Array(buffer1) : buffer1, 0)
tmp.set(buffer2 instanceof ArrayBuffer ? new Uint8Array(buffer2) : buffer2, l1)
return tmp.buffer;
return tmp.buffer
}
function longToInts (sLong) {
var divRem = bigStringInt(sLong).divideAndRemainder(bigint(0x100000000));
var divRem = bigStringInt(sLong).divideAndRemainder(bigint(0x100000000))
return [divRem[0].intValue(), divRem[1].intValue()];
return [divRem[0].intValue(), divRem[1].intValue()]
}
function longToBytes (sLong) {
return bytesFromWords({words: longToInts(sLong), sigBytes: 8}).reverse();
return bytesFromWords({words: longToInts(sLong), sigBytes: 8}).reverse()
}
function longFromInts (high, low) {
return bigint(high).shiftLeft(32).add(bigint(low)).toString(10);
return bigint(high).shiftLeft(32).add(bigint(low)).toString(10)
}
function intToUint (val) {
val = parseInt(val);
val = parseInt(val)
if (val < 0) {
val = val + 4294967296;
val = val + 4294967296
}
return val;
return val
}
function uintToInt (val) {
if (val > 2147483647) {
val = val - 4294967296;
val = val - 4294967296
}
return val;
return val
}
function sha1HashSync (bytes) {
this.rushaInstance = this.rushaInstance || new Rusha(1024 * 1024);
this.rushaInstance = this.rushaInstance || new Rusha(1024 * 1024)
// console.log(dT(), 'SHA-1 hash start', bytes.byteLength || bytes.length);
var hashBytes = rushaInstance.rawDigest(bytes).buffer;
// console.log(dT(), 'SHA-1 hash finish');
// console.log(dT(), 'SHA-1 hash start', bytes.byteLength || bytes.length)
var hashBytes = rushaInstance.rawDigest(bytes).buffer
// console.log(dT(), 'SHA-1 hash finish')
return hashBytes;
return hashBytes
}
function sha1BytesSync (bytes) {
return bytesFromArrayBuffer(sha1HashSync(bytes));
return bytesFromArrayBuffer(sha1HashSync(bytes))
}
function sha256HashSync (bytes) {
// console.log(dT(), 'SHA-2 hash start', bytes.byteLength || bytes.length);
var hashWords = CryptoJS.SHA256(bytesToWords(bytes));
// console.log(dT(), 'SHA-2 hash finish');
// console.log(dT(), 'SHA-2 hash start', bytes.byteLength || bytes.length)
var hashWords = CryptoJS.SHA256(bytesToWords(bytes))
// console.log(dT(), 'SHA-2 hash finish')
var hashBytes = bytesFromWords(hashWords);
var hashBytes = bytesFromWords(hashWords)
return hashBytes;
return hashBytes
}
function rsaEncrypt (publicKey, bytes) {
bytes = addPadding(bytes, 255);
bytes = addPadding(bytes, 255)
// console.log('RSA encrypt start');
var N = new BigInteger(publicKey.modulus, 16),
E = new BigInteger(publicKey.exponent, 16),
X = new BigInteger(bytes),
encryptedBigInt = X.modPowInt(E, N),
encryptedBytes = bytesFromBigInt(encryptedBigInt, 256);
// console.log('RSA encrypt finish');
// console.log('RSA encrypt start')
var N = new BigInteger(publicKey.modulus, 16)
var E = new BigInteger(publicKey.exponent, 16)
var X = new BigInteger(bytes)
var encryptedBigInt = X.modPowInt(E, N),
encryptedBytes = bytesFromBigInt(encryptedBigInt, 256)
// console.log('RSA encrypt finish')
return encryptedBytes;
return encryptedBytes
}
function addPadding(bytes, blockSize, zeroes) {
blockSize = blockSize || 16;
var len = bytes.byteLength || bytes.length;
var needPadding = blockSize - (len % blockSize);
function addPadding (bytes, blockSize, zeroes) {
blockSize = blockSize || 16
var len = bytes.byteLength || bytes.length
var needPadding = blockSize - (len % blockSize)
if (needPadding > 0 && needPadding < blockSize) {
var padding = new Array(needPadding);
var padding = new Array(needPadding)
if (zeroes) {
for (var i = 0; i < needPadding; i++) {
padding[i] = 0
}
} else {
(new SecureRandom()).nextBytes(padding);
(new SecureRandom()).nextBytes(padding)
}
if (bytes instanceof ArrayBuffer) {
bytes = bufferConcat(bytes, padding);
bytes = bufferConcat(bytes, padding)
} else {
bytes = bytes.concat(padding);
bytes = bytes.concat(padding)
}
}
return bytes;
return bytes
}
function aesEncryptSync (bytes, keyBytes, ivBytes) {
var len = bytes.byteLength || bytes.length;
var len = bytes.byteLength || bytes.length
// console.log(dT(), 'AES encrypt start', len/*, bytesToHex(keyBytes), bytesToHex(ivBytes)*/);
bytes = addPadding(bytes);
// console.log(dT(), 'AES encrypt start', len/*, bytesToHex(keyBytes), bytesToHex(ivBytes)*/)
bytes = addPadding(bytes)
var encryptedWords = CryptoJS.AES.encrypt(bytesToWords(bytes), bytesToWords(keyBytes), {
iv: bytesToWords(ivBytes),
padding: CryptoJS.pad.NoPadding,
mode: CryptoJS.mode.IGE
}).ciphertext;
}).ciphertext
var encryptedBytes = bytesFromWords(encryptedWords);
// console.log(dT(), 'AES encrypt finish');
var encryptedBytes = bytesFromWords(encryptedWords)
// console.log(dT(), 'AES encrypt finish')
return encryptedBytes;
return encryptedBytes
}
function aesDecryptSync (encryptedBytes, keyBytes, ivBytes) {
// console.log(dT(), 'AES decrypt start', encryptedBytes.length);
// console.log(dT(), 'AES decrypt start', encryptedBytes.length)
var decryptedWords = CryptoJS.AES.decrypt({ciphertext: bytesToWords(encryptedBytes)}, bytesToWords(keyBytes), {
iv: bytesToWords(ivBytes),
padding: CryptoJS.pad.NoPadding,
mode: CryptoJS.mode.IGE
});
})
var bytes = bytesFromWords(decryptedWords);
// console.log(dT(), 'AES decrypt finish');
var bytes = bytesFromWords(decryptedWords)
// console.log(dT(), 'AES decrypt finish')
return bytes;
return bytes
}
function gzipUncompress (bytes) {
// console.log('Gzip uncompress start');
var result = (new Zlib.Gunzip(bytes)).decompress();
// console.log('Gzip uncompress finish');
return result;
// console.log('Gzip uncompress start')
var result = (new Zlib.Gunzip(bytes)).decompress()
// console.log('Gzip uncompress finish')
return result
}
function nextRandomInt (maxValue) {
return Math.floor(Math.random() * maxValue);
};
return Math.floor(Math.random() * maxValue)
}
function pqPrimeFactorization (pqBytes) {
var what = new BigInteger(pqBytes),
result = false;
var what = new BigInteger(pqBytes)
var result = false
// console.log(dT(), 'PQ start', pqBytes, what.toString(16), what.bitLength());
// console.log(dT(), 'PQ start', pqBytes, what.toString(16), what.bitLength())
try {
result = pqPrimeLeemon(str2bigInt(what.toString(16), 16, Math.ceil(64 / bpe) + 1))
} catch (e) {
console.error('Pq leemon Exception', e);
console.error('Pq leemon Exception', e)
}
if (result === false && what.bitLength() <= 64) {
// console.time('PQ long');
// console.time('PQ long')
try {
result = pqPrimeLong(goog.math.Long.fromString(what.toString(16), 16));
result = pqPrimeLong(goog.math.Long.fromString(what.toString(16), 16))
} catch (e) {
console.error('Pq long Exception', e);
};
// console.timeEnd('PQ long');
console.error('Pq long Exception', e)
}
// console.timeEnd('PQ long')
}
// console.log(result);
// console.log(result)
if (result === false) {
// console.time('pq BigInt');
result = pqPrimeBigInteger(what);
// console.timeEnd('pq BigInt');
// console.time('pq BigInt')
result = pqPrimeBigInteger(what)
// console.timeEnd('pq BigInt')
}
// console.log(dT(), 'PQ finish');
// console.log(dT(), 'PQ finish')
return result;
return result
}
function pqPrimeBigInteger (what) {
var it = 0,
g;
g
for (var i = 0; i < 3; i++) {
var q = (nextRandomInt(128) & 15) + 17,
x = bigint(nextRandomInt(1000000000) + 1),
y = x.clone(),
lim = 1 << (i + 18);
var q = (nextRandomInt(128) & 15) + 17
var x = bigint(nextRandomInt(1000000000) + 1)
var y = x.clone()
var lim = 1 << (i + 18)
for (var j = 1; j < lim; j++) {
++it;
var a = x.clone(),
b = x.clone(),
c = bigint(q);
++it
var a = x.clone()
var b = x.clone()
var c = bigint(q)
while (!b.equals(BigInteger.ZERO)) {
if (!b.and(BigInteger.ONE).equals(BigInteger.ZERO)) {
c = c.add(a);
c = c.add(a)
if (c.compareTo(what) > 0) {
c = c.subtract(what);
c = c.subtract(what)
}
}
a = a.add(a);
a = a.add(a)
if (a.compareTo(what) > 0) {
a = a.subtract(what);
a = a.subtract(what)
}
b = b.shiftRight(1);
b = b.shiftRight(1)
}
x = c.clone();
var z = x.compareTo(y) < 0 ? y.subtract(x) : x.subtract(y);
g = z.gcd(what);
x = c.clone()
var z = x.compareTo(y) < 0 ? y.subtract(x) : x.subtract(y)
g = z.gcd(what)
if (!g.equals(BigInteger.ONE)) {
break;
break
}
if ((j & (j - 1)) == 0) {
y = x.clone();
y = x.clone()
}
}
if (g.compareTo(BigInteger.ONE) > 0) {
break;
break
}
}
var f = what.divide(g), P, Q;
var f = what.divide(g), P, Q
if (g.compareTo(f) > 0) {
P = f;
Q = g;
P = f
Q = g
} else {
P = g;
Q = f;
P = g
Q = f
}
return [bytesFromBigInt(P), bytesFromBigInt(Q), it];
return [bytesFromBigInt(P), bytesFromBigInt(Q), it]
}
function gcdLong(a, b) {
function gcdLong (a, b) {
while (a.notEquals(goog.math.Long.ZERO) && b.notEquals(goog.math.Long.ZERO)) {
while (b.and(goog.math.Long.ONE).equals(goog.math.Long.ZERO)) {
b = b.shiftRight(1);
b = b.shiftRight(1)
}
while (a.and(goog.math.Long.ONE).equals(goog.math.Long.ZERO)) {
a = a.shiftRight(1);
a = a.shiftRight(1)
}
if (a.compare(b) > 0) {
a = a.subtract(b);
a = a.subtract(b)
} else {
b = b.subtract(a);
b = b.subtract(a)
}
}
return b.equals(goog.math.Long.ZERO) ? a : b;
return b.equals(goog.math.Long.ZERO) ? a : b
}
function pqPrimeLong(what) {
function pqPrimeLong (what) {
var it = 0,
g;
g
for (var i = 0; i < 3; i++) {
var q = goog.math.Long.fromInt((nextRandomInt(128) & 15) + 17),
x = goog.math.Long.fromInt(nextRandomInt(1000000000) + 1),
y = x,
lim = 1 << (i + 18);
var q = goog.math.Long.fromInt((nextRandomInt(128) & 15) + 17)
var x = goog.math.Long.fromInt(nextRandomInt(1000000000) + 1)
var y = x
var lim = 1 << (i + 18)
for (var j = 1; j < lim; j++) {
++it;
var a = x,
b = x,
c = q;
++it
var a = x
var b = x
var c = q
while (b.notEquals(goog.math.Long.ZERO)) {
if (b.and(goog.math.Long.ONE).notEquals(goog.math.Long.ZERO)) {
c = c.add(a);
c = c.add(a)
if (c.compare(what) > 0) {
c = c.subtract(what);
c = c.subtract(what)
}
}
a = a.add(a);
a = a.add(a)
if (a.compare(what) > 0) {
a = a.subtract(what);
a = a.subtract(what)
}
b = b.shiftRight(1);
b = b.shiftRight(1)
}
x = c;
var z = x.compare(y) < 0 ? y.subtract(x) : x.subtract(y);
g = gcdLong(z, what);
x = c
var z = x.compare(y) < 0 ? y.subtract(x) : x.subtract(y)
g = gcdLong(z, what)
if (g.notEquals(goog.math.Long.ONE)) {
break;
break
}
if ((j & (j - 1)) == 0) {
y = x;
y = x
}
}
if (g.compare(goog.math.Long.ONE) > 0) {
break;
break
}
}
var f = what.div(g), P, Q;
var f = what.div(g), P, Q
if (g.compare(f) > 0) {
P = f;
Q = g;
P = f
Q = g
} else {
P = g;
Q = f;
P = g
Q = f
}
return [bytesFromHex(P.toString(16)), bytesFromHex(Q.toString(16)), it];
return [bytesFromHex(P.toString(16)), bytesFromHex(Q.toString(16)), it]
}
function pqPrimeLeemon (what) {
var minBits = 64,
minLen = Math.ceil(minBits / bpe) + 1,
it = 0, i, q, j, lim, g, P, Q,
a = new Array(minLen),
b = new Array(minLen),
c = new Array(minLen),
g = new Array(minLen),
z = new Array(minLen),
x = new Array(minLen),
y = new Array(minLen);
var minBits = 64
var minLen = Math.ceil(minBits / bpe) + 1
var it = 0
var i, q
var j, lim
var g, P
var Q
var a = new Array(minLen)
var b = new Array(minLen)
var c = new Array(minLen)
var g = new Array(minLen)
var z = new Array(minLen)
var x = new Array(minLen)
var y = new Array(minLen)
for (i = 0; i < 3; i++) {
q = (nextRandomInt(128) & 15) + 17;
copyInt_(x, nextRandomInt(1000000000) + 1);
copy_(y, x);
lim = 1 << (i + 18);
q = (nextRandomInt(128) & 15) + 17
copyInt_(x, nextRandomInt(1000000000) + 1)
copy_(y, x)
lim = 1 << (i + 18)
for (j = 1; j < lim; j++) {
++it;
copy_(a, x);
copy_(b, x);
copyInt_(c, q);
++it
copy_(a, x)
copy_(b, x)
copyInt_(c, q)
while (!isZero(b)) {
if (b[0] & 1) {
add_(c, a);
add_(c, a)
if (greater(c, what)) {
sub_(c, what);
sub_(c, what)
}
}
add_(a, a);
add_(a, a)
if (greater(a, what)) {
sub_(a, what);
sub_(a, what)
}
rightShift_(b, 1);
rightShift_(b, 1)
}
copy_(x, c);
if (greater(x,y)) {
copy_(z, x);
sub_(z, y);
copy_(x, c)
if (greater(x, y)) {
copy_(z, x)
sub_(z, y)
} else {
copy_(z, y);
sub_(z, x);
copy_(z, y)
sub_(z, x)
}
eGCD_(z, what, g, a, b);
eGCD_(z, what, g, a, b)
if (!equalsInt(g, 1)) {
break;
break
}
if ((j & (j - 1)) == 0) {
copy_(y, x);
copy_(y, x)
}
}
if (greater(g, one)) {
break;
break
}
}
divide_(what, g, x, y);
divide_(what, g, x, y)
if (greater(g, x)) {
P = x;
Q = g;
P = x
Q = g
} else {
P = g;
Q = x;
P = g
Q = x
}
// console.log(dT(), 'done', bigInt2str(what, 10), bigInt2str(P, 10), bigInt2str(Q, 10));
// console.log(dT(), 'done', bigInt2str(what, 10), bigInt2str(P, 10), bigInt2str(Q, 10))
return [bytesFromLeemonBigInt(P), bytesFromLeemonBigInt(Q), it];
return [bytesFromLeemonBigInt(P), bytesFromLeemonBigInt(Q), it]
}
function bytesModPow (x, y, m) {
try {
var xBigInt = str2bigInt(bytesToHex(x), 16),
yBigInt = str2bigInt(bytesToHex(y), 16),
mBigInt = str2bigInt(bytesToHex(m), 16),
resBigInt = powMod(xBigInt, yBigInt, mBigInt);
var xBigInt = str2bigInt(bytesToHex(x), 16)
var yBigInt = str2bigInt(bytesToHex(y), 16)
var mBigInt = str2bigInt(bytesToHex(m), 16)
var resBigInt = powMod(xBigInt, yBigInt, mBigInt)
return bytesFromHex(bigInt2str(resBigInt, 16));
return bytesFromHex(bigInt2str(resBigInt, 16))
} catch (e) {
console.error('mod pow error', e);
console.error('mod pow error', e)
}
return bytesFromBigInt(new BigInteger(x).modPow(new BigInteger(y), new BigInteger(m)), 256);
return bytesFromBigInt(new BigInteger(x).modPow(new BigInteger(y), new BigInteger(m)), 256)
}

30
js/lib/crypto_worker.js

@ -13,38 +13,38 @@ importScripts(
'../../vendor/closure/long.js',
'../../vendor/cryptoJS/crypto.js',
'../../vendor/rusha/rusha.js'
);
)
onmessage = function (e) {
var taskID = e.data.taskID,
result;
result
switch (e.data.task) {
case 'factorize':
result = pqPrimeFactorization(e.data.bytes);
break;
result = pqPrimeFactorization(e.data.bytes)
break
case 'mod-pow':
result = bytesModPow(e.data.x, e.data.y, e.data.m);
break;
result = bytesModPow(e.data.x, e.data.y, e.data.m)
break
case 'sha1-hash':
result = sha1HashSync(e.data.bytes);
break;
result = sha1HashSync(e.data.bytes)
break
case 'aes-encrypt':
result = aesEncryptSync(e.data.bytes, e.data.keyBytes, e.data.ivBytes);
break;
result = aesEncryptSync(e.data.bytes, e.data.keyBytes, e.data.ivBytes)
break
case 'aes-decrypt':
result = aesDecryptSync(e.data.encryptedBytes, e.data.keyBytes, e.data.ivBytes);
break;
result = aesDecryptSync(e.data.encryptedBytes, e.data.keyBytes, e.data.ivBytes)
break
default:
throw new Error('Unknown task: ' + e.data.task);
throw new Error('Unknown task: ' + e.data.task)
}
postMessage({taskID: taskID, result: result});
postMessage({taskID: taskID, result: result})
}
postMessage('ready');
postMessage('ready')

145
js/lib/polyfill.js

@ -1,135 +1,136 @@
// Console-polyfill. MIT license.
// https://github.com/paulmillr/console-polyfill
// Make it safe to do console.log() always.
(function(global) {
'use strict';
global.console = global.console || {};
var con = global.console;
var prop, method;
var empty = {};
var dummy = function() {};
var properties = 'memory'.split(',');
;(function (global) {
'use strict'
global.console = global.console || {}
var con = global.console
var prop
var method
var empty = {}
var dummy = function () {}
var properties = 'memory'.split(',')
var methods = ('assert,clear,count,debug,dir,dirxml,error,exception,group,' +
'groupCollapsed,groupEnd,info,log,markTimeline,profile,profiles,profileEnd,' +
'show,table,time,timeEnd,timeline,timelineEnd,timeStamp,trace,warn').split(',');
while (prop = properties.pop()) if (!con[prop]) con[prop] = empty;
while (method = methods.pop()) if (!con[method]) con[method] = dummy;
})(typeof window === 'undefined' ? this : window);
'groupCollapsed,groupEnd,info,log,markTimeline,profile,profiles,profileEnd,' +
'show,table,time,timeEnd,timeline,timelineEnd,timeStamp,trace,warn').split(',')
while (prop = properties.pop()) if (!con[prop]) con[prop] = empty
while (method = methods.pop()) if (!con[method]) con[method] = dummy
})(typeof window === 'undefined' ? this : window)
// Using `this` for web workers while maintaining compatibility with browser
// targeted script loaders such as Browserify or Webpack where the only way to
// get to the global object is via `window`.
/* Array.indexOf polyfill */
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function(searchElement, fromIndex) {
var k;
Array.prototype.indexOf = function (searchElement, fromIndex) {
var k
if (this == null) {
throw new TypeError('"this" is null or not defined');
throw new TypeError('"this" is null or not defined')
}
var O = Object(this);
var len = O.length >>> 0;
var O = Object(this)
var len = O.length >>> 0
if (len === 0) {
return -1;
return -1
}
var n = +fromIndex || 0;
var n = +fromIndex || 0
if (Math.abs(n) === Infinity) {
n = 0;
n = 0
}
if (n >= len) {
return -1;
return -1
}
k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
k = Math.max(n >= 0 ? n : len - Math.abs(n), 0)
while (k < len) {
if (k in O && O[k] === searchElement) {
return k;
return k
}
k++;
k++
}
return -1;
};
return -1
}
}
/* Array.isArray polyfill */
if (!Array.isArray) {
Array.isArray = function(arg) {
return Object.prototype.toString.call(arg) === '[object Array]';
};
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() {};
Object.create = (function () {
var Object = function () {}
return function (prototype) {
if (arguments.length > 1) {
throw Error('Second argument not supported');
throw Error('Second argument not supported')
}
if (typeof prototype != 'object') {
throw TypeError('Argument must be an object');
throw TypeError('Argument must be an object')
}
Object.prototype = prototype;
var result = new Object();
Object.prototype = null;
return result;
};
})();
Object.prototype = prototype
var result = { }
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");
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)));
};
var aArgs = Array.prototype.slice.call(arguments, 1)
var fToBind = this
var fNOP = function () {}
var 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();
fNOP.prototype = this.prototype
fBound.prototype = new fNOP()
return fBound;
};
return fBound
}
}
/* setZeroTimeout polyfill, from http://dbaron.org/log/20100309-faster-timeouts */
(function(global) {
var timeouts = [];
var messageName = 'zero-timeout-message';
(function (global) {
var timeouts = []
var messageName = 'zero-timeout-message'
function setZeroTimeout(fn) {
timeouts.push(fn);
global.postMessage(messageName, '*');
function setZeroTimeout (fn) {
timeouts.push(fn)
global.postMessage(messageName, '*')
}
function handleMessage(event) {
function handleMessage (event) {
if (event.source == global && event.data == messageName) {
event.stopPropagation();
event.stopPropagation()
if (timeouts.length > 0) {
var fn = timeouts.shift();
fn();
var fn = timeouts.shift()
fn()
}
}
}
global.addEventListener('message', handleMessage, true);
global.addEventListener('message', handleMessage, true)
var originalSetTimeout = global.setTimeout;
var originalSetTimeout = global.setTimeout
global.setTimeout = function (callback, delay) {
if (!delay || delay <= 5) {
return setZeroTimeout(callback);
return setZeroTimeout(callback)
}
return originalSetTimeout(callback, delay);
};
return originalSetTimeout(callback, delay)
}
global.setZeroTimeout = setZeroTimeout;
})(this);
global.setZeroTimeout = setZeroTimeout
})(this)

1
js/lib/push_worker.js

@ -0,0 +1 @@
console.log('push worker placeholder')

26
js/locales/en-us.json

@ -1,7 +1,7 @@
{
"modal_search": "Search",
"modal_close": "Close",
"modal_edit": "Edit",
"modal_edit": "Edit",
"modal_cancel": "Cancel",
"modal_more": "More...",
"modal_next": "Next",
@ -20,7 +20,9 @@
"group_modal_menu_delete_photo": "Delete photo",
"group_modal_menu_edit_group": "Edit group",
"group_modal_menu_leave": "Leave",
"group_modal_menu_delete_chat": "Delete chat",
"group_modal_menu_delete_group": "Delete and exit",
"group_modal_menu_clear_history": "Clear history",
"group_modal_delete_group": "Delete group",
"group_modal_settings": "Settings",
"group_modal_notifications": "Notifications",
"group_modal_menu_share_link": "Invite to group via link",
@ -33,7 +35,6 @@
"group_modal_migrate_item2": "New members see the entire chat history",
"group_modal_migrate_item3": "Admins delete messages for everyone",
"group_modal_migrate_item4": "Notifications are muted by default",
"group_modal_delete_group": "Delete group",
"channel_modal_info": "Channel info",
"channel_modal_description": "Description",
@ -132,7 +133,8 @@
"user_modal_share_contact": "Share contact",
"user_modal_block_user": "Block user",
"user_modal_unblock_user": "Unblock user",
"user_modal_delete_chat": "Delete chat",
"user_modal_clear_history": "Clear history",
"user_modal_delete_chat": "Delete conversation",
"user_modal_add_to_group": "Add to group",
"user_modal_info": "Info",
"user_modal_phone": "Phone",
@ -206,9 +208,14 @@
"group_invite_revoke_active": "Revoking...",
"group_invite_revoke": "Revoke",
"clipboard_copied": "Copied!",
"clipboard_press_ctrl_c": "Press Ctrl+C to copy",
"clipboard_press_cmd_c": "Press ⌘+C to copy",
"confirm_modal_logout": "Are you sure you want to log out?",
"confirm_modal_update_reload": "A new version of Telegram Web has been downloaded. Launch it?",
"confirm_modal_history_flush": "Are you sure? This can not be undone!",
"confirm_modal_history_leave_flush_md": "Are you sure, you want to delete all message history and leave the group?\n\nThis action cannot be undone.",
"confirm_modal_terminate_sessions": "Are you sure you want to log out all devices except for this one?",
"confirm_modal_terminate_session": "Are you sure you want to log out this device?",
"confirm_modal_clipboard_file_send": "Are you sure to send file(s) from clipboard?",
@ -245,7 +252,9 @@
"confirm_modal_are_u_sure": "Are you sure?",
"confirm_modal_logout_submit": "Log out",
"confirm_modal_history_flush_submit": "Delete chat",
"confirm_modal_clear_history_submit": "Clear history",
"confirm_modal_leave_chat_submit": "Leave",
"confirm_modal_delete_chat_submit": "Delete chat",
"confirm_modal_clipboard_files_send_submit": "Send",
"confirm_modal_clipboard_file_send_submit": "Send",
"confirm_modal_message_delete_submit": "Delete",
@ -270,7 +279,8 @@
"conversations_modal_forward_submit": "Forward",
"conversations_modal_select_recipients": "Select recipients",
"conversations_modal_recipients": "Recipients:",
"conversations_modal_share_url_loading": "Loading{dots}",
"conversations_modal_share_url_copy": "Click to copy share link",
"contact_edit_modal_first_name": "First name",
"contact_edit_modal_last_name": "Last name",
@ -284,8 +294,8 @@
"contact_import_modal_submit": "Save",
"contact_import_modal_submit_active": "Importing...",
"conversation_message_deleted": "deleted message",
"conversation_you": "You",
"conversation_draft": "Draft:",
"conversation_media_photo": "Photo",
"conversation_media_video": "Video",
"conversation_media_document": "File",
@ -413,7 +423,7 @@
"head_media_documents": "Files",
"head_media_audio": "Voice messages",
"head_about": "About",
"head_clear_all": "Clear all",
"head_clear_all": "Clear history",
"head_edit": "Edit",
"head_typing": "typing",
"head_pluralize_participants": "{'0': 'No members', 'one': '1 member', 'other': '{} members'}",

1
manifest.json

@ -17,6 +17,7 @@
"unlimitedStorage",
"fullscreen"
],
"gcm_sender_id": "122867383838",
"icons": {
"16": "img/icons/icon16.png",
"32": "img/icons/icon32.png",

260
service_worker.js

File diff suppressed because one or more lines are too long

15
vendor/angular/i18n/angular-locale_de-de.js vendored

@ -80,6 +80,20 @@ $provide.value("$locale", {
"Nov.",
"Dez."
],
"STANDALONEMONTH": [
"Januar",
"Februar",
"M\u00e4rz",
"April",
"Mai",
"Juni",
"Juli",
"August",
"September",
"Oktober",
"November",
"Dezember"
],
"WEEKENDRANGE": [
5,
6
@ -123,6 +137,7 @@ $provide.value("$locale", {
]
},
"id": "de-de",
"localeID": "de_DE",
"pluralCat": function(n, opt_precision) { var i = n | 0; var vf = getVF(n, opt_precision); if (i == 1 && vf.v == 0) { return PLURAL_CATEGORY.ONE; } return PLURAL_CATEGORY.OTHER;}
});
}]);

15
vendor/angular/i18n/angular-locale_en-us.js vendored

@ -80,6 +80,20 @@ $provide.value("$locale", {
"Nov",
"Dec"
],
"STANDALONEMONTH": [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
],
"WEEKENDRANGE": [
5,
6
@ -123,6 +137,7 @@ $provide.value("$locale", {
]
},
"id": "en-us",
"localeID": "en_US",
"pluralCat": function(n, opt_precision) { var i = n | 0; var vf = getVF(n, opt_precision); if (i == 1 && vf.v == 0) { return PLURAL_CATEGORY.ONE; } return PLURAL_CATEGORY.OTHER;}
});
}]);

15
vendor/angular/i18n/angular-locale_es-es.js vendored

@ -62,6 +62,20 @@ $provide.value("$locale", {
"nov.",
"dic."
],
"STANDALONEMONTH": [
"Enero",
"Febrero",
"Marzo",
"Abril",
"Mayo",
"Junio",
"Julio",
"Agosto",
"Septiembre",
"Octubre",
"Noviembre",
"Diciembre"
],
"WEEKENDRANGE": [
5,
6
@ -105,6 +119,7 @@ $provide.value("$locale", {
]
},
"id": "es-es",
"localeID": "es_ES",
"pluralCat": function(n, opt_precision) { if (n == 1) { return PLURAL_CATEGORY.ONE; } return PLURAL_CATEGORY.OTHER;}
});
}]);

15
vendor/angular/i18n/angular-locale_it-it.js vendored

@ -80,6 +80,20 @@ $provide.value("$locale", {
"nov",
"dic"
],
"STANDALONEMONTH": [
"Gennaio",
"Febbraio",
"Marzo",
"Aprile",
"Maggio",
"Giugno",
"Luglio",
"Agosto",
"Settembre",
"Ottobre",
"Novembre",
"Dicembre"
],
"WEEKENDRANGE": [
5,
6
@ -123,6 +137,7 @@ $provide.value("$locale", {
]
},
"id": "it-it",
"localeID": "it_IT",
"pluralCat": function(n, opt_precision) { var i = n | 0; var vf = getVF(n, opt_precision); if (i == 1 && vf.v == 0) { return PLURAL_CATEGORY.ONE; } return PLURAL_CATEGORY.OTHER;}
});
}]);

15
vendor/angular/i18n/angular-locale_nl-nl.js vendored

@ -80,6 +80,20 @@ $provide.value("$locale", {
"nov.",
"dec."
],
"STANDALONEMONTH": [
"Januari",
"Februari",
"Maart",
"April",
"Mei",
"Juni",
"Juli",
"Augustus",
"September",
"Oktober",
"November",
"December"
],
"WEEKENDRANGE": [
5,
6
@ -123,6 +137,7 @@ $provide.value("$locale", {
]
},
"id": "nl-nl",
"localeID": "nl_NL",
"pluralCat": function(n, opt_precision) { var i = n | 0; var vf = getVF(n, opt_precision); if (i == 1 && vf.v == 0) { return PLURAL_CATEGORY.ONE; } return PLURAL_CATEGORY.OTHER;}
});
}]);

15
vendor/angular/i18n/angular-locale_pt-br.js vendored

@ -62,6 +62,20 @@ $provide.value("$locale", {
"nov",
"dez"
],
"STANDALONEMONTH": [
"janeiro",
"fevereiro",
"mar\u00e7o",
"abril",
"maio",
"junho",
"julho",
"agosto",
"setembro",
"outubro",
"novembro",
"dezembro"
],
"WEEKENDRANGE": [
5,
6
@ -105,6 +119,7 @@ $provide.value("$locale", {
]
},
"id": "pt-br",
"localeID": "pt_BR",
"pluralCat": function(n, opt_precision) { if (n >= 0 && n <= 2 && n != 2) { return PLURAL_CATEGORY.ONE; } return PLURAL_CATEGORY.OTHER;}
});
}]);

15
vendor/angular/i18n/angular-locale_ru-ru.js vendored

@ -80,6 +80,20 @@ $provide.value("$locale", {
"\u043d\u043e\u044f\u0431.",
"\u0434\u0435\u043a."
],
"STANDALONEMONTH": [
"\u044f\u043d\u0432\u0430\u0440\u044c",
"\u0444\u0435\u0432\u0440\u0430\u043b\u044c",
"\u043c\u0430\u0440\u0442",
"\u0430\u043f\u0440\u0435\u043b\u044c",
"\u043c\u0430\u0439",
"\u0438\u044e\u043d\u044c",
"\u0438\u044e\u043b\u044c",
"\u0430\u0432\u0433\u0443\u0441\u0442",
"\u0441\u0435\u043d\u0442\u044f\u0431\u0440\u044c",
"\u043e\u043a\u0442\u044f\u0431\u0440\u044c",
"\u043d\u043e\u044f\u0431\u0440\u044c",
"\u0434\u0435\u043a\u0430\u0431\u0440\u044c"
],
"WEEKENDRANGE": [
5,
6
@ -123,6 +137,7 @@ $provide.value("$locale", {
]
},
"id": "ru-ru",
"localeID": "ru_RU",
"pluralCat": function(n, opt_precision) { var i = n | 0; var vf = getVF(n, opt_precision); if (vf.v == 0 && i % 10 == 1 && i % 100 != 11) { return PLURAL_CATEGORY.ONE; } if (vf.v == 0 && i % 10 >= 2 && i % 10 <= 4 && (i % 100 < 12 || i % 100 > 14)) { return PLURAL_CATEGORY.FEW; } if (vf.v == 0 && i % 10 == 0 || vf.v == 0 && i % 10 >= 5 && i % 10 <= 9 || vf.v == 0 && i % 100 >= 11 && i % 100 <= 14) { return PLURAL_CATEGORY.MANY; } return PLURAL_CATEGORY.OTHER;}
});
}]);

4
webogram.appcache

@ -1,10 +1,11 @@
CACHE MANIFEST
# Time: Sun Jun 12 2016 22:29:17 GMT+0300 (MSK)
# Time: Tue Jul 05 2016 17:22:42 GMT+0300 (MSK)
CACHE:
favicon.ico
favicon_unread.ico
service_worker.js
css/app.css
css/desktop.css
css/mobile.css
@ -65,6 +66,7 @@ img/placeholders/VideoThumbModal.gif
js/lib/bin_utils.js
js/lib/crypto_worker.js
js/lib/polyfill.js
js/lib/push_worker.js
js/locales/de-de.json
js/locales/en-us.json
js/locales/es-es.json

Loading…
Cancel
Save