Support one click search in Editor
This commit is contained in:
parent
95f0a5f0f0
commit
1dd6dbcce2
|
@ -109,6 +109,64 @@ function textareaKeydown(target, event) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** Check whether the query will be executed with index
|
||||||
|
* @param HTMLFormElement
|
||||||
|
*/
|
||||||
|
function selectFieldChange(form) {
|
||||||
|
var ok = (function () {
|
||||||
|
var inputs = form.getElementsByTagName('input');
|
||||||
|
for (var i=0; i < inputs.length; i++) {
|
||||||
|
if (inputs[i].value && /^fulltext/.test(inputs[i].name)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var ok = form.limit.value;
|
||||||
|
var selects = form.getElementsByTagName('select');
|
||||||
|
var group = false;
|
||||||
|
var columns = {};
|
||||||
|
for (var i=0; i < selects.length; i++) {
|
||||||
|
var select = selects[i];
|
||||||
|
var col = selectValue(select);
|
||||||
|
var match = /^(where.+)col\]/.exec(select.name);
|
||||||
|
if (match) {
|
||||||
|
var op = selectValue(form[match[1] + 'op]']);
|
||||||
|
var val = form[match[1] + 'val]'].value;
|
||||||
|
if (col in indexColumns && (!/LIKE|REGEXP/.test(op) || (op == 'LIKE' && val.charAt(0) != '%'))) {
|
||||||
|
return true;
|
||||||
|
} else if (col || val) {
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((match = /^(columns.+)fun\]/.exec(select.name))) {
|
||||||
|
if (/^(avg|count|count distinct|group_concat|max|min|sum)$/.test(col)) {
|
||||||
|
group = true;
|
||||||
|
}
|
||||||
|
var val = selectValue(form[match[1] + 'col]']);
|
||||||
|
if (val) {
|
||||||
|
columns[col && col != 'count' ? '' : val] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (col && /^order/.test(select.name)) {
|
||||||
|
if (!(col in indexColumns)) {
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (group) {
|
||||||
|
for (var col in columns) {
|
||||||
|
if (!(col in indexColumns)) {
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
})();
|
||||||
|
setHtml('noindex', (ok ? '' : '!'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var added = '.', rowCount;
|
var added = '.', rowCount;
|
||||||
|
|
||||||
/** Check if val is equal to a-delimiter-b where delimiter is '_', '' or big letter
|
/** Check if val is equal to a-delimiter-b where delimiter is '_', '' or big letter
|
||||||
|
|
|
@ -220,62 +220,6 @@ function selectAddRow(field) {
|
||||||
field.parentNode.parentNode.appendChild(row);
|
field.parentNode.parentNode.appendChild(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Check whether the query will be executed with index
|
|
||||||
* @param HTMLFormElement
|
|
||||||
*/
|
|
||||||
function selectFieldChange(form) {
|
|
||||||
var ok = (function () {
|
|
||||||
var inputs = form.getElementsByTagName('input');
|
|
||||||
for (var i=0; i < inputs.length; i++) {
|
|
||||||
if (inputs[i].value && /^fulltext/.test(inputs[i].name)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var ok = form.limit.value;
|
|
||||||
var selects = form.getElementsByTagName('select');
|
|
||||||
var group = false;
|
|
||||||
var columns = {};
|
|
||||||
for (var i=0; i < selects.length; i++) {
|
|
||||||
var select = selects[i];
|
|
||||||
var col = selectValue(select);
|
|
||||||
var match = /^(where.+)col\]/.exec(select.name);
|
|
||||||
if (match) {
|
|
||||||
var op = selectValue(form[match[1] + 'op]']);
|
|
||||||
var val = form[match[1] + 'val]'].value;
|
|
||||||
if (col in indexColumns && (!/LIKE|REGEXP/.test(op) || (op == 'LIKE' && val.charAt(0) != '%'))) {
|
|
||||||
return true;
|
|
||||||
} else if (col || val) {
|
|
||||||
ok = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((match = /^(columns.+)fun\]/.exec(select.name))) {
|
|
||||||
if (/^(avg|count|count distinct|group_concat|max|min|sum)$/.test(col)) {
|
|
||||||
group = true;
|
|
||||||
}
|
|
||||||
var val = selectValue(form[match[1] + 'col]']);
|
|
||||||
if (val) {
|
|
||||||
columns[col && col != 'count' ? '' : val] = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (col && /^order/.test(select.name)) {
|
|
||||||
if (!(col in indexColumns)) {
|
|
||||||
ok = false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (group) {
|
|
||||||
for (var col in columns) {
|
|
||||||
if (!(col in indexColumns)) {
|
|
||||||
ok = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ok;
|
|
||||||
})();
|
|
||||||
setHtml('noindex', (ok ? '' : '!'));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Toggles column context menu
|
/** Toggles column context menu
|
||||||
|
@ -302,7 +246,7 @@ function selectSearch(name) {
|
||||||
var divs = el.getElementsByTagName('div');
|
var divs = el.getElementsByTagName('div');
|
||||||
for (var i=0; i < divs.length; i++) {
|
for (var i=0; i < divs.length; i++) {
|
||||||
var div = divs[i];
|
var div = divs[i];
|
||||||
if (selectValue(div.firstChild) == name) {
|
if (/select/i.test(div.firstChild.tagName) && selectValue(div.firstChild) == name) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,7 +193,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
|
||||||
|
|
||||||
function selectSearchPrint($where, $columns, $indexes) {
|
function selectSearchPrint($where, $columns, $indexes) {
|
||||||
$where = (array) $_GET["where"];
|
$where = (array) $_GET["where"];
|
||||||
echo '<fieldset><legend>' . lang('Search') . "</legend><div>\n";
|
echo '<fieldset id="fieldset-search"><legend>' . lang('Search') . "</legend><div>\n";
|
||||||
$keys = array();
|
$keys = array();
|
||||||
foreach ($where as $key => $val) {
|
foreach ($where as $key => $val) {
|
||||||
$keys[$val["col"]] = $key;
|
$keys[$val["col"]] = $key;
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
function bodyLoad(version) {
|
function bodyLoad(version) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function selectFieldChange(form) {
|
||||||
|
}
|
||||||
|
|
||||||
function whisperClick(event, field) {
|
function whisperClick(event, field) {
|
||||||
var el = event.target || event.srcElement;
|
var el = event.target || event.srcElement;
|
||||||
if (/^a$/i.test(el.tagName) && !(event.button || event.ctrlKey || event.shiftKey || event.altKey || event.metaKey)) {
|
if (/^a$/i.test(el.tagName) && !(event.button || event.ctrlKey || event.shiftKey || event.altKey || event.metaKey)) {
|
||||||
|
|
Loading…
Reference in a new issue