Commit b371d1a2 authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Добавил функцию для получения изображения из изменений g_fGetImageFromChanges

bug #29603

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@64369 954022d7-b5bf-4e40-9824-e11837661b57
parent 3c5b8b56
...@@ -13,6 +13,7 @@ if (typeof String.prototype.endsWith !== 'function') { ...@@ -13,6 +13,7 @@ if (typeof String.prototype.endsWith !== 'function') {
String.prototype['endsWith'] = String.prototype.endsWith; String.prototype['endsWith'] = String.prototype.endsWith;
} }
var g_oZipChanges = null;
var g_sMainServiceLocalUrl = "/CanvasService.ashx"; var g_sMainServiceLocalUrl = "/CanvasService.ashx";
var g_sResourceServiceLocalUrl = "/ResourceService.ashx?path="; var g_sResourceServiceLocalUrl = "/ResourceService.ashx?path=";
var g_sUploadServiceLocalUrl = "/UploadService.ashx"; var g_sUploadServiceLocalUrl = "/UploadService.ashx";
...@@ -62,6 +63,15 @@ function g_fSaveWithParts(fSendCommand, fCallback, oAdditionalData, aParts) { ...@@ -62,6 +63,15 @@ function g_fSaveWithParts(fSendCommand, fCallback, oAdditionalData, aParts) {
}, oAdditionalData); }, oAdditionalData);
} }
function g_fGetImageFromChanges (name) {
var file;
var ext = GetFileExtension(sName);
if (null !== ext && g_oZipChanges && (file = g_oZipChanges.files[name])) {
var oFileArray = file.asUint8Array();
return 'data:image/' + ext + ';base64,' + Base64Encode(oFileArray, oFileArray.length, 0);
}
return null;
}
function g_fOpenFileCommand (binUrl, changesUrl, Signature, callback) { function g_fOpenFileCommand (binUrl, changesUrl, Signature, callback) {
var bError = false, oResult = new OpenFileResult(), bEndLoadFile = false, bEndLoadChanges = false; var bError = false, oResult = new OpenFileResult(), bEndLoadFile = false, bEndLoadChanges = false;
var onEndOpen = function () { var onEndOpen = function () {
...@@ -102,10 +112,10 @@ function g_fOpenFileCommand (binUrl, changesUrl, Signature, callback) { ...@@ -102,10 +112,10 @@ function g_fOpenFileCommand (binUrl, changesUrl, Signature, callback) {
return; return;
} }
var oZipFile = new (require('jszip'))(data); g_oZipChanges = new (require('jszip'))(data);
oResult.changes = []; oResult.changes = [];
for(var i in oZipFile.files) for(var i in g_oZipChanges.files)
oResult.changes.push(JSON.parse(oZipFile.file(i).asText())) oResult.changes.push(JSON.parse(g_oZipChanges[i].asText()));
onEndOpen(); onEndOpen();
}); });
} else } else
...@@ -396,7 +406,7 @@ function test_ws_name2() { ...@@ -396,7 +406,7 @@ function test_ws_name2() {
} }
return true; return true;
} }
} };
return this; return this;
...@@ -422,7 +432,7 @@ function test_defName(){ ...@@ -422,7 +432,7 @@ function test_defName(){
} }
return true; return true;
} };
return this; return this;
} }
...@@ -478,40 +488,45 @@ var c_oAscImageUploadProp = {//Не все браузеры позволяют ...@@ -478,40 +488,45 @@ var c_oAscImageUploadProp = {//Не все браузеры позволяют
SupportedFormats:[ "jpg", "jpeg", "jpe", "png", "gif", "bmp", "ico"] SupportedFormats:[ "jpg", "jpeg", "jpe", "png", "gif", "bmp", "ico"]
}; };
function GetFileExtension (sName) {
var nIndex = sName.lastIndexOf(".");
if (-1 != nIndex)
return sName.substring(nIndex + 1).toLowerCase();
return null;
}
function ValidateUploadImage( files ) { function ValidateUploadImage( files ) {
var nRes = c_oAscServerError.NoError; var nRes = c_oAscServerError.NoError;
if ( files.length > 0 ) { if (files.length > 0) {
for ( var i = 0, length = files.length; i < length; i++ ) { for (var i = 0, length = files.length; i < length; i++) {
var file = files[i]; var file = files[i];
//проверяем расширение файла //проверяем расширение файла
var sName = file.fileName || file.name; var sName = file.fileName || file.name;
if ( sName ) { if (sName) {
var bSupported = false; var bSupported = false;
var nIndex = sName.lastIndexOf( "." ); var ext = GetFileExtension(sName);
if ( -1 != nIndex ) { if (null !== ext) {
var ext = sName.substring( nIndex + 1 ).toLowerCase(); for (var j = 0, length2 = c_oAscImageUploadProp.SupportedFormats.length; j < length2; j++) {
for ( var j = 0, length2 = c_oAscImageUploadProp.SupportedFormats.length; j < length2; j++ ) { if (c_oAscImageUploadProp.SupportedFormats[j] == ext) {
if ( c_oAscImageUploadProp.SupportedFormats[j] == ext ) { bSupported = true;
bSupported = true; break;
break; }
} }
} }
} if (false == bSupported)
if ( false == bSupported ) nRes = c_oAscServerError.UploadExtension;
nRes = c_oAscServerError.UploadExtension; }
} if (c_oAscError.ID.No == nRes) {
if ( c_oAscError.ID.No == nRes ) { var nSize = file.fileSize || file.size;
var nSize = file.fileSize || file.size; if (nSize && c_oAscImageUploadProp.MaxFileSize < nSize)
if ( nSize && c_oAscImageUploadProp.MaxFileSize < nSize ) nRes = c_oAscServerError.UploadContentLength;
nRes = c_oAscServerError.UploadContentLength; }
} if (c_oAscServerError.NoError != nRes)
if ( c_oAscServerError.NoError != nRes ) break;
break; }
} } else
} nRes = c_oAscServerError.UploadCountFiles;
else return nRes;
nRes = c_oAscServerError.UploadCountFiles;
return nRes;
} }
function CanDropFiles( event ) { function CanDropFiles( event ) {
var bRes = false; var bRes = false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment