PageSourceSearch

https://www.trt9.jus.br/portal/javax.faces.resource/formatacaoNume…vI427W.portal-deploy-585b566749-hm8lz?ln=js

js trt9.jus.br collected 2026-10-02 10:46:36 UTC 4,811 bytes, 148 lines download raw bytes

1/**
2 * 
3 */
4function SomenteNumeros(e) {
5    if (window.event){ // IE
6        var keyCode = window.event.keyCode;
7    }else{
8        var keyCode = e.which;
9    }
10
11    if (e.ctrlKey || (keyCode >= 0 && keyCode <= 31) || (keyCode >= 48 && keyCode <= 57) || (keyCode == 8 || keyCode == 127)) {
12        return true;
13    } else {
14        if (window.event){ // IE
15            window.event.returnValue = false;
16        }else{
17            e.preventDefault();
18        }
19    }
20}
21
22
23//seletor - seletor geral, colocado em todos os campos de entrada
24//seletorFirst - seletor do primeiro campo, onde ocorre o comando colar
25//tipo - TRT ou CNJ
26function AtribuirEventosEEfeitos(seletor, seletorFirst, tipo) {
27    // Permite que o usuário digite somente números nos campos de processo
28    $(seletor).on('keypress', function (e) {
29        SomenteNumeros(e);
30    });
31
32    //auto tabulação dos campos. Como os dois grupos não ficam visíveis em uma só tela, podemos usar as duas classes ao mesmo tempo
33    $(seletor).on('input', function (e) {
34        AvancoAutomaticoTabulacao(this, seletor);
35    });
36    $(seletor).on('keydown', function (e) {
37        RetornoAutomaticoBackspace(this, seletor, e);
38    });
39
40	if(tipo == 'CNJ'){
41        // Permite que o usuário cole um número de processo
42        //numero no formato CNJ - 1234567-12.2017.5.09.1234
43        $(seletorFirst).on('paste', function (e) {
44            ColarNumeroProcesso(this, e, seletor, 13, 3);
45        });
46	}else if(tipo == 'TRT'){
47        //numero no formato do TRT - 12345.2017.123.09.12.1
48        $(seletorFirst).on('paste', function (e) {
49            ColarNumeroProcesso(this, e, seletor, 12, 2);
50        });
51	}else if(tipo == 'CNJ_GERAL'){
52        //numero no formato CNJ - 0120600-86.2007.5.17.0008
53        $(seletorFirst).on('paste', function (e) {
54            ColarNumeroProcesso(this, e, seletor, 0, 0);
55        });
56	}
57	
58
59}
60function AvancoAutomaticoTabulacao(controle, selector) {
61	if (controle.value.length < $(controle).attr('maxlength')) {
62        return false;
63    }
64    var input = $(controle).nextAll(selector);
65    if (input.first() != null) {
66        input.first().focus();
67    }
68    return false;
69}
70
71function RetornoAutomaticoBackspace(controle, selector, evento) {
72    if (window.event) // IE
73        var keyCode = window.event.keyCode;
74    else
75        var keyCode = evento.which;
76    if (keyCode == 8) { // Backspace
77        if (controle.value.length == 0) {
78            var input = $(controle).prevAll(selector);
79            if (input.first() != null) {
80                input.first().focus();
81            }
82        }
83    }
84}
85
86function ColarNumeroProcesso(controle, evento, selector, posicaoInicialIgnorada, quantidadeIgnorada) {
87    var clipboardData;
88    var pastedData;
89    var IE = false;
90
91    if (evento.originalEvent.clipboardData == null) { // IE
92        clipboardData = window.clipboardData;
93        IE = true;
94    } else {
95        clipboardData = evento.originalEvent.clipboardData;
96    }
97
98    pastedData = clipboardData.getData('text');
99
100    // Pegar só os números do texto copiado
101    var numeroCompleto = ObterDigitos(pastedData);
102    numeroCompleto = numeroCompleto.substring(0, posicaoInicialIgnorada) +
103                     numeroCompleto.substring(posicaoInicialIgnorada + quantidadeIgnorada, numeroCompleto.length);
104
105    ColarNumeroProcessoAux(controle, selector, numeroCompleto, 0);
106
107    if (IE) {
108        event.returnValue = false;
109    } else {
110        evento.preventDefault();
111    }
112}
113
114function ColarNumeroProcessoAux(controle, selector, numeroColado, posicaoInicial) {
115    var tamanhoMaximoControle = parseInt($(controle).attr('maxlength'));
116    //alert($(controle).attr('id') + posicaoInicial + tamanhoMaximoControle);
117
118    if (numeroColado.length <= posicaoInicial) {
119        return;
120    }
121    if (numeroColado.length < posicaoInicial + tamanhoMaximoControle) {
122        $(controle).val(numeroColado.substr(posicaoInicial, numeroColado.length - posicaoInicial))
123        return;
124    }
125    $(controle).val(numeroColado.substr(posicaoInicial, tamanhoMaximoControle));
126    var proximoControle = $(controle).nextAll(selector).first();
127    if (proximoControle != null) {
128        ColarNumeroProcessoAux(proximoControle, selector, numeroColado, posicaoInicial + tamanhoMaximoControle);
129    }
130}
131
132function ObterDigitos(string) {
133    var digitos = "";
134
135    //pegar só os números do texto copiado
136    var getNum = string.match(/(\d+)/g);
137
138    for (i = 0; i < getNum.length; i++) {
139        digitos = digitos + getNum[i];
140    }
141
142    return digitos;
143}
144
145function padLeftZeros(str, max) {
146    str = str.toString();
147    return str.length < max ? padLeftZeros("0" + str, max) : str;
148}

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.