Skip to content

Commit be74b29

Browse files
author
James Leigh
committed
Fix #640: Use async XMLHttpRequests in workbench
Signed-off-by: James Leigh <james.leigh@ontotext.com>
1 parent 72a0146 commit be74b29

5 files changed

Lines changed: 30 additions & 24 deletions

File tree

core/http/workbench/src/main/webapp/scripts/create.js

Lines changed: 9 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/http/workbench/src/main/webapp/scripts/delete.js

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/http/workbench/src/main/webapp/scripts/ts/create.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ function checkOverwrite() {
2424
var id = workbench.create.id.val();
2525
$.ajax({
2626
url: '../' + id + '/info',
27-
async: false,
2827
success: function () {
2928
submit = confirm('WARNING: You are about to overwrite the ' +
3029
'configuration of an existing repository!');
@@ -33,15 +32,17 @@ function checkOverwrite() {
3332
500: function () {
3433
submit = true;
3534
}
36-
}
35+
},
36+
complete : function(xhr, status) {
37+
if (submit && !id.match(/^[a-z0-9._-]+$/)) {
38+
submit = confirm('WARNING: There are potentially incompatible ' +
39+
'characters in the repository id.');
40+
}
41+
if (submit) {
42+
$("form[action='create']").submit();
43+
}
44+
}
3745
});
38-
if (submit && !id.match(/^[a-z0-9._-]+$/)) {
39-
submit = confirm('WARNING: There are potentially incompatible ' +
40-
'characters in the repository id.');
41-
}
42-
if (submit) {
43-
$("form[action='create']").submit();
44-
}
4546
}
4647

4748
workbench.addLoad(function createPageLoaded() {

core/http/workbench/src/main/webapp/scripts/ts/delete.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@
1010
* DeleteServlet whether the given ID has been proxied, giving a chance to back
1111
* out if it is.
1212
*/
13-
function checkIsSafeToDelete() {
13+
function checkIsSafeToDelete(event) {
1414
var id = $('#id').val();
1515
var submitForm = false;
1616
var feedback = $('#delete-feedback');
1717
$
1818
.ajax({
1919
dataType : 'json',
2020
url : 'delete',
21-
async : false,
2221
timeout : 5000,
2322
data : {
2423
checkSafe : id
@@ -41,7 +40,10 @@ function checkIsSafeToDelete() {
4140
if (!submitForm) {
4241
submitForm = confirm('WARNING: You are about to delete a repository that has been proxied by another repository!');
4342
}
43+
if (submitForm) {
44+
$(event.target).closest('form')[0].submit();
45+
}
4446
}
4547
});
46-
return submitForm;
48+
return false;
4749
}

core/http/workbench/src/main/webapp/transformations/delete.xsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<xsl:include href="template.xsl" />
1313

1414
<xsl:template match="sparql:sparql">
15-
<form action="delete" method="post" onsubmit="return checkIsSafeToDelete();">
15+
<form action="delete" method="post" onsubmit="checkIsSafeToDelete(event);">
1616
<table class="dataentry">
1717
<tbody>
1818
<tr>

0 commit comments

Comments
 (0)