Good morning dear friends,
I have a question here in my code that is taking my sleep, if anyone can help.
Stopping at the next ...
On the screen of the system you need to be passing a message (s) (marquee type HTML) as a link for when the user clicks it to go to the page that is in the link.
These messages are registered by a specific user so I get these messages via query and transform into links (via PHP) and use a javascript to pass the messages on the screen and when there is more than one it passes one at a time. p>
The code is running and does the want, however it takes a while to mount the link (run the javascript), it runs the first time the message goes out like this ( Globe Test ) after a while, it assembles the right link that would be like the (Test Globe)
If someone can help, I appreciate it.
I'm using the Yii2 Framework. BD SQL SErver 2012.
I have the following code.
the php that brings up the DB search already separating the messages (which comes by a register) separating by, and ''. And it transforms the message into links to access the messages directly from that link by turning the page.
public static function getNoticias() {
$models = self::find()
->select('ds_alerta, nm_link, nm_imagem')
->where('st_ativo = 1')
->asArray()
->all();
$rec = [];
foreach ($models as $model) {
$imagem = '';
$conteudo = '';
if (empty($model['nm_link'])) {
$conteudo = $model['ds_alerta'];
} else {
$conteudo = '<a href="' . $model['nm_link'] . '">' . $model['ds_alerta'] . '</a>';
}
if (!empty($model['nm_imagem'])) {
$imagem = '<img src="' . $model['nm_imagem'] . '">';
}
$rec[] = $imagem . $conteudo;
}
return "'" . implode("','", $rec) . "'";
}
The Js code to run the messages one at a time. (it runs each message according to the angle it is in the php search.)
var alertMessages;
$ (function () {
$('.link-menu').click(function () {
$(this).find("span").toggleClass("glyphicon-chevron-down").toggleClass("glyphicon-chevron-right");
});
Util.urlCaminho = $('#pathCaminho').val();
$(function () {
$(".menu-lateral-body").mCustomScrollbar({
axis: "y",
theme: "minimal-dark"
});
});
$(document).ready(function () {
$('body').on('click', 'a.manual-download', function (event) {
event.preventDefault();
Util.ModalAlertExclusaoJson({
mensagem: "Clique aqui para obter o manual de utilização?",
url: $(this).attr('href')
});
});
var indice = 0;
var tamanho = alertaMensagens.length;
$(".marquee-text").text(alertaMensagens[indice]);
var marquee = $('div.marquee');
marquee.each(function () {
var mar = $(this), indent = mar.width();
mar.marquee = function () {
indent--;
mar.css('text-indent', indent);
if (indent < -1 * mar.children('div.marquee-text').width()) {
if ((indice + 1) > tamanho) {
indice = 0;
} else {
indice++;
}
indent = mar.width();
$(".marquee-text").html(alertaMensagens[indice]);
}
};
mar.data('interval', setInterval(mar.marquee, 10 / 6000000));
});
});
})
and my div marquee gets
alertMessages = []; to display the messages on the screen.