i'm trying to blow up my pc, so i decided to make some practice alone.
i was able to extend the signupModal with a new field, and into that field i just want to generate e secure password.
i'm stucked here:
import { extend } from 'flarum/common/extend';
import SignUpModal from 'flarum/components/SignUpModal';
import Stream from 'flarum/common/utils/Stream';
function randomPassword(length) {
var chars = "abcdefghijklmnopqrstuvwxyz!@#$%^&*()-+<>ABCDEFGHIJKLMNOP1234567890";
var pass = "";
for (var x = 0; x < length; x++) {
var i = Math.floor(Math.random() * chars.length);
pass += chars.charAt(i);
}
return pass;
}
function generatePw() {
myform.row_password.value = randomPassword(myform.length.value);
}
app.initializers.add('justoverclock/flarum-ext-pwgen', () => {
extend(SignUpModal.prototype, 'oninit', function() {
this.confirmPassword = Stream('');
});
extend(SignUpModal.prototype, 'fields', function(items) {
items.add(
'justoverclockPWgen',
m('.Form-group', [
m('input.FormControl', {
name: 'row_password',
type: 'text',
id: '',
placeholder: app.translator.trans('qui sarΓ generata la password'),
})
]),
10
);
});
extend(SignUpModal.prototype, 'fields', function(items) {
items.add(
'genPW',
m('.Form-group', [
m("button", {
name: 'generate',
type: 'text',
value: 'generate',
onclick: "generatePw();"
})
]),
10
);
});
});
i think is a good result XD, but nothing work (obviously). can someone explain me better ways to do this? π