Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 25064

Using Javascript to hide SharePoint2013 forum user information

$
0
0
<script type="text/javascript">

        function changeReplyName()
        {
            var checkPage = <%=siteTitleStatus.Value%>;

        if(checkPage.toString() == "true")
        {

           withSiteTitle();

            var observeDOM = (function(){
                var MutationObserver = window.MutationObserver || window.WebKitMutationObserver,
                    eventListenerSupported = window.addEventListener;

                return function(obj, callback){
                    if( MutationObserver ){
                        // define a new observer
                        var obs = new MutationObserver(function(mutations, observer){
                            if( mutations[0].addedNodes.length || mutations[0].removedNodes.length )
                                callback();
                        });
                        // have the observer observe foo for changes in children
                        obs.observe( obj, { childList:true, subtree:true });
                    }
                    else if( eventListenerSupported ){
                        obj.addEventListener('DOMNodeInserted', callback, false);
                        obj.addEventListener('DOMNodeRemoved', callback, false);
                    }
                }
            })();

            // Observe a specific DOM element:
            observeDOM( document.getElementById('scriptWPQ2') ,function(){

                withSiteTitle();

            });
        }

        else
        {
            forNonSiteTitle();
        }
    }

    //For masking all the username if they belong to catagories group - DONE
    function withSiteTitle()
    {
        var l_username = <%=lstUserName.Value%>;
        var l_group = <%=lstUserGroup.Value%>;

        for (var i = 0; i < l_username.length; i++) {

            var user_N = l_username[i];
            var group_N = l_group[i];


            $("#scriptWPQ2 a.ms-subtleLink").filter(function (index) { return $(this).text().toLowerCase() == user_N.toLowerCase(); }).text(group_N).attr('href', '#').css({'pointer-events' : 'none', 'cursor' : 'default', 'text-decoration' : 'none', 'color' : '#000'});

            $("#scriptWPQ2 a.ms-subtleLink").filter(function (index) { return $(this).text().toLowerCase() == user_N.toLowerCase() + "\'s post"; }).text(group_N + "\'s post").attr('href', '#').css({'pointer-events' : 'none', 'cursor' : 'default', 'text-decoration' : 'none', 'color' : '#000'});


        }

    }

    window.onload = function () {
        changeReplyName();

    }


    </script>

Hi,  I need to hide the username show in the sharepoint 2013 forum. the above code work find at the initial loading phrase. But if I reply a post or select the next pages, the username that is affected (hidden) does not load. can anyone provide me solution?

The following is the IE error generated:

Thank,



Viewing all articles
Browse latest Browse all 25064

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>