How can i raise an event based on distance - html

I need to send Geolocation to server in 2 scenarios.
1. particular time interval,say 300000 ms(configurable)
and
2. whenever device moves a particular distance,say 500 mtrs(configurable)
First scenario has done using setInterval() in javascript.
How can i raise an event based on distance.
I am using jquery Mobile with phonegap/cordova.
Thank in advance.

Related

What is the default frame rate in cocos2dx

I know that the Node's update method will be called every frame if we call scheduleUpdate for the current node. Is the delta parameter in the update method the same on all devices and platforms? If not, then how can I calculate what the frame rate or the delta value is on the device running my game?
I the AppDelegate you will see a line like below:
director->setDisplayStats(true);
If the value passed down is set to true you will see the frame rate of your game in the bottom left corner. You can follow that code to see how they calculate the FPS, if you want to add constant frame rate functionality to your code.
[EDIT: Based on the comment below]
The way I have done what you want in the past is by having a dedicated game controller which has a scheduled update function and I use that to set a delta value that can be passed around or accessed by other components of the game.

How to protect flash app from changing system time in runtime

Is there any way to measure time from starting flash without using system time? System time can be changed by user when flash running
I'm also not sure what exactly you mean but if you want to grab a time which cannot be altered by user you could e.g. call a webservice and get "accurate" time.
Check this website here http://www.earthtools.org/webservices.htm.
By passing parameters for a certain region to the request you will get the appropriate time.
Other than retreiving time from a server there is no way to make sure the (system)time has not been altered by user.
There is also a function called "getTimer()" which returns the number of milliseconds that have elapsed since your app started. Refer to this url:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/utils/package.html#getTimer()
The Timer class is the interface to timers, which let you run code on a specified time sequence. Use the timer.start() method to start a timer.
Add an event listener for the timer event to set up code to be run on the timer interval.

How to add more than 10 locations for pass

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>

Stream Position Returned By Box API Cannot Be Used To Track Events

Thanks for your reply for my question: Is this a bug of Box API v2 when getting events
This is a new problem related to this. The problem is that I cannot reliably use the next_stream_position I got from previous calls to track events.
Given this scenario:
Given the following two GET HTTP queries:
1. GET https://api.box.com/2.0/events?stream_position=1336039062458
This one returns the JSON file which contains one file entry of myfile.pdf and the next stream position = 1336039062934
2. GET https://api.box.com/2.0/events?stream_position=1336039062934
This call uses the stream position I got from the first call. However, it returns the JSON contains the exactly same file entry of myfile.pdf with the first call.
I think if the first call gives a stream position, it should be used as a mark for that exact time (say: TIme A). If I use that stream position in subsequent queries, no events before "Time A" should be returned.
Is this a bug? Or did I use the API in the wrong way?
Many thanks.
Box’s /events endpoint is focused on delivering to you a highly reliable list of all the events relevant to your Box account. Events are registered against a time-sequenced list we call the stream_position. When you hit the /events API and pass in a stream_position we respond to you with the events that happened slightly before that stream position, up to the current stream_position, or the chunk_size, whichever is lesser. Due to timing lag and our preference to make sure you don’t miss some event, you may receive duplicate events when you call the /events API. You may also receive events that look like they are ‘before’ events that you’ve already received. Our philosophy is that it is better for you to know what has happened, than to be in the dark and miss something important.
Box events currently give you a window roughly 5 seconds into the past, so that you don't miss some event.
We have considered just delaying the events we send you by about 5 seconds and de-duplicating the events on our side, but at this point we've turned the dial more towards real-time. Let us know if you'd prefer a fully de-duped stream, that was slower.
For now, (in beta) if you write your client to check for duplicate events, and discard them, that will be best. We are about to add an event_id to the payload so you can de-duplicate on that. Until then, you'll have to look at a bunch of fields, depending on the event type... It's probably more challenging that it is worth.
In order to help you be able to figure out if an event is a duplicate, we have now added to each event an event_id that will be unique. It is our intention that the event_id will allow you to de-duplicate the responses you receive from subsequent GET /events calls.
You can see this reflected in the updated documentation here, including example payloads.

How to implement a time wait before html form resubmission?

I have an html form which inserts data into a database. I just built it.. it's very basic, as I'm just doing this to learn. In doing this, I see that I can hit the back browser button and post again.. and again.. and again.. and it keeps writing to the db.
I've seen sites where I try to resubmit info and it tells me I must wait 60 seconds (or whatever). Is this the preferred method to solve this problem? If so, how does one go about implementing it?
Or maybe you would handle it a different way?
When you insert a row, store the submission time in the table, or in the user's session.
Whenever you process the form, compare that time to the current time. If it's within 60 seconds, display an error instead of inserting a row.
There are two methods :
i) Simple client side javascript:
Store the time of last event in a javascript variable,
when the user does the event again , send an alert message about timing.
( This method can be fooled though by users knowing javascript )
ii) Store the time of last event in your database at backend when the form post is done. When the same form post is done again, check for the time, if it is allowed, do the processing, else reply with a message about the timing.