Skip to content

Commit 68eeb60

Browse files
committed
Microsoft Internet Explorer adaptation for Upload Subscriptions file implemented.
1 parent b3a077c commit 68eeb60

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

src/main/resources/static/js/main.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -539,20 +539,11 @@ jQuery(document).ready(function() {
539539

540540
function createUploadWindow() {
541541

542-
543542
var pom = document.createElement('input');
544543
pom.setAttribute('id', 'uploadFile');
545544
pom.setAttribute('type', 'file');
546545
pom.setAttribute('name', 'upFile');
547-
548-
// Internet Explorer adaptation
549-
pom.setAttribute('onchange', "function uploadFinished() {" +
550-
"var subscriptionFile = pom.files[0];" +
551-
"console.log('Uploaded File: ' + subscriptionFile);" +
552-
"validateJsonandSubscriptionFormat(subscriptionFile);" +
553-
"};");
554-
555-
// All other Web Browser
546+
556547
pom.onchange = function uploadFinished() {
557548
var subscriptionFile = pom.files[0];
558549
validateJsonAndCreateSubscriptions(subscriptionFile);
@@ -567,9 +558,22 @@ jQuery(document).ready(function() {
567558
pom.click();
568559
}
569560
}
570-
571-
createUploadWindow();
572-
561+
562+
function createUploadWindowMSExplorer() {
563+
564+
$('#upload_subscription_file').click();
565+
var file = $('#upload_subscription_file').prop('files')[0];
566+
validateJsonAndCreateSubscriptions(file);
567+
}
568+
569+
// If MS Internet Explorer -> special handling for creating download file window.
570+
if (window.navigator.msSaveOrOpenBlob) {
571+
createUploadWindowMSExplorer();
572+
}
573+
else {
574+
// HTML5 Download File window handling
575+
createUploadWindow();
576+
}
573577
});
574578
// /END ## upload_subscriptions #################################################
575579

src/main/resources/templates/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ <h3>Subscription Data</h3>
5353
<button data-toggle="tooltip" title="Delete all marked subscriptions from EI" class="btn btn-danger bulk_delete" ><i class="glyphicon glyphicon-trash"></i> Bulk Delete</button>
5454
<button data-toggle="tooltip" title="Download Subscription JSON template" class="btn btn-primary get_subscription_template" ><i class="glyphicon glyphicon-download"></i> Get Template</button>
5555
<button data-toggle="tooltip" title="Upload Subscription JSON" class="btn btn-info upload_subscriptions"><i class="glyphicon glyphicon-upload"></i>Upload Subscriptions</button>
56+
<input type='file' id='upload_subscription_file' name='file' style="width:0;height:0"/>
5657

5758
<br />
5859
<br />

0 commit comments

Comments
 (0)