I'm using a very basic setup of Twitter's typeahead. I have 2 different search fields, hence the two typeahead initalizations.
Javascript:
$(document).ready(function() {
$('input.search-event').typeahead({
name: 'Events',
prefetch: '/media/json/events.json',
ttl: 0,
limit: 10
});
$('input.search-artist').typeahead({
name: 'Artists',
prefetch: '/media/json/artists.json',
ttl: 0,
limit: 10
});
});
Both events.json and artists.json are formatted as ["entry1", "entry2", "entry3", "..."].
I get different results in normal and incognito mode in Chrome. In normal mode it seems to be using an old json file that doesn't exist anymore (I've deleted it). In incognito mode it uses the correct json file, but it doesn't autosuggest the last item added to the json file. I was hoping ttl set to 0 would solve this problem but it doesn't. I've cleared my browser cache but that doesn't resolve the problem. I've read in other posts that I should clear my browser's localStorage but I don't really know how. There are no errors in the console log.
And I've just found out that typeahead is not showing anything at all in FF and Safari :-)
EDIT:
The results also seem to be depending on the name: value. Is that supposed to happen? For instance: if I change the name: value to 'test' typeahead doesn't work at all.
Typeahead does work in FF and in Safari. And the fact the without a name it doesn't work for you suggests (to me) that something in your json file is wrong, and that it didn't use to be the case, and that your browser is using a cached version.
Since name is the key to the cache, that might explain everything you're seeing:
Doesn't work in incognito mode, since the local storage isn't used in incognito, and there's something wrong with the json file itself.
Doesn't work with a different name, since a dataset with the different name isn't found in the cache (and again -- the json file is somehow bad).
Doesn't work in FF and in Safari -- same reason: the json is bad, and they don't have anything cached yet.
To debug, start with looking in the Developer Tools in Chrome (F12) under the network tab, and see the request and response to /media/json/artists.json, and make sure they are OK. Then make sure the content is indeed valid JSON.
Related
I'm trying to create a Chrome ext that uses the chrome.downloads API. But it doesn't seem to... do anything. First time Chrome developing so I'm a bit unfamiliar with the environment, but no one else online seems to have this problem.
Searching for the issue, I've minimized my code to the following (using the jQuery code as a test download, but have tried many others):
chrome.downloads.download({
url: "https://code.jquery.com/jquery-3.6.0.min.js",
}, (dlid) => {
chrome.downloads.search({id: dlid}, (dl) => {
console.log(dl[0]);
});
});
This results in the following DownloadItem being printed in the console:
byExtensionId: [redacted for privacy]
byExtensionName: [redacted for privacy]
bytesReceived: 0
canResume: false
danger: "safe"
exists: true
fileSize: 0
filename: ""
finalUrl: "https://code.jquery.com/jquery-3.6.0.min.js"
id: 2675
incognito: false
mime: "application/javascript"
paused: false
referrer: ""
startTime: "2021-09-04T09:18:02.401Z"
state: "in_progress"
totalBytes: 0
url: "https://code.jquery.com/jquery-3.6.0.min.js"
But the file doesn't download, nor does anything happen to indicate even an attempt at it. Continued readings of the DownloadItem always gives the same result: stating that the download is in progress and 0 bytes has been downloaded so far. And nothing else on my system gives any indication that the file is being downloaded. But never does it result in any errors - instead it just sits seemingly idling.
Here's what I've ruled out to be the cause so far:
Permission is declared in manifest.json: "permissions": [..., "downloads", ...]. Removing it and running the same code throws errors.
Context is correct, this is not run in a content script. Trying to do so throws errors.
Playing around with any of the DownloadOptions parameters has no effect at all. DownloadOptions.saveAs opens no dialog, and DownloadOptions.filename has no effect on the DownloadItem.filename which is always an empty string.
I've tried many other download targets, both different domains and different filetypes. The resulting mime parameter updates according to the URL extension, but otherwise it creates the same error-free perpetual idling.
I've even tried fake URLs with the same outcome - invalid URL syntaxes throws errors, but nonexistent URLs just gives the same idle result.
There's no evident Internet connectivity issues with my system, and I don't use any proxy or VPN.
Running it on another machine, albeit with the same Chrome user login and the same Internet connection. Same result.
I'm trying to get the SKUs available for a freemium Chrome Extension I'm developing.
I'm following all of the documentation here:
https://developer.chrome.com/webstore/payments-iap
...and I'm using the provided buy.js file, but it doesn't seem to work and the returned error messages are useless: "INVALID_RESPONSE_ERROR"
My code:
google.payments.inapp.getSkuDetails({
parameters: {env: 'prod'},
success: (r) => {
console.log(r);
},
failure: (err) => {
console.log(err);
},
});
Thoughts:
- Am I missing some permission in my manifest? I don't see any mention that it needs any additional ones.
Other StackOverflow questions have mentioned needing to proxy due to region issues. I'm in the states, shouldn't be an issue.
I've tried the above from both an options page and a popup - does it need to happen in a background page?
I'm pretty baffled. Any help is appreciated!
Thanks.
Updates:
The above works when released (in prod), but not locally
In prod you cannot buy your own thing (heads-up). It'll give you some stupid, meaningless error, but won't tell you that.
Still can't get this to work locally which means I have to test in prod.
If you need this to work locally, you must set the 'key' in your manifest.json file. When you reload it, it will show the same ID as the loaded extension from production.
Here are instructions on how to get the relevant key
If you debugging your extension in unpacked mode, you may need to set production "key" in your manifest.
I have a simple setup for Desktop Capturing using html5 libraries.
This includes a simple webpage and a chrome-extension. I am using
Extension to get the sourceId
Using the sourceId I call navigator.mediaDevices.getUserMedia to get the MediaStream
This MediaStream is then fed into an instance of MediaRecorder for recording.
This setup works most of the times, but a few times I see that requestData() on MediaRecorder instance returns blob with empty data consistently. I am clueless as to what can cause a running setup to start misbehaving sometimes.
Some weird behaviour that I noticed in the bad state:
When I try to close/refresh the window it doesn't respond.
The MediaStreamTrack object in Step 2) above is 'live' but as soon as I go to Step 3) it becomes 'muted'.
There's no pattern to it, sometimes it even happens when I request for the MediaStreams the very first time(which rules out the possibility that there could be some dangling resources eating up the contexts)
Is there anything that I am doing wrong and am unaware of? Any help/pointers would be highly appreciated!
Recently I read a query about "What does console.log do" and I read an answer, tried using it and found that despite the answer stating that it outputs to the console in googles browser, I just tried it and I get no output.
I did try this code:
function put(p){
if ( window.console && window.console.log ) {
console.log(p); // console is available
}else{
alert(p);
}
}
BUT... I get neither console output or alert and furthermore .log is a Math property, what gives with that?
Make sure that in the Developer Tools the Filter in the console section is set to All or Logs...
I had a similar experience where I couldn't see any of my console.log output and it was because the console was set to filter on Errors only... All the log entries were there - they just weren't visible.
Bonus marks: you can also Ctrl + Click to select multiple filters (Errors + Logs for example).
Press F12 and look at in Developer Tools: Console. I tried your code just now, works fine for me -- Chrome version 30.0.
Since you're after console logging, not mathematical logarithms, perhaps you could stop going on about there being similarly-named function in the Math object. It's not relevant here whatsoever.
You're also coming across just a little shouty. console.log() works fine, and your question didn't indicate that you knew where to look. This is totally your problem, but I'm trying to help you. I can obviously only go on the information you provide, and I can't say your initial question was written very clearly.
It appears, since the snippet of code you posted works here absolutely fine, that your calling code & containing (which you haven't posted) would be the cause of the problem. You should debug these, to find out what's going wrong.
Do you know how to use the Chrome debugger? Are there any error messages showing in Chrome or on the console?
Test it on a simple page if necessary, to rule out other errors in the page/ or surrounding context breaking it. One common mistakes is declare functions in a jQuery ready handler or similar, and then try & access them globally. Make sure your logging function is actually global (outside any other function(){} or object {} blocks).
Lastly, it's good to have a logging function for portability (I have one myself) but put() is not a good name for it. Naming it consoleLog() or log() would be better.
Had the same issue .
Make sure your using de right path when you try import thing's .
Example whit my issue :
Wrong path ----> ** import normalizedData from 'normalizr'; **
Right path ---> ** import normalizedData from '../schemas/index.js'; **
I had also faced the same problem. Make sure you apply no filter in the console. It worked for me.
I have created a directive for handling binary file uploading. Here's a plunker using it:
http://plnkr.co/edit/9qcKW5A6yq1hS8OuWTNK?p=preview
The idea is that the model is initialized by the controller with (initially) just the current filename - not the current data.
If the user clicks on the link, the data will be downloaded to his machine.
If the user clicks on the '-' button, both the filedata and the filename parts of the model will be set to undefined.
If the user clicks on '+' and selects his own file, the model gets a new filename, as well as the data (in base64) of the file in question. Now if you do this, and look at your browser's console, you will find that in both Chrome and Firefox, there's a very weird error reported (from the bowels of Angular) about accessing things we are not allowed to. Firefox even says something specifically about security.
To stop the error from being reported, instead of assigning
model.filedata = values;
try
model.filedata = '';
...and indeed, the error goes away. This is very weird - it appears the browser is keeping some kind of state about the string of base64 data contained in 'values', and has an issue with Angular touching it in its internal watchers.
Is this a bug on my side, a bug on the Angular side, or a bug on the browser side?
Any help most appreciated.
On line 15 of your script.js it says:
' type="file" data-ng-model="model.filedata" />' +
ng-model establishes a two-way data binding between scope.model.filedata and the "value" of the input element. When you update model.filedata with ...
model.filedata = values;
... Angular tries to update the "value" of the input element and this fails.
I don't see why you need this ng-model on your input element. By removing it, your code works.
It is no bug.
The issue is that you bind a model to the file input. (data-ng-model="model.filedata")
This means that angular will try to update the value of the file input once you change the filedata.
And no browser allows to programmatically set the value of file inputs for security reasons.
(otherwise i could set the path to a local file on your system with passwords and force an upload to my server)
Just remove the binding and it works as expected (demo)
(and most likely you meant to bind it to the model.filename and not the model.filedata, although it would produce the same exception..)