Skip to content

Instantly share code, notes, and snippets.

@CEBracco
Last active November 30, 2023 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CEBracco/60653d3c98e84f4799a1584f78804f81 to your computer and use it in GitHub Desktop.
Save CEBracco/60653d3c98e84f4799a1584f78804f81 to your computer and use it in GitHub Desktop.
Userscript que agrega interfaz a FunctionsUtil, agregando botones en la ventana de edicion de funciones de un usuario
// ==UserScript==
// @name FunctionUtilUI
// @namespace http://tampermonkey.net/
// @version 1.2
// @updateURL https://gist.github.com/CEBracco/60653d3c98e84f4799a1584f78804f81/raw/7cd221fcc0a70862d7f59879ee19909010f4f71e/FunctionUtilUI.user.js
// @description Agrega interfaz a FunctionsUtil
// @author cbracco
// @match *://*.movypark.com
// @match *://*.dat.cespi.unlp.edu.ar
// @match http://163.10.20.80/universe-web/
// @match *://*.gob.ar
// @match *://*.gov.ar
// @match https://semlamatanza.com.ar
// @match https://sem.estacionamientojunin.com.ar/
// @match *://*.parxin.com.py/
// @grant none
// @require http://code.jquery.com/jquery-3.3.1.min.js
// @require https://gist.githubusercontent.com/CEBracco/3840b85d881d4a536eaa0c9641dcdec9/raw/waitForKeyElements.js
// ==/UserScript==
(function() {
'use strict';
/**
*
* Userscript que agrega interfaz a FunctionsUtil, agregando botones en la ventana de edicion de funciones de un usuario
*
*/
function addShowFunctionsButton() {
$('#functionButtons').prepend('<button class="btn btn-primary" id="btn_showFunctions">Todas las funciones</button>');
$('#btn_showFunctions').click(function(){
$('#functionSearch').val('aa|');
$('#functionSearch').change();
$('#btn_copyFunctions').show();
$(this).hide();
});
}
function addCopyFunctionsButton() {
$('#functionButtons').prepend('<button class="btn btn-warning collapse" id="btn_copyFunctions">Copiar Funciones</button>');
$('#btn_copyFunctions').click(function(){
window.copiedFunctions = functionUtils.obtainKeys();
window.copiedFunctionsUser = window.currentUserFunctions;
$('#btn_replaceFunctions').show();
$('#btn_checkFunctions').show();
$(this).hide();
functionAlert(window.copiedFunctions.keys.length +' funciones copiadas (Usuario ' + window.copiedFunctionsUser + ')');
});
}
function addReplaceFunctionsButton() {
$('#functionButtons').prepend('<button class="btn btn-success collapse" id="btn_replaceFunctions">Reemplazar con funciones copiadas</button>');
$('#btn_replaceFunctions').click(function(){
if(window.copiedFunctions){
functionUtils.replaceFunctions(window.copiedFunctions);
alert("Se reemplazaron las funciones copiadas, presione 'Modificar' para guardar los cambios");
}
});
}
function addCheckFunctionsButton() {
$('#functionButtons').prepend('<button class="btn btn-success collapse" id="btn_checkFunctions">Agregar funciones copiadas</button>');
$('#btn_checkFunctions').click(function(){
if(window.copiedFunctions){
functionUtils.checkFunctions(window.copiedFunctions);
alert("Se agregaron las funciones copiadas, presione 'Modificar' para guardar los cambios");
}
});
}
function addCleanButton() {
$('#functionButtons').prepend('<button class="btn btn-default" id="btn_cleanFunctionProcess">Limpiar</button>');
$('#btn_cleanFunctionProcess').click(function(){
window.copiedFunctions = null;
window.copiedFunctionsUser = null;
functionAlert('');
$('#btn_showFunctions').show();
$('#btn_copyFunctions').hide();
$('#btn_replaceFunctions').hide();
$('#btn_checkFunctions').hide();
});
}
function addButtons(){
addCleanButton();
addReplaceFunctionsButton();
addCheckFunctionsButton();
addCopyFunctionsButton();
addShowFunctionsButton();
}
function init(){
$('#editFunctions').find('form').prepend("<div id='functionButtons' class='col-sm-12 text-right'><p id='functionAlert' style='margin-top:10px;'></p><hr></div>");
addGetUserLogic();
addButtons();
}
function functionAlert(msg){
$('#functionAlert').text(msg);
}
function addGetUserLogic(){
$(".table[id!='functionsTable']").click(function(e){
if($(e.target).hasClass('glyphicon-edit operation')){
window.currentUserFunctions = $(e.target).closest('tr').find('td:first').text();
}
})
}
waitForKeyElements ("#editFunctions", init);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment