서버 점검 안내

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

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

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

Twave [BETA] 패치 - 멘션 및 태그 관련 > 코딩 스토리

Twave [BETA] 패치 - 멘션 및 태그 관련

페이지 정보

작성자 profile_image tak2 (115.♡.171.219) 작성일 24-08-16 00:01 조회 223 댓글 0

본문

[code]

<!-- @ 태그 발견 시 프로필 링크처리{ -->

<script>

document.addEventListener('DOMContentLoaded', function() {

    var currentPage = window.location.pathname;

    var blockedPages = [

        '/bbs/member_profile.php',

        '/bbs/profile.php'

    ];

    if (blockedPages.includes(currentPage)) {

        return;

    }


    // 정규 표현식 수정: @ 앞에 공백이 없을 경우 매치하지 않도록 설정

    var regex = /(?<!\S)@(\w+)/g; 

    var textNodes = document.evaluate(

        "//text()",

        document,

        null,

        XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,

        null

    );


    for (var i = 0; i < textNodes.snapshotLength; i++) {

        var node = textNodes.snapshotItem(i);

        var text = node.nodeValue;

        var newText = text.replace(regex, function(match, id) {

            var url = 'http://' + window.location.host + '/bbs/profile.php?mb_id=' + id;

            return '<a href="' + url + '" class="mansion" style="text-decoration-line: none;color:#2497ff;">@' + id + '</a>';

        });


        if (newText !== text) {

            var newNode = document.createElement('span');

            newNode.innerHTML = newText;

            node.parentNode.replaceChild(newNode, node);

        }

    }

});

</script>

<!-- # 검색 태그 발견 시 검색 링크처리{ -->

<script>

document.addEventListener('DOMContentLoaded', function() {

    var regex = /(?<!\S)#([\w가-힣]+)/g; // 앞에 공백이 없을 때만 매치하도록 수정

    var textNodesIterator = document.evaluate(

        "//text()",

        document,

        null,

        XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,

        null

    );

    

    for (var i = 0; i < textNodesIterator.snapshotLength; i++) {

        var textNode = textNodesIterator.snapshotItem(i);

        var originalText = textNode.nodeValue;

        var modifiedText = originalText.replace(regex, function(match, title) {

            if (textNode.parentNode.tagName.toLowerCase() === 'a' || 

                textNode.parentNode.tagName.toLowerCase() === 'style' || 

                textNode.parentNode.tagName.toLowerCase() === 'id') {

                return match;

            } else {

                var searchUrl = 'http://' + window.location.host + '/bbs/search.php?sfl=wr_subject%7C%7Cwr_content%7C%7Cmb_id%7C%7Cwr_name%7C%7Cwr_datetime%7C%7Cwr_last%7C%7Cwr_ip&sop=and&stx=' + encodeURIComponent(title);

                return '<a href="' + searchUrl + '" class="search_tag" style="text-decoration-line: none;color:#ee8438;">#' + title + '</a>';

            }

        });


        if (modifiedText !== originalText) {

            var newNode = document.createElement('span');

            newNode.innerHTML = modifiedText;

            textNode.parentNode.replaceChild(newNode, textNode);

        }

    }

});

</script>

[/code]

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

등록된 댓글이 없습니다.

전체 269건
게시물 검색

접속자집계

오늘
284
어제
1,445
최대
4,271
전체
291,194