我的代码如下所示:
CREATE TRIGGER `audit_events_nice`
AFTER UPDATE ON `accounts`
FOR EACH ROW
BEGIN
DECLARE changes VARCHAR(8000);
DECLARE N INT DEFAULT 1;
FOREACH OLD, NEW as OldValue, NewValue
BEGIN
IF OldValue <> NewValue THEN
SET changes = CONCAT(changes, ', column N: % to %');
SET N = N + 1;
END IF;
CALL reg_event(how_canI_get_tableName?, @user_id, changes);
-- now I can paste this code in every table that is audited..
END;
我希望每隔5000秒显示不同的通知,例如:TestA,TestB,Test3。我尝试过这样的事情:
$(document).ready(function() {
var callnotification = function() {
$.sticky('<b>TestA</b>');
}
setInterval(callnotification, 5000);
});
但它似乎成倍增加。我认为这是因为函数互相循环,它显示如下通知: 测试A. 测试B. 测试B. 测试B. 测试C. 测试B. 测试A. 等。
那么..我怎么能循环呢?假设我想从测试A循环到测试M并再次从测试A循环到测试M.
答案 0 :(得分:1)
试试这个:
$(document).ready(function() {
var callnotification = function() {
var counter = 65;
$.sticky('<b>Test' + String.fromCharCode(counter++) + '</b>');
}
setInterval(callnotification, 5000);
});
从M重新循环到A:
$(document).ready(function() {
var callnotification = function() {
var counter = 65;
$.sticky('<b>Test' + String.fromCharCode(counter++) + '</b>');
if (counter == 78) {counter = 65};
}
setInterval(callnotification, 5000);
});
答案 1 :(得分:0)
试试这个:
var i = 0;
var letters = ['A', 'B', 'C'];
var callnotification = function(msg) {
$.sticky('<b>'+msg+'</b>');
}
var t = setInterval(function(){
callnotification('Test'+letters[i%letters.length]);
i++;
},5000);
答案 2 :(得分:0)
在我看来,Sticky js是一个很差的库。
以下是您的案例的几个示例,看看哪一个适合您:
$(function() {
var charCode = 65;
setInterval(function() {
var notification = window.createNotification();
var msg = 'Test ' + String.fromCharCode(charCode++);
notification.addMsg({
text: msg, type: 'alert'
});
notification.render(null, function(notif) {
// example 1
notif.destroy(5000);
/* example 2
notif.destroy(5000, function() {
var newNotif = window.createNotification();
newNotif.addMsg({
text: '(' + msg + ' is closed)',
type: 'info'
});
newNotif.render();
});
*/
/* example 3
var newNotif = window.createNotification();
newNotif.addMsg({text:'('+msg+' is closed)', type:'info'});
newNotif.render(5000);
*/
});
(charCode == 78) && (charCode = 65);
}, 1000);
});