PageSourceSearch

https://intranet.sinte-sc.org.br/js/site.js?v=xRNg_3S_PMfgTjE3e5LPMLCYJd41cfarqv_ecpiODGI

js sinte-sc.org.br collected 2026-09-29 09:03:50 UTC 19,006 bytes, 559 lines download raw bytes

1// Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
2// for details on configuring this project to bundle and minify static web assets.
3
4// Write your JavaScript code.
5
6const KEY_DATA = 'authData';
7const KEY_CPF_ACAO = 'cpfAcao';
8
9const isMobileDevice = () => {
10    return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
11}
12
13const handlerHttpError = (error) => {
14    try { $.unblockUI(); } catch { }
15
16    let msg = "";
17    if (!error.response) {
18        msg = "Houve um erro inesperado. Tente novamente mais tarde.";
19    } else {
20        console.log(error.response);
21        const status = error.response.status;
22        switch (status) {
23            case 400:
24                console.log('Erro 400');
25                msg = error.response.data.erro;
26                break;
27            case 404:
28                console.log('Erro 404');
29                msg = error.response.data.erro;
30                break;
31            case 422:
32                console.log('Erro 422');
33                msg = error.response.data.erro
34                break;
35            case 401:
36                console.log('Erro 401');
37                msg =
38                    "Você não tem permissão para acessar esse recurso. Efetue o login novamente";
39                break;
40            case 500:
41                console.log('Erro 500');
42                msg = error.response.data
43                    ? error.response.data.erro
44                    : "Houve um erro inesperado ao tentar comunicar-se com o servidor. Tente novamente mais tarde.";
45                break;
46            default:
47                console.log('Erro default');
48                msg = "Houve um erro inesperado. Tente novamente mais tarde.";
49        }
50    }
51
52    return msg === "" ? "Houve um erro inesperado. Tente novamente mais tarde." : msg;
53}
54
55const getUser = () => {
56    const data = window.localStorage.getItem(KEY_DATA);
57    return !data || data === "null" ? null : JSON.parse(data).Usuario;
58}
59
60const usuarioEstaAutenticado = () => {
61    var userData = window.localStorage.getItem(KEY_DATA);
62
63    if (userData && userData !== "null")
64        userData = JSON.parse(userData);
65    else
66        userData = null;
67
68    var estaAutenticado = userData != null
69        && userData.Usuario != null
70        && userData.Usuario !== undefined
71        && userData.Token !== ""
72        && userData.Token !== null
73        && userData.Token !== undefined
74        && (!userData.Expiration || new Date(userData.Expiration) > new Date(Date.now()));
75
76    if (estaAutenticado)
77        return true;
78
79    window.localStorage.setItem(KEY_DATA, null);
80    setTimeout(() => window.location.href = "/login", 100);
81    return false;
82}
83
84const formatDate = (date) => {
85    if (!date) {
86        return "";
87    }
88
89    return moment(date).format('DD/MM/YYYY');
90}
91
92const formatDateTime = (date) => {
93    if (!date) {
94        return "";
95    }
96
97    return moment(date).format('DD/MM/YYYY [às] HH:mm:ss');
98}
99
100const formataData = (date) => {
101    if (!date) {
102        return "";
103    }
104
105    const [newDate] = date.split("T");
106
107    if (newDate.length > 0) {
108        const [newDate] = date.split("T");
109        const [year, month, day] = newDate.split("-");
110        return `${day}/${month}/${year}`;
111    }
112
113    const [year, month, day] = date.split("-");
114    return `${day}/${month}/${year}`;
115}
116
117const getToken = () => {
118    const data = JSON.parse(window.localStorage.getItem(KEY_DATA));
119
120    return !data ? "" : data.Token;
121}
122
123const getPessoaAtendimento = () => {
124    const data = window.localStorage.getItem('pessoaAtendimento');
125    if (!data) {
126        return null
127    }
128    return JSON.parse(data);
129}
130
131const getInfoAcao = () => {
132    const data = window.localStorage.getItem('infoAcao');
133    if (!data) {
134        return null
135    }
136    return JSON.parse(data);
137}
138
139const getHeaders = () => {
140    return {
141        'Authorization': 'Bearer ' + getToken(),
142        'Content-Type': 'application/json',
143        'hash': _hc
144    };
145}
146
147const getHeadersFile = () => {
148    return {
149        'Authorization': 'Bearer ' + getToken(),
150        'hash': _hc,
151        'Content-Type': 'multipart/form-data'
152    };
153}
154
155const getHash = () => {
156    return {
157        'Content-Type': 'application/json',
158        'hash': _hc
159    };
160}
161
162const getCpfAcao = () => {
163    return window.localStorage.getItem(KEY_CPF_ACAO);
164}
165
166const setCpfAcao = (payload) => {
167    window.localStorage.setItem(KEY_CPF_ACAO, payload);
168}
169
170const maskBRL = (value) => {
171    const newValue = formatTextMoney(value).split("R$")[1];
172    return newValue.trim();
173};
174
175const formatTextMoney = (value) => {
176    return Intl.NumberFormat("pt-BR", {
177        style: "currency",
178        currency: "BRL",
179    }).format(value);
180};
181
182const removerMascara = (doc) => {
183    return doc.replace(/[^0-9]+/g, "");
184}
185
186const obterNumeroPorExtenso = (c) => {
187    const ex = [
188        ["zero", "um", "dois", "três", "quatro", "cinco", "seis", "sete", "oito", "nove", "dez", "onze", "doze", "treze", "quatorze", "quinze", "dezesseis", "dezessete", "dezoito", "dezenove"],
189        ["dez", "vinte", "trinta", "quarenta", "cinquenta", "sessenta", "setenta", "oitenta", "noventa"],
190        ["cem", "cento", "duzentos", "trezentos", "quatrocentos", "quinhentos", "seiscentos", "setecentos", "oitocentos", "novecentos"],
191        ["mil", "milhão", "bilhão", "trilhão", "quadrilhão", "quintilhão", "sextilhão", "setilhão", "octilhão", "nonilhão", "decilhão", "undecilhão", "dodecilhão", "tredecilhão", "quatrodecilhão", "quindecilhão", "sedecilhão", "septendecilhão", "octencilhão", "nonencilhão"]
192    ];
193    var a, n, v, i, n = c.replace(c ? /[^,\d]/g : /\D/g, "").split(","), e = " e ", $ = "real", d = "centavo", sl;
194    for (var f = n.length - 1, l, j = -1, r = [], s = [], t = ""; ++j <= f; s = []) {
195        j && (n[j] = (("." + n[j]) * 1).toFixed(2).slice(2));
196        if (!(a = (v = n[j]).slice((l = v.length) % 3).match(/\d{3}/g), v = l % 3 ? [v.slice(0, l % 3)] : [], v = a ? v.concat(a) : v).length) continue;
197        for (a = -1, l = v.length; ++a < l; t = "") {
198            if (!(i = v[a] * 1)) continue;
199            i % 100 < 20 && (t += ex[0][i % 100]) ||
200                i % 100 + 1 && (t += ex[1][(i % 100 / 10 >> 0) - 1] + (i % 10 ? e + ex[0][i % 10] : ""));
201            s.push((i < 100 ? t : !(i % 100) ? ex[2][i == 100 ? 0 : i / 100 >> 0] : (ex[2][i / 100 >> 0] + e + t)) +
202                ((t = l - a - 2) > -1 ? " " + (i > 1 && t > 0 ? ex[3][t].replace("ão", "ões") : ex[3][t]) : ""));
203        }
204        a = ((sl = s.length) > 1 ? (a = s.pop(), s.join(" ") + e + a) : s.join("") || ((!j && (n[j + 1] * 1 > 0) || r.length) ? "" : ex[0][0]));
205        a && r.push(a + (c ? (" " + (v.join("") * 1 > 1 ? j ? d + "s" : (/0{6,}$/.test(n[0]) ? "de " : "") + $.replace("l", "is") : j ? d : $)) : ""));
206    }
207    return r.join(e).toUpperCase();
208}
209
210const validaCPF = (cpf) => {
211    cpf = cpf.replace('.', '');
212    cpf = cpf.replace('.', '');
213    cpf = cpf.replace('-', '');
214
215    erro = "";
216
217    if (cpf.length < 11) erro += "Sao necessarios 11 digitos para";
218
219    var nonNumbers = /\D/;
220    if (nonNumbers.test(cpf)) erro += "A verificacao de CPF suporta";
221
222    if (cpf == "00000000000" || cpf == "11111111111" ||
223        cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" ||
224        cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" ||
225        cpf == "88888888888" || cpf == "99999999999") {
226        erro += "Numero de CPF invalido!";
227    }
228
229    var a = [];
230    var b = new Number;
231    var c = 11;
232
233    for (i = 0; i < 11; i++) {
234        a[i] = cpf.charAt(i);
235        if (i < 9) b += (a[i] * --c);
236    }
237
238    if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11 - x }
239    b = 0;
240    c = 11;
241
242    for (y = 0; y < 10; y++) b += (a[y] * c--);
243
244    if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11 - x; }
245    status = a[9] + "" + a[10]
246
247    if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10])) {
248        erro += "Digito verificador com problema!";
249    }
250
251    if (erro.length > 0) {
252        return false;
253    }
254
255    return true;
256}
257
258const formataCPF = (cpf) => {
259    //retira os caracteres indesejados...
260    cpf = cpf.replace(/[^\d]/g, "");
261
262    //realizar a formatação...
263    return cpf.replace(/(\d{3})(\d{3})(\d{3})(\d{2})/, "$1.$2.$3-$4");
264}
265
266
267const validaCNPJ = (cnpj) => {
268    cnpj = cnpj.replace(/[^\d]+/g, '');
269
270    if (cnpj == '') return false;
271
272    if (cnpj.length != 14)
273        return false;
274
275    if (cnpj == "00000000000000" ||
276        cnpj == "11111111111111" ||
277        cnpj == "22222222222222" ||
278        cnpj == "33333333333333" ||
279        cnpj == "44444444444444" ||
280        cnpj == "55555555555555" ||
281        cnpj == "66666666666666" ||
282        cnpj == "77777777777777" ||
283        cnpj == "88888888888888" ||
284        cnpj == "99999999999999")
285        return false;
286
287    tamanho = cnpj.length - 2
288    numeros = cnpj.substring(0, tamanho);
289    digitos = cnpj.substring(tamanho);
290    soma = 0;
291    pos = tamanho - 7;
292    for (i = tamanho; i >= 1; i--) {
293        soma += numeros.charAt(tamanho - i) * pos--;
294        if (pos < 2)
295            pos = 9;
296    }
297    resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
298    if (resultado != digitos.charAt(0))
299        return false;
300
301    tamanho = tamanho + 1;
302    numeros = cnpj.substring(0, tamanho);
303    soma = 0;
304    pos = tamanho - 7;
305    for (i = tamanho; i >= 1; i--) {
306        soma += numeros.charAt(tamanho - i) * pos--;
307        if (pos < 2)
308            pos = 9;
309    }
310    resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
311    if (resultado != digitos.charAt(1))
312        return false;
313
314    return true;
315}
316
317const formataCNPJ = (cnpj) => {
318    cnpj = cnpj.replace(/[^\d]/g, "");
319
320    return cnpj.replace(/^(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})/, "$1.$2.$3/$4-$5");
321}
322
323const validForm = (form) => {
324    var valid = true;
325    $.each($(`#${form} input,textarea,select`).filter('[required]:visible'), function (index, value) {
326        if (!$(value).val()) {
327            valid = false;
328        }
329    });
330
331    return valid;
332}
333
334const somenteNumeros = (e) => {
335    if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
336        return false;
337    }
338}
339
340const somenteNumerosEX = (e) => {
341    if (e.which != 8 && e.which != 0 &&
342        (e.which < 48 || e.which > 57) &&
343        e.which != 88 && e.which != 120) {
344        return false;
345    }
346    return true;
347}
348
349const extrairSomenteNumeros = (valor) => {
350    return valor.replaceAll(/[^a-zA-Z0-9]+/g, "");
351}
352
353const verificaSeEstaPreenchido = (valor) => {
354    return valor != undefined && valor != null && valor != "";
355}
356
357function FormataSerializeArrayParaDataPost(formArray) {
358    var returnArray = {};
359    for (var i = 0; i < formArray.length; i++) {
360        returnArray[formArray[i]['name']] = formArray[i]['value'];
361    }
362    return returnArray;
363}
364
365const obterUrlApi = () => {
366    if (window.location.href.indexOf("localhost") > 0)
367        return "https://apisunlit.prod.dohms.com.br";
368
369    if (window.location.href.indexOf(".dev.") > 0)
370        return "https://apisunlit.dohms.com.br";
371
372    if (window.location.href.indexOf(".homolog.") > 0)
373        return "https://apisunlit.homolog.dohms.com.br";
374
375    return "https://apisunlit.prod.dohms.com.br";
376}
377
378const obertUrlSimasit2 = () => {
379    return "https://simasit2.dohms.com.br";
380}
381
382const validarMatriculaAtualizacaoCadastralAreaRestrita = function (matricula) {
383    let erros = [];
384
385    if (!verificaSeEstaPreenchido(matricula.regionalId) || matricula.regionalId == "null")
386        erros.push("Obrigatório informar a regional. <br/>");
387
388    if (!verificaSeEstaPreenchido(matricula.localTrabalhoId) || matricula.localTrabalhoId == "null")
389        erros.push("Obrigatório informar o local de trabalho. <br/>");
390
391    if (!verificaSeEstaPreenchido(matricula.cargoValorId) || matricula.cargoValorId == "null")
392        erros.push("Obrigatório informar o cargo. <br/>");
393
394    if (erros.length > 0)
395        return { valido: false, erros: erros };
396
397    return { valido: true };
398}
399
400const validarMatriculasCadastroAreaRestrita = function (matricula) {
401    let erros = [];
402
403    if (!verificaSeEstaPreenchido(matricula.numero))
404        erros.push("Obrigatório informar o número. <br/>");
405
406    if (!verificaSeEstaPreenchido(matricula.vinculoValorId) || matricula.vinculoValorId == "null")
407        erros.push("Obrigatório informar o vínculo. <br/>");
408
409    if (!verificaSeEstaPreenchido(matricula.regionalId) || matricula.regionalId == "null")
410        erros.push("Obrigatório informar a regional. <br/>");
411
412    if (!verificaSeEstaPreenchido(matricula.localTrabalhoId) || matricula.localTrabalhoId == "null")
413        erros.push("Obrigatório informar o local de trabalho. <br/>");
414
415    if (!verificaSeEstaPreenchido(matricula.cargoValorId) || matricula.cargoValorId == "null")
416        erros.push("Obrigatório informar o cargo. <br/>");
417
418    if (erros.length > 0)
419        return { valido: false, erros: erros };
420
421    return { valido: true };
422}
423
424const validarDadosPessoaisCadastroAreaRestrita = function (dadosPessoais) {
425    let erros = [];
426
427    if (!verificaSeEstaPreenchido(dadosPessoais.dataNascimento))
428        erros.push("Obrigatório informar a data de nascimento. <br/>");
429
430    if (!verificaSeEstaPreenchido(dadosPessoais.nacionalidade))
431        erros.push("Obrigatório informar a nacionalidade. <br/>");
432
433    if (!verificaSeEstaPreenchido(dadosPessoais.email))
434        erros.push("Obrigatório informar o e-mail. <br/>");
435
436    if (!verificaSeEstaPreenchido(dadosPessoais.celular))
437        erros.push("Obrigatório informar o celular. <br/>");
438
439    if (!verificaSeEstaPreenchido(dadosPessoais.sexo) || dadosPessoais.sexo == "null")
440        erros.push("Obrigatório informar o sexo. <br/>");
441
442    if (!verificaSeEstaPreenchido(dadosPessoais.estadoCivilValorId) || dadosPessoais.estadoCivilValorId == "null")
443        erros.push("Obrigatório informar o estado civil. <br/>");
444
445    if (!verificaSeEstaPreenchido(dadosPessoais.cep))
446        erros.push("Obrigatório informar o cep. <br/>");
447
448    if (!verificaSeEstaPreenchido(dadosPessoais.endereco))
449        erros.push("Obrigatório informar o logradouro. <br/>");
450
451    if (!verificaSeEstaPreenchido(dadosPessoais.bairro))
452        erros.push("Obrigatório informar o bairro. <br/>");
453
454    if (!verificaSeEstaPreenchido(dadosPessoais.numero))
455        erros.push("Obrigatório informar o número. <br/>");
456
457    if (!verificaSeEstaPreenchido(dadosPessoais.estado) || dadosPessoais.estado == "null")
458        erros.push("Obrigatório informar o estado. <br/>");
459
460    if (!verificaSeEstaPreenchido(dadosPessoais.cidade))
461        erros.push("Obrigatório informar a cidade. <br/>");
462
463    if (erros.length > 0)
464        return { valido: false, erros: erros };
465
466    return { valido: true };
467}
468
469const validarDocumentosCadastroAreaRestrita = function (documentos) {
470    let erros = [];
471
472    var documentoContraCheque = documentos.filter(d => d.descricao.indexOf("Contra Cheque") > -1)[0];
473
474    if (!verificaSeEstaPreenchido(documentoContraCheque.nomeArquivo))
475        erros.push("Obrigatório informar o Contra Cheque. <br/>");
476
477    var documentoCNH = documentos.filter(d => d.descricao.indexOf("CNH") > -1)[0];
478    var documentoCPF = documentos.filter(d => d.descricao.indexOf("CPF") > -1)[0];
479    var documentoRG = documentos.filter(d => d.descricao.indexOf("RG") > -1)[0];
480
481    if (!verificaSeEstaPreenchido(documentoCNH.nomeArquivo) && !verificaSeEstaPreenchido(documentoCPF.nomeArquivo) && !verificaSeEstaPreenchido(documentoRG.nomeArquivo))
482        erros.push("Obrigatório informar a CNH ou CPF e RG. <br/>");
483    else if (!verificaSeEstaPreenchido(documentoCNH.nomeArquivo) && (!verificaSeEstaPreenchido(documentoCPF.nomeArquivo) || !verificaSe
483EstaPreenchido(documentoRG.nomeArquivo)))
484        erros.push("Obrigatório informar o CPF e RG. <br/>");
485
486    if (erros.length > 0)
487        return { valido: false, erros: erros };
488
489    return { valido: true };
490}
491
492
493const validarDocumentosCadastroAreaRestritaFiliese = function (documentos) {
494    let erros = [];
495
496    console.log(documentos);
497
498    var documentoContraCheque = documentos.filter(d => d.descricao.indexOf("Ficha de Filiação") > -1)[0];
499
500    if (!verificaSeEstaPreenchido(documentoContraCheque.nomeArquivo))
501        erros.push("Obrigatório informar a Ficha de Filiação. <br/>");
502
503    if (erros.length > 0)
504        return { valido: false, erros: erros };
505
506    return { valido: true };
507}
508
509const validarDadosPessoaisAtualizacaoCadastralAreaRestrita = function (dadosPessoais) {
510    let erros = [];
511
512    if (!verificaSeEstaPreenchido(dadosPessoais.dataNascimento))
513        erros.push("Obrigatório informar a data de nascimento. <br/>");
514
515    if (!verificaSeEstaPreenchido(dadosPessoais.nacionalidade))
516        erros.push("Obrigatório informar a nacionalidade. <br/>");
517
518    if (!verificaSeEstaPreenchido(dadosPessoais.email))
519        erros.push("Obrigatório informar o e-mail. <br/>");
520
521    if (!verificaSeEstaPreenchido(dadosPessoais.celular))
522        erros.push("Obrigatório informar o celular. <br/>");
523
524    if (!verificaSeEstaPreenchido(dadosPessoais.sexo) || dadosPessoais.sexo == "null")
525        erros.push("Obrigatório informar o sexo. <br/>");
526
527    if (!verificaSeEstaPreenchido(dadosPessoais.estadoCivilValorId) || dadosPessoais.estadoCivilValorId == "null")
528        erros.push("Obrigatório informar o estado civil. <br/>");
529
530    if (!verificaSeEstaPreenchido(dadosPessoais.cep))
531        erros.push("Obrigatório informar o cep. <br/>");
532
533    if (!verificaSeEstaPreenchido(dadosPessoais.endereco))
534        erros.push("Obrigatório informar o logradouro. <br/>");
535
536    if (!verificaSeEstaPreenchido(dadosPessoais.bairro))
537        erros.push("Obrigatório informar o bairro. <br/>");
538
539    if (!verificaSeEstaPreenchido(dadosPessoais.numero))
540        erros.push("Obrigatório informar o número. <br/>");
541
542    if (!verificaSeEstaPreenchido(dadosPessoais.estado) || dadosPessoais.estado == "null")
543        erros.push("Obrigatório informar o estado. <br/>");
544
545    if (!verificaSeEstaPreenchido(dadosPessoais.cidade))
546        erros.push("Obrigatório informar a cidade. <br/>");
547
548    if (erros.length > 0)
549        return { valido: false, erros: erros };
550
551    return { valido: true };
552}
553
554const validarTermoChecado = function (termoChecado) {
555    if (termoChecado)
556        return { valido: true };
557
558    return { valido: false, erro: "Obrigatório concordar com os termos" };
559}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.