Skip to content

Instantly share code, notes, and snippets.

@fazen
Last active January 13, 2017 23:55
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 fazen/00b9a30719953f96d240 to your computer and use it in GitHub Desktop.
Save fazen/00b9a30719953f96d240 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Inserimento su Lapis
// @namespace palestralupo
// @include http://www.lapisnet.it/index.php?s=pagina&k=segnala-un-evento-suoni-visioni
// @version 1.2
// @grant none
// ==/UserScript==
// Anonymous "self-invoking" function
(function() {
// Load the script
var script = document.createElement("SCRIPT");
script.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js';
script.type = 'text/javascript';
document.getElementsByTagName("head")[0].appendChild(script);
// Poll for jQuery to come into existance
var checkReady = function(callback) {
if (window.jQuery) {
callback(jQuery);
}
else {
window.setTimeout(function() { checkReady(callback); }, 100);
}
};
// Start polling...
checkReady(function($) {
$("input[name=prezzo]").val("Ingresso libero con sottoscrizione volontaria");
$("input[name=luogo]").val("Palestra LUPo");
$("input[name=indirizzo]").val("Piazza Pietro Lupo, 25");
$("input[name=email]").val("info@palestralupo.it");
$("input[name=telefono]").val("339****");
$("select[name=id_comune]").val("3");
$("input[name=acconsento]").attr("checked", "checked");
var codice = prompt("Se vuoi caricare i dati di una attività, inserisci il codice.").trim().toUpperCase();
if (codice && codice.match(/^A?\d{3}$/)) {
if (codice.indexOf("A") != 0) {
codice = "A" + codice;
}
$.getJSON("http://www.palestralupo.it/lupo/static/attivita.json",function(result){
var att = result[codice];
$("input[name=titolo]").val(att.nome);
var quando = att.tempo.match(/(\d+)\/(\d+)\/(\d+)/);
$("input[name=dal_dd]").val(quando[1]);
$("input[name=dal_mm]").val(quando[2]);
$("input[name=dal_yy]").val(quando[3]);
$("input[name=al_dd]").val(quando[1]);
$("input[name=al_mm]").val(quando[2]);
$("input[name=al_yy]").val(quando[3]);
$("textarea[name=corpo]").val(att.descrizione);
});
}
else {
alert("Codice invalido o non trovato");
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment