Wednesday, 2 October 2013

Prevent timer from stopping when window is inactive Javascript

Prevent timer from stopping when window is inactive Javascript

Helllo, I'm making a quiz application, and want to set a timer. I want to
make it in Javascript. This is my function:
function countDown(sec, elem) {
_(elem).innerHTML = sec;
if(sec < 1) {
clearTimeout(timer);
endGame ();
return;
}
sec--;
var timer = setTimeout('countDown('+sec+',"'+elem+'")',1000);
}
The problem is that, for example, for mobile Saffari browser, when you
hold your finger on the screen (like scrolling effect), the timer stops,
yet you can still see the questions... So, basically, you can have an
unlimited time. How can I make the timer to run nomatter what?
Thank you in advance!

Java: turning an arraylist into an array with an added element

Java: turning an arraylist into an array with an added element

I know that the code to turn an arraylist into an array is:
private String[] arrayLst_to_array(ArrayList<String> al) {
String[] arr = new String[al.size()];
arr = al.toArray(arr);
return arr;
}
But I want my new array to have a certain string in the beginning and then
after that, I want the rest of the arraylist.
I know that I could just add the string that I want to the beginning of
the arraylist and then convert it, but is there a more efficient way?

Is call to preventDefault() really necessary on drop event?

Is call to preventDefault() really necessary on drop event?

I am learning about Drag & Drop. I have copied a W3Schools example in
JSFiddle.
The W3School example calls preventDefault() in the drop event:
function drop(ev) {
ev.preventDefault();
var data=ev.dataTransfer.getData("Text");
ev.target.appendChild(document.getElementById(data));
}
Yet, I don't understand the need when reading documentation. When I remove
this call, the example still works fine:
function drop(ev) {
var data=ev.dataTransfer.getData("Text");
ev.target.appendChild(document.getElementById(data));
}
So, what is the use of this call to preventDefault()? Do I really need it?
If yes why?

Tuesday, 1 October 2013

disable edit script button in menu sl4a

disable edit script button in menu sl4a

is there some way of hidden or disabbling (graying may be) edit button in
menu of sl4a?
the button in question is that appear when tap or click a name script in
the script list of the sl4a
other: Can I configure these buttons caption and actions?

Visibility Expression regarding data value

Visibility Expression regarding data value

I have a table with 4 columns: AKA, Value, Unit, and Metric.
I have a filter on the dataset on AKA based on a parameter. I am trying to
use the following in the visibility filter:
=IIF(Fields!Metric.Value, "MONTHLY_SummaryStats" = "Availablility", FALSE,
TRUE)
I am getting an error regarding the expression referring directly to a
field without a dataset aggregate.
Any idea why it's asking for an aggregate when I am trying to filter on a
specific value?
Based on the filter on the dataset, this expression should only return 1
value.

Apache and PHP interaction

Apache and PHP interaction

Suppose we have a typical LAMP setup. When a person requests a web page
coded in php, what happens at the Apache level? Does Apache create a new
php instance to create and return that web page? Or is there a continuous
php instance running at all times?
Basically, here is how I think it works:
Person visits http://example.com/index.php
Apache receives the request, spins up an instance of php to create the page
Page is created, sent back to the requesting browser
PHP instance is closed
Thus, only one php instance deals with page requests...Is my thinking
correct on this?

What are these localhosts accessing Apache virtualhost?

What are these localhosts accessing Apache virtualhost?

In my server-status page I see a lot of requests from localhost. what are
these for? are they actually doing anything?
201-0 - 0/0/327 . 0.94 28653 0 0.0 0.00 99.83 ::1
domain.com OPTIONS * HTTP/1.0
202-0 - 0/0/140 . 1.65 28333 0 0.0 0.00 52.80 ::1
domain.com OPTIONS * HTTP/1.0
203-0 - 0/0/359 . 3.15 28425 0 0.0 0.00 88.87 ::1
domain.com OPTIONS * HTTP/1.0
204-0 - 0/0/353 . 4.16 28861 0 0.0 0.00 150.89 ::1
domain.com OPTIONS * HTTP/1.0
205-0 - 0/0/382 . 0.18 28275 0 0.0 0.00 86.17 ::1
domain.com OPTIONS * HTTP/1.0
206-0 - 0/0/242 . 1.19 28586 0 0.0 0.00 119.88 ::1
domain.com OPTIONS * HTTP/1.0
207-0 - 0/0/260 . 1.06 28475 0 0.0 0.00 90.53 ::1
domain.com OPTIONS * HTTP/1.0
208-0 - 0/0/381 . 4.92 28644 0 0.0 0.00 57.20 ::1
domain.com OPTIONS * HTTP/1.0
209-0 - 0/0/172 . 0.81 28273 0 0.0 0.00 101.78 ::1
domain.com OPTIONS * HTTP/1.0
210-0 - 0/0/277 . 1.76 28695 0 0.0 0.00 70.73 ::1
domain.com OPTIONS * HTTP/1.0
211-0 - 0/0/776 . 6.57 20491 0 0.0 0.00 211.93 ::1
domain.com OPTIONS * HTTP/1.0