I've been able to add a list of suggestions to autocomplete but there is a large list of other suggestions as well.
Is there a way to get rid of the default autocomplete suggestions?
I'm looking at the source here and here and it doesn't describe anything about it. Here is what I have so far:
public function codeCompleter(editor, session, position, prefix, callback):void {
var row:int = position.row;
var column:int = position.column;
if (prefix.length === 0) {
callback(null, []);
}
var testing:Boolean = false;
if (testing) {
callback(null, attributes);
}
else {
callback(null, [{value:"addedToStage"},{value:"test"},{value:"test1"},{value:"adding"},{value:"added"}]);
}
}
I tried setting the completers to an empty array but no effect:
editor.setCompleters([]);
The problem was on my end. The version I was using must have been outdated. I updated to a newer version and the following code clears the auto complete list:
// either line does it
languageTools.setCompleters(null);
languageTools.setCompleters([]);
FYI:
Using version 1.2.6+, 12.03.2016
PS Sorry to anyone looking into this. I will post version numbers in future questions.
Related
I'm using Cypress for my automated tests. I'm trying to find a product on a page and click on it. If the product not displayed on the page, go to the next one until it is found.
I've been trying a lot of things already: while loop, each loop, simple cy.get but none of them work. Can anyone help me to solve this?
You'll need a recursive command, implementation of which will depend on your specific scenario. There's no one-size-fits-all solution, but generally it will look something like this:
function findElem ( targetSelector ) {
// first, we need to query a container (could be table, or a generic item
// container). The important thing is, this container must exist on every
// page you'll traverse.
cy.get('.someContainer').then( $container => {
// synchronously find the target element, however you want. In this
// example I use an attribute selector, but you can do whatever you
// want.
if ( $container.find(targetSelector).length ) {
return true;
} else {
return false;
}
}).then( found => {
if ( found ) {
return cy.log(`found elem "${targetSelector}"`);
} else {
// synchronously check if there's a next page/table
if ( Cypress.$('.nextPageButton').length ) {
// when know that there is a next page, click it using cypress
cy.get('.nextPageButton').click();
// here, assert that next page/table is loaded, possibly by
// asserting that current page/table is removed from DOM
// then, recurse
return findElem(targetSelector);
} else {
throw new Error(`Couldn't find elem "${targetSelector}" on any page`);
}
}
});
}
it('test', () => {
findElem(`[data-id="42"]`);
});
The crux of the solution is using a combination of commands to query a container, and synchronous inspection (using jQuery or whatever) to find the actual element. Learn more at Conditional Testing.
For a concrete implementation, you can refer to an older answer I gave to a similar question.
Update: It appears that the fix for bug 967982 is what's causing this. It would still be great to know either (a) how to work around this or (b) if there's an alternative way to find text in a given page.
One of my Firefox extensions programmatically uses the browser's find bar to locate text on a web page. In recent versions of Firefox, executing my add-ons code causes the find bar to appear when a search term is not found, something it didn't do previously. My routine looks like this:
// Reuse the find bar mechanisms in Firefox (we get a bunch of stuff for free that way)
FindInPage: function(term, e) {
var findBar = document.defaultView.gFindBar;
var shiftKey = e.shiftKey;
var findObj;
var cachedFindTerm;
if ("_find" in findBar) {
findObj = {
find: function(t) {
findBar._find(findBar._findField.value = t);
},
findNext: function() {
findBar._findAgain(false);
},
findPrevious: function() {
findBar._findAgain(true);
}
};
cachedFindTerm = gFindBar._findField.value;
} else {
findObj = findBar;
cachedFindTerm = getBrowser().findString;
}
if (cachedFindTerm == term) {
if(shiftKey)
findObj.findPrevious();
else
findObj.findNext();
} else {
findObj.find(term);
if(shiftKey)
findObj.findPrevious();
}
},
Is there some way I can prevent the find bar from appearing when this block gets executed? I'm aware that using private functions like this is not a best practice, but is there a better way to find a given word in a web page? Some sort of search API available to add-on authors that I'm not aware of?
Is it possible to change the FineUploader options after it has been constructed? I would like to construct the instance once, but then change the itemLimit based on the circumstances. So I would construct the instance like this:
App.fineUploader = new qq.FineUploaderBasic({ itemLimit: 25 });
And then change the itemLimit at some point:
App.fineUploader.setOption('itemLimit', 10);
I can't seem to find a function like that in the docs. Am I missing something?
I think thats not possible on the current version, however you can try overriding the limit as a workaround, here is an example (JS):
$("#uploader").fineUploader()
.on("validate", function() {
if (itemLimitOverride > 0) {
return itemLimitOverride > $(this).fineUploader("getNetUploads");
}
});
An you set itemLimitOverride to an non 0 value in-scope.
Check this thread: https://github.com/Widen/fine-uploader/issues/999
I haven't been able to track this down, but for my set up, isAuthenticated always returns false even after a successful login. Here's the passport code:
req.isAuthenticated = function() {
var property = 'user';
if (this._passport && this._passport.instance._userProperty) {
property = this._passport.instance._userProperty;
}
return (this[property]) ? true : false;
};
But in a quick look around I don't see the _userProperty proeprty anywhere in the local strategy (sorry if I didn't look hard enough), so I suppose that might be why it's always returning false?
I'd leave a code sample of my application code, but I feel it's probably easier to have a quick look at the repo for my work in progress:
passport api token sessionless
Ultimately, my goal is to have logout work properly for that boilerplate project (which it currently it doesn't).
I guess you forgot to put: req.login(...) inside passport.authenticate('local', function(...){}).
See here (at the end of the page)
Apologies if my original question is not that useful in the first place, but...
I found that my combination of passport, passport-local, and passport-local-mongoose, a solution was to simply create an invalidation method on my mongoose Schema (that has the passportLocalMongoose "plugged in", and when my /logout route gets hit I essentially remove that user's token. Here's that method:
Account.statics.invalidateUserToken = function(email, cb) {
var self = this;
this.findOne({email: email}, function(err, usr) {
if(err || !usr) {
console.log('err');
}
usr.token = null;
usr.save(function(err, usr) {
if (err) {
cb(err, null);
} else {
cb(false, 'removed');
}
});
});
};
I presume it's more interesting to see this in context so again please feel free to refer to the repo listed in question...hope this helps someone.
Also, if a core from one of the aformentioned libs wants to suggest a better way I'd of course love to refactor my code to make it idiomatic; if not, this approach seemed to work.
I am trying to get dataView.collapseAllGroups() to work with SlickGrid.
The post In SlickGrid, how do I collapse grouping via javascript says to just use collapseAllGroups() but it doesn't seem to work.
Even when going to the current demo page http://mleibman.github.io/SlickGrid/examples/example5-collapsing.html and typing dataView.collapseAllGroups() into the console, it doesn't seem to do anything. Is there something else that I need to do to refresh the grid?
Edit
I was trying to get the Grid to display a tree where the groups are collapsed by default. Although I cannot get CollapseAllGroups() to work, I was able to do a hack by adding "if (item._collapsed == null) item._collapsed = true;" to myFilter function that is in the example above.
This is a rough worksound but it does the job for now until I find the real solution:
function myFilter(item) {
// Added this line:
if (item._collapsed == null) item._collapsed = true;
if (item.parent != null) {
var parent = gridData[item.parent];
while (parent) {
if (parent._collapsed) {
return false;
}
parent = gridData[parent.parent];
}
}
return true;
}
That particular example demonstrates how to implement hierarchies using custom formatters and a filter. It does NOT use the DataView's grouping feature, so the collapseAllGroups() call has no effect.