Plea for simple OK alert

There is the <$action-confirm> widget which does a fine job to display a simple dialog box for OK/Cancel dialog.

What about pure information box ? This would be a simple OK dialog box.

So I tried creating my own, adapting the js code for <$action-confirm> as shown below:

/*\

title: $:/user/common/widgets/action-ack.js
type: application/javascript
module-type: widget

\*/
(function(){

/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";

var Widget = require("$:/core/modules/widgets/widget.js").widget;

var AckWidget = function(parseTreeNode, options) {
	this.initialise(parseTreeNode, options);
};

/*
Inherit from the base widget class
*/
AckWidget.prototype = new Widget();

/*
Render this widget into the DOM
*/
AckWidget.prototype.render = function(parent, nextSibling) {
	this.computeAttributes();
	this.execute();
	this.parentDomNode = parent;
	this.renderChildren(parent, nextSibling);
};

/*
Compute the internal state of the widget
*/
AckWidget.prototype.execute = function() {
	this.message = this.getAttribute("$message", "By Jove!");
	this.prompt = this.getAttribute("$prompt", "OK");
	this.makeChildWidgets();
};

/*
Refresh the widget by ensuring our attributes are up to date
*/
AckWidget.prototype.refresh = function(changedTiddlers) {
	var changedAttributes = this.computeAttributes();
	if(changedAttributes["$message"] || changedAttributes["$prompt"]) {
		this.refreshSelf();
		return true;
	}
	return this.refreshChildren(changedTiddlers);
};

/*
Invoke the action associated with this widget
*/
AckWidget.prototype.invokeAction = function(triggeringWidget, event) {
	var invokeActions = true,
		handled = true,
	    	win = event && event.event && event.event.view ? event.event.view : window;
	if(this.prompt) {
		invokeActions = win.confirm(this.message);
	}
	if(invokeActions) {
		handled = this.invokeActions(triggeringWidget, event);
	}
	return handled;
};

AckWidget.prototype.allowActionPropagation = function() {
	return false;
};

exports["action-ack"] = AckWidget;

})();

There is just a problem: I still have both OK and Cancel buttons in the dialog box. This means I still needs to have a proper template or customize the parameters for the template currently in use. But where is that template?

TIA for all you clever folks!

$action-confirm uses the JavaScript confirm() method. The equivalent for an alert would be to use alert() in the code instead in the invokeAction method.
So something along these lines:

AckWidget.prototype.invokeAction = function(triggeringWidget, event) {
	var win = event && event.event && event.event.view ? event.event.view : window;
	win.confirm(this.message);
	return this.invokeActions(triggeringWidget, event);
};

Note that you may wish to consider less intrusive means of communicating the same information, depending of course on your use case.

Many thanks @saqimtiaz ! I was not loooking in the right place.

I have now got rid of the “prompt” parameter as I cannot change the caption of the OK button. I think this simple AckWidget would be useful in the standard edition even though you must use alert with caution and parcimony indeed!