What happens if you call watchPosition and change page without calling clearWatch? - html

I am using HTML5 geolocation watchPosition. I have a page that calls watchPosition once that constantly checks the user's location. I am curious what happens if I transfer to another page within the website without calling the clearWatch function. Will watchPosition continue to run and get location data?

No. All Javascript that was loaded with the page gets discarded and stopped. That includes all event watchers and geolocation watch requests.
The only thing that has even a chance of continuing to run in the background are web workers, which you very explicitly need to get up and running.

Related

How do I start a DevTools user flow recording from a dynamic URL?

Google recently released their DevTools user flow recorder and it seems like an interesting and easy-to-use tool. One limitation I'm running into is that replaying a recording will always bring you to the page you initiated the recording on. For example, if I create and save a recording on this array processing question then navigate to this git question, running the recording on the latter will redirect me back to the former. I would like to be able to make a recording, then kick it off from whatever page I'm currently viewing. So far, I've tried both removing the URL from the initial step and replacing the initial URL with a JS IIFE that gets the current URL; neither of these have worked.

How to execute web worker task continuously even though the location url is redirect?

I use gifjs to generate a lot of gifs from png/jpg files once user logins success. At same time, I want to change the location.url to direct user to my website main page. But the problem is that the web worker task stopped once the url is changed. So how to execute web worker task continuously even though the location url is redirect?
If the browser does a load of a new page, the short answer is that workers will be terminated. Definitely dedicated workers, and according to Do Shared Web Workers persist across a single page reload, link navigation shared workers (that aren't being used by other windows/tabs) will be too.
But...
If you didn't use any full page loads, and made the entire site use Javascript for navigation / posting of forms, and use the HTML history API to change the URL, then the worker will survive as the user logs in and navigates the site. The worker will only be terminated when they leave the site, or force a reload in the browser.
Depending on the current setup of your site, this might mean considerable change of both the browser and server architecture, the details of which I suspect are beyond the scope of this question.

Windows .net Google.Apis hangs on the call to InsertMediaUpload.Upload -- there is no timeout

I am using GoogleApis to upload documents to Google Drive using the InsertMediaUpload class from the FilesResource namespace and the Upload method. It is working well for me with the following exception:
After calling InsertMediaUpload, a browser window appears asking the user to log into their Google (usually Gmail) account. If the user simply closes the browser window instead of clicking on "Accept" or "Cancel" then the current process appears to be hung. I suppose there should a timeout of a minute or two so that if the user opts to not log in the current windows application will not simply hang and stop working indefinitely.
There is no need for sample code here. What should happen when the user simply closes the browser window instead of clicking cancel if they are no longer interested in uploading a document? Crashing (or hanging) the current process should not be a possibility, but that is what occurs. One would hope closing the browser window would have the same effect as clicking the cancel button -- just another way of opting out of an upload to Google Drive, right?
Thanks in advance for any help with this.
You're not supposed to get authentication message from InsertMediaUpload class. You should handle authentication by yourself. Authentication browser window you get is for your development convenience, not for production code. Please take a look at .net quickstart. In this quickstart, you'll see GetAuthorization method which handles authentication. Modify this method on your needs and you'll get what you want.

How to implement server side screen capture with Chromium?

I am building a site that can take web page screen capture of the given URL, and then output a image URL. There have been so many services like this, but I am curious about how it works.
Initially, I guess I have to execute a browser on server-side, feed the URL given from client. The browser then load the URL, after that, wait for a few seconds for executing javascript because some pages cost time to perform its UI, like Trello. In the end, call certain API to capture that page.
I made up my mind to using the open source browser, Chromium. Even so, I still have doubt about if I am doing the right thing.
Questions
Does my direction right?
I am wondering how to execute a long-live Chromium browser on my server.
Is there a shell I can control Chromium in command line?
Chrome has a built in API that may meet your needs "captureVisibleTab":
chrome.tabs.captureVisibleTab(integer windowId, object options, function callback)
Captures the visible area of the currently active tab in the specified window. You must have host permission for the URL displayed by the tab.
http://developer.chrome.com/trunk/extensions/tabs.html#method-captureVisibleTab

Google Map disappears in ajax loaded page

I have a testsite which loads at the push of the magnifying button .../forms/viewlab.php?sid=2 dynamically via jquery 'load' (ajax).
Viewlab.php contains a with id "map" and should load/display a google map.
Strange thing is that upon push of the button ("load map"), the goggle map only loads for a split second (depending on the speed of your computer you can actually see it flicker once) and then disappears.
I am using the google ajax api to load google maps and jquery. Any any idea how to make that work?
Try not calling GUnload() until your page exits. At present you're calling GUnload() before creating the map.
I guess that GUnload() might be asynchronous, so that you manage to create the map before GUnload() finishes destroying the API code, but as soon as you return control from your map creation the rest of the GUnload() processing executes, taking down the API, erasing the map and recovering the memory used.
I don't have a concrete maps example by hand, but it's rather an AJAX related issue, i assume.
the problem might be, when which events do happen and when which code gets triggered:
You might need to move some code out of the document ready function,
then you can bind the AJAX on document ready by a function call ...
... and later re-bind it by a callback function call within the form's success function.