var show_alarm_exist=false; function check_alarm(){ $.ajax({ type: 'POST', data: { act: 'alarm' }, url: memo_alarm_url + '/get-events.php', dataType: 'json', async: true, cache: false, success: function(result) { if(result.msg == 'SUCCESS') { // URL을 추출하는 정규식 const urlRegex = /(https?:\/\/[^\s]+)/g; const urlMatches = result.content.match(urlRegex); // 추출된 URL이 있으면 그 값을 사용하고, 없으면 me_id 사용 const urlOrMeId = urlMatches ? urlMatches[0] : result.me_id; // 추출된 값을 show_alarm으로 전달 show_alarm(result.title, result.content, result.url, urlOrMeId, result.me_send_datetime, result.me_id); } else { // 오류 처리 } } }); } function show_alarm(title, content, url, urlOrMeId, me_send_datetime, me_id) { if(show_alarm_exist) hide_alarm(); show_alarm_exist = true; var html = ""; // audio.play(); // 알림 소리 재생 html = "
"; $('body').prepend(html); $('#alarm_layer').fadeIn(); setTimeout(function(){ hide_alarm(); }, 30000); } function hide_alarm(){ if(show_alarm_exist){ show_alarm_exist=false; $("#alarm_layer").fadeOut(400,function(){ $('#alarm_layer').remove(); }); } } function set_recv_memo(me_id){ $.ajax({ type:'POST', data : ({act : 'recv_memo', me_id : me_id}), url: memo_alarm_url + '/get-events.php', dataType:'json', async:true, cache:false, success:function(result){ if(result.msg=='SUCCESS'){ hide_alarm(); }else{ } } }); } function RemoveTag(s){ var tmp = ''; tmp = s; tmp = tmp.replace('<','<'); tmp = tmp.replace('>','>'); tmp = tmp.replace('"','"'); return tmp; }