diff --git a/static/js/script.js b/static/js/script.js index 222a4383833572080993e040f2e20ce44ce8a848..4d69e5ef2eda2ca04d6270c5f288c0692c29c652 100644 --- a/static/js/script.js +++ b/static/js/script.js @@ -120,4 +120,14 @@ window.onload=function() { textarea.addEventListener("keydown", function(e){tab_func(e); delayed()}, false); resize_textarea(textarea)(); } + // confirm buttons + for (var element of document.querySelectorAll('[confirm]')) { + element.onclick = function(evt) { + var target = evt.target; + while (!target.hasAttribute("confirm")) { + target = target.parentElement; + } + return confirm(target.getAttribute("confirm")); + }; + } }; diff --git a/templates/documentation-configuration-todomails.html b/templates/documentation-configuration-todomails.html index c862393f16141f85e5d636c3645b4cbd4c881ddf..9a0aaa0b847a73a7e64045c686901f8540f1b0a7 100644 --- a/templates/documentation-configuration-todomails.html +++ b/templates/documentation-configuration-todomails.html @@ -26,12 +26,12 @@ <tr> <td>mmustermann</td> <td>mmustermann@domain.example</td> - <td><a href="#example_todomails_overview">Ändern</a>, <a href="#example_todomails_overview" onclick="return confirm('Bist du dir sicher, dass du die Todomailzuordnung mmustermann zu mmustermann@domain.example löschen willst?');">Löschen</a></td> + <td><a href="#example_todomails_overview">Ändern</a>, <a href="#example_todomails_overview" confirm="Bist du dir sicher, dass du die Todomailzuordnung mmustermann zu mmustermann@domain.example löschen willst?">Löschen</a></td> </tr> <tr> <td>kmusterfrau</td> <td>kmusterfrau@domain.example</td> - <td><a href="#example_todomails_overview">Ändern</a>, <a href="#example_todomails_overview" onclick="return confirm('Bist du dir sicher, dass du die Todomailzuordnung kmusterfrau zu kmusterfrau@domain.example löschen willst?');">Löschen</a></td> + <td><a href="#example_todomails_overview">Ändern</a>, <a href="#example_todomails_overview" confirm="Bist du dir sicher, dass du die Todomailzuordnung kmusterfrau zu kmusterfrau@domain.example löschen willst?">Löschen</a></td> </tr> </tbody> </table> diff --git a/templates/documentation-configuration-types.html b/templates/documentation-configuration-types.html index cf80ab4f7217eeeeaf388030b712e4eb9f823f30..2823ade39a9510a101f6cfb92932936a8793cdc2 100644 --- a/templates/documentation-configuration-types.html +++ b/templates/documentation-configuration-types.html @@ -295,7 +295,7 @@ <td>1 Tage</td> <td>Intern</td> <td>Es ist mal wieder soweit und unsere Sitzung soll mit der angegeben TO statt finden.</td> - <td><a href="#example_mails_overview">Ändern</a>, <a onclick="return confirm('Bist du dir sicher, dass du die Einladungsmail 1 Tage vor der Sitzung löschen willst?');" href="#example_mails_overview">Löschen</a></td> + <td><a href="#example_mails_overview">Ändern</a>, <a confirm="Bist du dir sicher, dass du die Einladungsmail 1 Tage vor der Sitzung löschen willst?" href="#example_mails_overview">Löschen</a></td> </tr> </tbody> </table> @@ -358,22 +358,22 @@ <tr> <td>Begrüßung, Beschluss der TO und Protokolle</td> <td>-100</td> - <td><a href="#example_tops_overview">Runter</a>, <a href="#example_tops_overview">Hoch</a>, <a href="#example_tops_overview">Ändern</a>, <a onclick="return confirm('Bist du dir sicher, dass du den Standard-TOP Begrüßung, Beschluss der TO und Protokolle löschen willst?');" href="#example_tops_overview">Löschen</a></td> + <td><a href="#example_tops_overview">Runter</a>, <a href="#example_tops_overview">Hoch</a>, <a href="#example_tops_overview">Ändern</a>, <a confirm="Bist du dir sicher, dass du den Standard-TOP Begrüßung, Beschluss der TO und Protokolle löschen willst?" href="#example_tops_overview">Löschen</a></td> </tr> <tr> <td>Bericht</td> <td>-90</td> - <td><a href="#example_tops_overview">Runter</a>, <a href="#example_tops_overview">Hoch</a>, <a href="#example_tops_overview">Ändern</a>, <a onclick="return confirm('Bist du dir sicher, dass du den Standard-TOP Bericht löschen willst?');" href="#example_tops_overview">Löschen</a></td> + <td><a href="#example_tops_overview">Runter</a>, <a href="#example_tops_overview">Hoch</a>, <a href="#example_tops_overview">Ändern</a>, <a confirm="Bist du dir sicher, dass du den Standard-TOP Bericht löschen willst?" href="#example_tops_overview">Löschen</a></td> </tr> <tr> <td>Todos</td> <td>-80</td> - <td><a href="#example_tops_overview">Runter</a>, <a href="#example_tops_overview">Hoch</a>, <a href="#example_tops_overview">Ändern</a>, <a onclick="return confirm('Bist du dir sicher, dass du den Standard-TOP Todos löschen willst?');" href="#example_tops_overview">Löschen</a></td> + <td><a href="#example_tops_overview">Runter</a>, <a href="#example_tops_overview">Hoch</a>, <a href="#example_tops_overview">Ändern</a>, <a confirm="Bist du dir sicher, dass du den Standard-TOP Todos löschen willst?" href="#example_tops_overview">Löschen</a></td> </tr> <tr> <td>Verschiedenes</td> <td>100</td> - <td><a href="#example_tops_overview">Runter</a>, <a href="#example_tops_overview">Hoch</a>, <a href="#example_tops_overview">Ändern</a>, <a onclick="return confirm('Bist du dir sicher, dass du den Standard-TOP Verschiedenes löschen willst?');" href="#example_tops_overview">Löschen</a></td> + <td><a href="#example_tops_overview">Runter</a>, <a href="#example_tops_overview">Hoch</a>, <a href="#example_tops_overview">Ändern</a>, <a confirm="Bist du dir sicher, dass du den Standard-TOP Verschiedenes löschen willst?" href="#example_tops_overview">Löschen</a></td> </tr> </tbody> </table> @@ -433,7 +433,7 @@ <td>Fachschaftsraum</td> <td>Nein</td> <td>Nein</td> - <td><a href="#example_meta_overview">Ändern</a>, <a onclick="return confirm('Bist du dir sicher, dass du das Metadatenfeld Ort löschen willst?');" href="#example_meta_overview">Löschen</a></td> + <td><a href="#example_meta_overview">Ändern</a>, <a confirm="Bist du dir sicher, dass du das Metadatenfeld Ort löschen willst?" href="#example_meta_overview">Löschen</a></td> </tr> <tr> <td>Anwesend</td> @@ -441,7 +441,7 @@ <td></td> <td>Nein</td> <td>Nein</td> - <td><a href="#example_meta_overview">Ändern</a>, <a onclick="return confirm('Bist du dir sicher, dass du das Metadatenfeld Anwesend löschen willst?');" href="#example_meta_overview">Löschen</a></td> + <td><a href="#example_meta_overview">Ändern</a>, <a confirm="Bist du dir sicher, dass du das Metadatenfeld Anwesend löschen willst?" href="#example_meta_overview">Löschen</a></td> </tr> <tr> <td>Protokoll</td> @@ -449,7 +449,7 @@ <td></td> <td>Nein</td> <td>Nein</td> - <td><a href="#example_meta_overview">Ändern</a>, <a onclick="return confirm('Bist du dir sicher, dass du das Metadatenfeld Protokoll löschen willst?');" href="#example_meta_overview">Löschen</a></td> + <td><a href="#example_meta_overview">Ändern</a>, <a confirm="Bist du dir sicher, dass du das Metadatenfeld Protokoll löschen willst?" href="#example_meta_overview">Löschen</a></td> </tr> </tbody> </table> @@ -514,7 +514,7 @@ <tbody> <tr> <td>finanzwirksam</td> - <td><a href="#example_decision_categories">Ändern</a>, <a href="#example_decision_categories" onclick="return confirm('Bist du dir sicher, dass du die Beschlusskategorie finanzwirksam löschen willst?');">Löschen</a></td> + <td><a href="#example_decision_categories">Ändern</a>, <a href="#example_decision_categories" confirm="Bist du dir sicher, dass du die Beschlusskategorie finanzwirksam löschen willst?">Löschen</a></td> </tr> </tbody> </table> diff --git a/templates/documentation-sessionmanagement-plan.html b/templates/documentation-sessionmanagement-plan.html index 78ec216935ce046afcb4f7cc25b0b76dab51360e..4ac9904a7991ff078cf2eecb9c743f2c1e8b41bc 100644 --- a/templates/documentation-sessionmanagement-plan.html +++ b/templates/documentation-sessionmanagement-plan.html @@ -198,11 +198,11 @@ {% endif %} <a class="btn btn-default" href="#example_update_protocoll">Editieren</a> {% if config.ETHERPAD_ACTIVE %} - <a class="btn btn-primary" href="#example_update_protocoll" onclick="return confirm('Bist du dir sicher, dass du das Template bereits in das Etherpad kopieren willst? Die Sitzung ist erst einigen Tagen.');">Etherpad</a> + <a class="btn btn-primary" href="#example_update_protocoll" confirm="Bist du dir sicher, dass du das Template bereits in das Etherpad kopieren willst? Die Sitzung ist erst einigen Tagen.">Etherpad</a> {% endif %} <a class="btn btn-default" href="#example_update_protocoll">Vorlage</a> {% if config.MAIL_ACTIVE %} - <a class="btn btn-default" href="#example_update_protocoll" onclick="return confirm('Bist du dir sicher, dass du manuell eine Einladung verschicken willst? Dies wird auch automatisch geschehen.');">Einladung versenden</a> + <a class="btn btn-default" href="#example_update_protocoll" confirm="Bist du dir sicher, dass du manuell eine Einladung verschicken willst? Dies wird auch automatisch geschehen.">Einladung versenden</a> {% endif %} <a class="btn btn-default" href="#example_update_protocoll">Typ</a> </div> @@ -275,7 +275,7 @@ <a href="#example_top_overview">Ändern</a> <a href="#example_top_overview">Runter</a> <a href="#example_top_overview">Hoch</a> - <a href="#example_top_overview" onclick="return confirm('Bist du dir sicher, dass du den TOP Änderungsbedarf löschen möchtest?');">Löschen</a> + <a href="#example_top_overview" confirm="Bist du dir sicher, dass du den TOP Änderungsbedarf löschen möchtest?">Löschen</a> </li> <li class="expansion-button" id="top-2271" title=""> Neutralität @@ -283,7 +283,7 @@ <a href="#example_top_overview">Ändern</a> <a href="#example_top_overview">Runter</a> <a href="#example_top_overview">Hoch</a> - <a href="#example_top_overview" onclick="return confirm('Bist du dir sicher, dass du den TOP Neutralität löschen möchtest?');">Löschen</a> + <a href="#example_top_overview" confirm="Bist du dir sicher, dass du den TOP Neutralität löschen möchtest?">Löschen</a> </li> <li class="defaulttop"> Verschiedenes diff --git a/templates/documentation-sessionmanagement-write.html b/templates/documentation-sessionmanagement-write.html index dcd781ecc652327080065597854e5a2f955fd7de..266bab70963bcefe4a53957e0c14309ef8b26661 100644 --- a/templates/documentation-sessionmanagement-write.html +++ b/templates/documentation-sessionmanagement-write.html @@ -39,11 +39,11 @@ {% endif %} <a class="btn btn-default" href="#example_create_protocoll">Editieren</a> {% if config.ETHERPAD_ACTIVE %} - <a class="btn btn-primary" href="#example_create_protocoll" onclick="return confirm('Bist du dir sicher, dass du das Template bereits in das Etherpad kopieren willst? Die Sitzung ist erst einigen Tagen.');">Etherpad</a> + <a class="btn btn-primary" href="#example_create_protocoll" confirm="Bist du dir sicher, dass du das Template bereits in das Etherpad kopieren willst? Die Sitzung ist erst einigen Tagen.">Etherpad</a> {% endif %} <a class="btn btn-default" href="#example_create_protocoll">Vorlage</a> {% if config.MAIL_ACTIVE %} - <a class="btn btn-default" href="#example_create_protocoll" onclick="return confirm('Bist du dir sicher, dass du manuell eine Einladung verschicken willst? Dies wird auch automatisch geschehen.');">Einladung versenden</a> + <a class="btn btn-default" href="#example_create_protocoll" confirm="Bist du dir sicher, dass du manuell eine Einladung verschicken willst? Dies wird auch automatisch geschehen.">Einladung versenden</a> {% endif %} <a class="btn btn-default" href="#example_create_protocoll">Typ</a> </div> @@ -99,10 +99,10 @@ <div class="btn-group"> <a class="btn btn-primary" href="#example_import_protocoll">Aus Etherpad</a> <a class="btn btn-default" href="#example_import_protocoll">Editieren</a> - <a class="btn btn-primary" href="#example_import_protocoll" onclick="return confirm('Bist du dir sicher, dass du das Template bereits in das Etherpad kopieren willst? Die Sitzung ist erst einigen Tagen.');">Etherpad</a> + <a class="btn btn-primary" href="#example_import_protocoll" confirm="Bist du dir sicher, dass du das Template bereits in das Etherpad kopieren willst? Die Sitzung ist erst einigen Tagen.">Etherpad</a> <a class="btn btn-default" href="#example_import_protocoll">Vorlage</a> {% if config.MAIL_ACTIVE %} - <a class="btn btn-default" href="#example_import_protocoll" onclick="return confirm('Bist du dir sicher, dass du manuell eine Einladung verschicken willst? Dies wird auch automatisch geschehen.');">Einladung versenden</a> + <a class="btn btn-default" href="#example_import_protocoll" confirm="Bist du dir sicher, dass du manuell eine Einladung verschicken willst? Dies wird auch automatisch geschehen.">Einladung versenden</a> {% endif %} <a class="btn btn-default" href="#example_import_protocoll">Typ</a> </div> @@ -146,7 +146,7 @@ <a class="btn btn-primary" href="#example_corect_protocoll">Quelltext</a> <a class="btn btn-success" href="#example_corect_protocoll">Editieren</a> {% if config.ETHERPAD_ACTIVE %} - <a class="btn btn-primary" href="#example_corect_protocoll" onclick="return confirm('Bist du dir sicher, dass du das Template bereits in das Etherpad kopieren willst? Die Sitzung ist erst einigen Tagen.');">Etherpad</a> + <a class="btn btn-primary" href="#example_corect_protocoll" confirm="Bist du dir sicher, dass du das Template bereits in das Etherpad kopieren willst? Die Sitzung ist erst einigen Tagen.">Etherpad</a> {% endif %} {% if config.MAIL_ACTIVE %} <a class="btn btn-default" href="#example_corect_protocoll">Intern versenden</a> @@ -181,7 +181,7 @@ <a class="btn btn-primary" href="#example_publish_protocoll">Quelltext</a> <a class="btn btn-success" href="#example_publish_protocoll">Editieren</a> {% if config.ETHERPAD_ACTIVE %} - <a class="btn btn-primary" href="#example_publish_protocoll" onclick="return confirm('Bist du dir sicher, dass du das Template bereits in das Etherpad kopieren willst? Die Sitzung ist erst einigen Tagen.');">Etherpad</a> + <a class="btn btn-primary" href="#example_publish_protocoll" confirm="Bist du dir sicher, dass du das Template bereits in das Etherpad kopieren willst? Die Sitzung ist erst einigen Tagen.">Etherpad</a> {% endif %} {% if config.MAIL_ACTIVE %} <a class="btn btn-default" href="#example_publish_protocoll">Intern versenden</a> @@ -231,11 +231,11 @@ {% endif %} <a class="btn btn-default" href="#example_internal_protocoll">Editieren</a> {% if config.ETHERPAD_ACTIVE %} - <a class="btn btn-primary" href="#example_internal_protocoll" onclick="return confirm('Bist du dir sicher, dass du das Template bereits in das Etherpad kopieren willst? Die Sitzung ist erst einigen Tagen.');">Etherpad</a> + <a class="btn btn-primary" href="#example_internal_protocoll" confirm="Bist du dir sicher, dass du das Template bereits in das Etherpad kopieren willst? Die Sitzung ist erst einigen Tagen.">Etherpad</a> {% endif %} <a class="btn btn-default" href="#example_internal_protocoll">Vorlage</a> {% if config.MAIL_ACTIVE %} - <a class="btn btn-default" href="#example_internal_protocoll" onclick="return confirm('Bist du dir sicher, dass du manuell eine Einladung verschicken willst? Dies wird auch automatisch geschehen.');">Einladung versenden</a> + <a class="btn btn-default" href="#example_internal_protocoll" confirm="Bist du dir sicher, dass du manuell eine Einladung verschicken willst? Dies wird auch automatisch geschehen.">Einladung versenden</a> {% endif %} <a class="btn btn-default" href="#example_internal_protocoll">Typ</a> </div> diff --git a/templates/protocol-show.html b/templates/protocol-show.html index 16188fca6cdc3d82d661d4244822ef98528a9b75..4885019054c4c8707a0d11346fd7f1778a3a2f45 100644 --- a/templates/protocol-show.html +++ b/templates/protocol-show.html @@ -26,13 +26,13 @@ {% endif %} {% if not protocol.public %} {% if config.ETHERPAD_ACTIVE %} - <a class="btn btn-primary" href="{{url_for("etherpush_protocol", protocol_id=protocol.id, csrf_token=get_csrf_token())}}"{% if large_time_diff %} onclick="return confirm('Bist du dir sicher, dass du das Template bereits in das Etherpad kopieren willst? Die Sitzung ist erst {% if time_diff.days != 1 %}in {{time_diff.days}} Tagen{% else %}morgen{% endif %}.');"{% endif %} target="_blank">Etherpad</a> + <a class="btn btn-primary" href="{{url_for("etherpush_protocol", protocol_id=protocol.id, csrf_token=get_csrf_token())}}"{% if large_time_diff %} confirm="Bist du dir sicher, dass du das Template bereits in das Etherpad kopieren willst? Die Sitzung ist erst {% if time_diff.days != 1 %}in {{time_diff.days}} Tagen{% else %}morgen{% endif %}."{% endif %} target="_blank">Etherpad</a> {% endif %} {% endif %} {% if not protocol.is_done() %} <a class="btn btn-default" href="{{url_for("get_protocol_template", protocol_id=protocol.id)}}">Vorlage</a> {% if config.MAIL_ACTIVE %} - <a class="btn btn-default" href="{{url_for("send_protocol_reminder", protocol_id=protocol.id, csrf_token=get_csrf_token())}}" onclick="return confirm('Bist du dir sicher, dass du manuell eine Einladung verschicken willst? Dies wird auch automatisch geschehen.');">Einladung versenden</a> + <a class="btn btn-default" href="{{url_for("send_protocol_reminder", protocol_id=protocol.id, csrf_token=get_csrf_token())}}" confirm="Bist du dir sicher, dass du manuell eine Einladung verschicken willst? Dies wird auch automatisch geschehen.">Einladung versenden</a> {% endif %} {% else %} {% if config.MAIL_ACTIVE %} @@ -51,7 +51,7 @@ {% endif %} {% if has_admin_right %} <a class="btn btn-default" href="{{url_for("recompile_protocol", protocol_id=protocol.id, csrf_token=get_csrf_token())}}">Neu kompilieren</a> - <a class="btn btn-danger" href="{{url_for("delete_protocol", protocol_id=protocol.id, csrf_token=get_csrf_token())}}" onclick="return confirm('Bist du dir sicher, dass du das Protokoll {{protocol.get_short_identifier()}} löschen möchtest?');">Löschen</a> + <a class="btn btn-danger" href="{{url_for("delete_protocol", protocol_id=protocol.id, csrf_token=get_csrf_token())}}" confirm="Bist du dir sicher, dass du das Protokoll {{protocol.get_short_identifier()}} löschen möchtest?">Löschen</a> {% endif %} {% endif %} </div> diff --git a/templates/protocol-tops-include.html b/templates/protocol-tops-include.html index b9c8a3c2156dcb87af0240a2dcdee1af02095ba1..74418a66c46f2b4f29e0dbe9786d5ec5c6f35a94 100644 --- a/templates/protocol-tops-include.html +++ b/templates/protocol-tops-include.html @@ -31,7 +31,7 @@ <a href="{{url_for('edit_top', top_id=top.id)}}">Ändern</a> <a href="{{url_for('move_top', top_id=top.id, diff=1, csrf_token=get_csrf_token())}}">Runter</a> <a href="{{url_for('move_top', top_id=top.id, diff=-1, csrf_token=get_csrf_token())}}">Hoch</a> - <a href="{{url_for('delete_top', top_id=top.id, csrf_token=get_csrf_token())}}" onclick="return confirm('Bist du dir sicher, dass du den TOP {{top.name}} löschen möchtest?');">Löschen</a> + <a href="{{url_for('delete_top', top_id=top.id, csrf_token=get_csrf_token())}}" confirm="Bist du dir sicher, dass du den TOP {{top.name}} löschen möchtest?">Löschen</a> {% endif %} {% if has_private_view_right and top.description is not none and top.description|length > 0 %} <span class="glyphicon glyphicon-info-sign"></span> diff --git a/views/tables.py b/views/tables.py index 9db9c096196a4a44bfa230bc4e05d2e4dcbef47d..d2efafa1eb241ce8a450c7311c5a33c0973c076f 100644 --- a/views/tables.py +++ b/views/tables.py @@ -26,8 +26,7 @@ class Table: "href=\"{}\"".format(target) ] if confirm: - attributes.append( - "onclick=\"return confirm('{}');\"".format(confirm)) + attributes.append(f"confirm=\"{confirm}\"") if css_class: attributes.append("class=\"{}\"".format(css_class)) return Markup("<a {}>{}</a>".format(" ".join(attributes), text)) @@ -47,6 +46,7 @@ class Table: return Table.link( target=target, text=Table.glyphicon(icon), + confirm=confirm, css_class="btn btn-{}".format(style)) @staticmethod @@ -149,7 +149,7 @@ class ProtocolsTable(Table): csrf_token=get_csrf_token()), icon="trash", style="danger", - confirm="Bist du dir sicher, dass du das Protokoll {} " + confirm=f"Bist du dir sicher, dass du das Protokoll {protocol.get_title()} " "löschen möchtest?")) result.append(Table.button_group(buttons))