Project

General

Profile

« Previous | Next » 

Revision c6505d41

Added by koszko over 1 year ago

update Google Forms fix

View differences:

src/google_forms.js
24 24
 */
25 25

  
26 26
var form = document.forms[0];
27

  
28
/* Fix form fields. */
27 29
for (let div of form.querySelectorAll('div[data-params]')) {
28 30
    var data = JSON.parse('[' + div.dataset.params.substring(4));
29 31
    var name = 'entry.' + data[0][4][0][0];
30
    var input = div.querySelector('input');
32
    var input = div.querySelector('input, textarea');
31 33

  
32 34
    if (!input) {
33 35
	console.error(`cannot enable input ${name}`, div);
34 36
	continue;
35 37
    }
36 38

  
37
    if (input.name === name + '_sentinel') { // Radio
38
	for (const input_div of div.querySelectorAll('.appsMaterialWizToggleRadiogroupEl')) {
39
    if (input.name === name + '_sentinel') {
40
	/* Handle radio buttons. */
41
	for (const input_div of div.querySelectorAll('[data-value]')) {
39 42
	    const new_radio = document.createElement('input');
40 43
	    new_radio.type = 'radio';
41 44
	    new_radio.name = name;
......
45 48
    } else {
46 49
	input.removeAttribute('disabled');
47 50
	input.name = name;
51

  
52
	/* Enlarge textareas and make them stand out from mere input fields. */
53
	if (input.tagName === "TEXTAREA") {
54
	    input.style.height = "8em";
55
	    input.style.overflowY = "scroll";
56
	}
48 57
    }
49 58
}
50 59

  
51
for (div of document.querySelectorAll('.quantumWizTextinputPaperinputPlaceholder'))
52
    div.remove();
60
/* Remove placeholders in text input fields and textareas. */
61
document.querySelectorAll('[jsname=LwH6nd]').forEach(n => n.remove());
53 62

  
63
/* Enable the form sumbission button (if any). */
64
for (const submit_but of document.querySelectorAll('[jsname=M2UYVd]'))
65
    submit_but.addEventListener("click", () => form.submit());
66

  
67
/* Enable the "next page" button (if any). */
54 68
function goToNext()
55 69
{
56 70
    var next = document.createElement('input');
......
61 75
    form.submit();
62 76
}
63 77

  
64
const submit_selector = ".freebirdFormviewerViewNavigationSubmitButton";
65
const next_selector = ".freebirdFormviewerViewNavigationNoSubmitButton";
66
for (const but_div of document.querySelectorAll(submit_selector))
67
    but_div.addEventListener("click", () => form.submit());
68

  
69
for (const but_div of document.querySelectorAll(next_selector))
70
    but_div.addEventListener("click", goToNext);
78
for (const next_but of document.querySelectorAll('[jsname=OCpkoe]'))
79
    next_but.addEventListener("click", goToNext);
71 80

  
72
// TODO: back, instate previous entries, fix form parts that still don't work
81
// TODO:
82
// * support "back" with instatiation of previous entries
83
// * find and fix form parts that still don't work (if any)

Also available in: Unified diff