* @param string
* @param [string]
* @param [boolean]
+* @param [boolean]
* @return XMLHttpRequest or false in case of an error
*/
-function ajaxSend(url, data, popState) {
+function ajaxSend(url, data, popState, noscroll) {
if (!history.pushState) {
return false;
}
} else {
if (!popState) {
if (data || url != location.href) {
- history.pushState(data, '', url);
+ history.pushState(data, '', url); //! remember window position
}
+ }
+ if (!noscroll) {
scrollTo(0, 0);
}
setHtml('content', xmlhttp.responseText);
/** Send form by AJAX GET
* @param HTMLFormElement
* @param [string]
+* @param [boolean]
* @return XMLHttpRequest or false in case of an error
*/
-function ajaxForm(form, data) {
+function ajaxForm(form, data, noscroll) {
if (/&(database|scheme|create|view|sql|user|dump|call)=/.test(location.href) && !/\./.test(data)) { // . - type="image"
return false;
}
params.push(data);
}
if (form.method == 'post') {
- return ajaxSend((/\?/.test(form.action) ? form.action : location.href), params.join('&')); // ? - always part of Adminer URL
+ return ajaxSend((/\?/.test(form.action) ? form.action : location.href), params.join('&'), noscroll); // ? - always part of Adminer URL
}
- return ajaxSend((form.action || location.href).replace(/\?.*/, '') + '?' + params.join('&'));
+ return ajaxSend((form.action || location.href).replace(/\?.*/, '') + '?' + params.join('&'), noscroll);
}
return !(db == (match ? match[1] : '') && ns == (match2 ? match2[1] : '') && ajaxSend(el.href));
}
if (/^input$/i.test(el.tagName) && /image|submit/.test(el.type)) {
- return !ajaxForm(el.form, (el.name ? encodeURIComponent(el.name) + (el.type == 'image' ? '.x' : '') + '=1' : ''));
+ return !ajaxForm(el.form, (el.name ? encodeURIComponent(el.name) + (el.type == 'image' ? '.x' : '') + '=1' : ''), el.type == 'image');
}
return true;
}