Jump to content

Recommended Posts

Posted

Un mic script in js pentru a te avertiza dupa o anumita perioada de timp predefinita de utilizator. // Alarm Clock

Mai jos aveti codul sursa care il puteti copia in consola din chrome. // (Ctrl-Shift-C)


(function() {
(function() {
var tim_def = prompt("Timp pana la declansarea alarmei?");
if (tim_def.length === 1) {
var tim = tim_def;
} else if (tim_def.length > 1) {
var tim = tim_def.slice(0,-1);
} else {
alert ('Raspunsul nu este valid incearca din nou!')
}
var lctim = tim_def.slice(-1);
var audio = new Audio('http://soundjax.com/reddo/97744%5EALARM.mp3');


var alerta = function(smo) {
var mes = prompt("Ce ai vrea sa spun alerta ta?", "Alert!");
if (tim_def !== null) {
setTimeout(function() {
audio.play();
alert(mes ? mes : 'Alarma!');
}, 1000 * smo * parseFloat(tim));
}
};
switch (lctim) {
case 's':
//secunde
alerta(1);
break;
case 'm':
//minute
alerta(60);
break;
case 'o':
//ore
alerta(3600);
break;
default:
alerta(60);
break;
}
})();
})();

In plus puteti face un bookmark cu codul de mai jos:


javascript:!function(){!function(){var a=prompt("Timp pana la declansarea alarmei?");if(1===a.length)var e=a;else if(a.length>1)var e=a.slice(0,-1);else alert("Raspunsul nu este valid incearca din nou!");var l=a.slice(-1),n=new Audio("http://soundjax.com/reddo/97744%5EALARM.mp3"),r=function(l){var r=prompt("Ce ai vrea sa spun alerta ta?","Alert!");null!==a&&setTimeout(function(){n.play(),alert(r?r:"Alarma!")},1e3*l*parseFloat(e))};switch(l){case"s":r(1);break;case"m":r(60);break;case"o":r(3600);break;default:r(60)}}()}();

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...