Widget:ContactsPageWidget: различия между версиями

Перейти к навигации Перейти к поиску
Нет описания правки
Нет описания правки
Строка 50: Строка 50:
     const buttons = document.getElementsByClassName(buttonId);
     const buttons = document.getElementsByClassName(buttonId);


     if (buttons.length > 0) {
     if (buttons. Length > 0) {
         for (let index in buttons) {
         for (let index in buttons) {
             const targetButton = buttons[index];
             const targetButton = buttons[index];
Строка 91: Строка 91:
wk2bFuncTurnButtonIntoLink(buttonLoginId);
wk2bFuncTurnButtonIntoLink(buttonLoginId);


             const targetDiv = document.getElementById(targetDivId);
             const buttons = document.getElementsByClassName(buttonId);
            if (targetDivId != undefined) {
            if (buttons. Length > 0) {
                console.log(mw.user);
                for (let index in buttons) {
                window.wk2bRedirectAddress = targetDiv.childNodes[1].childNodes[0].href;
                    const targetDiv = buttons[index];
                const redirectButtonText = targetDiv.childNodes[1].childNodes[0].textContent;
                                        console.log(mw.user);
                targetDiv.childNodes[1].removeChild(targetDiv.childNodes[1].childNodes[0])
                    window.wk2bRedirectAddress = targetDiv.childNodes[1].childNodes[0].href;
 
                    const redirectButtonText = targetDiv.childNodes[1].childNodes[0].textContent;
                targetDiv.innerHTML = '<p>' + redirectButtonText + '</p>';
                    targetDiv.childNodes[1].removeChild(targetDiv.childNodes[1].childNodes[0])
                if (mw.user.tokens.values.csrfToken ===  
   
                        mw.user.tokens.values.patrolToken &&
                    targetDiv.innerHTML = '<p>' + redirectButtonText + '</p>';
                        mw.user.tokens.values.patrolToken ==
                    if (mw.user.tokens.values.csrfToken ===
                        mw.user.tokens.values.watchToken) {
                            mw.user.tokens.values.patrolToken &&
                    /* User is not authenticated */                     
                            mw.user.tokens.values.patrolToken ==
                    targetDiv.onclick = wk2bFuncShowUnauthPopUp;
                            mw.user.tokens.values.watchToken) {
                    document.getElementById("wk2bUnAuthPopup-close-btn").onclick = wk2bFuncHideUnauthPopUp;
                        /* User is not authenticated */                   
                    console.log("User is NOT authenticated")
                        targetDiv.onclick = wk2bFuncShowUnauthPopUp;
                        document.getElementById("wk2bUnAuthPopup-close-btn").onclick = wk2bFuncHideUnauthPopUp;
                        console.log("User is NOT authenticated")
                    } else {
                        targetDiv.onclick = wk2bFuncRedirectToContactsPage;
                        console.log("User IS authenticated")
                    }
                }
            } else {
                const targetDiv = document.getElementById(targetDivId);
                if (targetDivId != undefined) {
                    console.log(mw.user);
                    window.wk2bRedirectAddress = targetDiv.childNodes[1].childNodes[0].href;
                    const redirectButtonText = targetDiv.childNodes[1].childNodes[0].textContent;
                    targetDiv.childNodes[1].removeChild(targetDiv.childNodes[1].childNodes[0])
   
                    targetDiv.innerHTML = '<p>' + redirectButtonText + '</p>';
                    if (mw.user.tokens.values.csrfToken ===  
                            mw.user.tokens.values.patrolToken &&
                            mw.user.tokens.values.patrolToken ==
                            mw.user.tokens.values.watchToken) {
                        /* User is not authenticated */                     
                        targetDiv.onclick = wk2bFuncShowUnauthPopUp;
                        document.getElementById("wk2bUnAuthPopup-close-btn").onclick = wk2bFuncHideUnauthPopUp;
                        console.log("User is NOT authenticated")
                    } else {
                        targetDiv.onclick = wk2bFuncRedirectToContactsPage;
                        console.log("User IS authenticated")
                    }
                 } else {
                 } else {
                    targetDiv.onclick = wk2bFuncRedirectToContactsPage;
                     console.log("Target div for contacts was not found")
                     console.log("User IS authenticated")
                 }
                 }
            } else {
                console.log("Target div for contacts was not found")
             }
             }
         },
         },

Версия от 23:32, 7 августа 2025

This widget created to hold some JavaScript code for Contacts Button custom behaiour