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

Twave 테마 채팅 알람 기능

본문

[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의 원하는 부분)

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

카테고리 분류 학습 시스템 (총 0개 학습됨)

예측 카테고리: 문학 (랜덤 - 학습 데이터 없음)

이 분류가 맞나요? 학습시켜주세요!

등록된 댓글이 없습니다.

  • RSS
  • _  글쓰기 글쓰기
전체 302건
게시물 검색

접속자집계

오늘
1,171
어제
3,897
최대
42,418
전체
939,399