0
Good morning dear friends,
I have a question here in my code that is taking my sleep, if anyone can help.
The stop to the next...
On the system screen you need to pass a (s) Mensagen(s) (HTML type Marquee) in the form of a link so that when the user clicks it is directed to the page that is on the link.
These messages are registered by a specific user so I take these messages via query and turn 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.
The code is running and do want, but it takes a while to assemble the link (run javascript), it runs the first time is the message comes out like this ( Globo Teste ) ai after a while mounts the right link that would be so the (Test Globe)
If anyone can help I appreciate.
I’m using the Yii2 Framework. BD SQL Server 2012.
I have the following code.
php that brings the BD search already separating the messages (that comes by a register) separating by , and ''. And turns the message into links to access messages directly from this link running on 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 comma that is jerada in php pessquisa.
var alertMensagens ;
$(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 Mom gets
alertMensagens = []; to show the Mensagen on the screen.
Thanks Mano, I’ll try here, but I can tell you that even though it’s just a message, it showcases the whole href and then assembles the link.
– Skaylle Barreto