I'm testing HTML5 geolocation.
I have some weird results in Opera and Opera Mobile.
When I visit the site after some time (for example 25 minutes) after the last visit position timestamp is from some time in the past. But I pass options telling that I want position not older then 5 seconds. After page refresh I get position timestamp close to 'now'. I think it should return position timestamp close to 'now' on every visit.
Example:
First visit: position time stamp 23:23:13
close browser:
return to site at 23:45:20: position timestamp 23:25:21
refresh: position timestamp 23:45:11
Here is my API call:
navigator.geolocation.getCurrentPosition(geoSuccess, geoError, { maximumAge: 5000, timeout: 10000, enableHighAccuracy: true });
You can observe this on azure website I created for test
geotest.apphb.com
Edit:
Few minutes ago I learned that opera:config gives me access to geolocation settings among wich I found Send location request only on change.
When I turn it off geolocation api works as it's supposed to. But I don't understand this setting. What has to change in order to send location request?
With this setting turned on geolocation api gives me location from few hours ago. Even though I'm in different city already.
According to Opera's config website for Windows, the Send location request only on change means the following:
Only send location request if some of the data providers (Wi-Fi, cell, etc) actually changed.
So I am assuming that when you changed cities, you didn't change data providers as mentioned above. If you were to find a Wi-Fi access point or use another technology to access the internet, it would probably send a location request and would be updated.
As the page already loaded, getCurrentPosition assumes that the position you want is the position when the page has been loaded(the users current position on page load).
Use watchPosition to update the position continuously(without page reload).
Related
I'm having trouble finding any documentation in regards to Google One Tap UX and how to persist signin state after a signin redirect. I am using the html api, check the code here:
setTimeout(function () {
let target = document.getElementById('google-signin');
target.innerHTML = '<div id="g_id_onload" data-client_id="x" data-context="signin" data-login_uri="https://x/account/google/callback" data-auto_select="true" data-itp_support="true"></div>';
var s = document.createElement("script");
s.src = 'https://accounts.google.com/gsi/client';
document.head.appendChild(s);
console.log('appended script', s);
}, 30000);
</script>
Essentially I am delaying this signin popup for 30 seconds, that part works fine but soon after this is what happens:
Sign in occurs
Redirect happens
Server redirects back to the referer page
After 30 seconds the process starts again
I would have assumed the google sdk would set a cookie or something somewhere but I guess it does not, either that I'm supposed to handle persisting signin state through my own means. I just want to know the correct approach here.
My question is: How does google know if a user has already signed in using Google One Tap UX?
Figured out a solution. Google allows you to put a property on your div tag called data-skip_prompt_cookie="yourcookie" this will skip the one tap prompt if that cookie is present with a truthy value.
What I did was on my server callback in asp.net I added a cookie to the response. This ensures the prompt is only disabled once someone actually signs in.
Response.Cookies.Append(
"yourcookie", "true");
This ensures when my server redirects back to the originating page, the cookie exists and the one tap does not show up again
I have a Chrome kiosk app that basically just uses webview to allow someone to browse through a catalog.
I found the chrome.idle API, and believe I understand how to set idle time and query if the device is idle, but can I have it restart the application when the state changes to idle or at least navigate back to a set URL?
The end goal is to have the catalog reset itself for the next user after being left idle for a set period of time.
https://developer.chrome.com/apps/idle
Well, the documentation is pretty clear..
First, you need to declare in the manifest that you want to use this API, as it needs a permission.
"permissions" : ["idle"],
You could go with a poll-based approach as you suggested, but why? There's an event provided. So, we go on to use that.
You need to inform Chrome how long an interval without user input you consider an idle state.
chrome.idle.setDetectionInterval(120); // 120 seconds
Lastly, you need to react to a change to an idle state.
chrome.idle.onStateChanged.addListener(function(newState) {
if(newState == "idle") {
// Reset the state as you wish
}
});
I want to use many locations to show on lock screen. I tested already, only 10 locations is shown. Are there any way to show more than 10 locations ?
Rachel is correct in that Passbook will only recognise the first 10 locations included in pass.json. If there are any more than 10, then these will be ignored.
The workaround that you link to, proposes the following:
You create a location enabled app
Whenever your app detects a significant location change, it signals your server, providing the pass serial number and the new location
Your server then selects the 10 closest locations, compiles a new pass and pushes it to the device
Depending on how sophisticated you want to get in determining the most appropriate locations, it could be a bit of work. It also doesn't make for a great user experience since the location will eat battery and the constant updating of the pass will eat data.
Three alternative approaches are:
Letting the user select the 10 most appropriate locations for them, or
Updating the locations whenever the pass is used. If the pass is scanned, then you can use the location of the scanning device to determine the 10 closest locations and push an updated pass, or
Adding a unique link on the back of the pass to a HTML5 page that grabs their current location with Javascript (see below), then initiates a push. E.g. To update you pass with the 10 nearest locations, click the link below http://www.yourservice.com/?passSerial=xxxx
Sample location JS:
<script>
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(success,fail);
}
function success(a) {
$("#long").val(a.coords.longitude).focus(); // focus required to force an update of the field value in webkit browsers
$("#lat").val(a.coords.latitude).focus();
// initiate ajax callback to push new pass and alert the user that it is on the way
}
function fail() {
alert("You must give permission to provide your location, please refresh this page and try again");
}
</script>
I am developing an IIS8 website where users can log in and once logged in watch videos. I want to serve my videos, which may be up to 6 hours long, using HTML5 <video />. I want to limit users to one login only so they can not share their login credentials with others, this will be a pay site. For static pages (non-video) this is easy, but I'm not sure how to do it for video. Once a HTML5 video starts playing how can I prevent the user from loggin in again? Or, if he does log in again, it there a way to interrupt the video playback from the 1st login? I'd love to hear ideas...
thanks
David
While I'm not sure enough about your framework and criteria, have you considered using jQuery and aJax to send requests to your server every X minutes to verify that the session is still active? Here is some sample untested ajax -- just use Javascript's setTimeout function to send every x minutes:
$.ajax({
url: "yourpage.asp",
type: "post",
data: "sessionId=sessionIdVal",
dataType: "json",
success: function(msg){
//Do Logic Here with msg
}
});
And documentation.
Good luck.
elaborating on sgeddes's answer a solution I've used in the past is
- when the user logs in generate a GUID that gets stored both as a cookie for the user and in a lookup table... so if the user logs in again the GUID (and timestamp) will change
- every n seconds have the client poll the server to make sure they still have the right GUID and if not stop the video so only the most recent log-in continues to work
however... there are a couple of issues with this. If the video is a single progressive stream once connected there's nothing to stop the user downloading it and watching it locally, and if they want to get really tricky they could interrupt the polling javascript and simply stop the check.
If you want to go a bit further you can implement a server side handler that checks the validity of the cookie token before delivering more of the video (something similar to http://blog.offbeatmammal.com/post/2006/06/30/Using-ASPNET-to-restrict-access-to-images.aspx) though because the <video> element does it's best to download enough of the video to play without buffering depending on how long it is and how much pre-buffering is done by the time that check kicks in it may be too late.
i'm looking at a stock/index:
http://www.google.com/finance?q=google
I've got firebug open, in firefox and when the price updates on the page, i dont see any GETs or POSTs, just a get maybe 30 to 60 seconds later.
Surely if the page is being updated with a value, wouldnt firebug show this data reaching the page as it happens? Or does firebug collect connections in batches?
Look further back in the GET connection logs to see if there is a connection that was opened but not closed. It's likely that the page is opening an XmlHttpRequest connection to the data server and keeping the connection open indefinitely. This is common for streaming data situations, even when the data stream is fairly low volume. If this is the case, then new data will arrive on the open connection without any new connection activity reported in the log.
There is one request that never finishes responding (or at least not for the time I watched), you can see this in the NET panel, this response periodically outputs more data which is then used to update the application. If you examine the request you will see that it specifies a header Transfer-Encoding: Chunked, which is used for these purposes, see http://en.wikipedia.org/wiki/Chunked_transfer_encoding.