mirror of
https://github.com/vrana/adminer.git
synced 2025-08-12 09:34:10 +02:00
Edit, clone and delete by AJAX
This commit is contained in:
@@ -380,10 +380,10 @@ if (!$columns) {
|
||||
if (!information_schema(DB)) {
|
||||
?>
|
||||
<fieldset><legend><?php echo lang('Edit'); ?></legend><div>
|
||||
<input type="submit" id="save" value="<?php echo lang('Save'); ?>" title="<?php echo lang('Double click on a value to modify it.'); ?>" onclick='return !ajaxForm(this.form);'>
|
||||
<input type="submit" name="edit" value="<?php echo lang('Edit'); ?>">
|
||||
<input type="submit" name="clone" value="<?php echo lang('Clone'); ?>">
|
||||
<input type="submit" name="delete" value="<?php echo lang('Delete'); ?>" onclick="return confirm('<?php echo lang('Are you sure?'); ?> (' + (this.form['all'].checked ? <?php echo $found_rows; ?> : formChecked(this, /check/)) + ')');">
|
||||
<input type="submit" id="save" value="<?php echo lang('Save'); ?>" title="<?php echo lang('Double click on a value to modify it.'); ?>" onclick="return !ajaxForm(this.form);">
|
||||
<input type="submit" name="edit" value="<?php echo lang('Edit'); ?>" onclick="return !ajaxForm(this.form, 'edit=1');">
|
||||
<input type="submit" name="clone" value="<?php echo lang('Clone'); ?>" onclick="return !ajaxForm(this.form, 'clone=1');">
|
||||
<input type="submit" name="delete" value="<?php echo lang('Delete'); ?>" onclick="return confirm('<?php echo lang('Are you sure?'); ?> (' + (this.form['all'].checked ? <?php echo $found_rows; ?> : formChecked(this, /check/)) + ')') && !ajaxForm(this.form, 'delete=1');">
|
||||
</div></fieldset>
|
||||
<?php
|
||||
}
|
||||
|
@@ -168,7 +168,7 @@ var ajaxTimeout;
|
||||
|
||||
/** Create AJAX request
|
||||
* @param string
|
||||
* @param string
|
||||
* @param [string]
|
||||
* @return XMLHttpRequest or false in case of an error
|
||||
*/
|
||||
function ajax(url, data) {
|
||||
@@ -202,9 +202,10 @@ function ajax(url, data) {
|
||||
|
||||
/** Send form by AJAX GET
|
||||
* @param HTMLFormElement
|
||||
* @param [string]
|
||||
* @return XMLHttpRequest or false in case of an error
|
||||
*/
|
||||
function ajaxForm(form) {
|
||||
function ajaxForm(form, data) {
|
||||
var params = [ ];
|
||||
for (var i=0; i < form.elements.length; i++) {
|
||||
var el = form.elements[i];
|
||||
@@ -212,6 +213,9 @@ function ajaxForm(form) {
|
||||
params.push(encodeURIComponent(el.name) + '=' + encodeURIComponent(/select/i.test(el.tagName) ? selectValue(el) : el.value));
|
||||
}
|
||||
}
|
||||
if (data) {
|
||||
params.push(data);
|
||||
}
|
||||
if (form.method == 'post') {
|
||||
return ajax(form.action || location.href, params.join('&'));
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user