diff --git a/app/js/init.js b/app/js/init.js index 91aae840..96948280 100644 --- a/app/js/init.js +++ b/app/js/init.js @@ -1,8 +1,8 @@ -(function () { +;(function () { // Prevent click-jacking try { - if (window.chrome && chrome.app && chrome.app.window || self == top) { + if (window == window.top || window.chrome && chrome.app && chrome.app.window) { document.documentElement.style.display = 'block'; } else { top.location = self.location; @@ -40,7 +40,7 @@ }, delay || 300000); }, attach = function () { - appCache.addEventListener('updateready', function(e) { + appCache.addEventListener('updateready', function (e) { if (appCache.status == appCache.UPDATEREADY) { if (!declined) { safeConfirm({type: 'WEBOGRAM_UPDATED_RELOAD', message: 'A new version of Webogram is available. Load it?'}, function (result) { @@ -60,4 +60,4 @@ scheduleUpdate(3000); window.addEventListener('load', attach); -})(); \ No newline at end of file +})(); diff --git a/app/js/lib/mtproto.js b/app/js/lib/mtproto.js index 199352a1..a2a42976 100644 --- a/app/js/lib/mtproto.js +++ b/app/js/lib/mtproto.js @@ -32,9 +32,10 @@ function dHexDump (bytes) { } function bytesToHex (bytes) { + bytes = bytes || []; var arr = []; for (var i = 0; i < bytes.length; i++) { - arr.push((bytes[i] < 16 ? '0' : '') + bytes[i].toString(16)); + arr.push((bytes[i] < 16 ? '0' : '') + (bytes[i] || 0).toString(16)); } return arr.join(''); }