mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-02-10 18:05:10 +08:00
feat(csharp): convert button
This commit is contained in:
@ -0,0 +1,4 @@
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M14.4285 13C14.4102 13 14 13 14 13.5V15H6C5.44772 15 5 15.4477 5 16V17C5 17.5523 5.44771 18 6 18H14V19.5C14 20 14.3816 20 14.4285 20C14.6359 20 15.0099 19.9113 15.2172 19.7363L18.6207 17.0833C19.1264 16.6566 19.1264 16.3434 18.6207 15.9167L15.2172 13.2637C15.0099 13.0887 14.6359 13 14.4285 13Z" fill="#444444"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.5715 4C9.58984 4 10 4 10 4.50002V6H18C18.5523 6 19 6.44772 19 7V8C19 8.55228 18.5523 9 18 9H10V10.5C10 11 9.61841 11 9.57151 11C9.36409 11 8.99012 10.9113 8.78279 10.7363L5.37934 8.08333C4.87356 7.65662 4.87356 7.34338 5.37934 6.91667L8.78279 4.26366C8.99012 4.08874 9.36409 4 9.5715 4Z" fill="#444444"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 821 B |
@ -42,10 +42,14 @@
|
||||
}
|
||||
|
||||
.tableHeaderCellViewers {
|
||||
width: 29%;
|
||||
width: 18%;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.tableHeaderCellAction {
|
||||
width: 23%;
|
||||
}
|
||||
|
||||
.tableHeaderCellDownload {
|
||||
width: 21%;
|
||||
padding-right: 18px;
|
||||
@ -220,7 +224,7 @@
|
||||
}
|
||||
|
||||
.tableHeaderCellFileName {
|
||||
width: 16%;
|
||||
width: 9%;
|
||||
}
|
||||
|
||||
.tableHeaderCellEditors {
|
||||
@ -229,7 +233,12 @@
|
||||
|
||||
.tableHeaderCellViewers {
|
||||
text-align: right;
|
||||
width: 37%;
|
||||
width: 9%;
|
||||
}
|
||||
|
||||
.tableHeaderCellAction{
|
||||
width: 11%;
|
||||
padding-right: 82px;
|
||||
}
|
||||
|
||||
.tableHeaderCellDownload {
|
||||
@ -244,19 +253,24 @@
|
||||
}
|
||||
|
||||
.tableHeaderCellEditors {
|
||||
width: 26%;
|
||||
width: 15%;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.tableHeaderCellFileName {
|
||||
width: 17%;
|
||||
width: 28%;
|
||||
}
|
||||
|
||||
.tableHeaderCellViewers {
|
||||
width: 27%;
|
||||
width: 6%;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.tableHeaderCellAction{
|
||||
width: 18%;
|
||||
padding-right: 54px;
|
||||
}
|
||||
|
||||
.tableHeaderCellDownload {
|
||||
padding-right: 18px;
|
||||
width: 20%;
|
||||
@ -277,12 +291,17 @@
|
||||
|
||||
.tableRow td:first-child {
|
||||
flex-grow: 0;
|
||||
width: 15%;
|
||||
width: 25%;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.contentCells-icon {
|
||||
width: 3%;
|
||||
}
|
||||
|
||||
.firstContentCellViewers {
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 890px) and (min-width: 769px ) {
|
||||
@ -290,7 +309,7 @@
|
||||
width: 20%;
|
||||
}
|
||||
.contentCells-shift {
|
||||
padding-right: 28px;
|
||||
padding-right: 27px;
|
||||
}
|
||||
|
||||
.main-panel {
|
||||
@ -323,11 +342,16 @@
|
||||
|
||||
.tableHeaderCellEditors {
|
||||
text-align: left;
|
||||
width: 31%;
|
||||
width: 1%;
|
||||
}
|
||||
|
||||
.tableHeaderCellViewers {
|
||||
width: 18%;
|
||||
width: 19%;
|
||||
}
|
||||
|
||||
.tableHeaderCellAction {
|
||||
width: 19%;
|
||||
padding-right: 45px;
|
||||
}
|
||||
}
|
||||
|
||||
@ -429,8 +453,8 @@
|
||||
|
||||
.downloadContentCellShift {
|
||||
max-width: 7%;
|
||||
margin-right: -11px;
|
||||
margin-left: auto;
|
||||
margin-right: 24px;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.contentCells-icon {
|
||||
@ -438,13 +462,13 @@
|
||||
}
|
||||
|
||||
.tableRow td:last-child {
|
||||
width: 12%;
|
||||
padding-right: 40px;
|
||||
width: 7%;
|
||||
padding-right: 0px;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.contentCells-shift {
|
||||
padding-right: 35px;
|
||||
padding-right: 0px;
|
||||
}
|
||||
|
||||
.downloadContentCellShift:after {
|
||||
@ -530,6 +554,15 @@
|
||||
height: 56px;
|
||||
margin-bottom: 24px !important;
|
||||
}
|
||||
.button.hoar{
|
||||
width: 18%;
|
||||
height: 27px;
|
||||
margin-bottom: 7px !important;
|
||||
}
|
||||
.button.converting{
|
||||
width: 126px;
|
||||
margin-top: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 560px) and (min-width: 510px) {
|
||||
@ -538,7 +571,7 @@
|
||||
}
|
||||
|
||||
.downloadContentCellShift {
|
||||
padding-right: 45px;
|
||||
padding-right: 16px;
|
||||
max-width: 4%;
|
||||
}
|
||||
}
|
||||
@ -558,7 +591,7 @@
|
||||
|
||||
.downloadContentCellShift {
|
||||
max-width: 6%;
|
||||
padding-right: 37px;
|
||||
padding-right: 6px;
|
||||
}
|
||||
|
||||
.firstContentCellShift {
|
||||
@ -584,12 +617,12 @@
|
||||
|
||||
.downloadContentCellShift {
|
||||
max-width: 3%;
|
||||
padding-right: 37px;
|
||||
padding-right: 0px;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.firstContentCellShift {
|
||||
margin-left: 1px;
|
||||
margin-left: 2px;
|
||||
flex-basis: 14%;
|
||||
}
|
||||
|
||||
@ -619,7 +652,7 @@
|
||||
|
||||
.downloadContentCellShift {
|
||||
max-width: 4%;
|
||||
margin-right: -18px;
|
||||
margin-right: 18px;
|
||||
margin-left: -1px;
|
||||
}
|
||||
|
||||
@ -628,7 +661,7 @@
|
||||
}
|
||||
|
||||
.contentCells-icon{
|
||||
width: 10%;
|
||||
width: 12%;
|
||||
}
|
||||
footer table td {
|
||||
margin: 0;
|
||||
|
||||
@ -238,6 +238,52 @@ label .checkbox {
|
||||
color: #FF6F3D;
|
||||
}
|
||||
|
||||
.button.converting {
|
||||
margin-top: -20px;
|
||||
padding: 16px 16px;
|
||||
}
|
||||
|
||||
.button.converting.wide {
|
||||
padding: 16px 29px;
|
||||
}
|
||||
|
||||
.button.hoar {
|
||||
background: #EFEFEF;
|
||||
border: 1px solid #EFEFEF;
|
||||
margin-right: 7px;
|
||||
margin-bottom: 7px;
|
||||
width: 13%;
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.button.hoar.disable {
|
||||
opacity: 30%;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.button.hoar:not(.disable):hover {
|
||||
background: #FF6F3D;
|
||||
border: 1px solid #FF6F3D;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
.button.hoar.orange {
|
||||
background: #FF6F3D;
|
||||
border: 1px solid #FF6F3D;
|
||||
color: #FFFFFF;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.button.hoar.orange.disable {
|
||||
background: #444444;
|
||||
border: 1px solid #444444;
|
||||
color: #FFFFFF;
|
||||
cursor: default;
|
||||
opacity: 100%;
|
||||
}
|
||||
|
||||
.button.file-type {
|
||||
font-size: 11px;
|
||||
color: #FFFFFF;
|
||||
@ -380,6 +426,32 @@ label .checkbox {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#convertingProgress {
|
||||
color: #333333;
|
||||
display: none;
|
||||
font-size: 12px;
|
||||
margin: 30px 35px;
|
||||
}
|
||||
|
||||
#convertingProgress .convertFileName{
|
||||
background-position: left center;
|
||||
background-repeat: no-repeat;
|
||||
display: block;
|
||||
font-size: 14px;
|
||||
line-height: 160%;
|
||||
overflow: hidden;
|
||||
padding-left: 28px;
|
||||
margin-bottom: 16px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
#convertingProgress .describeUpload {
|
||||
line-height: 150%;
|
||||
letter-spacing: -0.02em;
|
||||
padding: 16px 0;
|
||||
}
|
||||
|
||||
.error-message {
|
||||
background: url("images/error.svg") no-repeat scroll 4px 10px;
|
||||
color: #CB0000;
|
||||
@ -401,6 +473,10 @@ label .checkbox {
|
||||
padding-left: 35px;
|
||||
}
|
||||
|
||||
.waiting {
|
||||
opacity: 30%;
|
||||
}
|
||||
|
||||
.current {
|
||||
background-image: url("images/loader16.gif");
|
||||
}
|
||||
@ -413,6 +489,12 @@ label .checkbox {
|
||||
background-image: url("images/notdone.svg");
|
||||
}
|
||||
|
||||
.convertPercent {
|
||||
color: #FF6F3D;
|
||||
font-weight: 700;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.step-descr {
|
||||
display: block;
|
||||
margin-left: 35px;
|
||||
@ -420,6 +502,10 @@ label .checkbox {
|
||||
line-height: 188%;
|
||||
}
|
||||
|
||||
.step-descr.disable {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.progress-descr {
|
||||
letter-spacing: -0.02em;
|
||||
line-height: 150%;
|
||||
@ -525,21 +611,25 @@ footer a:hover {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.convertFileName.word,
|
||||
.stored-edit.word,
|
||||
.uploadFileName.word {
|
||||
background-image: url("images/icon_docx.svg");
|
||||
}
|
||||
|
||||
.convertFileName.cell,
|
||||
.stored-edit.cell,
|
||||
.uploadFileName.cell {
|
||||
background-image: url("images/icon_xlsx.svg");
|
||||
}
|
||||
|
||||
.convertFileName.slide,
|
||||
.stored-edit.slide,
|
||||
.uploadFileName.slide {
|
||||
background-image: url("images/icon_pptx.svg");
|
||||
}
|
||||
|
||||
.convertFileName.pdf,
|
||||
.stored-edit.pdf,
|
||||
.uploadFileName.pdf {
|
||||
background-image: url("images/icon_pdf.svg");
|
||||
@ -596,6 +686,11 @@ footer a:hover {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.convertTable {
|
||||
margin-top: 10px;
|
||||
margin-left: 35px;
|
||||
}
|
||||
|
||||
.tableRow {
|
||||
background: transparent;
|
||||
-moz-transition: all 0.2s ease-in-out;
|
||||
@ -642,6 +737,12 @@ footer a:hover {
|
||||
width: 11%;
|
||||
}
|
||||
|
||||
.tableHeaderCellAction{
|
||||
width: 13%;
|
||||
text-align: right;
|
||||
padding-right: 88px;
|
||||
}
|
||||
|
||||
.tableHeaderCellDownload {
|
||||
width: 13%;
|
||||
text-align: right;
|
||||
@ -666,7 +767,7 @@ footer a:hover {
|
||||
}
|
||||
|
||||
.contentCells-shift {
|
||||
padding-right: 44px;
|
||||
padding-right: 43px;
|
||||
}
|
||||
|
||||
.contentCells-icon {
|
||||
@ -730,7 +831,7 @@ footer a:hover {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.icon-delete {
|
||||
.icon-action {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
@ -809,6 +910,13 @@ html {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.typeButtonsRow {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
flex-direction: row;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.tableRow td:first-child {
|
||||
display: flex;
|
||||
@ -817,11 +925,11 @@ html {
|
||||
}
|
||||
|
||||
.tableHeaderCellFileName {
|
||||
width: 30%;
|
||||
width: 20%;
|
||||
}
|
||||
|
||||
.tableHeaderCellEditors {
|
||||
width: 28%;
|
||||
width: 20%;
|
||||
}
|
||||
|
||||
.tableHeaderCellViewers {
|
||||
|
||||
@ -194,8 +194,7 @@
|
||||
<td class="tableHeaderCell tableHeaderCellFileName">Filename</td>
|
||||
<td class="tableHeaderCell tableHeaderCellEditors contentCells-shift">Editors</td>
|
||||
<td class="tableHeaderCell tableHeaderCellViewers">Viewers</td>
|
||||
<td class="tableHeaderCell tableHeaderCellDownload">Download</td>
|
||||
<td class="tableHeaderCell tableHeaderCellRemove">Remove</td>
|
||||
<td class="tableHeaderCell tableHeaderCellAction">Action</td>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
@ -303,14 +302,22 @@
|
||||
<img src="app_themes/images/embeded.svg" alt="Open in embedded mode" title="Open in embedded mode"/>
|
||||
</a>
|
||||
</td>
|
||||
<td class="contentCells contentCells-icon contentCells-shift downloadContentCellShift">
|
||||
<% if (docType != null ) { %>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a class="convert-file" data="<%= storedFile.Name %>" data-type="<%= docType %>">
|
||||
<img class="icon-action" src="app_themes/images/convert.svg" alt="Convert" title="Convert" /></a>
|
||||
</td>
|
||||
<% } else { %>
|
||||
<td class="contentCells contentCells-icon downloadContentCellShift"></td>
|
||||
<% } %>
|
||||
<td class="contentCells contentCells-icon downloadContentCellShift">
|
||||
<a href="webeditor.ashx?type=download&fileName=<%= HttpUtility.UrlEncode(storedFile.Name) %>">
|
||||
<img class="icon-download" src="app_themes/images/download.svg" alt="Download" title="Download" />
|
||||
</a>
|
||||
</td>
|
||||
<td class="contentCells contentCells-icon contentCells-shift">
|
||||
<a class="delete-file" data-filename="<%= storedFile.Name %>">
|
||||
<img class="icon-delete" src="app_themes/images/delete.svg" alt="Delete" title="Delete" />
|
||||
<img class="icon-action" src="app_themes/images/delete.svg" alt="Delete" title="Delete" />
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
@ -379,6 +386,32 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="convertingProgress">
|
||||
<div id="convertingSteps">
|
||||
<span id="convertFileName" class="convertFileName"></span>
|
||||
<span id="convertStep1" class="step">1. Select a format file to convert</span>
|
||||
<span class="step-descr">The converting speed depends on file size and additional elements it contains.</span>
|
||||
<table cellspacing="0" cellpadding="0" width="100%" class="convertTable">
|
||||
<tbody>
|
||||
<tr class="typeButtonsRow" id="convTypes"></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<br />
|
||||
<span id="convertStep2" class="step">2. File conversion</span>
|
||||
<span class="step-descr disable" id="convert-descr">The file is converted <div class="convertPercent" id="convertPercent">0 %</div></span>
|
||||
<span class="step-error hidden" id="convert-error"></span>
|
||||
<div class="describeUpload">Note the speed of all operations depends on your connection quality and server location.</div>
|
||||
<input type="hidden" name="hiddenFileName" id="hiddenFileName" />
|
||||
</div>
|
||||
<br />
|
||||
<div class="buttonsMobile">
|
||||
<div id="downloadConverted" class="button converting orange disable">DOWNLOAD</div>
|
||||
<div id="beginViewConverted" class="button converting wide gray disable">VIEW</div>
|
||||
<div id="beginEditConverted" class="button converting wide gray disable">EDIT</div>
|
||||
<div id="cancelEdit" class="button converting gray">CANCEL</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<span id="loadScripts" data-docs="<%= UrlPreloadScripts %>"></span>
|
||||
|
||||
<footer>
|
||||
|
||||
@ -447,8 +447,15 @@ namespace OnlineEditorsExample
|
||||
conversionExtension = fileExt.ToString();
|
||||
}
|
||||
|
||||
object keepOriginal;
|
||||
bool removeOriginal = true;
|
||||
if (body.TryGetValue("keepOriginal", out keepOriginal) && !String.IsNullOrEmpty(keepOriginal.ToString()))
|
||||
{
|
||||
removeOriginal = keepOriginal.ToString().ToLower() != "true";
|
||||
}
|
||||
|
||||
// check if the file with such an extension can be converted
|
||||
if (ConvertExts.Contains("." + extension))
|
||||
if (ConvertExts.Contains("." + extension) || conversionExtension != "ooxml")
|
||||
{
|
||||
// generate document key
|
||||
var key = ServiceConverter.GenerateRevisionId(FileUri(_fileName, true));
|
||||
@ -469,9 +476,13 @@ namespace OnlineEditorsExample
|
||||
}
|
||||
|
||||
var newFileUri = newFileData["fileUrl"];
|
||||
var newFileType = "." + newFileData["fileType"];
|
||||
var newFileType = newFileData["fileType"];
|
||||
if (!FormatManager.All().Any(f => f.Name == newFileType && f.Type != ""))
|
||||
{
|
||||
return "{\"step\": \"" + result + "\", \"filename\": \"" + newFileUri + "\", \"error\": \"FileTypeIsNotSupported\"}";
|
||||
}
|
||||
// get a file name of an internal file extension with an index if the file with such a name already exists
|
||||
var fileName = GetCorrectName(Path.GetFileNameWithoutExtension(_fileName) + newFileType);
|
||||
var fileName = GetCorrectName(Path.GetFileNameWithoutExtension(_fileName) + "." + newFileType);
|
||||
|
||||
var req = (HttpWebRequest)WebRequest.Create(newFileUri);
|
||||
|
||||
@ -493,17 +504,21 @@ namespace OnlineEditorsExample
|
||||
}
|
||||
}
|
||||
|
||||
// remove the original file and its history if it exists
|
||||
var storagePath = StoragePath(_fileName, null);
|
||||
var histDir = HistoryDir(storagePath);
|
||||
File.Delete(storagePath);
|
||||
if (Directory.Exists(histDir)) Directory.Delete(histDir, true);
|
||||
|
||||
if (removeOriginal)
|
||||
{
|
||||
// remove the original file and its history if it exists
|
||||
var storagePath = StoragePath(_fileName, null);
|
||||
var histDir = HistoryDir(storagePath);
|
||||
File.Delete(storagePath);
|
||||
if (Directory.Exists(histDir)) Directory.Delete(histDir, true);
|
||||
}
|
||||
// create meta information about the converted file with user id and name specified
|
||||
_fileName = fileName;
|
||||
var id = context.Request.Cookies.GetOrDefault("uid", null);
|
||||
var user = Users.getUser(id); // get the user
|
||||
DocEditor.CreateMeta(_fileName, user.id, user.name, null);
|
||||
|
||||
return "{\"step\": \"" + result + "\", \"filename\": \"" + _fileName + "\"}";
|
||||
}
|
||||
|
||||
return "{ \"filename\" : \"" + _fileName + "\"}";
|
||||
|
||||
@ -294,6 +294,134 @@ if (typeof jQuery != "undefined") {
|
||||
jq("#embeddedView").attr("src", url);
|
||||
});
|
||||
|
||||
jq(document).on("click", "#beginEditConverted:not(.disable)", function () {
|
||||
var fileId = encodeURIComponent(jq('#hiddenFileName').attr("data"));
|
||||
var url = "doceditor.aspx?fileID=" + fileId;
|
||||
window.open(url, "_blank");
|
||||
jq('#hiddenFileName').val("");
|
||||
jq.unblockUI();
|
||||
document.location.reload();
|
||||
});
|
||||
|
||||
jq(document).on("click", "#beginViewConverted:not(.disable)", function () {
|
||||
var fileId = encodeURIComponent(jq('#hiddenFileName').attr("data"));
|
||||
var url = "doceditor.aspx?editorsMode=view&fileID=" + fileId;
|
||||
window.open(url, "_blank");
|
||||
jq('#hiddenFileName').val("");
|
||||
jq.unblockUI();
|
||||
document.location.reload();
|
||||
});
|
||||
|
||||
jq(document).on("click", "#downloadConverted:not(.disable)", function () {
|
||||
var fileId = jq('#hiddenFileName').attr("data");
|
||||
if (jq("#downloadConverted").attr("data") == "fromConverter") window.location.assign(fileId);
|
||||
else window.open("webeditor.ashx?type=download&fileName=" + encodeURIComponent(fileId), "_blank");
|
||||
});
|
||||
|
||||
jq(document).on("click", ".convert-file", function () {
|
||||
const currentElement = jq(this);
|
||||
var fileName = currentElement.attr("data");
|
||||
var type = currentElement.attr("data-type");
|
||||
|
||||
jq.blockUI({
|
||||
theme: true,
|
||||
title: "Converting file" + "<div class=\"dialog-close\"></div>",
|
||||
message: jq("#convertingProgress"),
|
||||
overlayCSS: { "background-color": "#aaa" },
|
||||
themedCSS: { width: "539px", top: "20%", left: "50%", marginLeft: "-269px" }
|
||||
});
|
||||
|
||||
jq("#convertFileName").text(decodeURIComponent(fileName));
|
||||
jq("#convertFileName").removeClass("word slide cell");
|
||||
jq("#convertFileName").addClass(type);
|
||||
jq("#convTypes").empty();
|
||||
|
||||
let format = formatManager.findByExtension(fileName.split('.').pop());
|
||||
if (format) {
|
||||
format.convert.forEach(ext => {
|
||||
jq("#convTypes").append(jq(`<td name="convertingTypeButton" id="wordTo${ext}" class="button hoar" data="${ext}">${ext}</td>`));
|
||||
});
|
||||
}
|
||||
|
||||
jq("#hiddenFileName").val(fileName);
|
||||
jq("#convertStep1").addClass("done");
|
||||
jq("#convertStep2").addClass("waiting");
|
||||
});
|
||||
|
||||
jq(document).on("click", "td[name='convertingTypeButton']:not(.disable, .orange)", function () {
|
||||
const currentElement = jq(this);
|
||||
let id = currentElement[0].id;
|
||||
let fileExt = jq(`#${id}`).attr("data");
|
||||
jq(`#${id}`).addClass("orange");
|
||||
jq("td[name='convertingTypeButton']").addClass("disable");
|
||||
jq("#convertStep2").removeClass("waiting").removeClass("done").addClass("current");
|
||||
jq("#convertStep2").text('2. File conversion');
|
||||
jq("#convert-descr").removeClass("disable");
|
||||
jq("#convertPercent").text("0 %");
|
||||
jq("#hiddenFileName").attr("placeholder",fileExt);
|
||||
jq("#downloadConverted").addClass("disable");
|
||||
jq("#beginEditConverted").addClass("disable");
|
||||
jq("#beginViewConverted").addClass("disable");
|
||||
mustReload = true;
|
||||
|
||||
convertFile();
|
||||
});
|
||||
|
||||
function convertFile (filePass) {
|
||||
let fileName = decodeURIComponent(jq("#hiddenFileName").val());
|
||||
let fileExt = jq("#hiddenFileName").attr("placeholder");
|
||||
|
||||
filePass = filePass ? filePass : null;
|
||||
if (timer != null) {
|
||||
clearTimeout(timer);
|
||||
}
|
||||
timer = setTimeout(function () {
|
||||
jq.ajax({
|
||||
async: true,
|
||||
contentType: "text/xml",
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
data: JSON.stringify({filename: fileName, filePass: filePass, lang: language, fileExt: fileExt, keepOriginal: true}),
|
||||
url: "webeditor.ashx?type=convert",
|
||||
complete: function (data) {
|
||||
try {
|
||||
var response = jq.parseJSON(data.responseText);
|
||||
} catch (e) {
|
||||
response = { error: e };
|
||||
}
|
||||
if (!response.filename && !response.step && response.error) {
|
||||
jq("#convertStep2").removeClass("current").addClass("error");
|
||||
jq("#convertStep2").text(`2. File conversion to ${fileExt}`);
|
||||
jq("#convert-error").removeClass("hidden");
|
||||
jq("#convert-error").text(`${response.error}`);
|
||||
jq("td[name='convertingTypeButton']").removeClass("disable orange");
|
||||
return;
|
||||
}
|
||||
if (response.step != undefined && response.step != 100) {
|
||||
jq("#convertPercent").text(`${response.step} %`);
|
||||
convertFile();
|
||||
} else {
|
||||
jq("#convertPercent").text(`${response.step} %`);
|
||||
jq("#convertStep2").removeClass("current").addClass("done");
|
||||
jq("#convertStep2").text(`2. File conversion to ${fileExt}`);
|
||||
jq("#downloadConverted").removeClass("disable");
|
||||
if (response.error !== "FileTypeIsNotSupported") {
|
||||
jq("#hiddenFileName").attr("data",response.filename);
|
||||
jq("#beginEditConverted").removeClass("disable");
|
||||
jq("#beginViewConverted").removeClass("disable");
|
||||
jq("#downloadConverted").attr("data","fromStorage");
|
||||
} else {
|
||||
let newFilename = fileName.split('.').slice(0,-1).join('.')
|
||||
jq("#hiddenFileName").attr("data",response.filename.split("&filename=download").join(`&filename=${newFilename}`));
|
||||
jq("#downloadConverted").attr("data","fromConverter");
|
||||
}
|
||||
jq("td[name='convertingTypeButton']").removeClass("disable orange");
|
||||
}
|
||||
}
|
||||
});
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
jq(document).on("click", "#cancelEdit, .dialog-close", function () {
|
||||
jq('#hiddenFileName').val("");
|
||||
jq("#embeddedView").attr("src", "");
|
||||
|
||||
Reference in New Issue
Block a user