Last active
March 31, 2017 01:17
-
-
Save dhaupin/980d10bce526f2913e994d512eae3bcd to your computer and use it in GitHub Desktop.
Vtiger - VTExperts Notification JS Cleaner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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