Skip to content

Instantly share code, notes, and snippets.

@dhaupin
Last active March 31, 2017 01:17
Show Gist options
  • Save dhaupin/980d10bce526f2913e994d512eae3bcd to your computer and use it in GitHub Desktop.
Save dhaupin/980d10bce526f2913e994d512eae3bcd to your computer and use it in GitHub Desktop.
Vtiger - VTExperts Notification JS Cleaner
// Cleans out notifications from this Vtiger plugin
// (For those without privs to see the global list)
// https://www.vtexperts.com/product/vtiger-notifications-reminders/
function notifDestroyer(dataTarget = $('[data-id]'), speed = 600, limit = 500) {
var i = 0;
dataTarget.each(function(i, v) {
var this_id = $(this).attr('data-id');
i++;
if (i > limit) {
return false;
}
setTimeout(function () {
// Mark notification read
var params = {
'module': 'Notifications',
'action': 'ActionAjax',
'mode': 'markNotificationRead',
'record': this_id
};
var instance = new NotificationsJS();
AppConnector.request(params).then(
function (response) {
if (response.success == true) {
//instance.updateTotalCounter(notificationLink, notificationList, notificationCounter);
console.log('Cleaning: ' + this_id + ' (Step '+ i + ')');
} else {
Vtiger_Helper_Js.showMessage({
text: response.error.message
})
}
},
function (error) {
console.log(error);
Vtiger_Helper_Js.showMessage({
text: error
})
}
);
}, i*speed);
});
}
notifDestroyer();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment