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

Для показа версий заделал открытие zip на стороне клиента (использую для этого...

Для показа версий заделал открытие zip на стороне клиента (использую для этого JSZip). Сделал применение изменений.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@62463 954022d7-b5bf-4e40-9824-e11837661b57
parent 051cdca0
......@@ -159,7 +159,9 @@
"../../Word/Drawing/scrolls/jquery.min.js",
"../../Common/3rdparty/Underscore/underscore-min.js",
"../../Common/3rdparty/Sockjs/sockjs-0.3.min.js",
"../../Common/3rdparty/XRegExp/xregexp-all-min.js"
"../../Common/3rdparty/XRegExp/xregexp-all-min.js",
"../../Common/3rdparty/jszip/jszip.min.js",
"../../Common/3rdparty/jszip-utils/jszip-utils.min.js"
],
"map": "sdk-all.js.map",
"log": "../../Word/Build/Log",
......
/*!
JSZipUtils - A collection of cross-browser utilities to go along with JSZip.
<http://stuk.github.io/jszip-utils>
(c) 2014 Stuart Knightley, David Duponchel
Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip-utils/master/LICENSE.markdown.
*/
!function(e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):"undefined"!=typeof window?window.JSZipUtils=e():"undefined"!=typeof global?global.JSZipUtils=e():"undefined"!=typeof self&&(self.JSZipUtils=e())}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
'use strict';
var JSZipUtils = {};
// just use the responseText with xhr1, response with xhr2.
// The transformation doesn't throw away high-order byte (with responseText)
// because JSZip handles that case. If not used with JSZip, you may need to
// do it, see https://developer.mozilla.org/En/Using_XMLHttpRequest#Handling_binary_data
JSZipUtils._getBinaryFromXHR = function (xhr) {
// for xhr.responseText, the 0xFF mask is applied by JSZip
return xhr.response || xhr.responseText;
};
// taken from jQuery
function createStandardXHR() {
try {
return new window.XMLHttpRequest();
} catch( e ) {}
}
function createActiveXHR() {
try {
return new window.ActiveXObject("Microsoft.XMLHTTP");
} catch( e ) {}
}
// Create the request object
var createXHR = window.ActiveXObject ?
/* Microsoft failed to properly
* implement the XMLHttpRequest in IE7 (can't request local files),
* so we use the ActiveXObject when it is available
* Additionally XMLHttpRequest can be disabled in IE7/IE8 so
* we need a fallback.
*/
function() {
return createStandardXHR() || createActiveXHR();
} :
// For all other browsers, use the standard XMLHttpRequest object
createStandardXHR;
JSZipUtils.getBinaryContent = function(path, callback) {
/*
* Here is the tricky part : getting the data.
* In firefox/chrome/opera/... setting the mimeType to 'text/plain; charset=x-user-defined'
* is enough, the result is in the standard xhr.responseText.
* cf https://developer.mozilla.org/En/XMLHttpRequest/Using_XMLHttpRequest#Receiving_binary_data_in_older_browsers
* In IE <= 9, we must use (the IE only) attribute responseBody
* (for binary data, its content is different from responseText).
* In IE 10, the 'charset=x-user-defined' trick doesn't work, only the
* responseType will work :
* http://msdn.microsoft.com/en-us/library/ie/hh673569%28v=vs.85%29.aspx#Binary_Object_upload_and_download
*
* I'd like to use jQuery to avoid this XHR madness, but it doesn't support
* the responseType attribute : http://bugs.jquery.com/ticket/11461
*/
try {
var xhr = createXHR();
xhr.open('GET', path, true);
// recent browsers
if ("responseType" in xhr) {
xhr.responseType = "arraybuffer";
}
// older browser
if(xhr.overrideMimeType) {
xhr.overrideMimeType("text/plain; charset=x-user-defined");
}
xhr.onreadystatechange = function(evt) {
var file, err;
// use `xhr` and not `this`... thanks IE
if (xhr.readyState === 4) {
if (xhr.status === 200 || xhr.status === 0) {
file = null;
err = null;
try {
file = JSZipUtils._getBinaryFromXHR(xhr);
} catch(e) {
err = new Error(e);
}
callback(err, file);
} else {
callback(new Error("Ajax error for " + path + " : " + this.status + " " + this.statusText), null);
}
}
};
xhr.send();
} catch (e) {
callback(new Error(e), null);
}
};
// export
module.exports = JSZipUtils;
// enforcing Stuk's coding style
// vim: set shiftwidth=4 softtabstop=4:
},{}]},{},[1])
(1)
});
;
\ No newline at end of file
/*!
JSZipUtils - A collection of cross-browser utilities to go along with JSZip.
<http://stuk.github.io/jszip-utils>
(c) 2014 Stuart Knightley, David Duponchel
Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip-utils/master/LICENSE.markdown.
*/
!function(a){"object"==typeof exports?module.exports=a():"function"==typeof define&&define.amd?define(a):"undefined"!=typeof window?window.JSZipUtils=a():"undefined"!=typeof global?global.JSZipUtils=a():"undefined"!=typeof self&&(self.JSZipUtils=a())}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b){"use strict";function c(){try{return new window.XMLHttpRequest}catch(a){}}function d(){try{return new window.ActiveXObject("Microsoft.XMLHTTP")}catch(a){}}var e={};e._getBinaryFromXHR=function(a){return a.response||a.responseText};var f=window.ActiveXObject?function(){return c()||d()}:c;e.getBinaryContent=function(a,b){try{var c=f();c.open("GET",a,!0),"responseType"in c&&(c.responseType="arraybuffer"),c.overrideMimeType&&c.overrideMimeType("text/plain; charset=x-user-defined"),c.onreadystatechange=function(){var d,f;if(4===c.readyState)if(200===c.status||0===c.status){d=null,f=null;try{d=e._getBinaryFromXHR(c)}catch(g){f=new Error(g)}b(f,d)}else b(new Error("Ajax error for "+a+" : "+this.status+" "+this.statusText),null)},c.send()}catch(d){b(new Error(d),null)}},b.exports=e},{}]},{},[1])(1)});
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
......@@ -3,12 +3,18 @@
var g_sMainServiceLocalUrl = "/CanvasService.ashx";
var g_sResourceServiceLocalUrl = "/ResourceService.ashx?path=";
var g_sUploadServiceLocalUrl = "/UploadService.ashx";
var g_sSpellCheckServiceLocalUrl = "/SpellChecker.ashx";
var g_sTrackingServiceLocalUrl = "/TrackingService.ashx";
var g_nMaxJsonLength = 2097152;
var g_nMaxJsonLengthChecked = g_nMaxJsonLength / 1000;
var g_nMaxRequestLength = 1048576;//<requestLimits maxAllowedContentLength="30000000" /> default 30mb
function OpenFileResult () {
this.bSerFormat = false;
this.data = null;
this.url = null;
this.changes = null;
}
function g_fSaveWithParts(fSendCommand, fCallback, oAdditionalData, aParts) {
if(null == aParts){
var nDataLength = 0;
......@@ -43,6 +49,11 @@ function g_fSaveWithParts(fSendCommand, fCallback, oAdditionalData, aParts) {
}
function g_fOpenFileCommand (data, Signature, callback) {
var bError = false, oResult = new OpenFileResult(), bEndLoadFile = false, bEndLoadChanges = false;
var onEndOpen = function () {
if (bEndLoadFile && bEndLoadChanges)
if (callback) callback(bError, oResult);
};
var openData = JSON.parse(data);
var sFileUrl = g_sResourceServiceLocalUrl + openData['urlfile'];
asc_ajax({
......@@ -54,15 +65,37 @@ function g_fOpenFileCommand (data, Signature, callback) {
var nIndex = sFileUrl.lastIndexOf("/");
url = (-1 !== nIndex) ? sFileUrl.substring(0, nIndex + 1) : sFileUrl;
if (0 < result.length) {
if (callback) callback(false, {bSerFormat: Signature === result.substring(0, Signature.length), data: result, url: url});
} else {
if (callback) callback(true);
}
oResult.bSerFormat = Signature === result.substring(0, Signature.length);
oResult.data = result;
oResult.url = url;
} else
bError = true;
bEndLoadFile = true;
onEndOpen();
},
error: function () {
if (callback) callback(true);
bEndLoadFile = true;
bError = true;
onEndOpen();
}
});
if (null != openData['urlchanges']) {
JSZipUtils.getBinaryContent(g_sResourceServiceLocalUrl + openData['urlchanges'], function(err, data) {
bEndLoadChanges = true;
if(err) {
bError = true;
onEndOpen();
return;
}
var oZipFile = new JSZip(data);
oResult.changes = [];
for(var i in oZipFile.files)
oResult.changes.push(JSON.parse(oZipFile.file(i).asText()))
onEndOpen();
});
} else
bEndLoadChanges = true;
}
function fSortAscending( a, b ) {
......
......@@ -7128,6 +7128,14 @@ function _onOpenCommand(fCallback, incomeObject) {
return;
}
if (result.changes) {
g_oIdCounter.Clear();
g_oTableId.Clear();
editor.isApplyChangesOnOpenEnabled = true;
for (var i = 0; i < result.changes.length; ++i)
editor._coAuthoringSetChanges(result.changes[i], new CDocumentColor( 191, 255, 199 ));
}
if (result.bSerFormat)
editor.OpenDocument2(result.url, result.data);
else
......@@ -7435,7 +7443,8 @@ asc_docs_api.prototype.asc_showRevision = function (url, urlChanges, currentChan
else
bUpdate = this.VersionHistory.update(url, urlChanges, currentChangeId);
if (bUpdate) {
documentUrl = url;
this.DocInfo.put_Id('1233211');
this.DocInfo.put_Url(url);
documentUrlChanges = urlChanges;
this.isCoAuthoringEnable = false;
this.LoadDocument();
......
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