1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-08 07:36:44 +02:00

Move inline event handlers to <script>

This commit is contained in:
Jakub Vrana
2018-01-13 09:34:01 +01:00
parent fc559a1cf6
commit d39a6e59c7
3 changed files with 23 additions and 6 deletions

View File

@@ -34,7 +34,16 @@ class AdminerSlugify {
}
$slug = $slugify[$field["field"]];
if ($slug !== null) {
return "<input value='" . h($value) . "' maxlength='$field[length]' size='40'$attrs onchange=\"var find = '$this->from'; var repl = '$this->to'; this.form['fields[$slug]'].value = this.value.toLowerCase().replace(new RegExp('[' + find + ']', 'g'), function (str) { return repl[find.indexOf(str)]; }).replace(/[^a-z0-9_]+/g, '-').replace(/^-|-\$/g, '').substr(0, $field[length]);\">";
return "<input value='" . h($value) . "' maxlength='$field[length]' size='40'$attrs>"
. script("qsl('input').onchange = function () {
var find = '$this->from';
var repl = '$this->to';
this.form['fields[$slug]'].value = this.value.toLowerCase()
.replace(new RegExp('[' + find + ']', 'g'), function (str) { return repl[find.indexOf(str)]; })
.replace(/[^a-z0-9_]+/g, '-')
.replace(/^-|-\$/g, '')
.substr(0, $field[length]);
};");
}
}
}