// ===================== PREENCHER COM COOKIES ===================== $(window).on('load', function () { function getCookie(name) { var value = '; ' + document.cookie; var parts = value.split('; ' + name + '='); if (parts.length === 2) return decodeURIComponent(parts.pop().split(';').shift()); } var strVatnumber = getCookie("strVatnumber"); var strEmail = getCookie("strEmail"); var strContactName = getCookie("strContactName"); var strMobileNumber = getCookie("strMobileNumber"); var strPlatformLabel = getCookie("strPlatformLabel"); if (strEmail) document.getElementById("ticketEmail").value = strEmail; if (strVatnumber) document.getElementById("ticketTaxNumber").value = strVatnumber; if (strContactName) document.getElementById("ticketName").value = strContactName; if (strMobileNumber) document.getElementById("ticketPhone").value = strMobileNumber; // Última plataforma usada (por texto, porque inSales e inSales WEB têm o mesmo valor) if (strPlatformLabel) { $('#ticketPlatform option').each(function () { if ($(this).val() && $.trim($(this).text()) === strPlatformLabel) { $(this).prop('selected', true); $('#ticketPlatform').trigger('change'); return false; } }); } var conhecido = mostrarResumoCliente(); // Cursor no primeiro campo por preencher (só no computador, para não abrir o teclado no telemóvel) if (window.innerWidth >= 992) { if (conhecido) { if (!$('#ticketPlatform').val()) { $('#ticketPlatform').focus(); } else { var editor = tinymce.get('ticketMessage'); if (editor) editor.focus(); } } else { $('#ticketTaxNumber, #ticketName, #ticketPhone, #ticketEmail').filter(function () { return $.trim(this.value) === ''; }).first().focus(); } } });