<commit_before>/**
 * Copyright (c) 2014, <NAME> <<EMAIL>>
 * This file is licensed under the Affero General Public License version 3 or later.
 * See the COPYING-README file.
 */


/**
 * @brief takes care of deleting things represented by an ID
 * @param String endpoint: the corresponding ajax PHP script. Currently limited
 * to settings - ajax path.
 * @param String paramID: the by the script expected parameter name holding the
 * ID of the object to delete
 * @param Function markCallback: the function to be called after successfully
 * marking the object for deletion.
 * @param Function removeCallback: the function to be called after successful
 * delete. The id of the object will be passed as argument. Unsuccessful
 * operations will display an error using OC.dialogs, no callback is fired.
 */
function DeleteHandler(endpoint, paramID, markCallback, removeCallback) {
	this.oidToDelete = false;
	this.canceled = false;

	this.ajaxEndpoint = endpoint;
	this.ajaxParamID = paramID;

	this.markCallback = markCallback;
	this.removeCallback = removeCallback;
	this.undoCallback = false;

	this.notifier = false;
	this.notificationDataID = false;
	this.notificationMessage = false;
	this.notificationPlaceholder = '%oid';
}

/**
 * @brief enabled the notification system. Required for undo UI.
 * @param Object notifier: Usually OC.Notification
 * @param String dataID: an identifier for the notifier, e.g. 'deleteuser'
 * @param String message: the message that should be shown upon delete. %oid
 * will be replaced with the affected id of the item to be deleted
 * @param Function undoCb: called after "undo" was clicked so the consumer can
 * update the web interface
 */
DeleteHandler.prototype.setNotification = function(notifier, dataID, message, undoCallback) {
	this.notifier = notifier;
	this.notificationDataID = dataID;
	this.notificationMessage = message;
	this.undoCallback = undoCallback;

	var dh = this;

	$('#notification').on('click', '.undo', function () {
		if ($('#notification').data(dh.notificationDataID)) {
			var oid = dh.oidToDelete;
			UserDeleteHandler.cancel();
			if(typeof dh.undoCallback !== 'undefined') {
				dh.undoCallback(oid);
			}
		}
		dh.notifier.hide();
	});
};

/**
 * @brief shows the Undo Notification (if configured)
 */
DeleteHandler.prototype.showNotification = function() {
	if(this.notifier !== false) {
		if(!this.notifier.isHidden()) {
			this.hideNotification();<commit_msg>bind undo to current deleteHandler<commit_after>/**
 * Copyright (c) 2014, <NAME> <<EMAIL>>
 * This file is licensed under the Affero General Public License version 3 or later.
 * See the COPYING-README file.
 */


/**
 * @brief takes care of deleting things represented by an ID
 * @param String endpoint: the corresponding ajax PHP script. Currently limited
 * to settings - ajax path.
 * @param String paramID: the by the script expected parameter name holding the
 * ID of the object to delete
 * @param Function markCallback: the function to be called after successfully
 * marking the object for deletion.
 * @param Function removeCallback: the function to be called after successful
 * delete. The id of the object will be passed as argument. Unsuccessful
 * operations will display an error using OC.dialogs, no callback is fired.
 */
function DeleteHandler(endpoint, paramID, markCallback, removeCallback) {
	this.oidToDelete = false;
	this.canceled = false;

	this.ajaxEndpoint = endpoint;
	this.ajaxParamID = paramID;

	this.markCallback = markCallback;
	this.removeCallback = removeCallback;
	this.undoCallback = false;

	this.notifier = false;
	this.notificationDataID = false;
	this.notificationMessage = false;
	this.notificationPlaceholder = '%oid';
}

/**
 * @brief enabled the notification system. Required for undo UI.
 * @param Object notifier: Usually OC.Notification
 * @param String dataID: an identifier for the notifier, e.g. 'deleteuser'
 * @param String message: the message that should be shown upon delete. %oid
 * will be replaced with the affected id of the item to be deleted
 * @param Function undoCb: called after "undo" was clicked so the consumer can
 * update the web interface
 */
DeleteHandler.prototype.setNotification = function(notifier, dataID, message, undoCallback) {
	this.notifier = notifier;
	this.notificationDataID = dataID;
	this.notificationMessage = message;
	this.undoCallback = undoCallback;

	var dh = this;

	$('#notification').on('click', '.undo', function () {
		if ($('#notification').data(dh.notificationDataID)) {
			var oid = dh.oidToDelete;
			dh.cancel();
			if(typeof dh.undoCallback !== 'undefined') {
				dh.undoCallback(oid);
			}
		}
		dh.notifier.hide();
	});
};

/**
 * @brief shows the Undo Notification (if configured)
 */
DeleteHandler.prototype.showNotification = function() {
	if(this.notifier !== false) {
		if(!this.notifier.isHidden()) {
			this.hideNotification();
{'fraction_non_alphanumeric': 0.10319410319410319, 'fraction_numerical': 0.0020475020475020475, 'mean_word_length': 4.397790055248619, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5267287', 'n_tokens_mistral': 1409, 'n_tokens_neox': 1327, 'n_words': 501}