// line-login.js
//console.log( "Hello from line-login.js")
console.log( "Hello from line-login.js")

// Get the full URL
const url = window.location.href;

// Create a URL object
const urlObj = new URL(url);

// Get the parameters from the URL
const params = new URLSearchParams(urlObj.search);

// Get the value of a specific parameter
const redirect_url = params.get('redirect_to'); // "value1"

console.log( "redirect_url: " + redirect_url)


function line_login_auth() {
    // Assuming you have an endpoint that initiates the OAuth process
    window.location.href = '/wp-admin/admin-ajax.php?action=line_login_auth&redirect_to=' + encodeURIComponent(redirect_url);
}

// Attach the event to the LINE login button, if it exists
document.addEventListener('DOMContentLoaded', function() {
    var loginButton = document.querySelector('.line-login-button');
    if (loginButton) {
        //loginButton.addEventListener('click', line_login_auth);
    }
});

