Skip to content

Instantly share code, notes, and snippets.

@dlgombert
Last active April 7, 2022 15:08
Show Gist options
  • Select an option

  • Save dlgombert/f46d500eb46bf795c63a62384f720f2e to your computer and use it in GitHub Desktop.

Select an option

Save dlgombert/f46d500eb46bf795c63a62384f720f2e to your computer and use it in GitHub Desktop.
[truancy tracker parent] Bookmarklet for Truancy tracker - on new referral parent add #bookmarklet
$f = (function (n) {
return $('.modal-body').find(`[name="${n}"]`);
});
$fa = (function (n) {
return $(`[name="${n}"]`);
});
function opened(){
$('.nav.nav-tabs').find('li:eq(1)').find('a').trigger('click');
populate();
}
if (typeof chance === "undefined") {
$.getScript('//cdnjs.cloudflare.com/ajax/libs/chance/1.1.8/chance.min.js').then(populate);
} else {
populate();
}
function populate() {
if ($('#addParent.modal:visible').length>0) {
var gender = ['female', 'male'][Math.round(Math.random())];
$f('firstname').val(chance.first({ gender: gender }));
$f('lastname').val(chance.last());
$f('phone_home').val(chance.phone({ formatted: false }));
$f('phone_work').val(chance.phone({ formatted: false }));
$f('phone_cell').val(chance.phone({ formatted: false }));
$f('email').val(chance.email());
$f('address1').val([3460, 3502, 3530, 3558, 3586, 3628, 3642][Math.round(Math.random() * 6)] + ' Warwick Dr');
$f('city').val('Rochester Hills');
$f('postal').val(48309);
$f('relationship').val(gender === 'female' ? 'mother' : 'father');
$f('state').val('MI');
$('.modal-footer:visible').find('button[type="submit"]').trigger('click');
} else {
$(document).one('shown.bs.modal', opened);
$fa('ethnicity_id').val(Math.max(1, Math.round(Math.random() * 5)));
$fa('grade').val(Math.round(Math.random() * 13));
$fa('gender').first().click();
$fa('addParent').trigger('click');
}
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment