서버 점검 안내

dsclub은 서비스의 안정성과 성능 향상을 위해
매일 04시 30분에 정기 점검이 진행됩니다.

점검 시간: 오전 4시 30분 ~ 4시 35분

해당 시간 동안 일시적으로 서비스에 접속이 불가능하오니, 양해 부탁드립니다.

Twave 테마 채팅 알람 기능 > 코딩 스토리

Twave 테마 채팅 알람 기능

페이지 정보

작성자 profile_image tak2 (192.♡.0.1) 작성일 24-09-22 12:14 조회 142 댓글 0

본문

[code]

<?php if ($is_member) {  ?>
<script>
function checkNoRead() {
    fetch('<?php echo G5_BBS_URL ?>/memo.php')
        .then(response => response.text())
        .then(data => {
            // 응답 데이터에서 no_read 요소 확인
            const parser = new DOMParser();
            const doc = parser.parseFromString(data, 'text/html');
            const noReadElement = doc.querySelector('.no_read');

            if (noReadElement) {
                // 알림 표시 아이콘 생성
                const notificationIcon = document.createElement('span');
                notificationIcon.style.position = 'absolute';
                notificationIcon.style.width = '20px'; // 아이콘 크기 조정
                notificationIcon.style.height = '20px'; // 아이콘 크기 조정
                notificationIcon.style.backgroundColor = '#ff5c00'; // 색깔 점
                notificationIcon.style.borderRadius = '50%';
                notificationIcon.style.right = '-12px'; // 아이콘 위치 조정
                notificationIcon.style.top = '18px'; // 아이콘 위치 조정
                notificationIcon.style.display = 'flex';
                notificationIcon.style.justifyContent = 'center';
                notificationIcon.style.alignItems = 'center';
                notificationIcon.className = 'notification-dot'; // 클래스 추가 (선택적)

                // 느낌표 추가
                const exclamationMark = document.createElement('span');
                exclamationMark.innerText = '!';
                exclamationMark.style.color = '#fff'; // 느낌표 색상 조정
                exclamationMark.style.fontSize = '10px'; // 느낌표 크기 조정
                exclamationMark.style.fontWeight = '950'; // 느낌표 볼드 처리

                // 알림 아이콘에 느낌표 추가
                notificationIcon.appendChild(exclamationMark);

                // 알림 아이콘을 1:1 채팅 링크에 추가
                const chatLink = document.querySelector('.hd_modi');
                if (chatLink && !chatLink.querySelector('.notification-dot')) {
                    chatLink.appendChild(notificationIcon);
                }
            }
        })
        .catch(error => console.error('Error fetching memo.php:', error));
}

// 페이지 로드 시 초기 체크
checkNoRead();
</script>
<?php }  ?>

[/code]

 

이것을 head.sub.php의 </header> 아래에 추가하시면 채팅 알람을 출력하실 수 있습니다. (또는 tail.sub.php의 원하는 부분)

좋아요1 이 글을 좋아요하셨습니다
url 복사 카카오톡 공유 라인 공유 페이스북 공유 트위터 공유

등록된 댓글이 없습니다.

전체 270건
게시물 검색

접속자집계

오늘
699
어제
779
최대
4,271
전체
290,164