Disable phpMyAdmin's Overriding of Ctrl+Arrow Keys - user-interface

In phpMyAdmin, using the Control key in conjunction with the arrows keys (such as ctrl+right, ctrl+left, ctrl+shift+right, and ctrl+shift+left) causes the cursor to move to another cell.
This behavior can be extremely annoying if one instinctively uses these key combinations to move between and/or select words in a text.
Older versions of phpMyAdmin, had a configuration setting, $cfg['CtrlArrowsMoving']=false, that would disable it, but that setting is no longer supported and there doesn't seem to be a way to disable it through the settings or configuration anymore.
The Alt key does exactly the same thing when you're editing a table, and the tab key allows you to move from one cell to another as you would expect, so there's no reason for the ctrl key to be used this way unless the user actually wants to.
I love phpMyAdmin, but after years of instinctively pressing ctrl+shift+left to select a word only to remember it doesn't work, I decided to search the code and figure out how to disable it.
I'm using phpMyAdmin version 5.0.2 and don't know if other versions use the same code for this, but hopefully they're similar enough that this information will help people modify the behavior if they want to.

There are two different functions that control this behavior.
The function that controls the behavior when you're editing a table is in the PHPMyAdmin directory under /js/makegrid.js
function handleCtrlNavigation (e) {
if ((e.ctrlKey && e.which === 38) || (e.altKey && e.which === 38)) {
g.moveUp(e);
} else if ((e.ctrlKey && e.which === 40) || (e.altKey && e.which === 40)) {
g.moveDown(e);
} else if ((e.ctrlKey && e.which === 37) || (e.altKey && e.which === 37))
g.moveLeft(e);
} else if ((e.ctrlKey && e.which === 39) || (e.altKey && e.which === 39)) {
g.moveRight(e);
}
}
Just remove the parts that refer to the ctrl key, or replace the entire function with this:
function handleCtrlNavigation (e) {
if ((e.altKey && e.which === 38)) {
g.moveUp(e);
} else if ((e.altKey && e.which === 40)) {
g.moveDown(e);
} else if ((e.altKey && e.which === 37)) {
g.moveLeft(e);
} else if ((e.altKey && e.which === 39)) {
g.moveRight(e);
}
}
This will preserve the alt-key functionality. If you don't care about that you can also just add a return statement after the function declaration:
function handleCtrlNavigation (e) {
return;
((e.ctrlKey && e.which === 38) || (e.altKey && e.which === 38)) {...
The function that controls the behavior in other areas (like when you're inserting a new entry) is in the file /js/keyhandler.js under the function onKeyDownArrowsHandler, which is described as "Allows moving around inputs/select by Ctrl+arrows". Here, you can just put a return statement at the top of the function to bypass it:
function onKeyDownArrowsHandler (event) {
return;

Related

Cypress - How to use if statement with contains

so I have to use cy.contains to find the element I want, but all I can find online is how to use if() with cy.find or cy.get if there a way to do this with contains?
Example code:
if(cy.contains('div.name', 'Test 1').length > 0) {
//Type in name
cy.get('input.newName').click().type('Test 1');
cy.wait(2000);
//Click Add Name
cy.get('div.createNewName> a').click();
cy.wait(2000);
}
What I am trying to do there is:
if(Name doesnt exist){
Create it
}
I'm not sure if I have explained myself too well, if any more clarifications are needed feel free to ask
You can also do like this:
cy.get('body').then(($body) => {
if ($body.find('div.name:contains("Test 1")').length > 0) {
//Element Found
} else {
//Element not found
}
})
The general pattern for this would be as follows:
const element = Cypress.$('div.name:contains(Test 1)')
if (element.length > 0) {
...
Make sure the DOM is stable when you run this code, there is no retry built in as there is with cy.contains()
If the code inside if() is creating the name, then maybe the logic would be
const element = Cypress.$('div.name:contains(Test 1)')
if (element.length === 0) {
// not found so create it
...
You can also do it like this
cy.get('div.name').then($div => {
const found = $div.find(':contains("Test 1")')
if (found.length === 0) {
// create...
}
})

Filter a value in all properties with Laravel

This question is very similar to Laravel filter a value in all columns. Sorry, if it turns out as a duplicate later on, but I have another working code to provide.
What does work is filtering on the client side via JavaScript:
filterfunction : function(entry, filter)
{
if(filter != null)
filter.trim().split(' ').forEach(function(item){
if(!this.eachRecursive(entry, item))
return false;
});
return true;
},
eachRecursive: function(obj, localfilter) {
for(const key in obj) {
if (!obj.hasOwnProperty(key))
continue;
if(typeof obj[key] == "object" && obj[key] !== null){
if(this.eachRecursive(obj[key], localfilter))
return true;
}
else
if((obj[key] + "").toLowerCase().indexOf(localfilter.toLowerCase()) != -1)
return true;
}
return false;
},
The filter function is used as the filter function for the Bootstrap-Vue table component like described in custom-filter-function.
The question is now: how to achieve similar functionality in the Laravel-Backend (for using with Livewire)?
I can imagine, that listing all columns via getColumnListing, mentioned in Laravel filter a value in all columns is possible, but this wouldn't suffice, I still need the relations, like in laravel mysql query with multiple where orwhere and inner join.
Currently, I'm trying out to convert the Eloquent object to JSON and then to parse it, as it includes all the loaded relations eloquent-serialization. But this seems like the last resort and a kind of misuse of serialization.
For now I'm going to use the route over converting to json. However, I found a way to not to parse json by regular expressions. Instead, I convert the jsonified collection back to php objects. With them I'm able to reimplement the functions from above:
private function eachRecursive(stdClass $obj, string $localfilter) {
foreach($obj as $key => $val){
if(is_object($val)){
if($this->eachRecursive($val, $localfilter))
return true;
} elseif(is_array($val)){
foreach($val as $k => $v)
if($this->eachRecursive($v, $localfilter))
return true;
} elseif(stripos(strval($val), $localfilter) !== false){
return true;
}
}
return false;
}
private function filterfunction(Collection $collection, string $filter){
$retVal = [];
foreach (json_decode($collection->toJson()) as $entity){
foreach(explode(' ', trim($filter)) as $localfilter)
if(!$this->eachRecursive($entity, $localfilter))
continue 2;
array_push($retVal, $entity->id);
}
return $retVal;
}

Linq Query Always returns False and Failed to Fetch Data

I am consuming wcf service into angular js application. I wrote linq query to check user information . If the is not null then query should catch the information and return true otherwise its should return false . But the problem is its always returns false and catch values null
Here is the linq Query .
public bool CreateCurrentAccountCheck(Current_Account_Holder_Details current_Account_Details)
{
using (HalifaxDatabaseEntities context =new HalifaxDatabaseEntities())
{
var query = (from x in context.Current_Account_Holder_Details
where x.Account_Holder_First_Name == current_Account_Details.Account_Holder_First_Name && x.Account_Holder_Last_Name == current_Account_Details.Account_Holder_Last_Name
&& x.Account_Holder_DOB == current_Account_Details.Account_Holder_DOB && x.Account_Holder_House_No == current_Account_Details.Account_Holder_House_No
&& x.Account_Holder_Street_Name == current_Account_Details.Account_Holder_Street_Name && x.Account_Holder_Post_Code == current_Account_Details.Account_Holder_Post_Code
select x).FirstOrDefault();
if (query!=null)
{
return true;
}
else
{
return false;
}
}
}
Here is the screen shot on debugging Mode .
The problem is pretty clear that there is no matched record with the where clauses. Also, you want to check the record and you should check it with using an unique id instead of other required or not required fields. It is the exact way to apply it. You should have some kind of unique AccountDetailId or other name which applies unique info for the records.
var query = (from x in context.Current_Account_Holder_Details
where x.AccountDetailId == current_Account_Details.AccountDetailId
select x).FirstOrDefault();

Disable caching for a node type in Drupal 7

I would like to disable caching for nodes of a particular node type 'event'. I did it using hook_boot() and set the page cache as FALSE. I have cleared cache, then in one node of type event, I have made a change, but the anonymous user cannot see the page. It is just giving the copy of its cache.
function hook_boot() {
if ($_GET['q'] != '') {
$url = $_GET['q'];
$nid = substr($url, strrpos($url, '-') + 1);
$type = db_select('node','n')
->fields('n', array('type'))
->condition('n.nid', $nid)
->execute()
->fetchAssoc();
if ($type == 'event') {
drupal_page_is_cacheable(FALSE);
}
}
}
Maybe this module can help you?
https://www.drupal.org/project/cacheexclude

UI and info_dialog Jqgrid

How do I set the z-index for info_dialog, when using UI dialog ?
$.jgrid.info_dialog uses internally $.jgrid.createModal which uses $.jgrid.jqModal (see the line) which introduced since not so long time (see my suggestion here). So you can do something like
$.jgrid.jqModal = $.extend($.jgrid.jqModal || {}, {
zIndex: 1234
});
because of another parameter of navGrid you have to add additionally
$.extend($.jgrid.nav, {
alertzIndex: 1234
});
to make $.jgrid.jqModal.zIndex setting working.
UPDATED: In any way you can use "subclassing" of $.jgrid.info_dialog (like in the answer for example). The corresponding code could be like the following:
var oldInfoDialog = $.jgrid.info_dialog;
$.extend($.jgrid,{
info_dialog: function (caption, content, c_b, modalopt) {
if (modalopt && (modalopt.zIndex === null || modalopt.zIndex === undefined ||
(typeof modalopt.zIndex === "number" && modalopt.zIndex < 1234))) {
modalopt.zIndex = 1234;
}
return oldInfoDialog.call (this, caption, content, c_b, modalopt);
}
});

Resources