csharp-mvc: add password for convert

This commit is contained in:
Alexandr Fedorov
2021-04-14 15:07:55 +03:00
parent d6db3cae2b
commit 1f7b085455
5 changed files with 98 additions and 18 deletions

View File

@ -28,6 +28,7 @@ if (typeof jQuery != "undefined") {
jq(".current").removeClass("current");
jq("#step1").addClass("current");
jq("#mainProgress .error-message").hide().find("span").text("");
jq("#blockPassword").hide();
jq("#mainProgress").removeClass("embedded");
jq("#uploadFileName").text("");
@ -60,7 +61,6 @@ if (typeof jQuery != "undefined") {
jq("#uploadFileName").addClass(response.documentType);
jq("#step1").addClass("done").removeClass("current");
jq("#step2").addClass("current");
checkConvert();
}
@ -70,7 +70,7 @@ if (typeof jQuery != "undefined") {
});
var timer = null;
var checkConvert = function () {
var checkConvert = function (filePass = null) {
if (timer != null) {
clearTimeout(timer);
}
@ -78,6 +78,8 @@ if (typeof jQuery != "undefined") {
if (!jq("#mainProgress").is(":visible")) {
return;
}
jq("#step2").addClass("current");
jq("#filePass").val("");
var fileName = jq("#hiddenFileName").val();
var posExt = fileName.lastIndexOf('.');
@ -95,24 +97,36 @@ if (typeof jQuery != "undefined") {
contentType: "text/xml",
type: "post",
dataType: "json",
data: JSON.stringify({ filename: fileName }),
data: JSON.stringify({ filename: fileName, filePass: filePass }),
url: UrlConverter,
complete: function (data) {
var responseText = data.responseText;
var response = jq.parseJSON(responseText);
if (response.error) {
jq(".current").removeClass("current");
jq(".step:not(.done)").addClass("error");
jq("#mainProgress .error-message").show().find("span").text(response.error);
jq('#hiddenFileName').val("");
return;
if (response.error.includes("Incorrect password")) {
jq(".current").removeClass("current");
jq("#step2").addClass("error");
jq("#blockPassword").show();
if (filePass) {
jq("#filePass").addClass("errorInput");
jq(".errorPass").text("The password is incorrect, please try again.");
}
return;
} else {
jq(".current").removeClass("current");
jq(".step:not(.done)").addClass("error");
jq("#mainProgress .error-message").show().find("span").text(response.error);
jq('#hiddenFileName').val("");
return;
}
}
jq("#hiddenFileName").val(response.filename);
if (response.step && response.step < 100) {
checkConvert();
checkConvert(filePass);
} else {
jq("#step2").addClass("done").removeClass("current");
loadScripts();
}
}
@ -124,7 +138,6 @@ if (typeof jQuery != "undefined") {
if (!jq("#mainProgress").is(":visible")) {
return;
}
jq("#step2").addClass("done").removeClass("current");
jq("#step3").addClass("current");
if (jq("#loadScripts").is(":empty")) {
@ -182,6 +195,23 @@ if (typeof jQuery != "undefined") {
});
};
jq(document).on("click", "#enterPass", function () {
var filePass = jq("#filePass").val();
if (filePass) {
jq("#step2").removeClass("error");
jq("#blockPassword").hide();
checkConvert(filePass);
} else {
jq("#filePass").addClass("errorInput");
jq(".errorPass").text("Password can't be blank.");
}
});
jq(document).on("click", "#skipPass", function () {
jq("#blockPassword").hide();
loadScripts();
});
jq(document).on("click", "#beginEdit:not(.disable)", function () {
var fileId = encodeURIComponent(jq('#hiddenFileName').val());
var url = UrlEditor + "?fileName=" + fileId;