Skip to content

Commit

Permalink
initial drop type inference
Browse files Browse the repository at this point in the history
  • Loading branch information
umut-er committed Jul 10, 2024
1 parent b09f105 commit 8993bf0
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 15 deletions.
Binary file added app/.DS_Store
Binary file not shown.
65 changes: 56 additions & 9 deletions app/js/app-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ module.exports = function() {
});

$("#file-input").change(function (e, fileObject) {


// use the active chise instance
var chiseInstance = appUtilities.getActiveChiseInstance();
Expand All @@ -392,18 +393,67 @@ module.exports = function() {
var cy = appUtilities.getActiveCy();

if ($(this).val() != "" || fileObject) {
var file = this.files[0] || fileObject;
var loadCallbackSBGNMLValidity = function (text) {
//validateSBGNML(text);
}
// var file = this.files[0] || fileObject;
var file = fileObject;

var params, caller;
var fileExtension = file.name.split('.').pop();

var loadCallbackInvalidityWarning = function () {
promptInvalidFileView.render();
}

if(fileExtension == 'sif'){
var layoutBy = function() {
appUtilities.triggerLayout( cy, true );
};
params = [layoutBy, loadCallbackInvalidityWarning];
caller = chiseInstance.loadSIFFile;
}
else if(fileExtension == 'sbml'){
var layoutBy = function() {
appUtilities.triggerLayout( cy, true );
};
var success = function(data){
chiseInstance.loadSBMLText(data.message, false, file.name, cy);
};
var error = function(data){
promptFileConversionErrorView.render();
document.getElementById("file-conversion-error-message").innerText = "Conversion service is not available!";
},
caller = chiseInstance.loadSbmlForSBML;
params = [success, error, layoutBy];
}
else if(fileExtension == 'xml'){
appUtilities.setFileContent(file.name);
caller = chiseInstance.loadCellDesigner;
var success = function(data){
chiseInstance.loadSBGNMLText(data, true, file.name, cy);
}
var error = function(data){
promptFileConversionErrorView.render();
document.getElementById("file-conversion-error-message").innerText = "Conversion service is not available!";
};
params = [success, error];
}
else if(fileExtension == 'gpml'){
// TODO
}
else{
var loadCallbackSBGNMLValidity = function (text) {
//validateSBGNML(text);
}
params = [loadCallbackSBGNMLValidity, loadCallbackInvalidityWarning];
caller = chiseInstance.loadNwtFile;
}

if(cy.elements().length != 0) {
promptConfirmationView.render(function(){chiseInstance.loadNwtFile(file, loadCallbackSBGNMLValidity, loadCallbackInvalidityWarning)});
promptConfirmationView.render(() => {
setTimeout(() => caller(file, ...params), 150);
});
}
else {
chiseInstance.loadNwtFile(file, loadCallbackSBGNMLValidity, loadCallbackInvalidityWarning);
caller(file, ...params);
}
$(this).val("");
}
Expand Down Expand Up @@ -539,9 +589,6 @@ module.exports = function() {
// use cy instance assocated with chise instance
var cy = appUtilities.getActiveCy();

var loadCallbackInvalidityWarning = function () {
promptInvalidFileView.render();
}

if ($(this).val() != "") {
var file = this.files[0];
Expand Down
7 changes: 1 addition & 6 deletions app/js/backbone-views.js
Original file line number Diff line number Diff line change
Expand Up @@ -4355,12 +4355,7 @@ var PromptConfirmationView = Backbone.View.extend({
.off("click", "#prompt-confirmation-accept")
.on("click", "#prompt-confirmation-accept", function (evt) {
$(self.el).modal("toggle");

// This timeout is to insure that the modal disappers properly.
// Without this sometimes there would be weird behavior on file loading.
setTimeout(() => {
afterFunction();
}, 500);
afterFunction();
});

$(document)
Expand Down

0 comments on commit 8993bf0

Please sign in to comment.