Filter Too Quickly issue - ajax

In ExtJS 4.1.3 we have a filter setup on a text field to run 'onchange' of the text field. This is the function onchange:
var store = this.getStore();
value = field.getValue();
if (value.length > 0) {
// Param name is ignored here since we use custom encoding in the proxy.
// id is used by the Store to replace any previous filter
store.filter({
id: 'query',
property: 'query',
value: 'LegalName|#|#|' + value
});
} else {
store.clearFilter();
}
Now, we are running into an issue where when I type something in the text field too fast I am getting errors and am getting stuck on a load screen. When I type in the same thing slowly it works. Considering typing it in slowly makes it work, but fast makes it fail and the data coming back from the server is the same in both instances, I'm assuming it's an issue with ExtJS. Has anyone seen an issue like this? What are potential problems and fixes. I can't figure out why it's breaking. Here is the trail I get:
Uncaught TypeError: Cannot convert null to object ext-all-debug.js:51752
Ext.define.cancelAllPrefetches ext-all-debug.js:51752
Ext.util.Event.Ext.extend.fire ext-all-debug.js:8638
Ext.define.continueFireEvent ext-all-debug.js:25117
Ext.define.fireEvent ext-all-debug.js:25095
Ext.define.clear ext-all-debug.js:44718
Base.implement.callParent ext-all-debug.js:3735
Ext.define.clear ext-all-debug.js:47485
Base.implement.callParent ext-all-debug.js:3735
PageMap.Ext.Class.clear ext-all-debug.js:52358
Ext.define.filter ext-all-debug.js:51377
Ext.define.onTextfieldChange /TEST/app/view/ContractGrid.js?_dc=1354553533935:447
Ext.util.Event.Ext.extend.fire ext-all-debug.js:8638
Ext.define.continueFireEvent ext-all-debug.js:25117
Ext.define.fireEvent ext-all-debug.js:25095
Ext.override.fireEvent ext-all-debug.js:58382
Ext.define.checkChange ext-all-debug.js:30310
call ext-all-debug.js:8426
Any thoughts?

I was able to fix the issue by changing the buffer setting on the store. Looks like I had set 'buffered' to true in the store and once I removed it, the issue went away.

Related

Cypress, how to check for text typed into a field?

I can verify text appears "somewhere" on the results page with
it.only('can verify an input element has certain text typed into it', function() {
cy.visit('http://google.com')
cy.get("input[name=q]").type('abc123{enter}') // with or without the {enter}
cy.contains('abc123') // Anywhere on the page :(
})
but how can I verify the text I type in the input text box?
I tried chaining to the element with
it.only('can verify an input element has certain text typed into it', function() {
cy.visit('http://google.com')
cy.get("input[name=q]").type('abc123{enter}')
cy.get("input[name=q]").contains('abc123')
})
but I get
CypressError: Timed out retrying: Expected to find content: 'abc123' within the element: <input.gLFyf.gsfi> but never did.
I tried cy.get("input[name=q]").contains('abc123') and
cy.contains('input[name=q]', 'abc123')
but both time out and fail.
Change .contains to use .should('have.value'...
cy.get("input[name=q]").type('abc123{enter}')
cy.get("input[name=q]").should('have.value', 'abc123')
You may not like this idea but here is just a suggestion so you don't have to keep calling cy.get each time.
You could always set a const value for your input name (could be in an external file) so:
export const inputField = () => cy.get('input[name=q]');
This will do the get whenever you call inputField.
so then your call would be:
inputField.type('abc123{enter}').should('have.value', 'abc123');
Thats just more a setup thing than an actual soluton, as I know you solved the issue yourself, but the above is quite a nice way so you don't have to keep doing cy.get on the same field.
Instead of using contains, you can read the text you already entered in the input field using "then()". Here's how:
cy.get("input[name=q]").type('abc123').then(function($input){ const value = $input.text() expect(value.includes('abc123')).to.be.true })

Any ar js multimarkers learning tutorial?

I have been searching for ar.js multimarkers tutorial or anything that explains about it. But all I can find is 2 examples, but no tutorials or explanations.
So far, I understand that it requires to learn the pattern or order of the markers, then it stores it in localStorage. This data is used later to display the image.
What I don't understand, is how this "learner" is implemented. Also, the learning process is only used once by the "creator", right? The output file should be stored and then served later when needed, not created from scratch at each person's phone or computer.
Any help is appreciated.
Since the question is mostly about the learner page, I'll try to break it down as much as i can:
1) You need to have an array of {type, URL} objects.
A sample of creating the default array is shown below (source code):
var markersControlsParameters = [
{
type : 'pattern',
patternUrl : 'examples/marker-training/examples/pattern-files/pattern-hiro.patt',
},
{
type : 'pattern',
patternUrl : 'examples/marker-training/examples/pattern-files/pattern-kanji.patt',
}]
2) You need to feed this to the 'learner' object.
By default the above object is being encoded into the url (source) and then decoded by the learner site. What is important, happens on the site:
for each object in the array, an ArMarkerControls object is created and stored:
// array.forEach(function(markerParams){
var markerRoot = new THREE.Group()
scene.add(markerRoot)
// create markerControls for our markerRoot
var markerControls = new THREEx.ArMarkerControls(arToolkitContext, markerRoot, markerParams)
subMarkersControls.push(markerControls)
The subMarkersControls is used to create the object used to do the learning. At long last:
var multiMarkerLearning = new THREEx.ArMultiMakersLearning(arToolkitContext, subMarkersControls)
The example learner site has multiple utility functions, but as far as i know, the most important here are the ArMultiMakersLearning members which can be used in the following order (or any other):
// this method resets previously collected statistics
multiMarkerLearning.resetStats()
// this member flag enables data collection
multiMarkerLearning.enabled = true
// this member flag stops data collection
multiMarkerLearning.enabled = false
// To obtain the 'learned' data, simply call .toJSON()
var jsonString = multiMarkerLearning.toJSON()
Thats all. If you store the jsonString as
localStorage.setItem('ARjsMultiMarkerFile', jsonString);
then it will be used as the default multimarker file later on. If you want a custom name or more areas - then you'll have to modify the name in the source code.
3) 2.1.4 debugUI
It seems that the debug UI is broken - the UI buttons do exist but are nowhere to be seen. A hot fix would be using the 'markersAreaEnabled' span style for the div
containing the buttons (see this source bit).
It's all in this glitch, you can find it under the phrase 'CHANGES HERE' in the arjs code.

web audio filter response

I have a simple filter.
var filter = ctx.createBiquadFilter();
filter.type = 'highpass';
filter.frequency.setValueAtTime(10,ctx.currentTime);
I would like to see its frequency response using getFrequencyResponse
window.setInterval(function() {
var frequencyHz = new Float32Array(1),
magResponse = new Float32Array(1),
phaseResponse = new Float32Array(1);
frequencyHz[0] = 10;
filter.getFrequencyResponse(frequencyHz,magResponse,phaseResponse);
console.log(magResponse);
},100);
I expect to see [0.9565200805664062] which is the correct response for 10Hz, but instead I see [0.0008162903832271695] which is the response for 350Hz, the default frequency value.
I can only get a sensible response if I manually set the value, whereas if I use param methods such as setValueAtTime, the filter response ignores them and spits out the default. In other words, getFrequencyResponse seems to only work if the filter values are set manually, preventing filter analysis when the values are set by automation. If this is true, this seems like more than a small problem with the api.
Someone please try something near to this, and if it works (doubtful) please post the code.
Actually, no, it should be taking effect, but because you're causing an instantaneous value change at the NEXT processing block (that's what ".currentTime" means), that change has not yet been processed - so you're seeing the default value. You should see, for example, getFrequencyResponse changes over time for a setLinearRamp.

Is it possible to print the created query, like shows up in error messages?

I really like how the error messages include a text string representing what the ReQL code looks like. Is it possible to get at this without forcing an error?
Example Error message:
RqlRuntimeError: No attribute `colors` in object:
{...}
in:
r.db("r_g").table("items").group("collection").ungroup().map(function(var_0) { return var_0("group").object(var_0("reduction")); }).concatMap(function(var_1) { return var_1("colors"); })
I'm wanting to get at the value after "in:" shown before I run() the query.
You can use .toString() like query.toString() (without .run(...))
It should use the same code as the one used to generate backtraces.
I opened an issue this morning to add it in the docs, it is somehow missing -- https://github.com/rethinkdb/docs/issues/354

How to print validation error outside of field constructor in Play framework 2

How can I show a validation error for a form field outside of a field constructor in Play framework 2? Here is what I tried:
#eventForm.("name").error.message
And I get this error:
value message is not a member of Option[play.api.data.FormError]
I'm confused because in the api docs it says message is a member of FormError. Also this works fine for global errors:
#eventForm.globalError.message
You can get a better grasp of it checking Form's sourcecode here
Form defines an apply method:
def apply(key: String): Field = Field(
this,
key,
constraints.get(key).getOrElse(Nil),
formats.get(key),
errors.collect { case e if e.key == key => e },
data.get(key))
That, as said in the doc, returns any field, even if it doesn't exist. And a Field has an errors member which returns a Seq[FormError]:
So, you could do something like that (for the Seq[FormError]):
eventForm("name").errors.foreach { error =>
<div>#error.message</div>
}
Or (for the Option[FormError])
eventForm("name").error.map { error =>
<div>#error.message</div>
}
Or, you could use Form errors:
def errors(key: String): Seq[FormError] = errors.filter(_.key == key)
And get all errors of a given key. Like this (for the Seq[FormError]):
eventForm.errors("name").foreach { error =>
<div>#error.message</div>
}
Or (for the Option[FormError])
eventForm.error("name").map { error =>
<div>#error.message</div>
}
If you want more details, check the source code. It's well written and well commented.
Cheers!
EDIT:
As biesior commented: to show human readable pretty messages with different languages you have to check how play works I18N out here
To be thorough you're probably going to have to deal with I18N. It's not hard at all to get it all working.
After reading the documentation you may still find yourself a bit consufed. I'll give you a little push. Add a messages file to your conf folder and you can copy its content from here. That way you'll have more control over the default messages. Now, in your view, you should be able to do something like that:
eventForm.errors("name").foreach { error =>
<div>#Messages(error.message, error.args: _*)</div>
}
For instance, if error.message were error.invalid it would show the message previously defined in the conf/messages file Invalid value. args define some arguments that your error message may handle. For instance, if you were handling an error.min, an arg could be the minimum value required. In your message you just have to follow the {n} pattern, where n is the order of your argument.
Of course, you're able to define your own messages like that:
error.futureBirthday=Are you sure you're born in the future? Oowww hay, we got ourselves a time traveler!
And in your controller you could check your form like that (just one line of code to show you the feeling of it)
"year" -> number.verifying("error.furtureBirthday", number <= 2012) // 2012 being the current year
If you want to play around with languages, just follow the documentation.
Cheers, again!
As you said yourself, message is a member of FormError, but you have an Option[FormError]. You could use
eventForm("name").error.map(_.message).getOrElse("")
That gives you the message, if there is an error, and "" if there isn't.

Resources