DEVELOPMENT ENVIRONMENT

~liljamo/tixe

ref: demo tixe/static/demo.js -rw-r--r-- 1.1 KiB
b283bb02Jonni Liljamo feat: demo patches 1 year, 1 month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const formsToTrack = [
    { "submit_id": "settings_submit_displayname", "form_id": "settings_form_displayname", "event": "settings-update-displayname" },
    { "submit_id": "linkedit_submit_delete", "form_id": "linkedit_form_delete", "event": "linkedit-delete" },
    { "submit_id": "linkedit_submit_visual", "form_id": "linkedit_form_visual", "event": "linkedit-update-visual" },
    { "submit_id": "linkedit_submit_link", "form_id": "linkedit_form_link", "event": "linkedit-update-link" },
    { "submit_id": "tags_submit_delete", "form_id": "tags_form_delete", "event": "tags-delete" },
    { "submit_id": "tags_submit_new", "form_id": "tags_form_new", "event": "tags-new" },
    { "submit_id": "index_submit_link_new", "form_id": "index_form_link_new", "event": "index-link-new" },
];

for (var i = 0; i < formsToTrack.length; i++) {
    const obj = formsToTrack[i];
    const submit = document.getElementById(obj.submit_id);

    if (submit == null) {
        continue;
    }

    submit.setAttribute("type", "button");
    submit.setAttribute("onclick", `umami.track('${obj.event}').then(function() {document.getElementById('${obj.form_id}').submit()})`)
}