Author: Jorg Sowa (jorgsowa) Committer: Derick Rethans (derickr) Date: 2026-12-01T13:21:49Z
Commit: https://github.com/php/web-wiki/commit/2861366a251d57ef9d461923939b966ec0864091 Raw diff: https://github.com/php/web-wiki/commit/2861366a251d57ef9d461923939b966ec0864091.diff Replace doodle javascript: edit/delete links with data-attribute buttons Changed paths: M dokuwiki/lib/plugins/doodle/script.js M dokuwiki/lib/plugins/doodle/style.css M dokuwiki/lib/plugins/doodle/syntax.php Diff: diff --git a/dokuwiki/lib/plugins/doodle/script.js b/dokuwiki/lib/plugins/doodle/script.js index 56a20242..47c1a830 100644 --- a/dokuwiki/lib/plugins/doodle/script.js +++ b/dokuwiki/lib/plugins/doodle/script.js @@ -1,30 +1,17 @@ /** * JavsScript methods for the dokuwiki doodle plugin - * + * * @author Robert Rackl <[email protected]> * @date January 2011 */ -/** - * edit an entry - * @param formId Id of the form tag - * @param fullname name of the entry that should be edited - */ -function editEntry(formId, fullname) { - var doodleForm = document.getElementById(formId); - doodleForm.formId = formId; - doodleForm.edit__entry.value = fullname; - doodleForm.submit(); -} - -/** - * delete the given entry - * @param formId Id of the form tag - * @param fullname name of the entry that should be edited - */ -function deleteEntry(formId, fullname) { - var doodleForm = document.getElementById(formId); - doodleForm.formId = formId; - doodleForm.delete__entry.value = fullname; - doodleForm.submit(); -} \ No newline at end of file +document.addEventListener('click', function (event) { + var button = event.target.closest('button[data-doodle-action]'); + if (!button || !button.form) return; + + var field = button.form.elements.namedItem(button.dataset.doodleAction); + if (!field) return; + + field.value = button.dataset.doodleName; + button.form.submit(); +}); diff --git a/dokuwiki/lib/plugins/doodle/style.css b/dokuwiki/lib/plugins/doodle/style.css index 3301b3cd..1ed02bda 100644 --- a/dokuwiki/lib/plugins/doodle/style.css +++ b/dokuwiki/lib/plugins/doodle/style.css @@ -86,6 +86,12 @@ table.doodle__results .data_row:nth-child(even) { background-color: #E2E4EF; } -a.poll_action { - margin-right: 0 !important; +button.poll_action { + margin: 0 0 0 .3em !important; + padding: 0; + border: 0; + background: none; + color: __link__; + font: inherit; + cursor: pointer; } diff --git a/dokuwiki/lib/plugins/doodle/syntax.php b/dokuwiki/lib/plugins/doodle/syntax.php index da1f9450..6e3b7fb9 100755 --- a/dokuwiki/lib/plugins/doodle/syntax.php +++ b/dokuwiki/lib/plugins/doodle/syntax.php @@ -319,14 +319,16 @@ function render($mode, Doku_Renderer $renderer, $data) { if ($ACT == 'show' && $REV == false && $this->isAllowedToEditEntry($fullname)) { - // the javascript source of these functions is in script.js + // keys are stored hsc()-encoded; the server re-encodes the submitted name + $name = hsc(htmlspecialchars_decode($fullname, ENT_QUOTES | ENT_HTML401)); + // click handling is in script.js $this->template['doodleData']["$fullname"]['editLinks'] = - '<a class="poll_action" href="javascript:editEntry(\''.$formId.'\',\''.$fullname.'\')">'. - ' <b title="edit entry">✎</b>'. - '</a>'. - '<a class="poll_action" href="javascript:deleteEntry(\''.$formId.'\',\''.$fullname.'\')">'. - ' <b title="delete entry">🗑</b>'. - '</a>'; + '<button type="button" class="poll_action" data-doodle-action="edit__entry" data-doodle-name="'.$name.'" title="edit entry">'. + '<b>✎</b>'. + '</button>'. + '<button type="button" class="poll_action" data-doodle-action="delete__entry" data-doodle-name="'.$name.'" title="delete entry">'. + '<b>🗑</b>'. + '</button>'; } }
