var str = "<b>Просто знать шаги <b>недостаточно</b>. Надо <i>чувствовать</i> музыку.</b>";
str.replace(/<b>(.+)<b>(.+)<\/b>(.+)<\/b>/gi, "<b>$1$2$3</b>");
$(function() {
check("first_event", function(){
alert("First Event Done");
}, 10);
check("second_event", function(){
alert("Second Event Done");
}, 20);
check("thirthd_event", function(){
alert("Thirthd Event Done");
}, 40);
});
function check(key, callback, seconds){
var LS = localStorage;
if (!LS || LS["check_"+key] == "done") return;
LS["check_"+key] = LS["check_"+key] || new Date().getTime();
if ((new Date().getTime() - LS["check_"+key]) >= seconds * 1000) (LS["check_"+key] = "done") && callback();
else setTimeout(check, 5000, key, callback, seconds);
}
$(function() {
check(function(){
alert("Done");
}, 10);
});
function check(callback, seconds){
var LS = localStorage;
if (!LS || LS.enter == "done") return;
LS.enter = LS.enter || new Date().getTime();
if ((new Date().getTime() - LS.enter) >= period * 1000) (LS.enter = "done") && callback();
else setTimeout(check, 5000, callback, seconds);
}
$(function(){
checkTime(function(){
alert('2 minutes')
});
});
function checkTime(callback){
var time = 10; //время, в секундах
if ( localStorage ) {
if (localStorage.userEnter == "end") return;
if (!localStorage.userEnter) localStorage.userEnter = new Date().getTime();
else if ((new Date().getTime() - localStorage.userEnter) > time * 1000 ) {
callback && callback();
localStorage.userEnter = "end";
}
}
}
/**
* Wraps around $_SESSION
*
* @param string $name name of session variable to set
* @param mixed $value value for the variable. Set this to null to unset the variable from the session.
*
* @return mixed value for the session variable
*/
function session($name, $value = null) {
static $session_active = false;
if ($session_active === false) {
if (($current = ini_get('session.use_trans_sid')) === false)
exit('Calls to session() requires [session.use_trans_sid] to be set');
$test = "mix{$current}{$current}";
$prev = @ini_set('session.use_trans_sid', $test);
$peek = @ini_set('session.use_trans_sid', $current);
if ($peek !== $current && $peek !== false)
session_start();
$session_active = true;
}
if (func_num_args() === 1)
return (isset($_SESSION[$name]) ? $_SESSION[$name] : null);
if ($value === null)
unset($_SESSION[$name]);
else
$_SESSION[$name] = $value;
}
var arr= [['a','b'],['c','d'],['e','f']]
for (var i in arr) {
console.log(arr[i][1])
}