Browse Source

merged with master

gh-pages
Igor Zhukov 11 years ago
parent
commit
4af7270008
  1. 2
      app.manifest
  2. 6
      css/app.css
  3. 64
      index.html
  4. 30
      js/app.js
  5. 2
      js/app.js.map
  6. 4
      js/background.js
  7. 2
      js/lib/aes_worker.js
  8. 91
      js/lib/mtproto.js
  9. 2
      js/lib/pq_worker.js
  10. 2
      js/lib/sha1_worker.js
  11. 5
      manifest.json
  12. 2
      manifest.webapp

2
app.manifest

@ -1,5 +1,5 @@
CACHE MANIFEST
# Time: Wed Apr 30 2014 11:52:49 GMT+0800 (SGT)
# Time: Fri May 09 2014 16:59:33 GMT+0100 (WEST)
CACHE:

6
css/app.css

File diff suppressed because one or more lines are too long

64
index.html

@ -1,63 +1 @@
<!doctype html><html lang=en ng-app=myApp manifest=app.manifest><head><meta charset=utf-8><meta name=viewport content="width=device-width, user-scalable=no"><title>Webogram</title><link rel=stylesheet href=css/app.css><link rel=icon href=favicon.ico type=image/x-icon><meta property=og:title content=Webogram><meta property=og:url content="http://zhukov.github.io/webogram/"><meta property=og:image content=http://zhukov.github.io/webogram/img/logo_share.png><meta property=og:site_name content=Webogram><meta property=og:description content="Welcome to an experimental web-client of Telegram messenger. See https://github.com/zhukov/webogram for more info."><script type=text/javascript>(function () {
// Prevent click-jacking
try {
if (self == top) {
document.documentElement.style.display = 'block';
} else {
top.location = self.location;
}
} catch (e) {console.error('CJ protection', e)};
window.safeConfirm = function (params, callback) {
if (typeof params === 'string') {
params = {message: params};
}
var result = false
try {
result = confirm(params.message);
} catch (e) {
result = true;
}
setTimeout(function () {callback(result)}, 10);
};
if (!window.applicationCache || !window.addEventListener) {
return;
}
var appCache = window.applicationCache,
declined = false,
updateTimeout = false,
scheduleUpdate = function (delay) {
clearTimeout(updateTimeout);
updateTimeout = setTimeout(function () {
try {
appCache.update();
} catch (ex) {
console.log('appCache.update: ' + ex);
}
}, delay || 300000);
},
attach = function () {
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) {
if (result) {
window.location.reload();
} else {
declined = true;
}
});
scheduleUpdate();
}
}
}, false);
appCache.addEventListener('noupdate', function () {scheduleUpdate()}, false);
appCache.addEventListener('error', function () {scheduleUpdate()}, false);
};
scheduleUpdate(3000);
window.addEventListener('load', attach);
})();</script></head><body><div ng-view=""></div><script src=js/app.js></script></body></html>
<!doctype html><html lang=en ng-app=myApp manifest=app.manifest><head><meta charset=utf-8><meta name=viewport content="width=device-width, user-scalable=no"><title>Webogram</title><link rel=stylesheet href=css/app.css><link rel=icon href=favicon.ico type=image/x-icon><meta property=og:title content=Webogram><meta property=og:url content="http://zhukov.github.io/webogram/"><meta property=og:image content=http://zhukov.github.io/webogram/img/logo_share.png><meta property=og:site_name content=Webogram><meta property=og:description content="Welcome to an experimental web-client of Telegram messenger. See https://github.com/zhukov/webogram for more info."></head><body><div ng-view=""></div><script src=js/app.js></script></body></html>

30
js/app.js

File diff suppressed because one or more lines are too long

2
js/app.js.map

File diff suppressed because one or more lines are too long

4
js/background.js

@ -1,5 +1,5 @@
/*!
* Webogram v0.0.21 - messaging web application for MTProto
* Webogram v0.1.0 - messaging web application for MTProto
* https://github.com/zhukov/webogram
* Copyright (C) 2014 Igor Zhukov <igor.beatle@gmail.com>
* https://github.com/zhukov/webogram/blob/master/LICENSE
@ -8,7 +8,7 @@
chrome.app.runtime.onLaunched.addListener(function(launchData) {
chrome.app.window.create('../index.html', {
bounds: {
width: 900,
width: 1000,
height: 700
},
minWidth: 320,

2
js/lib/aes_worker.js

@ -1,5 +1,5 @@
/*!
* Webogram v0.0.21 - messaging web application for MTProto
* Webogram v0.1.0 - messaging web application for MTProto
* https://github.com/zhukov/webogram
* Copyright (C) 2014 Igor Zhukov <igor.beatle@gmail.com>
* https://github.com/zhukov/webogram/blob/master/LICENSE

91
js/lib/mtproto.js

@ -1,5 +1,5 @@
/*!
* Webogram v0.0.21 - messaging web application for MTProto
* Webogram v0.1.0 - messaging web application for MTProto
* https://github.com/zhukov/webogram
* Copyright (C) 2014 Igor Zhukov <igor.beatle@gmail.com>
* https://github.com/zhukov/webogram/blob/master/LICENSE
@ -1005,12 +1005,12 @@ factory('MtpDcConfigurator', function () {
var dcOptions = window._testMode
? [
{id: 1, host: '173.240.5.253', port: 80},
{id: 2, host: '109.239.131.195', port: 80},
{id: 2, host: '149.154.167.40', port: 80},
{id: 3, host: '174.140.142.5', port: 80}
]
: [
{id: 1, host: '173.240.5.1', port: 80},
{id: 2, host: '109.239.131.193', port: 80},
{id: 2, host: '149.154.167.5', port: 80},
{id: 3, host: '174.140.142.6', port: 80},
{id: 4, host: '31.210.235.12', port: 80},
{id: 5, host: '116.51.22.2', port: 80},
@ -1789,7 +1789,7 @@ factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerato
serializer.storeInt(2496, 'api_id');
serializer.storeString(navigator.userAgent || 'Unknown UserAgent', 'device_model');
serializer.storeString(navigator.platform || 'Unknown Platform', 'system_version');
serializer.storeString('0.0.21', 'app_version');
serializer.storeString('0.1.0', 'app_version');
serializer.storeString(navigator.language || 'en', 'lang_code');
}
@ -2832,7 +2832,7 @@ factory('MtpApiFileManager', function (MtpApiManager, $q, $window) {
deferred.reject();
};
if (false) { // is file bytes
if (bytes instanceof Blob) { // is file bytes
fileWriter.write(bytes);
} else {
fileWriter.write(new Blob([bytesToArrayBuffer(bytes)]));
@ -2841,6 +2841,23 @@ factory('MtpApiFileManager', function (MtpApiManager, $q, $window) {
return deferred.promise;
}
function fileCopyTo (fromFileEntry, toFileEntry) {
var deferred = $q.defer();
toFileEntry.createWriter(function (fileWriter) {
fileWriteBytes(fileWriter, fromFileEntry).then(function () {
deferred.resolve(fileWriter);
}, function (e) {
fileWriter.truncate(0);
deferred.reject(e);
});
}, function (e) {
deferred.reject(e);
});
return deferred.promise;
}
function getFileName(location) {
switch (location._) {
case 'inputVideoFileLocation':
@ -2982,14 +2999,15 @@ factory('MtpApiFileManager', function (MtpApiManager, $q, $window) {
return cachedDownloadPromises[fileName] = deferred.promise;
}
function downloadFile (dcID, location, size, fileEntry, options) {
function downloadFile (dcID, location, size, options) {
options = options || {};
console.log(dT(), 'Dload file', dcID, location, size);
var fileName = getFileName(location),
toFileEntry = options.toFileEntry || null,
cachedPromise = cachedSavePromises[fileName] || cachedDownloadPromises[fileName];
if (cachedPromise) {
if (!toFileEntry && cachedPromise) {
return cachedPromise;
}
@ -3049,7 +3067,11 @@ factory('MtpApiFileManager', function (MtpApiManager, $q, $window) {
if (isFinal) {
// console.timeEnd(fileName + ' ' + (size / 1024));
resolved = true;
if (toFileEntry) {
deferred.resolve();
} else {
deferred.resolve(cachedDownloads[fileName] = fileEntry.toURL(options.mime || 'image/jpeg'));
}
} else {
// console.log('notify', {done: offset + limit, total: size});
deferred.notify({done: offset + limit, total: size});
@ -3070,28 +3092,43 @@ factory('MtpApiFileManager', function (MtpApiManager, $q, $window) {
};
if (fileEntry) {
saveToFileEntry(fileEntry);
} else {
requestFS().then(function () {
cachedFs.root.getFile(fileName, {create: false}, function(fileEntry) {
fileEntry.file(function(file) {
// console.log(dT(), 'Check size', file.size, size);
if (file.size >= size/* && false*/) {
resolved = true;
if (toFileEntry) {
fileCopyTo(file, toFileEntry).then(function () {
deferred.resolve();
})
} else {
deferred.resolve(cachedDownloads[fileName] = fileEntry.toURL());
}
} else {
// setTimeout(function () {
console.log('File bad size', file, size);
if (toFileEntry) {
saveToFileEntry(toFileEntry);
} else {
cachedFs.root.getFile(fileName, {create: true}, saveToFileEntry, errorHandler)
}
// }, 10000);
}
}, errorHandler);
}, function () {
if (toFileEntry) {
saveToFileEntry(toFileEntry);
} else {
cachedFs.root.getFile(fileName, {create: true}, saveToFileEntry, errorHandler)
}
});
}, function () {
if (toFileEntry) {
return saveToFileEntry(toFileEntry);
}
var blobParts = [];
var limit = size > 30400 ? 524288 : 4096;
var writeBlobPromise = $q.when(),
@ -3153,7 +3190,6 @@ factory('MtpApiFileManager', function (MtpApiManager, $q, $window) {
}
});
}
deferred.promise.cancel = function () {
if (!canceled && !resolved) {
@ -3163,37 +3199,12 @@ factory('MtpApiFileManager', function (MtpApiManager, $q, $window) {
}
}
return cachedDownloadPromises[fileName] = deferred.promise;
if (!toFileEntry) {
cachedDownloadPromises[fileName] = deferred.promise;
}
function writeFile (file) {
console.log(dT(), 'Write file', file);
var fileName = getTempFileName(file);
var deferred = $q.defer(),
cacheFileWriter,
errorHandler = function (error) {
console.log('fail');
deferred.reject(error);
if (cacheFileWriter) cacheFileWriter.truncate(0);
errorHandler = angular.noop;
};
requestFS().then(function () {
cachedFs.root.getFile(fileName, {create: false}, function(fileEntry) {
deferred.resolve(fileEntry);
}, function () {
cachedFs.root.getFile(fileName, {create: true}, function(fileEntry) {
fileEntry.createWriter(function (fileWriter) {
cacheFileWriter = fileWriter;
fileWriteBytes(fileWriter, file).then(function () {
deferred.resolve(fileEntry);
}, errorHandler);
}, errorHandler);
});
});
});
};
return deferred.promise;
}
function uploadFile (file) {
var fileSize = file.size,

2
js/lib/pq_worker.js

@ -1,5 +1,5 @@
/*!
* Webogram v0.0.21 - messaging web application for MTProto
* Webogram v0.1.0 - messaging web application for MTProto
* https://github.com/zhukov/webogram
* Copyright (C) 2014 Igor Zhukov <igor.beatle@gmail.com>
* https://github.com/zhukov/webogram/blob/master/LICENSE

2
js/lib/sha1_worker.js

@ -1,5 +1,5 @@
/*!
* Webogram v0.0.21 - messaging web application for MTProto
* Webogram v0.1.0 - messaging web application for MTProto
* https://github.com/zhukov/webogram
* Copyright (C) 2014 Igor Zhukov <igor.beatle@gmail.com>
* https://github.com/zhukov/webogram/blob/master/LICENSE

5
manifest.json

@ -1,6 +1,6 @@
{
"name": "Telegram UNOFFICIAL",
"version": "0.0.21",
"version": "0.1.0",
"short_name": "Webogram",
"manifest_version": 2,
"app": {
@ -12,7 +12,8 @@
"notifications",
"webview",
{"fileSystem": ["write"]},
"storage"
"storage",
"unlimitedStorage"
],
"icons": {
"16": "img/icons/icon16.png",

2
manifest.webapp

@ -1,7 +1,7 @@
{
"name": "Webogram",
"description": "Webogram – UNOFFICIAL Telegram Web App.\nMore info & source code here: https://github.com/zhukov/webogram",
"version": "0.0.21",
"version": "0.1.0",
"launch_path": "/index.html",
"developer": {
"name": "Igor Zhukov",

Loading…
Cancel
Save