Skip to content

Instantly share code, notes, and snippets.

@addieljuarez
Created September 21, 2014 22:18
Show Gist options
  • Select an option

  • Save addieljuarez/35bea042655b5f01a89d to your computer and use it in GitHub Desktop.

Select an option

Save addieljuarez/35bea042655b5f01a89d to your computer and use it in GitHub Desktop.
function inicio (data){
var seg = data;
function cronometro(){
if(seg!=0){
Titanium.API .info(seg);
seg--;
var m = seg/60;
var s = seg % 60;
$.display_lbl.text = " " + parseInt(m) + " m : " + parseInt(s) + " s ";
}else{
Titanium.API.info("Termino");
alert("Termino el tiempo");
clearInterval(test);
}
}
var test = setInterval(cronometro, 1000);
};
$.start_btn.addEventListener('click', function(e){
if($.minutos.value != "" || $.segundos.value != ""){
var totalSeg = function (){
if($.minutos.value != 0 || $.minutos.value != null){
var totalTime = (parseInt($.minutos.value) * 60) + parseInt($.segundos.value);
return totalTime;
}
else{
return $.segundos.value;
}
};
inicio(totalSeg());
}
else{
alert("Campos vacios");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment