Skip to content

Commit

Permalink
Merge pull request #161 from jonatasrs/fixs
Browse files Browse the repository at this point in the history
Correções - Versão 5.1
  • Loading branch information
jonatasrs authored Sep 30, 2022
2 parents 3a6863b + f9c1407 commit 6104846
Show file tree
Hide file tree
Showing 32 changed files with 506 additions and 502 deletions.
8 changes: 4 additions & 4 deletions cs_modules/anotacao_registrar/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* global ModuleInit, SavedOptions, AtualizarAnotacaoNaArvore */
/* global ModuleInit, AtualizarAnotacaoNaArvore */
const BaseName = 'anotacao_registrar'

if (ModuleInit(BaseName)) {
SavedOptions.CheckTypes.forEach(function (element) {
ModuleInit(BaseName).then((options) => {
options.CheckTypes.forEach(function (element) {
switch (element) {
case 'mostraranotacao':
AtualizarAnotacaoNaArvore(BaseName)
Expand All @@ -11,4 +11,4 @@ if (ModuleInit(BaseName)) {
break
}
}, this)
}
}).catch(e => console.log(e.message))
26 changes: 14 additions & 12 deletions cs_modules/arvore_visualizar/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
/* global SavedOptions, seiVersionCompare, novoDocumento */
/* global seiVersionCompare, novoDocumento */
const BaseName = 'arvore_visualizar'

SavedOptions.CheckTypes.forEach(function (element) {
switch (element) {
case 'atalhonovodoc':
if (seiVersionCompare('<', '4')) {
novoDocumento(BaseName)
}
break
default:
break
}
}, this)
ModuleInit(BaseName).then((options) => {
options.CheckTypes.forEach(function (element) {
switch (element) {
case 'atalhonovodoc':
if (seiVersionCompare('<', '4')) {
novoDocumento(BaseName)
}
break
default:
break
}
}, this)
}).catch(e => console.log(e.message))
8 changes: 4 additions & 4 deletions cs_modules/controle_unidade_gerar/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* global ModuleInit, SavedOptions, retirarSobrestamentoReabrirEmBloco, selecionarMultiplosProcessos */
/* global ModuleInit, retirarSobrestamentoReabrirEmBloco, selecionarMultiplosProcessos */
const BaseName = 'controle_unidade_gerar'

if (ModuleInit(BaseName, true)) {
SavedOptions.CheckTypes.forEach(function (element) {
ModuleInit(BaseName).then((options) => {
options.CheckTypes.forEach(function (element) {
switch (element) {
case 'retirarsobrestamentoreabrirembloco':
retirarSobrestamentoReabrirEmBloco(BaseName)
Expand All @@ -12,4 +12,4 @@ if (ModuleInit(BaseName, true)) {
}
}, this)
selecionarMultiplosProcessos(BaseName)
}
}).catch(e => console.log(e.message))
20 changes: 7 additions & 13 deletions cs_modules/core/end/getSeiVersion.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
/* global __mconsole, seiVersion */
/* global seiVersion, CompName */

/** Pega a versão atual do SEI */
function getSeiVersion (baseName) {
const mconsole = new __mconsole(baseName + '.getSeiVersion')
try {
const script = document.querySelectorAll('script[src^="js/sei.js?"]')[0]
if (!script) {
throw new Error(`versão não localizada: ${document.URL}`)
}
const version = script.getAttribute('src').match(/(?<=\?)([^=-]+)/g)[0]
const fixedVersion = fixVersionNumber(version)
mconsole.log(fixedVersion)
return fixedVersion
} catch (error) {
mconsole.error(error)
const script = document.querySelectorAll('script[src^="js/sei.js?"]')[0]
if (!script) {
return '0.0.0.0'
}
const version = script.getAttribute('src').match(/(?<=\?)([^=-]+)/g)[0]
const fixedVersion = fixVersionNumber(version)
console.log(`[${CompName} ${Date.now()}]${baseName}.getSeiVersion: ${fixedVersion}`)
return fixedVersion
}

function fixVersionNumber (version) {
Expand Down
25 changes: 11 additions & 14 deletions cs_modules/core/end/index.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
/* global ModuleInit, GetBaseUrl, redirecionarPagina, seiVersionCompare, theme */
/** Roda quando a o carregamento do html termina */
const ModNameEnd = 'core.d_end'

function mainModEnd () {
Init(ModNameEnd)
/** Pega a versão atual do SEI */
const seiVersion = getSeiVersion(ModNameEnd)

ModuleInit(ModNameEnd).then((options) => {
/** Redireciona para controle de processos */
if (window.location.href === GetBaseUrl()) {
redirecionarPagina(ModName_start)
redirecionarPagina(ModNameEnd)
}

if (SavedOptions.theme !== 'white') {
if (SavedOptions.theme === 'super-black' && seiVersionCompare('>=', '4')) {
theme(ModNameEnd, SavedOptions.theme)
} else if (SavedOptions.theme === 'black' && seiVersionCompare('<', '4')) {
theme(ModNameEnd, SavedOptions.theme)
if (options.theme !== 'white') {
if (options.theme === 'super-black' && seiVersionCompare('>=', '4')) {
theme(ModNameEnd, options.theme)
} else if (options.theme === 'black' && seiVersionCompare('<', '4')) {
theme(ModNameEnd, options.theme)
}
}
}

/** Pega a versão atual do SEI */
const seiVersion = getSeiVersion(ModNameEnd)

mainModEnd()
}).catch(e => console.log(e.message))
46 changes: 46 additions & 0 deletions cs_modules/core/end/moduleInit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/* eslint-disable no-global-assign */
/* global seiVersionCompare, CompName, SavedOptions */

async function ModuleInit (BaseName, PageReload = false) {
try {
const storageData = await getLocalStorage()
const defaultOptions = await loadDefaultOptions(storageData)

const ModName = CompName + '.' + BaseName
const IsModExec = $("head meta[name='" + ModName + "'").attr('value')

if (seiVersionCompare('<', '3')) {
throw new Error('SEI/SUPER não encontrado.')
}
if (IsModExec !== 'true') {
$('head').append("<meta name='" + ModName + "' value='true'>")
console.log('[' + CompName + ' ' + Date.now() + ']' + BaseName)
return defaultOptions
} else if (IsModExec === 'true' && PageReload) {
window.location.assign(window.location.href)
console.log('[' + CompName + ' ' + Date.now() + ']' + BaseName + 'Reload page')
throw new Error('Reload page')
} else {
throw new Error('Not init')
}
} catch (e) {
const message = `[${CompName} ${Date.now()}] ${BaseName} ${e.message}`
throw new Error(message)
}
}

async function loadDefaultOptions (storageData) {
SavedOptions = { ...SavedOptions, ...storageData }
return SavedOptions
}

function getLocalStorage (params = null) {
return new Promise((resolve, reject) => {
browser.storage.local.get(params, (storage) => {
if (browser.runtime.lastError) {
reject(browser.runtime.lastError)
}
resolve(storage)
})
})
}
1 change: 0 additions & 1 deletion cs_modules/core/end/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ function theme (BaseName, tema) {
'procedimento_paginar'
]

console.log(tema)
if (AplicarLinkCss()) {
if (tema === 'super-black') {
AdicionarLinkCss(document, 'seipp-theme', 'cs_modules/themes/super-black.css')
Expand Down
13 changes: 9 additions & 4 deletions cs_modules/core/idle/atalhoPublicacoesEletronicas.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// AtalhoPublicacoesEletronicas
function AtalhoPublicacoesEletronicas (BaseName) {
const mconsole = new __mconsole(BaseName + '.AtalhoPublicacoesEletronicas')
// atalhoPublicacoesEletronicas
function atalhoPublicacoesEletronicas (BaseName) {
const mconsole = new __mconsole(BaseName + '.atalhoPublicacoesEletronicas')

// Verifica se o link existe.
const url = 'publicacoes/controlador_publicacoes.php?acao=publicacao_pesquisar&id_orgao_publicacao=0'
const txtitle = 'Publicações Eletrônicas'
const linkStyle = seiVersionCompare('>', '4')
? 'align-self: center; border: none; color: var(--color-primary-default); font-size: .75rem;'
? getProps()
: $('#lnkAjuda').attr('style')
const containerClass = seiVersionCompare('>', '4') ? 'nav-item d-md-flex' : 'infraAcaoBarraSistema'

Expand All @@ -26,3 +26,8 @@ function AtalhoPublicacoesEletronicas (BaseName) {
)
}
}

function getProps () {
const style = getComputedStyle(document.querySelector('.power-off-btn'))
return `align-self: center; border: none; color: ${style.color}; font-size: ${style.fontSize};`
}
10 changes: 5 additions & 5 deletions cs_modules/core/idle/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
*******************************************************************************/
const ModName_idle = 'core.d_idle'

if (ModuleInit(ModName_idle)) {
ModuleInit(ModName_idle).then((options) => {
AdicionarIdentificadorSeipp(ModName_idle)
SavedOptions.CheckTypes.forEach(function (element) {
options.CheckTypes.forEach(function (element) {
switch (element) {
case 'chkbloco':
VerificarBlocoAssinatura(ModName_idle)
Expand All @@ -20,7 +20,7 @@ if (ModuleInit(ModName_idle)) {
PontoControleCores(ModName_idle)
break
case 'atalhopublicacoeseletronicas':
AtalhoPublicacoesEletronicas(ModName_idle)
atalhoPublicacoesEletronicas(ModName_idle)
break
case 'no_buttons':
noButtons(ModName_idle)
Expand All @@ -30,5 +30,5 @@ if (ModuleInit(ModName_idle)) {
}
}, this)

if (SavedOptions.InstallOrUpdate) IndicarConfiguracao(ModName_idle)
}
if (options.InstallOrUpdate) IndicarConfiguracao(ModName_idle)
}).catch(e => console.log(e.message))
67 changes: 34 additions & 33 deletions cs_modules/core/idle/menuSuspenso.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,48 @@
/*** MENU SUSPENSO ************************************************************/
function MenuSuspenso(BaseName) {
/* global __mconsole */
/** * MENU SUSPENSO ************************************************************/
function MenuSuspenso (BaseName) {
/** inicialização do módulo */
var mconsole = new __mconsole(BaseName + ".MenuSuspenso");
const mconsole = new __mconsole(BaseName + '.MenuSuspenso')

if ($("body").attr("onload").indexOf("infraMenuSistemaEsquema") != -1){
$("body").attr("onload", $("body").attr("onload") + "infraOcultarMenuSistemaEsquema();");
if ($('body').attr('onload').indexOf('infraMenuSistemaEsquema') !== -1) {
$('body').attr('onload', $('body').attr('onload') + 'infraOcultarMenuSistemaEsquema();')
}
if (!$("#main-menu").length) return;
$("#main-menu, #divInfraAreaTelaE").hide();
if (!$('#main-menu').length) return
$('#main-menu, #divInfraAreaTelaE').hide()

if ($("#lnkInfraMenuSistema").attr("title").indexOf("Ocultar") != -1) {
$("#divInfraAreaTelaD").width("99%");
if ($('#lnkInfraMenuSistema').attr('title').indexOf('Ocultar') !== -1) {
$('#divInfraAreaTelaD').width('99%')
}
/* Oculta o botao de exibir menu */
$("#lnkInfraMenuSistema").hide();
$("#divInfraAreaTelaE > div > p").hide();
$("#divInfraAreaTelaE > div > img").attr("title", $("#divInfraAreaTelaE > div > p").text());
$("#divInfraAreaTelaE > div > div").hide();
$('#lnkInfraMenuSistema').hide()
$('#divInfraAreaTelaE > div > p').hide()
$('#divInfraAreaTelaE > div > img').attr('title', $('#divInfraAreaTelaE > div > p').text())
$('#divInfraAreaTelaE > div > div').hide()

$("#divInfraAreaTelaE").css({
"position": "absolute",
"display": "block",
"width": "auto",
"background-color": "#d7d7d7"
});
$('#divInfraAreaTelaE').css({
position: 'absolute',
display: 'block',
width: 'auto',
'background-color': '#d7d7d7'
})

$("#divInfraAreaTelaE > div").css({ "border-bottom": "5px solid" }).hide();
$('#divInfraAreaTelaE > div').css({ 'border-bottom': '5px solid' }).hide()

$("#divInfraBarraSistemaE img").click(function (e) {
e.stopPropagation(); /* impede a propagação do evento click */
if ($("#main-menu").attr("style") != undefined) {
$("#main-menu").removeAttr("style");
$("#divInfraAreaTelaE").hide();
$('#divInfraBarraSistemaE img').click(function (e) {
e.stopPropagation() /* impede a propagação do evento click */
if ($('#main-menu').attr('style') !== undefined) {
$('#main-menu').removeAttr('style')
$('#divInfraAreaTelaE').hide()
}
$("#divInfraAreaTelaE").toggle("fast");
$("#divInfraAreaTelaE > div").show();
});
$('#divInfraAreaTelaE').toggle('fast')
$('#divInfraAreaTelaE > div').show()
})

$("#divInfraAreaTelaE").addClass("seipp-menu");
$("#main-menu ul").addClass("seipp-menu");
$("#divInfraAreaTelaE *").click(function (e) { e.stopPropagation(); })
$('#divInfraAreaTelaE').addClass('seipp-menu')
$('#main-menu ul').addClass('seipp-menu')
$('#divInfraAreaTelaE *').click(function (e) { e.stopPropagation() })
/* Oculta o menu ao clicar fora */
$('body').click(function () {
if (!$("#divInfraAreaTelaE").is(':hidden')) { $("#divInfraAreaTelaE").toggle("fast"); }
});
if (!$('#divInfraAreaTelaE').is(':hidden')) { $('#divInfraAreaTelaE').toggle('fast') }
})
}
27 changes: 14 additions & 13 deletions cs_modules/core/idle/pontoControleCores.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
function PontoControleCores(BaseName) {
/* global __mconsole, AdicionarLinkCss */
function PontoControleCores (BaseName) {
/** inicialização do módulo */
var mconsole = new __mconsole(BaseName + ".PontoControleCores");
var AplicarNestasPaginas = [
"procedimento_visualizar",
"procedimento_controlar"
];
const mconsole = new __mconsole(BaseName + '.PontoControleCores')
const AplicarNestasPaginas = [
'procedimento_visualizar',
'procedimento_controlar'
]

if (AplicarLinkCss()) {
mconsole.log(document.baseURI);
AdicionarLinkCss(document, "seipp-pontocores-anatel", "cs_modules/themes/PontoControleCores_Anatel.css");
mconsole.log(document.baseURI)
AdicionarLinkCss(document, 'seipp-pontocores-anatel', 'cs_modules/themes/PontoControleCores_Anatel.css')
}

function AplicarLinkCss() {
var Aplicar = false;
function AplicarLinkCss () {
let Aplicar = false
AplicarNestasPaginas.forEach(function (item) {
if (document.baseURI.indexOf("acao=" + item) != -1) { Aplicar = true; }
});
return Aplicar;
if (document.baseURI.indexOf('acao=' + item) !== -1) { Aplicar = true }
})
return Aplicar
}
}
33 changes: 0 additions & 33 deletions cs_modules/core/start/index.js

This file was deleted.

Loading

0 comments on commit 6104846

Please sign in to comment.