I have this JavaScript (KnockoutJS) code. I Have a function that in some cases prompt a confirm dialog, and returns the user's answer or "true" if it didn't have to prompt the dialog at all.

The JS regular dialog is ugly and I'd like to create a custom dialog, but I need a kind of modal dialog that **I can get the user's answer** - I don't want to define the next operation (what to do if the user clicks OK) in the dialog itself, because - as you can see in my code - I use the same dialog for many different functions that each has a different behavior so every time the next operation is different.

```
 self.confirmDialog = function () {
       if (condition) {
           return (confirm("text text text"));
       }
       else {
             return true;
       }
  }

 self.doSomething1 = function () {
     if (self.confirmDialog ()) {
         // do something 1
     }
     // some code
 }
 self.doSomething2 = function () {
     // some code
     if (self.confirmDialog ()) {
         // do something 2
     }
 }
 self.doSomething3 = function () {
     if (self.confirmDialog ()) {
         // do something 3
     }
 }

```